Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Modify attachment device index to be an integer as stated in the serv…
Browse files Browse the repository at this point in the history
…ice docs. Add unit test to make sure deviceIndex is passed to network interface attachments and to make sure it gets properly cast to an integer.
  • Loading branch information
danielgtaylor committed Aug 2, 2013
1 parent ff15e1f commit 8337a0b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion boto/ec2/networkinterface.py
Expand Up @@ -60,7 +60,7 @@ def endElement(self, name, value, connection):
elif name == 'instanceId':
self.instance_id = value
elif name == 'deviceIndex':
self.device_index = value
self.device_index = int(value)
elif name == 'instanceOwnerId':
self.instance_owner_id = value
elif name == 'status':
Expand Down
58 changes: 58 additions & 0 deletions tests/unit/ec2/test_connection.py
Expand Up @@ -562,5 +562,63 @@ def test_describe_vpc_attribute(self):
'Version'])


class TestGetAllNetworkInterfaces(TestEC2ConnectionBase):
def default_body(self):
return """<DescribeNetworkInterfacesResponse xmlns="http://ec2.amazonaws.com/doc/2013-06-15/">
<requestId>fc45294c-006b-457b-bab9-012f5b3b0e40</requestId>
<networkInterfaceSet>
<item>
<networkInterfaceId>eni-0f62d866</networkInterfaceId>
<subnetId>subnet-c53c87ac</subnetId>
<vpcId>vpc-cc3c87a5</vpcId>
<availabilityZone>ap-southeast-1b</availabilityZone>
<description/>
<ownerId>053230519467</ownerId>
<requesterManaged>false</requesterManaged>
<status>in-use</status>
<macAddress>02:81:60:cb:27:37</macAddress>
<privateIpAddress>10.0.0.146</privateIpAddress>
<sourceDestCheck>true</sourceDestCheck>
<groupSet>
<item>
<groupId>sg-3f4b5653</groupId>
<groupName>default</groupName>
</item>
</groupSet>
<attachment>
<attachmentId>eni-attach-6537fc0c</attachmentId>
<instanceId>i-22197876</instanceId>
<instanceOwnerId>053230519467</instanceOwnerId>
<deviceIndex>5</deviceIndex>
<status>attached</status>
<attachTime>2012-07-01T21:45:27.000Z</attachTime>
<deleteOnTermination>true</deleteOnTermination>
</attachment>
<tagSet/>
<privateIpAddressesSet>
<item>
<privateIpAddress>10.0.0.146</privateIpAddress>
<primary>true</primary>
</item>
<item>
<privateIpAddress>10.0.0.148</privateIpAddress>
<primary>false</primary>
</item>
<item>
<privateIpAddress>10.0.0.150</privateIpAddress>
<primary>false</primary>
</item>
</privateIpAddressesSet>
</item>
</networkInterfaceSet>
</DescribeNetworkInterfacesResponse>"""

def test_attachment_has_device_index(self):
self.set_http_response(status_code=200)
parsed = self.ec2.get_all_network_interfaces()

self.assertEqual(5, parsed[0].attachment.device_index)


if __name__ == '__main__':
unittest.main()

0 comments on commit 8337a0b

Please sign in to comment.