libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [10/11] libcloud git commit: Update the test to check gateway addresses, added ipv6 details to the VLAN object. changed the ex_create_vlan to return the VLAN object on response. Check for begin_port when establishing firewall rules.
Date Wed, 09 Dec 2015 10:19:28 GMT
Update the test to check gateway addresses, added ipv6 details to the VLAN object. changed
the ex_create_vlan to return the VLAN object on response. Check for begin_port when establishing
firewall rules.

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>


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

Branch: refs/heads/trunk
Commit: 5d6907686e3e324b42cb907d8c33236051b23652
Parents: 325f52e
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Wed Dec 9 09:43:53 2015 +1100
Committer: Anthony Shaw <anthony.p.shaw@gmail.com>
Committed: Wed Dec 9 21:19:16 2015 +1100

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py                | 26 +++++++++++++--
 libcloud/compute/drivers/dimensiondata.py       | 34 +++++++++++---------
 ...d8a_9cbc_8dabe5a7d0e4_network_deployVlan.xml |  2 +-
 libcloud/test/compute/test_dimensiondata.py     |  8 +++--
 4 files changed, 49 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/5d690768/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index 66075af..c734b75 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -460,7 +460,9 @@ class DimensionDataVlan(object):
     """
 
     def __init__(self, id, name, description, location, network_domain,
-                 status, private_ipv4_range_address, private_ipv4_range_size):
+                 status, private_ipv4_range_address, private_ipv4_range_size,
+                 ipv6_range_address, ipv6_range_size, ipv4_gateway,
+                 ipv6_gateway):
         """
         Initialize an instance of ``DimensionDataVlan``
 
@@ -486,9 +488,23 @@ class DimensionDataVlan(object):
                                             IP space
         :type  private_ipv4_range_address: ``str``
 
-        :param private_ipv4_range_address: The size (e.g. '24') of the VLAN
+        :param private_ipv4_range_size: The size (e.g. '24') of the VLAN
                                             as a CIDR range size
-        :type  private_ipv4_range_address: ``str``
+        :type  private_ipv4_range_size: ``int``
+
+        :param ipv6_range_address: The host address of the VLAN
+                                            IP space
+        :type  ipv6_range_address: ``str``
+
+        :param ipv6_range_size: The size (e.g. '32') of the VLAN
+                                            as a CIDR range size
+        :type  ipv6_range_size: ``int``
+
+        :param ipv4_gateway: The IPv4 default gateway addres
+        :type  ipv4_gateway: ``str``
+
+        :param ipv6_gateway: The IPv6 default gateway addres
+        :type  ipv6_gateway: ``str``
         """
         self.id = str(id)
         self.name = name
@@ -498,6 +514,10 @@ class DimensionDataVlan(object):
         self.status = status
         self.private_ipv4_range_address = private_ipv4_range_address
         self.private_ipv4_range_size = private_ipv4_range_size
+        self.ipv6_range_address = ipv6_range_address
+        self.ipv6_range_size = ipv6_range_size
+        self.ipv4_gateway = ipv4_gateway
+        self.ipv6_gateway = ipv6_gateway
 
     def __repr__(self):
         return (('<DimensionDataVlan: id=%s, name=%s, '

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5d690768/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 27f3a66..8440baf 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -751,16 +751,7 @@ class DimensionDataNodeDriver(NodeDriver):
             if info.get('name') == 'vlanId':
                 vlan_id = info.get('value')
 
-        return DimensionDataVlan(
-            id=vlan_id,
-            name=name,
-            description=description,
-            network_domain=network_domain,
-            location=network_domain.location,
-            status=NodeState.RUNNING,
-            private_ipv4_range_address=private_ipv4_base_address,
-            private_ipv4_range_size=private_ipv4_prefix_size
-        )
+        return self.ex_get_vlan(vlan_id)
 
     def ex_get_vlan(self, vlan_id):
         """
@@ -941,8 +932,9 @@ class DimensionDataNodeDriver(NodeDriver):
         else:
             source_ip.set('address', rule.source.ip_address)
             source_ip.set('prefixSize', rule.source.ip_prefix_size)
-            source_port = ET.SubElement(source, 'port')
-            source_port.set('begin', rule.source.port_begin)
+            if rule.source.port_begin is not None:
+                source_port = ET.SubElement(source, 'port')
+                source_port.set('begin', rule.source.port_begin)
             if rule.source.port_end is not None:
                 source_port.set('end', rule.source.port_end)
         # Setup destination port rule
