#!/usr/bin/env python
from optparse import OptionParser
import find_asg

def main():
    find_asg.run_command(user, password, command, asgName, sleep)

##### Option parsing
user = None
password = None
command = None
asgName = None
parser = OptionParser()
parser.add_option('-u', '--user', help='SSH user', type='string', dest="user")
parser.add_option('-W', '--password', help='password for ssh user', type='string', dest="password")
parser.add_option('-c', '--command', help='Remote Command to be used', type='string', dest="command")
parser.add_option('-a', '--asg', help='AutoScalingGroup targetted', type='string', dest="asg")
parser.add_option('-s', '--sleep', help='AutoScalingGroup targetted', type=int, dest="sleep")
(options, args) = parser.parse_args()
if options.user:
    user = options.user
else:
    user = None
if options.command:
    command = options.command
else:
    print "Need to specify command name"
    exit(1)
if options.asg:
    asgName = options.asg
else:
    print "Need to specify ASG name"
    exit(1)
if options.password:
    password = options.password
else:
    password = options.password
if options.sleep and options.sleep == int:
    sleep = options.sleep
else:
    sleep = 120
main()

