+
+ options.append("-oBatchMode=yes")
+
+ if strict_host_check:
+ options.append("-oStrictHostKeyChecking=yes")
+ else:
+ options.append("-oStrictHostKeyChecking=no")
+
+ else:
+ # non-batch mode
+
+ if ask_key:
+ options.append("-oStrictHostKeyChecking=ask")
+ elif strict_host_check:
+ options.append("-oStrictHostKeyChecking=yes")
+ else:
+ options.append("-oStrictHostKeyChecking=no")
+
+ if self.ipv6:
+ options.append("-6")
+
+ return options
+
+ def BuildCmd(self, hostname, user, command, batch=True, ask_key=False,
+ tty=False, use_cluster_key=True, strict_host_check=True,
+ private_key=None, quiet=True):
+ """Build an ssh command to execute a command on a remote node.
+
+ @param hostname: the target host, string
+ @param user: user to auth as
+ @param command: the command
+ @param batch: if true, ssh will run in batch mode with no prompting
+ @param ask_key: if true, ssh will run with
+ StrictHostKeyChecking=ask, so that we can connect to an
+ unknown host (not valid in batch mode)
+ @param use_cluster_key: whether to expect and use the
+ cluster-global SSH key
+ @param strict_host_check: whether to check the host's SSH key at all
+ @param private_key: use this private key instead of the default
+ @param quiet: whether to enable -q to ssh
+
+ @return: the ssh call to run 'command' on the remote host.
+
+ """
+ argv = [constants.SSH]
+ argv.extend(self._BuildSshOptions(batch, ask_key, use_cluster_key,
+ strict_host_check, private_key,
+ quiet=quiet))