libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [07/10] libcloud git commit: Completed flake8 updates and final tweaks to unit tests.
Date Thu, 08 Oct 2015 12:19:25 GMT
Completed flake8 updates and final tweaks to unit tests.

Closes #593


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

Branch: refs/heads/trunk
Commit: 1e6b54a45b6caa723d79191a3d1020e4c0ca22f7
Parents: 02feb81
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Tue Oct 6 16:01:10 2015 +1100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Thu Oct 8 14:12:21 2015 +0200

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py                |  7 +++++--
 libcloud/compute/drivers/dimensiondata.py       | 21 ++++++++------------
 libcloud/loadbalancer/drivers/dimensiondata.py  |  6 +++---
 libcloud/test/compute/test_dimensiondata.py     | 11 +++++++---
 .../test/loadbalancer/test_dimensiondata.py     |  2 +-
 5 files changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e6b54a4/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index fe296e8..424582b 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -79,11 +79,12 @@ API_ENDPOINTS = {
 # Default API end-point for the base connection class.
 DEFAULT_REGION = 'dd-na'
 
-# Service plans
+
 class NetworkDomainServicePlan(object):
     ESSENTIALS = "ESSENTIALS"
     ADVANCED = "ADVANCED"
 
+
 class DimensionDataResponse(XmlResponse):
     def parse_error(self):
         if self.status == httplib.UNAUTHORIZED:
@@ -353,7 +354,8 @@ class DimensionDataFirewallAddress(object):
     """
     The source or destination model in a firewall rule
     """
-    def __init__(self, any_ip, ip_address, ip_prefix_size, port_begin, port_end):
+    def __init__(self, any_ip, ip_address, ip_prefix_size,
+                 port_begin, port_end):
         self.any_ip = any_ip
         self.ip_address = ip_address
         self.ip_prefix_size = ip_prefix_size
@@ -376,6 +378,7 @@ class DimensionDataNatRule(object):
         return (('<DimensionDataNatRule: id=%s, status=%s>')
                 % (self.id, self.status))
 
+
 class DimensionDataVlan(object):
     """
     DimensionData VLAN.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e6b54a4/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index c394b27..4d911d2 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -442,9 +442,8 @@ class DimensionDataNodeDriver(NodeDriver):
                                       params=params).object
         return self._to_network_domains(response)
 
-    def ex_create_network_domain(self, location, name, description=None,
-                                 service_plan=
-                                 NetworkDomainServicePlan.ADVANCED):
+    def ex_create_network_domain(self, location, name, service_plan,
+                                 description=None):
         """
         Deploy a new network domain to a data center
         """
@@ -487,7 +486,7 @@ class DimensionDataNodeDriver(NodeDriver):
                 = network_domain.description
         ET.SubElement(edit_node, "type").text = network_domain.plan
 
-        response = self.connection.request_with_orgId_api_2(
+        self.connection.request_with_orgId_api_2(
             'network/editNetworkDomain',
             method='POST',
             data=ET.tostring(edit_node)).object
@@ -563,7 +562,7 @@ class DimensionDataNodeDriver(NodeDriver):
             ET.SubElement(edit_node, "description").text \
                 = vlan.description
 
-        response = self.connection.request_with_orgId_api_2(
+        self.connection.request_with_orgId_api_2(
             'network/editVlan',
             method='POST',
             data=ET.tostring(edit_node)).object
@@ -582,7 +581,7 @@ class DimensionDataNodeDriver(NodeDriver):
         ET.SubElement(edit_node, "privateIpv4PrefixSize").text =\
             vlan.private_ipv4_range_size
 
-        response = self.connection.request_with_orgId_api_2(
+        self.connection.request_with_orgId_api_2(
             'network/expandVlan',
             method='POST',
             data=ET.tostring(edit_node)).object
@@ -972,18 +971,14 @@ class DimensionDataNodeDriver(NodeDriver):
         location_id = element.get('datacenterId')
         location = list(filter(lambda x: x.id == location_id,
                                locations))[0]
-
+        ip_range = element.find(fixxpath('privateIpv4Range', TYPES_URN))
         return DimensionDataVlan(
             id=element.get('id'),
             name=findtext(element, 'name', TYPES_URN),
             description=findtext(element, 'description',
                                  TYPES_URN),
-            private_ipv4_range_address= \
-                element.find(fixxpath('privateIpv4Range', TYPES_URN)) \
-                    .get('address'),
-            private_ipv4_range_size= \
-                element.find(fixxpath('privateIpv4Range', TYPES_URN)) \
-                    .get('prefixSize'),
+            private_ipv4_range_address=ip_range.get('address'),
+            private_ipv4_range_size=ip_range.get('prefixSize'),
             location=location,
             status=status)
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e6b54a4/libcloud/loadbalancer/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/loadbalancer/drivers/dimensiondata.py b/libcloud/loadbalancer/drivers/dimensiondata.py
index 8c8c001..3325d4b 100644
--- a/libcloud/loadbalancer/drivers/dimensiondata.py
+++ b/libcloud/loadbalancer/drivers/dimensiondata.py
@@ -430,7 +430,7 @@ class DimensionDataLBDriver(Driver):
         ET.SubElement(create_node_elm, "connectionRateLimit") \
             .text = str(node.connection_rate_limit)
 
-        response = self.connection.request_with_orgId_api_2(
+        self.connection.request_with_orgId_api_2(
             action='networkDomainVip/createNode',
             method='POST',
             data=ET.tostring(create_node_elm)).object
@@ -441,7 +441,7 @@ class DimensionDataLBDriver(Driver):
         ET.SubElement(create_node_elm, "status") \
             .text = "ENABLED" if enabled is True else "DISABLED"
 
-        response = self.connection.request_with_orgId_api_2(
+        self.connection.request_with_orgId_api_2(
             action='networkDomainVip/editNode',
             method='POST',
             data=ET.tostring(create_node_elm)).object
@@ -707,7 +707,7 @@ class DimensionDataLBDriver(Driver):
         request = ET.Element('editPoolMember',
                              {'xmlns': TYPES_URN,
                               'id': member.id})
-        state = "ENABLED" if enabled == True else "DISABLED"
+        state = "ENABLED" if enabled is True else "DISABLED"
         ET.SubElement(request, 'status').text = state
 
         result = self.connection.request_with_orgId_api_2(

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e6b54a4/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index f3ccc7e..4013943 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -17,7 +17,7 @@ import unittest
 from libcloud.utils.py3 import httplib
 
 from libcloud.common.types import InvalidCredsError
-from libcloud.common.dimensiondata import DimensionDataAPIException
+from libcloud.common.dimensiondata import DimensionDataAPIException, NetworkDomainServicePlan
 from libcloud.compute.drivers.dimensiondata import DimensionDataNodeDriver as DimensionData
 from libcloud.compute.base import Node, NodeAuthPassword, NodeLocation
 
@@ -200,9 +200,11 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         node = self.driver.ex_get_node_by_id('e75ead52-692f-4314-8725-c8a4f4d13a87')
         vlan = self.driver.ex_get_vlan('0e56433f-d808-4669-821d-812769517ff8')
         ret = self.driver.ex_attach_node_to_vlan(node, vlan)
+        self.assertTrue(ret)
 
     def test_ex_destroy_nic(self):
         node = self.driver.ex_destroy_nic('a202e51b-41c0-4cfc-add0-b1c62fc0ecf6')
+        self.assertTrue(node)
 
     def test_list_networks(self):
         nets = self.driver.list_networks()
@@ -211,9 +213,11 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
 
     def test_ex_create_network_domain(self):
         location = self.driver.ex_get_location_by_id('NA9')
+        plan = NetworkDomainServicePlan.ADVANCED
         net = self.driver.ex_create_network_domain(location=location,
                                                    name='test',
-                                                   description='test')
+                                                   description='test',
+                                                   service_plan=plan)
         self.assertEqual(net.name, 'test')
         self.assertTrue(net.id, 'f14a871f-9a25-470c-aef8-51e13202e1aa')
 
@@ -278,12 +282,13 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
     def test_ex_expand_vlan(self):
         vlan = self.driver.ex_get_vlan('0e56433f-d808-4669-821d-812769517ff8')
         vlan.private_ipv4_range_size = '23'
-        result = self.driver.ex_expand_vlan(vlan)
+        vlan = self.driver.ex_expand_vlan(vlan)
         self.assertEqual(vlan.private_ipv4_range_size, '23')
 
     def test_ex_add_public_ip_block_to_network_domain(self):
         net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')
         block = self.driver.ex_add_public_ip_block_to_network_domain(net)
+        self.assertEqual(block.id, '9945dc4a-bdce-11e4-8c14-b8ca3a5d9ef8')
 
     def test_ex_list_public_ip_blocks(self):
         net = self.driver.ex_get_network_domain('8cdfd607-f429-4df6-9352-162cfc0891be')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e6b54a4/libcloud/test/loadbalancer/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/loadbalancer/test_dimensiondata.py b/libcloud/test/loadbalancer/test_dimensiondata.py
index 31ecd75..b28833b 100644
--- a/libcloud/test/loadbalancer/test_dimensiondata.py
+++ b/libcloud/test/loadbalancer/test_dimensiondata.py
@@ -505,7 +505,7 @@ class DimensionDataMockHttp(MockHttp):
         body = self.fixtures.load(
             'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-    
+
     def _caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node_34de6ed6_46a4_4dae_a753_2f8d3840c6f9(self,
method, url, body, headers):
         body = self.fixtures.load(
             'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node_34de6ed6_46a4_4dae_a753_2f8d3840c6f9.xml')


Mime
View raw message