libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/5] libcloud git commit: Extended the docs for the DimensionData driver to support the new loadbalancer component. Ensured both drivers are 90%+ coverage and added some unit tests for issues have seen in prod.
Date Mon, 31 Aug 2015 16:42:01 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 64f566455 -> 0f4b01fde


Extended the docs for the DimensionData driver to support the new loadbalancer component.
Ensured both drivers are 90%+ coverage and added some unit tests for issues have seen in prod.

Closes #570

Signed-off-by: Tomaz Muraus <tomaz@apache.org>


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

Branch: refs/heads/trunk
Commit: 3bbc62a7d660c0481c98ad2c6d2d73d26f886466
Parents: 64f5664
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Mon Aug 31 12:55:01 2015 +1000
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Mon Aug 31 18:16:35 2015 +0200

----------------------------------------------------------------------
 docs/loadbalancer/_supported_providers.rst      | 30 +++++------
 docs/loadbalancer/drivers/dimensiondata.rst     | 55 ++++++++++++++++++++
 libcloud/compute/drivers/dimensiondata.py       | 15 ++++--
 ...745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml | 17 ++++++
 libcloud/test/compute/test_dimensiondata.py     | 24 ++++++++-
 ..._9cbc_8dabe5a7d0e4_networkDomainVip_node.xml | 29 +++++++++++
 .../test/loadbalancer/test_dimensiondata.py     | 49 +++++++++++++++++
 7 files changed, 199 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/docs/loadbalancer/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/loadbalancer/_supported_providers.rst b/docs/loadbalancer/_supported_providers.rst
index 3d1d830..98516f8 100644
--- a/docs/loadbalancer/_supported_providers.rst
+++ b/docs/loadbalancer/_supported_providers.rst
@@ -1,20 +1,20 @@
 .. NOTE: This file has been generated automatically using generate_provider_feature_matrix_table.py
script, don't manually edit it
 
-====================================== ======================================== =================
================================================== ==============================
-Provider                               Documentation                            Provider
constant Module                                             Class Name                   

-====================================== ======================================== =================
================================================== ==============================
-`Brightbox`_                                                                    BRIGHTBOX
        :mod:`libcloud.loadbalancer.drivers.brightbox`     :class:`BrightboxLBDriver`    
-`CloudStack`_                                                                   CLOUDSTACK
       :mod:`libcloud.loadbalancer.drivers.cloudstack`    :class:`CloudStackLBDriver`   
-`Dimension Data Load Balancer`_                                                 DIMENSIONDATA
    :mod:`libcloud.loadbalancer.drivers.dimensiondata` :class:`DimensionDataLBDriver`
-`Amazon Elastic Load Balancing`_       :doc:`Click </loadbalancer/drivers/elb>` ELB
              :mod:`libcloud.loadbalancer.drivers.elb`           :class:`ElasticLBDriver`
     
-`Google Compute Engine Load Balancer`_ :doc:`Click </loadbalancer/drivers/gce>` GCE
              :mod:`libcloud.loadbalancer.drivers.gce`           :class:`GCELBDriver`    
     
-`GoGrid LB`_                                                                    GOGRID  
         :mod:`libcloud.loadbalancer.drivers.gogrid`        :class:`GoGridLBDriver`      

-`Ninefold LB`_                                                                  NINEFOLD
         :mod:`libcloud.loadbalancer.drivers.ninefold`      :class:`NinefoldLBDriver`    

-`Rackspace LB`_                                                                 RACKSPACE
        :mod:`libcloud.loadbalancer.drivers.rackspace`     :class:`RackspaceLBDriver`    
-`Rackspace LB`_                                                                 RACKSPACE_UK
     :mod:`libcloud.loadbalancer.drivers.rackspace`     :class:`RackspaceUKLBDriver`  
-`Rackspace LB`_                                                                 RACKSPACE_US
     :mod:`libcloud.loadbalancer.drivers.rackspace`     :class:`RackspaceLBDriver`    
