1
2 import sys
3 from completers import InstanceCompleter
4
5
7 """
8 sshinstance [options] <instance-id> [<remote-command>]
9
10 SSH to an EC2 instance
11
12 Examples:
13
14 $ starcluster sshinstance i-14e9157c
15 $ starcluster sshinstance ec2-123-123-123-12.compute-1.amazonaws.com
16
17 You can also execute commands without directly logging in:
18
19 $ starcluster sshinstance i-14e9157c 'cat /etc/hosts'
20 """
21 names = ['sshinstance', 'si']
22 show_dns_names = True
23
25 parser.add_option("-u", "--user", dest="user", action="store",
26 type="string", default='root',
27 help="login as USER (defaults to root)")
28
30 if not args:
31 self.parser.error(
32 "please specify an instance id or dns name to connect to")
33 instance = args[0]
34 cmd = ' '.join(args[1:])
35 retval = self.nm.ssh_to_node(instance, user=self.opts.user,
36 command=cmd)
37 if cmd and retval is not None:
38 sys.exit(retval)
39