@@ -953,8 +945,9 @@ class DimensionDataNodeDriver(NodeDriver):
         else:
             dest_ip.set('address', rule.destination.ip_address)
             dest_ip.set('prefixSize', rule.destination.ip_prefix_size)
-            dest_port = ET.SubElement(dest, 'port')
-            dest_port.set('begin', rule.destination.port_begin)
+            if rule.destination.port_begin is not None:
+                dest_port = ET.SubElement(dest, 'port')
+                dest_port.set('begin', rule.destination.port_begin)
             if rule.destination.port_end is not None:
                 dest_port.set('end', rule.destination.port_end)
         ET.SubElement(create_node, "enabled").text = 'true'
@@ -1577,6 +1570,7 @@ class DimensionDataNodeDriver(NodeDriver):
         location = list(filter(lambda x: x.id == location_id,
                                locations))[0]
         ip_range = element.find(fixxpath('privateIpv4Range', TYPES_URN))
+        ip6_range = element.find(fixxpath('ipv6Range', TYPES_URN))
         network_domain_el = element.find(
             fixxpath('networkDomain', TYPES_URN))
         network_domain = self.ex_get_network_domain(
@@ -1588,7 +1582,17 @@ class DimensionDataNodeDriver(NodeDriver):
                                  TYPES_URN),
             network_domain=network_domain,
             private_ipv4_range_address=ip_range.get('address'),
-            private_ipv4_range_size=ip_range.get('prefixSize'),
+            private_ipv4_range_size=int(ip_range.get('prefixSize')),
+            ipv6_range_address=ip6_range.get('address'),
+            ipv6_range_size=int(ip6_range.get('prefixSize')),
+            ipv4_gateway=findtext(
+                element,
+                'ipv4GatewayAddress',
+                TYPES_URN),
+            ipv6_gateway=findtext(
+                element,
+                'ipv6GatewayAddress',
+                TYPES_URN),
             location=location,
             status=findtext(element, 'state', TYPES_URN))
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5d690768/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_deployVlan.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_deployVlan.xml
b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_deployVlan.xml
index eb37402..946a505 100644
--- a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_deployVlan.xml
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_deployVlan.xml
@@ -5,5 +5,5 @@ xmlns="urn:didata.com:api:cloud:types" requestId="NA9/2015-02-13T05:58:00.905-05
 <responseCode>IN_PROGRESS</responseCode>
 <message>Request to deploy VLAN 'Production VLAN' has been accepted and is
 being processed.</message>
-<info name="vlanId" value="cee8df03-9117-44cc-baaa-631ffa099683"/>
+<info name="vlanId" value="0e56433f_d808_4669_821d_812769517ff8"/>
 </response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/5d690768/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index ad93b7d..02eb663 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -311,7 +311,7 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
                                           name='test',
                                           private_ipv4_base_address='10.3.4.0',
                                           private_ipv4_prefix_size='24')
-        self.assertEqual(vlan.id, 'cee8df03-9117-44cc-baaa-631ffa099683')
+        self.assertEqual(vlan.id, '0e56433f-d808-4669-821d-812769517ff8')
 
     def test_ex_get_vlan(self):
         vlan = self.driver.ex_get_vlan('0e56433f-d808-4669-821d-812769517ff8')
@@ -320,7 +320,11 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         self.assertEqual(vlan.status, 'NORMAL')
         self.assertEqual(vlan.name, 'Production VLAN')
         self.assertEqual(vlan.private_ipv4_range_address, '10.0.3.0')
-        self.assertEqual(vlan.private_ipv4_range_size, '24')
+        self.assertEqual(vlan.private_ipv4_range_size, 24)
+        self.assertEqual(vlan.ipv6_range_size, 64)
+        self.assertEqual(vlan.ipv6_range_address, '2607:f480:1111:1153:0:0:0:0')
+        self.assertEqual(vlan.ipv4_gateway, '10.0.3.1')
+        self.assertEqual(vlan.ipv6_gateway, '2607:f480:1111:1153:0:0:0:1')
 
     def test_ex_wait_for_state(self):
         self.driver.ex_wait_for_state('NORMAL',


Mime
View raw message