libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [4/6] libcloud git commit: if address_list is not none, then the ip element will be none and cannot do get attribute on None Type
Date Mon, 06 Jun 2016 12:42:59 GMT
if address_list is not none, then the ip element will be none and cannot do get attribute on
None Type


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6401a45b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6401a45b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6401a45b

Branch: refs/heads/trunk
Commit: 6401a45b620eebcefe7b7ba55f87fb0c81ef18dd
Parents: 7467dc2
Author: kumar Chockalingam <kumarappanc@gmail.com>
Authored: Tue May 17 09:06:52 2016 +1000
Committer: anthony-shaw <anthonyshaw@apache.org>
Committed: Mon Jun 6 22:42:28 2016 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py | 39 ++++++++++++++++----------
 1 file changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/6401a45b/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index d3ded7f..0f0ea17 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -2425,21 +2425,30 @@ class DimensionDataNodeDriver(NodeDriver):
             status=findtext(element, 'state', TYPES_URN))
 
     def _to_firewall_address(self, element):
-        ip = element.find(fixxpath('ip', TYPES_URN))
-        port = element.find(fixxpath('port', TYPES_URN))
-        port_list = element.find(fixxpath('portList', TYPES_URN))
-        address_list = element.find(fixxpath('ipAddressList', TYPES_URN))
-        return DimensionDataFirewallAddress(
-            any_ip=ip.get('address') == 'ANY',
-            ip_address=ip.get('address'),
-            ip_prefix_size=ip.get('prefixSize'),
-            port_begin=port.get('begin') if port is not None else None,
-            port_end=port.get('end') if port is not None else None,
-            port_list_id=port_list.get('id', None)
-            if port_list is not None else None,
-            address_list_id=address_list.get('id')
-            if address_list is not None else None
-        )
+        if address_list is None:
+            return DimensionDataFirewallAddress(
+                any_ip=ip.get('address') == 'ANY',
+                ip_address=ip.get('address'),
+                ip_prefix_size=ip.get('prefixSize'),
+                port_begin=port.get('begin') if port is not None else None,
+                port_end=port.get('end') if port is not None else None,
+                port_list_id=port_list.get('id', None)
+                if port_list is not None else None,
+                address_list_id=address_list.get('id')
+                if address_list is not None else None
+                )
+        else:
+            return DimensionDataFirewallAddress(
+                any_ip = False,
+                ip_address= None,
+                ip_prefix_size = None,
+                port_begin = None,
+                port_end = None,
+                port_list_id=port_list.get('id', None)
+                if port_list is not None else None,
+                address_list_id=address_list.get('id')
+                if address_list is not None else None
+                )
 
     def _to_ip_blocks(self, object):
         blocks = []


Mime
View raw message