-`Softlayer Load Balancing`_                                                     SOFTLAYER
        :mod:`libcloud.loadbalancer.drivers.softlayer`     :class:`SoftlayerLBDriver`    
-====================================== ======================================== =================
================================================== ==============================
+====================================== ==================================================
================= ================================================== ==============================
+Provider                               Documentation                                    
 Provider constant Module                                             Class Name
+====================================== ==================================================
================= ================================================== ==============================
+`Brightbox`_                                                                    		  BRIGHTBOX
        :mod:`libcloud.loadbalancer.drivers.brightbox`     :class:`BrightboxLBDriver`
+`CloudStack`_                                                                   	 	  CLOUDSTACK
       :mod:`libcloud.loadbalancer.drivers.cloudstack`    :class:`CloudStackLBDriver`
+`Dimension Data Load Balancer`_        :doc:`Click </loadbalancer/drivers/dimensiondata>`
DIMENSIONDATA     :mod:`libcloud.loadbalancer.drivers.dimensiondata` :class:`DimensionDataLBDriver`
+`Amazon Elastic Load Balancing`_       :doc:`Click </loadbalancer/drivers/elb>` 		
 ELB               :mod:`libcloud.loadbalancer.drivers.elb`           :class:`ElasticLBDriver`
+`Google Compute Engine Load Balancer`_ :doc:`Click </loadbalancer/drivers/gce>` 		
 GCE               :mod:`libcloud.loadbalancer.drivers.gce`           :class:`GCELBDriver`
+`GoGrid LB`_                                                                    		  GOGRID
           :mod:`libcloud.loadbalancer.drivers.gogrid`        :class:`GoGridLBDriver`
+`Ninefold LB`_                                                                  		  NINEFOLD
         :mod:`libcloud.loadbalancer.drivers.ninefold`      :class:`NinefoldLBDriver`
+`Rackspace LB`_                                                                 		  RACKSPACE
        :mod:`libcloud.loadbalancer.drivers.rackspace`     :class:`RackspaceLBDriver`
+`Rackspace LB`_                                                                 		  RACKSPACE_UK
     :mod:`libcloud.loadbalancer.drivers.rackspace`     :class:`RackspaceUKLBDriver`
+`Rackspace LB`_                                                                 		  RACKSPACE_US
     :mod:`libcloud.loadbalancer.drivers.rackspace`     :class:`RackspaceLBDriver`
+`Softlayer Load Balancing`_                                                     		  SOFTLAYER
        :mod:`libcloud.loadbalancer.drivers.softlayer`     :class:`SoftlayerLBDriver`
+====================================== ==================================================
================= ================================================== ==============================
 
 .. _`Brightbox`: http://www.brightbox.co.uk/
 .. _`CloudStack`: http://cloudstack.org/

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/docs/loadbalancer/drivers/dimensiondata.rst
----------------------------------------------------------------------
diff --git a/docs/loadbalancer/drivers/dimensiondata.rst b/docs/loadbalancer/drivers/dimensiondata.rst
new file mode 100644
index 0000000..a57d6f2
--- /dev/null
+++ b/docs/loadbalancer/drivers/dimensiondata.rst
@@ -0,0 +1,55 @@
+Dimension Data Load Balancer Driver Documentation
+=======================================
+
+Dimension Data are a global IT Services company and form part of the NTT Group.
+Dimension Data provide IT-as-a-Service to customers around the globe on their
+cloud platform (Compute as a Service). The CaaS service is available either on
+one of the public cloud instances or as a private instance on premises.
+
+.. figure:: /_static/images/provider_logos/dimensiondata.png
+    :align: center
+    :width: 300
+    :target: http://cloud.dimensiondata.com/
+
+CaaS has its own non-standard `API`_ , `libcloud` provides a Python
+wrapper on top of this `API`_ with common methods with other IaaS solutions and
+Public cloud providers. Therefore, you can use use the Dimension Data libcloud
+driver to communicate with both the public and private clouds.
+
+Instantiating a driver
+----------------------
+
+When you instantiate a driver you need to pass the following arguments to the
+driver constructor:
+
+* ``user_id`` - Your Dimension Data Cloud username
+* ``key`` - Your Dimension Data Cloud password
+
+The base `libcloud` API allows you to:
+
+* create balancers, add members and destroy members
+
+Non-standard functionality and extension methods
+------------------------------------------------
+
+The Dimension Data driver exposes some `libcloud` non-standard
+functionalities through extension methods and arguments.
+
+These functionalities include:
+
+* list nodes
+* list pools
+* set the network domain (zone)
+
+For information on how to use these functionalities please see the method
+docstrings below. You can also use an interactive shell for exploration as
+shown in the examples.
+
+API Docs
+--------
+
+.. autoclass:: libcloud.loadbalancer.drivers.dimensiondata.DimensionDataLBDriver
+    :members:
+    :inherited-members:
+
+.. _`API`: http://cloud.dimensiondata.com/au/en/services/public-cloud/api
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index dcfe4b5..fad4476 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -499,12 +499,16 @@ class DimensionDataNodeDriver(NodeDriver):
 
         status = self._to_status(element.find(fixxpath('progress', TYPES_URN)))
 
