Merge pull request #205 from DreadPirateShawn/DescribeInstancesBlockDeviceMapping

DescribeInstances: Added block_device_mapping to XML
This commit is contained in:
Steve Pulec 2014-09-11 22:40:43 -04:00
commit 21c8594612
3 changed files with 16 additions and 2 deletions

View File

@ -263,7 +263,7 @@ class Instance(BotoInstance, TaggedEC2Instance):
self.key_name = kwargs.get("key_name")
self.block_device_mapping = BlockDeviceMapping()
self.block_device_mapping['/dev/sda1'] = BlockDeviceType()
self.block_device_mapping['/dev/sda1'] = BlockDeviceType(volume_id=random_volume_id())
amis = ec2_backend.describe_images(filters={'image-id': image_id})
ami = amis[0] if amis else None

View File

@ -340,7 +340,17 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns='http://ec2.amazona
<kernelId>{{ instance.kernel }}</kernelId>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping />
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<volumeId>{{ instance.block_device_mapping['/dev/sda1'].volume_id }}</volumeId>
<status>attached</status>
<attachTime>YYYY-MM-DDTHH:MM:SS.SSSZ</attachTime>
<deleteOnTermination>true</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
<virtualizationType>{{ instance.virtualization_type }}</virtualizationType>
<clientToken>ABCDE1234567890123</clientToken>
<tagSet>

View File

@ -50,6 +50,10 @@ def test_instance_launch_and_terminate():
instances[0].id.should.equal(instance.id)
instances[0].state.should.equal('running')
root_device_name = instances[0].root_device_name
instances[0].block_device_mapping[root_device_name].status.should.equal('attached')
instances[0].block_device_mapping[root_device_name].volume_id.should.match(r'vol-\w+')
conn.terminate_instances([instances[0].id])
reservations = conn.get_all_instances()