Revision 51144e33 lib/ssh.py

b/lib/ssh.py
101 101
    return "-oHostKeyAlias=%s" % self.sstore.GetClusterName()
102 102

  
103 103
  def BuildCmd(self, hostname, user, command, batch=True, ask_key=False,
104
               tty=False):
104
               tty=False, use_cluster_key=True):
105 105
    """Build an ssh command to execute a command on a remote node.
106 106

  
107 107
    Args:
......
111 111
      batch: if true, ssh will run in batch mode with no prompting
112 112
      ask_key: if true, ssh will run with StrictHostKeyChecking=ask, so that
113 113
               we can connect to an unknown host (not valid in batch mode)
114
      use_cluster_key: Whether to expect and use the cluster-global SSH key
114 115

  
115 116
    Returns:
116 117
      The ssh call to run 'command' on the remote host.
......
118 119
    """
119 120
    argv = [constants.SSH, "-q"]
120 121
    argv.extend(KNOWN_HOSTS_OPTS)
121
    argv.append(self._GetHostKeyAliasOption())
122
    if use_cluster_key:
123
      argv.append(self._GetHostKeyAliasOption())
122 124
    if batch:
123 125
      # if we are in batch mode, we can't ask the key
124 126
      if ask_key:
......
131 133
    argv.extend(["%s@%s" % (user, hostname), command])
132 134
    return argv
133 135

  
134
  def Run(self, hostname, user, command, batch=True, ask_key=False):
136
  def Run(self, hostname, user, command, batch=True, ask_key=False,
137
          use_cluster_key=True):
135 138
    """Runs a command on a remote node.
136 139

  
137 140
    This method has the same return value as `utils.RunCmd()`, which it
......
150 153

  
151 154
    """
152 155
    return utils.RunCmd(self.BuildCmd(hostname, user, command, batch=batch,
153
                                      ask_key=ask_key))
156
                                      ask_key=ask_key,
157
                                      use_cluster_key=use_cluster_key))
154 158

  
155 159
  def CopyFileToNode(self, node, filename):
156 160
    """Copy a file to another node with scp.

Also available in: Unified diff