Ignore man/*.in.
[ganeti-local] / lib / ssh.py
index 7cf772a..2f33d46 100644 (file)
@@ -55,11 +55,8 @@ ASK_KEY_OPTS = [
   ]
 
 
-def SSHCall(hostname, user, command, batch=True, ask_key=False):
-  """Execute a command on a remote node.
-
-  This method has the same return value as `utils.RunCmd()`, which it
-  uses to launch ssh.
+def BuildSSHCmd(hostname, user, command, batch=True, ask_key=False):
+  """Build an ssh string to execute a command on a remote node.
 
   Args:
     hostname: the target host, string
@@ -70,7 +67,7 @@ def SSHCall(hostname, user, command, batch=True, ask_key=False):
              we can connect to an unknown host (not valid in batch mode)
 
   Returns:
-    `utils.RunResult` as for `utils.RunCmd()`
+    The ssh call to run 'command' on the remote host.
 
   """
   argv = ["ssh", "-q"]
@@ -83,7 +80,28 @@ def SSHCall(hostname, user, command, batch=True, ask_key=False):
   elif ask_key:
     argv.extend(ASK_KEY_OPTS)
   argv.extend(["%s@%s" % (user, hostname), command])
-  return utils.RunCmd(argv)
+  return argv
+
+
+def SSHCall(hostname, user, command, batch=True, ask_key=False):
+  """Execute a command on a remote node.
+
+  This method has the same return value as `utils.RunCmd()`, which it
+  uses to launch ssh.
+
+  Args:
+    hostname: the target host, string
+    user: user to auth as
+    command: the command
+    batch: if true, ssh will run in batch mode with no prompting
+    ask_key: if true, ssh will run with StrictHostKeyChecking=ask, so that
+             we can connect to an unknown host (not valid in batch mode)
+
+  Returns:
+    `utils.RunResult` as for `utils.RunCmd()`
+
+  """
+  return utils.RunCmd(BuildSSHCmd(hostname, user, command, batch=batch, ask_key=ask_key))
 
 
 def CopyFileToNode(node, filename):