示例#1
0
					break
			else:
				connectTo = i
		else:
			if iid == i['instanceId']:
				connectTo = i
	cmd = None
	if connectTo['instanceState.name'] == 'running':
		cmd = '%s %s@%s %s' % (options.externalcommand, options.user, connectTo['ipAddress'], options.command)
	print cmd
	if not options.dryrun:
		os.system(cmd)


if __name__ == '__main__':
	k, s = aaws.getBotoCredentials()
	parser = optparse.OptionParser(usage='usage: %prog [options] (key=value)* [instanceid]', version='%prog 1.00')
	parser.add_option('-k', '--key', help='Specify AWS key (default from .boto)', default=k)
	parser.add_option('-s', '--secret', help='Specify AWS secret (default from .boto)', default=s)
	parser.add_option('-r', '--region', help='Specify region to connect to (default us-west-1)', default='us-west-1')
	parser.add_option('-n', '--dryrun', action='store_true', help='Dont execute anything, just print what command would have been executed', default=False)
	parser.add_option('-e', '--externalcommand', help='External command', default='ssh')
	parser.add_option('-u', '--user', help='User to use for ssh', default='root')
	parser.add_option('-c', '--command', help='Remote command to execute', default='')

	(options, args) = parser.parse_args()

	ec2 = aaws.EC2(options.region, options.key, options.secret)

	if len(args) > 0:
		kws = {}
示例#2
0
文件: ec2ssh.py 项目: Mistobaan/aaws
            else:
                connectTo = i
        else:
            if iid == i['instanceId']:
                connectTo = i
    cmd = None
    if connectTo['instanceState.name'] == 'running':
        cmd = '%s %s@%s %s' % (options.externalcommand, options.user,
                               connectTo['ipAddress'], options.command)
    print cmd
    if not options.dryrun:
        os.system(cmd)


if __name__ == '__main__':
    k, s = aaws.getBotoCredentials()
    parser = optparse.OptionParser(
        usage='usage: %prog [options] (key=value)* [instanceid]',
        version='%prog 1.00')
    parser.add_option('-k',
                      '--key',
                      help='Specify AWS key (default from .boto)',
                      default=k)
    parser.add_option('-s',
                      '--secret',
                      help='Specify AWS secret (default from .boto)',
                      default=s)
    parser.add_option('-r',
                      '--region',
                      help='Specify region to connect to (default us-west-1)',
                      default='us-west-1')