+        has_network_info \
+            = element.find(fixxpath('networkInfo', TYPES_URN)) is not None
+
         extra = {
             'description': findtext(element, 'description', TYPES_URN),
             'sourceImageId': findtext(element, 'sourceImageId', TYPES_URN),
             'networkId': findtext(element, 'networkId', TYPES_URN),
-            'networkDomainId': element.find(fixxpath('networkInfo', TYPES_URN))
-                                      .get('networkDomainId'),
+            'networkDomainId': element.find(fixxpath('networkInfo', TYPES_URN))\
+            .get('networkDomainId') \
+                if has_network_info else None,
             'datacenterId': element.get('datacenterId'),
             'deployedTime': findtext(element, 'createTime', TYPES_URN),
             'cpuCount': int(findtext(
@@ -529,8 +533,11 @@ class DimensionDataNodeDriver(NodeDriver):
 
         public_ip = findtext(element, 'publicIpAddress', TYPES_URN)
 
-        private_ip = findtext(element, 'networkInfo/primaryNic/privateIpv4',
-                              TYPES_URN)
+        private_ip = element.find(
+            fixxpath('networkInfo/primaryNic', TYPES_URN)) \
+        .get('privateIpv4') \
+            if has_network_info else \
+            element.find(fixxpath('nic', TYPES_URN)).get('privateIpv4')
 
         n = Node(id=element.get('id'),
                  name=findtext(element, 'name', TYPES_URN),

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml
b/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml
index 64c691a..7c189c9 100644
--- a/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml
@@ -61,4 +61,21 @@ state="NORMAL"/>
 <machineStatus name="vmwareToolsRunningStatus" value="RUNNING"/>
 <machineStatus name="vmwareToolsApiVersion" value="9354"/>
 </Server>
+<Server id="f07445f8-8ba3-4066-86c1-d6d0dd5518a1" datacenterId="NA5">
+        <name>us-dc1.us.aperture.cloud</name>
+        <description>Domain Controller 1 for us.aperture.cloud</description>
+        <operatingSystem id="WIN2012S64" displayName="WIN2012S/64" family="WINDOWS"/>
+        <cpuCount>2</cpuCount>
+        <memoryGb>2</memoryGb>
+        <disk id="628a8134-8ebf-420d-afc2-08af0c402f4e" scsiId="0" sizeGb="50" speed="STANDARD"
state="NORMAL"/>
+        <nic id="fe72eebe-7b9d-11e4-8c14-b8ca3a5d9ef8" privateIpv4="10.192.176.11" networkId="4bba37be-506f-11e3-b29c-001517c4643e"
networkName="Aperture US1" state="NORMAL"/>
+        <sourceImageId>4787337e-0f31-11e3-b29c-001517c4643e</sourceImageId>
+        <createTime>2013-12-03T07:16:44.000Z</createTime>
+        <deployed>true</deployed>
+        <started>false</started>
+        <state>NORMAL</state>
+        <machineStatus name="vmwareToolsVersionStatus" value="NEED_UPGRADE"/>
+        <machineStatus name="vmwareToolsRunningStatus" value="NOT_RUNNING"/>
+        <machineStatus name="vmwareToolsApiVersion" value="9221"/>
+    </Server>
 </servers>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index 942cada..59c31df 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -35,6 +35,12 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         DimensionDataMockHttp.type = None
         self.driver = DimensionData(*DIMENSIONDATA_PARAMS)
 
+    def test_invalid_region(self):
+        try:
+            self.driver = DimensionData(*DIMENSIONDATA_PARAMS, region='blah')
+        except ValueError:
+            pass
+
     def test_invalid_creds(self):
         DimensionDataMockHttp.type = 'UNAUTHORIZED'
         try:
@@ -56,7 +62,7 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
     def test_list_nodes_response(self):
         DimensionDataMockHttp.type = None
         ret = self.driver.list_nodes()
-        self.assertEqual(len(ret), 2)
+        self.assertEqual(len(ret), 3)
 
     def test_list_sizes_response(self):
         DimensionDataMockHttp.type = None
@@ -109,6 +115,17 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')
         self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')
 
+    def test_create_node_no_network(self):
+        rootPw = NodeAuthPassword('pass123')
+        image = self.driver.list_images()[0]
+        network = self.driver.ex_list_networks()[0]
+        try:
+            node = self.driver.create_node(name='test2', image=image, auth=rootPw,
+                                       ex_description='test2 node', ex_network=None,
+                                       ex_isStarted=False)
+        except ValueError:
+            pass
+
     def test_ex_shutdown_graceful(self):
         node = Node(id='11', name=None, state=None,
                     public_ips=None, private_ips=None, driver=self.driver)
@@ -166,6 +183,11 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         ret = self.driver.ex_reset(node)
         self.assertTrue(ret is True)
 
+    def test_list_networks(self):
+        nets = self.driver.list_networks()
+        self.assertEqual(nets[0].name, 'test-net1')
+        self.assertTrue(isinstance(nets[0].location, NodeLocation))
+
     def test_ex_list_networks(self):
         nets = self.driver.ex_list_networks()
         self.assertEqual(nets[0].name, 'test-net1')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/libcloud/test/loadbalancer/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/loadbalancer/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node.xml
b/libcloud/test/loadbalancer/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node.xml
new file mode 100644
index 0000000..b58e58f
--- /dev/null
+++ b/libcloud/test/loadbalancer/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<nodes xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="1"
+totalCount="2" pageSize="250">
+<node id="34de6ed6-46a4-4dae-a753-2f8d3840c6f9" datacenterId="NA9">
+<networkDomainId>553f26b6-2a73-42c3-a78b-
+6116f11291d0</networkDomainId>
+<name>ProductionNode.1</name>
+<description>Production Server 1</description>
+<ipv4Address>10.10.10.101</ipv4Address>
+<state>NORMAL</state>
+<status>ENABLED</status>
+<healthMonitor id="0168b83a-d487-11e4-811f-005056806999" name="ICMP"/>
+<connectionLimit>10000</connectionLimit>
+<connectionRateLimit>2000</connectionRateLimit>
+<createTime>2015-05-29T13:56:13.000Z</createTime>
+</node>
+<node id="78d2437e-36e1-4dd5-9bfd-582a85d207ad" datacenterId="NA9">
+<networkDomainId>553f26b6-2a73-42c3-a78b-
+6116f11291d0</networkDomainId>
+<name>ProductionNode.2</name>
+<description>Production Server 2</description>
+<ipv4Address>10.5.2.15</ipv4Address>
+<state>NORMAL</state>
+<status>ENABLED</status>
+<connectionLimit>10000</connectionLimit>
+<connectionRateLimit>2000</connectionRateLimit>
+<createTime>2015-05-29T11:46:55.000Z</createTime>
+</node>
+</nodes>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3bbc62a7/libcloud/test/loadbalancer/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/loadbalancer/test_dimensiondata.py b/libcloud/test/loadbalancer/test_dimensiondata.py
index ff0b7fd..725f153 100644
--- a/libcloud/test/loadbalancer/test_dimensiondata.py
+++ b/libcloud/test/loadbalancer/test_dimensiondata.py
@@ -37,6 +37,12 @@ class DimensionDataTests(unittest.TestCase):
         DimensionDataMockHttp.type = None
         self.driver = DimensionData(*DIMENSIONDATA_PARAMS)
 
+    def test_invalid_region(self):
+        try:
+            self.driver = DimensionData(*DIMENSIONDATA_PARAMS, region='blah')
+        except ValueError:
+            pass
+
     def test_invalid_creds(self):
         DimensionDataMockHttp.type = 'UNAUTHORIZED'
         try:
@@ -67,6 +73,22 @@ class DimensionDataTests(unittest.TestCase):
         self.assertEqual(balancer.extra['pool_id'], '9e6b496d-5261-4542-91aa-b50c7f569c54')
         self.assertEqual(balancer.extra['network_domain_id'], '1234')
 
+    def test_create_balancer_with_defaults(self):
+        self.driver.ex_set_current_network_domain('1234')
+
+        balancer = self.driver.create_balancer(
+            name='test',
+            port=None,
+            protocol=None,
+            algorithm=None,
+            members=None)
+        self.assertEqual(balancer.name, 'test')
+        self.assertEqual(balancer.id, '8334f461-0df0-42d5-97eb-f4678eb26bea')
+        self.assertEqual(balancer.ip, '165.180.12.22')
+        self.assertEqual(balancer.port, 80)
+        self.assertEqual(balancer.extra['pool_id'], '9e6b496d-5261-4542-91aa-b50c7f569c54')
+        self.assertEqual(balancer.extra['network_domain_id'], '1234')
+
     def test_create_balancer_no_members(self):
         self.driver.ex_set_current_network_domain('1234')
         members = None
@@ -249,6 +271,21 @@ class DimensionDataTests(unittest.TestCase):
         self.assertEqual(listener.id, '8334f461-0df0-42d5-97eb-f4678eb26bea')
         self.assertEqual(listener.name, 'test')
 
+    def test_ex_create_virtual_listener_unusual_port(self):
+        listener = self.driver.ex_create_virtual_listener(
+            network_domain_id='12345',
+            name='test',
+            ex_description='test',
+            port=8900,
+            pool=DimensionDataPool(
+                id='1234',
+                name='test',
+                description='test',
+                status=State.RUNNING
+            ))
+        self.assertEqual(listener.id, '8334f461-0df0-42d5-97eb-f4678eb26bea')
+        self.assertEqual(listener.name, 'test')
+
     def test_get_balancer(self):
         bal = self.driver.get_balancer('6115469d-a8bb-445b-bb23-d23b5283f2b9')
         self.assertEqual(bal.name, 'myProduction.Virtual.Listener')
@@ -261,6 +298,13 @@ class DimensionDataTests(unittest.TestCase):
         protocols = self.driver.list_protocols()
         self.assertNotEqual(0, len(protocols))
 
+    def test_ex_get_nodes(self):
+        nodes = self.driver.ex_get_nodes()
+        self.assertEqual(2, len(nodes))
+        self.assertEqual(nodes[0].name, 'ProductionNode.1')
+        self.assertEqual(nodes[0].id, '34de6ed6-46a4-4dae-a753-2f8d3840c6f9')
+        self.assertEqual(nodes[0].ip, '10.10.10.101')
+
     def test_ex_get_pools(self):
         pools = self.driver.ex_get_pools()
         self.assertNotEqual(0, len(pools))
@@ -409,6 +453,11 @@ class DimensionDataMockHttp(MockHttp):
             'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_deleteNode.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node(self, method,
url, body, headers):
+        body = self.fixtures.load(
+            'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkDomainVip_node.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
 
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message