Revision 1ff08570 lib/ssh.py

b/lib/ssh.py
30 30
from ganeti import utils
31 31
from ganeti import errors
32 32
from ganeti import constants
33
from ganeti import ssconf
33 34

  
34 35

  
35 36
KNOWN_HOSTS_OPTS = [
......
90 91
  """Wrapper for SSH commands.
91 92

  
92 93
  """
94
  def __init__(self, sstore=None):
95
    if sstore is None:
96
      self.sstore = ssconf.SimpleStore()
97
    else:
98
      self.sstore = sstore
99

  
100
  def _GetHostKeyAliasOption(self):
101
    return "-oHostKeyAlias=%s" % self.sstore.GetClusterName()
102

  
93 103
  def BuildCmd(self, hostname, user, command, batch=True, ask_key=False,
94 104
               tty=False):
95 105
    """Build an ssh command to execute a command on a remote node.
......
108 118
    """
109 119
    argv = ["ssh", "-q"]
110 120
    argv.extend(KNOWN_HOSTS_OPTS)
121
    argv.append(self._GetHostKeyAliasOption())
111 122
    if batch:
112 123
      # if we are in batch mode, we can't ask the key
113 124
      if ask_key:
......
163 174
    command = ["scp", "-q", "-p"]
164 175
    command.extend(KNOWN_HOSTS_OPTS)
165 176
    command.extend(BATCH_MODE_OPTS)
177
    command.append(self._GetHostKeyAliasOption())
166 178
    command.append(filename)
167 179
    command.append("%s:%s" % (node, filename))
168 180

  

Also available in: Unified diff