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

Source Code for Module starcluster.commands.sshnode

 1  import sys 
 2  from completers import NodeCompleter 
 3   
 4   
5 -class CmdSshNode(NodeCompleter):
6 """ 7 sshnode <cluster> <node> [<remote-command>] 8 9 SSH to a cluster node 10 11 Examples: 12 13 $ starcluster sshnode mycluster master 14 $ starcluster sshnode mycluster node001 15 ... 16 17 or same thing in shorthand: 18 19 $ starcluster sshnode mycluster 0 20 $ starcluster sshnode mycluster 1 21 ... 22 23 You can also execute commands without directly logging in: 24 25 $ starcluster sshnode mycluster node001 'cat /etc/hosts' 26 """ 27 names = ['sshnode', 'sn'] 28
29 - def addopts(self, parser):
30 parser.add_option("-u", "--user", dest="user", action="store", 31 type="string", default='root', 32 help="login as USER (defaults to root)")
33
34 - def execute(self, args):
35 if len(args) < 2: 36 self.parser.error( 37 "please specify a cluster and node to connect to") 38 scluster = args[0] 39 node = args[1] 40 cmd = ' '.join(args[2:]) 41 retval = self.cm.ssh_to_cluster_node(scluster, node, 42 user=self.opts.user, command=cmd) 43 if cmd and retval is not None: 44 sys.exit(retval)
45