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