Revision 00003458 lib/ssh.py

b/lib/ssh.py
54 54
  "-oHashKnownHosts=no",
55 55
  ]
56 56

  
57

  
58
def SSHCall(hostname, user, command, batch=True, ask_key=False):
59
  """Execute a command on a remote node.
60

  
61
  This method has the same return value as `utils.RunCmd()`, which it
62
  uses to launch ssh.
57
def BuildSSHCmd(hostname, user, command, batch=True, ask_key=False):
58
  """Build an ssh string to execute a command on a remote node.
63 59

  
64 60
  Args:
65 61
    hostname: the target host, string
......
70 66
             we can connect to an unknown host (not valid in batch mode)
71 67

  
72 68
  Returns:
73
    `utils.RunResult` as for `utils.RunCmd()`
69
    The ssh call to run 'command' on the remote host.
74 70

  
75 71
  """
76 72
  argv = ["ssh", "-q"]
......
82 78
    argv.extend(BATCH_MODE_OPTS)
83 79
  elif ask_key:
84 80
    argv.extend(ASK_KEY_OPTS)
85
  argv.extend(["%s@%s" % (user, hostname), command])
86
  return utils.RunCmd(argv)
81
  argv.extend(["%s@%s" % (user, hostname), "'%s'" % command])
82
  return argv
83

  
84

  
85
def SSHCall(hostname, user, command, batch=True, ask_key=False):
86
  """Execute a command on a remote node.
87

  
88
  This method has the same return value as `utils.RunCmd()`, which it
89
  uses to launch ssh.
90

  
91
  Args:
92
    hostname: the target host, string
93
    user: user to auth as
94
    command: the command
95
    batch: if true, ssh will run in batch mode with no prompting
96
    ask_key: if true, ssh will run with StrictHostKeyChecking=ask, so that
97
             we can connect to an unknown host (not valid in batch mode)
98

  
99
  Returns:
100
    `utils.RunResult` as for `utils.RunCmd()`
101

  
102
  """
103
  return utils.RunCmd(BuildSSHCmd(hostname, user, command, batch=batch, ask_key=ask_key))
87 104

  
88 105

  
89 106
def CopyFileToNode(node, filename):

Also available in: Unified diff