class documentation
class SshRunner(object):
Wrapper for SSH commands.
Method | __init__ |
Initializes this class. |
Method |
|
Build an ssh command to execute a command on a remote node. |
Method |
|
Copy a file to another node with scp. |
Method |
|
Runs a command on a remote node. |
Method |
|
Verify hostname consistency via SSH. |
Instance Variable | cluster |
Undocumented |
Instance Variable | ipv6 |
Undocumented |
Method | _ |
Builds a list with needed SSH 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, port=None):
¶
Build an ssh command to execute a command on a remote node.
Parameters | |
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 | if true, ssh will run with StrictHostKeyChecking=ask, so that we can connect to an unknown host (not valid in batch mode) |
tty | Undocumented |
use | whether to expect and use the cluster-global SSH key |
strict | whether to check the host's SSH key at all |
private | use this private key instead of the default |
quiet | whether to enable -q to ssh |
port | the SSH port on which the node's daemon is running |
Returns | |
the ssh call to run 'command' on the remote host. |
Copy a file to another node with scp.
Parameters | |
node | node in the cluster |
port | Undocumented |
filename | absolute pathname of a local file |
Returns | |
boolean | the success of the operation |
Runs a command on a remote node.
This method has the same return value as `utils.RunCmd()`, which it uses to launch ssh.
Args: see SshRunner.BuildCmd.
Returns | |
utils.process.RunResult | the result as from utils.process.RunCmd() |
Verify hostname consistency via SSH.
This functions connects via ssh to a node and compares the hostname reported by the node to the name with have (the one that we connected to).
This is used to detect problems in ssh known_hosts files (conflicting known hosts) and inconsistencies between dns/hosts entries and local machine names
Parameters | |
node | nodename of a host to check; can be short or full qualified hostname |
ssh | the port of a SSH daemon running on the node |
Returns | |
(success, detail), where:
|
def _BuildSshOptions(self, batch, ask_key, use_cluster_key, strict_host_check, private_key=None, quiet=True, port=None):
¶
Builds a list with needed SSH options.
Parameters | |
batch | same as ssh's batch option |
ask | allows ssh to ask for key confirmation; this parameter conflicts with the batch one |
use | if True, use the cluster name as the HostKeyAlias name |
strict | this makes the host key checking strict |
private | use this private key instead of the default |
quiet | whether to enable -q to ssh |
port | the SSH port to use, or None to use the default |
Returns | |
list | the list of options ready to use in utils.process.RunCmd |