libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [06/10] libcloud git commit: Updated server nic functions (add and remove)
Date Thu, 08 Oct 2015 12:19:24 GMT
Updated server nic functions (add and remove)

Closes #593


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

Branch: refs/heads/trunk
Commit: 02feb81af23a70b83c6defc9a192489598b94af2
Parents: e94846e
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Tue Oct 6 15:46:12 2015 +1100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Thu Oct 8 14:12:17 2015 +0200

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py       | 26 ++++++++++++++++++++
 ...745_4d8a_9cbc_8dabe5a7d0e4_server_addNic.xml |  9 +++++++
 ..._4d8a_9cbc_8dabe5a7d0e4_server_removeNic.xml |  9 +++++++
 libcloud/test/compute/test_dimensiondata.py     | 18 ++++++++++++++
 4 files changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/02feb81a/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index b86146c..c394b27 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -376,6 +376,32 @@ class DimensionDataNodeDriver(NodeDriver):
         responseCode = findtext(body, 'responseCode', TYPES_URN)
         return responseCode == 'IN_PROGRESS' or responseCode == 'OK'
 
+    def ex_attach_node_to_vlan(self, node, vlan):
+        request = ET.Element('addNic',
+                             {'xmlns': TYPES_URN})
+        ET.SubElement(request, 'serverId').text = node.id
+        nic = ET.SubElement(request, 'nic')
+        ET.SubElement(nic, 'vlanId').text = vlan.id
+
+        response = self.connection.request_with_orgId_api_2(
+            'server/addNic',
+            method='POST',
+            data=ET.tostring(request)).object
+        responseCode = findtext(response, 'responseCode', TYPES_URN)
+        return responseCode == 'IN_PROGRESS' or responseCode == 'OK'
+
+    def ex_destroy_nic(self, nic_id):
+        request = ET.Element('removeNic',
+                             {'xmlns': TYPES_URN,
+                              'id': nic_id})
+
+        response = self.connection.request_with_orgId_api_2(
+            'server/removeNic',
+            method='POST',
+            data=ET.tostring(request)).object
+        responseCode = findtext(response, 'responseCode', TYPES_URN)
+        return responseCode == 'IN_PROGRESS' or responseCode == 'OK'
+
     def ex_list_networks(self, location=None):
         """
         List networks deployed across all data center locations for your

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02feb81a/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_addNic.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_addNic.xml
b/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_addNic.xml
new file mode 100644
index 0000000..56eeb02
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_addNic.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<response
+xmlns="urn:didata.com:api:cloud:types" requestId="NA9/2015-03-08T06:17:52.133-04:00/70e7458c-038c-4819-a1de-90d15007c2f5">
+<operation>ADD_NIC</operation>
+<responseCode>IN_PROGRESS</responseCode>
+<message>The request to add NIC for VLAN 'Subsystem VLAN' on Server
+'Production Mail Server' has been accepted and is being processed..</message>
+<info name="nicId" value="a202e51b-41c0-4cfc-add0-b1c62fc0ecf6"/>
+</response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02feb81a/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_removeNic.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_removeNic.xml
b/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_removeNic.xml
new file mode 100644
index 0000000..61be4e3
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_removeNic.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<response
+xmlns="urn:didata.com:api:cloud:types" requestId="NA9/2015-03-08T06:57:51.297-04:00/6857b7e6-e3a9-438c-87fe-ed2248c65c55">
+<operation>REMOVE_NIC</operation>
+<responseCode>IN_PROGRESS</responseCode>
+<message>Request to Remove NIC 5999db1d-725c-46ba-9d4e-d33991e61ab1 for
+VLAN 'Subsystem VLAN' from Server 'Production Mail Server' has been accepted
+and is being processed.</message>
+</response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/02feb81a/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index 2581d62..f3ccc7e 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -196,6 +196,14 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         ret = self.driver.ex_reset(node)
         self.assertTrue(ret is True)
 
+    def test_ex_attach_node_to_vlan(self):
+        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)
+
+    def test_ex_destroy_nic(self):
+        node = self.driver.ex_destroy_nic('a202e51b-41c0-4cfc-add0-b1c62fc0ecf6')
+
     def test_list_networks(self):
         nets = self.driver.list_networks()
         self.assertEqual(nets[0].name, 'test-net1')
@@ -659,6 +667,16 @@ class DimensionDataMockHttp(MockHttp):
             'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_network_deleteNatRule.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_addNic(self, method, url, body,
headers):
+        body = self.fixtures.load(
+            'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_addNic.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_removeNic(self, method, url,
body, headers):
+        body = self.fixtures.load(
+            'caas_2_0_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_removeNic.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
 
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message