starcluster.commands.sshmaster

Package starcluster :: Package commands :: Module sshmaster |
[hide private]
[frames] | no frames]

# Source Code for Module starcluster.commands.sshmaster

     1  #!/usr/bin/env python
     2  import sys
     3  from completers import ClusterCompleter
     4
     5
     6 -class CmdSshMaster(ClusterCompleter):
     7      """
     8      sshmaster [options] <cluster> [<remote-command>]
     9
    10      SSH to a cluster's master node
    11
    12      Example:
    13
    14          $ sshmaster mycluster
    15
    16      You can also execute commands without directly logging in:
    17
    18          $ starcluster sshmaster mycluster 'cat /etc/hosts'
    19      """
    20      names = ['sshmaster', 'sm']
    21
    22 -    def addopts(self, parser):
    23          parser.add_option("-u", "--user", dest="user", action="store",
    24                            type="string", default='root',
    25                            help="login as USER (defaults to root)")
    26
    27 -    def execute(self, args):
    28          if not args:
    29              self.parser.error("please specify a cluster")
    30          clname = args[0]
    31          cmd = ' '.join(args[1:])
    32          retval = self.cm.ssh_to_master(clname, user=self.opts.user,
    33                                         command=cmd)
    34          if cmd and retval is not None:
    35              sys.exit(retval)
    36