Merge pull request #2019 from acsbendi/launch_index
Correctly returning ami launch index
This commit is contained in:
commit
09855801ba
@ -388,6 +388,7 @@ class Instance(TaggedEC2Resource, BotoInstance):
|
|||||||
self.ebs_optimized = kwargs.get("ebs_optimized", False)
|
self.ebs_optimized = kwargs.get("ebs_optimized", False)
|
||||||
self.source_dest_check = "true"
|
self.source_dest_check = "true"
|
||||||
self.launch_time = utc_date_and_time()
|
self.launch_time = utc_date_and_time()
|
||||||
|
self.ami_launch_index = kwargs.get("ami_launch_index", 0)
|
||||||
self.disable_api_termination = kwargs.get("disable_api_termination", False)
|
self.disable_api_termination = kwargs.get("disable_api_termination", False)
|
||||||
self._spot_fleet_id = kwargs.get("spot_fleet_id", None)
|
self._spot_fleet_id = kwargs.get("spot_fleet_id", None)
|
||||||
associate_public_ip = kwargs.get("associate_public_ip", False)
|
associate_public_ip = kwargs.get("associate_public_ip", False)
|
||||||
@ -719,6 +720,7 @@ class InstanceBackend(object):
|
|||||||
instance_tags = tags.get('instance', {})
|
instance_tags = tags.get('instance', {})
|
||||||
|
|
||||||
for index in range(count):
|
for index in range(count):
|
||||||
|
kwargs["ami_launch_index"] = index
|
||||||
new_instance = Instance(
|
new_instance = Instance(
|
||||||
self,
|
self,
|
||||||
image_id,
|
image_id,
|
||||||
|
@ -244,7 +244,7 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
|
|||||||
<reason/>
|
<reason/>
|
||||||
<keyName>{{ instance.key_name }}</keyName>
|
<keyName>{{ instance.key_name }}</keyName>
|
||||||
<ebsOptimized>{{ instance.ebs_optimized }}</ebsOptimized>
|
<ebsOptimized>{{ instance.ebs_optimized }}</ebsOptimized>
|
||||||
<amiLaunchIndex>0</amiLaunchIndex>
|
<amiLaunchIndex>{{ instance.ami_launch_index }}</amiLaunchIndex>
|
||||||
<instanceType>{{ instance.instance_type }}</instanceType>
|
<instanceType>{{ instance.instance_type }}</instanceType>
|
||||||
<launchTime>{{ instance.launch_time }}</launchTime>
|
<launchTime>{{ instance.launch_time }}</launchTime>
|
||||||
<placement>
|
<placement>
|
||||||
@ -384,7 +384,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns="http://ec2.amazona
|
|||||||
<reason>{{ instance._reason }}</reason>
|
<reason>{{ instance._reason }}</reason>
|
||||||
<keyName>{{ instance.key_name }}</keyName>
|
<keyName>{{ instance.key_name }}</keyName>
|
||||||
<ebsOptimized>{{ instance.ebs_optimized }}</ebsOptimized>
|
<ebsOptimized>{{ instance.ebs_optimized }}</ebsOptimized>
|
||||||
<amiLaunchIndex>0</amiLaunchIndex>
|
<amiLaunchIndex>{{ instance.ami_launch_index }}</amiLaunchIndex>
|
||||||
<productCodes/>
|
<productCodes/>
|
||||||
<instanceType>{{ instance.instance_type }}</instanceType>
|
<instanceType>{{ instance.instance_type }}</instanceType>
|
||||||
<launchTime>{{ instance.launch_time }}</launchTime>
|
<launchTime>{{ instance.launch_time }}</launchTime>
|
||||||
|
@ -1254,3 +1254,18 @@ def test_create_instance_ebs_optimized():
|
|||||||
)
|
)
|
||||||
instance.load()
|
instance.load()
|
||||||
instance.ebs_optimized.should.be(False)
|
instance.ebs_optimized.should.be(False)
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_run_multiple_instances_in_same_command():
|
||||||
|
instance_count = 4
|
||||||
|
client = boto3.client('ec2', region_name='us-east-1')
|
||||||
|
client.run_instances(ImageId='ami-1234abcd',
|
||||||
|
MinCount=instance_count,
|
||||||
|
MaxCount=instance_count)
|
||||||
|
reservations = client.describe_instances()['Reservations']
|
||||||
|
|
||||||
|
reservations[0]['Instances'].should.have.length_of(instance_count)
|
||||||
|
|
||||||
|
instances = reservations[0]['Instances']
|
||||||
|
for i in range(0, instance_count):
|
||||||
|
instances[i]['AmiLaunchIndex'].should.be(i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user