Repository: libcloud Updated Branches: refs/heads/trunk 42839c65e -> a6d11ab75
FAM-966 fixed block_device_mapping parsing in node's extra Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9020eca9 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9020eca9 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9020eca9 Branch: refs/heads/trunk Commit: 9020eca984115cddeedff6a021079b70c1eb9b58 Parents: 42839c6 Author: Hennadii Stas <uty.arrg...@gmail.com> Authored: Wed Jun 14 18:31:56 2017 +0300 Committer: Anthony Shaw <anthonys...@apache.org> Committed: Thu Jun 22 13:12:51 2017 +1000 ---------------------------------------------------------------------- libcloud/compute/drivers/ec2.py | 44 +++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/9020eca9/libcloud/compute/drivers/ec2.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py index 589c03a..94b8c75 100644 --- a/libcloud/compute/drivers/ec2.py +++ b/libcloud/compute/drivers/ec2.py @@ -2508,6 +2508,24 @@ OUTSCALE_INC_REGION_DETAILS = { Define the extra dictionary for specific resources """ RESOURCE_EXTRA_ATTRIBUTES_MAP = { + 'ebs_instance_block_device': { + 'attach_time': { + 'xpath': 'ebs/attachTime', + 'transform_func': parse_date + }, + 'delete_on_termination': { + 'xpath': 'ebs/deleteOnTermination', + 'transform_func': str + }, + 'status': { + 'xpath': 'ebs/status', + 'transform_func': str + }, + 'volume_id': { + 'xpath': 'ebs/volumeId', + 'transform_func': str + } + }, 'ebs_volume': { 'snapshot_id': { 'xpath': 'ebs/snapshotId', @@ -6462,7 +6480,8 @@ class BaseEC2NodeDriver(NodeDriver): element, RESOURCE_EXTRA_ATTRIBUTES_MAP['node']) # Add additional properties to our extra dictionary - extra['block_device_mapping'] = self._to_device_mappings(element) + extra['block_device_mapping'] = self._to_instance_device_mappings( + element) extra['groups'] = self._get_security_groups(element) extra['network_interfaces'] = self._to_interfaces(element) extra['product_codes'] = product_codes @@ -6991,6 +7010,29 @@ class BaseEC2NodeDriver(NodeDriver): return mapping + def _to_instance_device_mappings(self, object): + return [self._to_instance_device_mapping(el) for el in object.findall( + fixxpath(xpath='blockDeviceMapping/item', namespace=NAMESPACE)) + ] + + def _to_instance_device_mapping(self, element): + """ + Parse the XML element and return a dictionary of device properties. + Additional information can be found at https://goo.gl/OGK88a. + + :rtype: ``dict`` + """ + mapping = {} + + mapping['device_name'] = findattr(element=element, + xpath='deviceName', + namespace=NAMESPACE) + mapping['ebs'] = self._get_extra_dict( + element, + RESOURCE_EXTRA_ATTRIBUTES_MAP['ebs_instance_block_device']) + + return mapping + def _to_internet_gateways(self, object, xpath): return [self._to_internet_gateway(el) for el in object.findall(fixxpath(xpath=xpath,