def main(): instantiate = False terminate = False connect = False #if system arguments were passed in, parse if( len(sys.argv) > 1 ): for arg in sys.argv: if arg == "-r": instantiate = True elif arg == "-t": terminate = True elif arg == "-c": connect = True elif arg == "-h" or arg == "--help": print "\nOptions are:\n\n\t-r\n\t\tRun a new instance\n\n\t-t\n\t\tTerminate all running instances\n\n\t-c\n\t\tConnect to instance with ssh\n\n" else: print "No command line arguments provided, please use -h for options" s3_Conn = AWSInteraction() net_Conn = NetInteraction() #ifname = "", ofname = "", foldername = "", permissions = "private" ): #s3_Conn.uploadAWS(ofname = "output_test2", foldername = "folderuploadtestaws2") if instantiate: dns = s3_Conn.startEC2Instance( ) print "Connecting to " + str(dns) if connect: net_Conn.netConnect( dns ) print "Connection established at %s" % time.time() os.popen( "ssh p -5050 -i ~/.ssh/automation-key3.pem ubuntu@%s mkdir data" % str(dns) ) net_Conn.upload("./upload/2012-03-17.tar.gz","~/data/upload.tar.gz") print "Upload finished at %s" % time.time() #time.sleep(10) if terminate: running_instances = s3_Conn.findAllRunningInstances() s3_Conn.terminateInstances( running_instances ) print "ran successfully\n" return 0
def startSingleEC2(): instance_Conn = AWSInteraction() instance_name = instance_Conn.startEC2Instance() print "Function returned dns name: " print str(instance_name)