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