if "AWSSECCONF" not in os.environ: print __doc__ raise IOError( "please specify keyfile or set AWSSECCONF environment variable!") keyfile = os.path.expanduser(os.environ["AWSSECCONF"]) import json jsondat = open(keyfile) security_config = json.loads(jsondat.read()) jsondat.close() lA.checksecjson(security_config) amazon_keypair_name = security_config["AccessKeys"]["AWS"]["KeyName"] subnet = security_config["Subnet"] existing_sn = lA.runawstojson( "ec2 describe-subnets") # "GroupId": "sg-c7c322b1" found = False for existing in existing_sn["Subnets"]: if existing["SubnetId"] == subnet: found = True break if not found: raise ValueError("no such subnet " + sn) # find all instances in the subgroup/subnet instances = lA.runawstojson( "ec2 describe-instances --filters Name=subnet-id,Values=" + subnet + " --filters Name=key-name,Values=" + amazon_keypair_name) # print instances
if not len(keyfile): if "AWSSECCONF" not in os.environ: print __doc__ raise IOError( "please specify keyfile or set AWSSECCONF environment variable!") keyfile = os.path.expanduser(os.environ["AWSSECCONF"]) jsondat = open(keyfile) security_config = json.loads(jsondat.read()) jsondat.close() lA.checksecjson(security_config) amazon_keypair_name = security_config["AccessKeys"]["AWS"]["KeyName"] subnet = security_config["Subnet"] existing_sn = lA.runawstojson( "ec2 describe-subnets") # "GroupId": "sg-c7c322b1" found = False for existing in existing_sn["Subnets"]: if existing["SubnetId"] == subnet: found = True break if not found: raise ValueError("no such subnet " + subnet) # # Find and kill all instances # # find all instances in the subgroup/subnet instances = lA.runawstojson(
_info = lA.wait_for_stack(_vpc_name) # print _info["Outputs"] for _output in _info["Outputs"]: if _output['OutputKey'] == "SubnetId": subnet = _output['OutputValue'] elif _output['OutputKey'] == "SecurityGroupId": security_group = _output['OutputValue'] elif _output['OutputKey'] == "DNSId": dnsiid = _output['OutputValue'] elif _output['OutputKey'] == "VPCId": vpcid = _output['OutputValue'] # authorize group members to see themselves # print security_group, subnet, dnsiid lA.add_group_to_group(security_group, security_group) # auto assign public IPs here lA.runawstojson("ec2 modify-subnet-attribute --subnet-id " + subnet + " --map-public-ip-on-launch") print "Created stack:", _vpc_name if "Tags" in security_config and vpcid: resources = lA.find_all_child_resources(vpcid) lA.tag_resources(resources, security_config["Tags"]) # sys.exit(1) print "====================================" print "up the instance groups" print "====================================" sys.stdout.flush() for instancegroup in cluster_config["InstanceGroups"]: count = instancegroup["Count"] autoname = True if count < 0:
if not len(keyfile): if "AWSSECCONF" not in os.environ: print __doc__ raise IOError("please specify keyfile or set AWSSECCONF environment variable!") keyfile = os.path.expanduser(os.environ["AWSSECCONF"]) jsondat = open(keyfile) security_config = json.loads(jsondat.read()) jsondat.close() lA.checksecjson(security_config) amazon_keypair_name = security_config["AccessKeys"]["AWS"]["KeyName"] subnet = security_config["Subnet"] existing_sn = lA.runawstojson("ec2 describe-subnets") # "GroupId": "sg-c7c322b1" found = False for existing in existing_sn["Subnets"]: if existing["SubnetId"] == subnet: found = True break if not found: raise ValueError("no such subnet " + subnet) # # Find and kill all instances # # find all instances in the subgroup/subnet instances = lA.runawstojson(