From d3bda7154a7bad30a4e944575dff290394c34418 Mon Sep 17 00:00:00 2001 From: alok Date: Thu, 5 Jul 2018 14:50:13 -0700 Subject: [PATCH] fixed instance type name collision --- aws-experiment-launch/create_and_deploy.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aws-experiment-launch/create_and_deploy.py b/aws-experiment-launch/create_and_deploy.py index a64bde808..6d8baea75 100644 --- a/aws-experiment-launch/create_and_deploy.py +++ b/aws-experiment-launch/create_and_deploy.py @@ -9,7 +9,7 @@ from Queue import Queue import base64 -class InstanceRequest: +class InstanceResource: ON_DEMAND = 1 SPOT_INSTANCE = 2 SPOT_FLEET = 3 @@ -51,7 +51,7 @@ Build (argparse,functions) support for ### CREATE INSTANCES ### -def run_one_region_instances(config, region_number, number_of_instances, instance_type=InstanceRequest.ON_DEMAND): +def run_one_region_instances(config, region_number, number_of_instances, instance_resource=InstanceResource.ON_DEMAND): #todo: explore the use ec2 resource and not client. e.g. create_instances -- Might make for better code. """ e.g. ec2.create_instances @@ -59,11 +59,11 @@ def run_one_region_instances(config, region_number, number_of_instances, instanc region_name = config[region_number][REGION_NAME] session = boto3.Session(region_name=region_name) ec2_client = session.client('ec2') - if instance_type == InstanceRequest.ON_DEMAND: + if instance_resource == InstanceResource.ON_DEMAND: NODE_NAME = create_instances( config, ec2_client, region_number, int(number_of_instances)) print("Created %s in region %s"%(NODE_NAME,region_number)) ##REPLACE ALL print with logger - elif instance_type == InstanceRequest.SPOT_INSTANCE: + elif instance_resource == InstanceResource.SPOT_INSTANCE: response = request_spot_instances( config, ec2_client, region_number, int(number_of_instances)) else: @@ -87,7 +87,7 @@ def create_instances(config, ec2_client, region_number, number_of_instances): }, KeyName=config[region_number][REGION_KEY], UserData=USER_DATA, - InstanceRequest=INSTANCE_TYPE, + InstanceType=INSTANCE_TYPE, TagSpecifications=[ { 'ResourceType': 'instance', @@ -403,6 +403,6 @@ if __name__ == "__main__": region_number = region_list[i] number_of_instances = instances_list[i] session = run_one_region_instances( - config, region_number, number_of_instances, InstanceRequest.SPOT_FLEET) + config, region_number, number_of_instances, InstanceResource.ON_DEMAND) results = launch_code_deploy(region_list, commitId) print(results)