You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/12/02 04:33:25 UTC

[23/40] libcloud git commit: Add feature exchange nic vlans

Add feature exchange nic vlans


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

Branch: refs/heads/trunk
Commit: 8404532020b576651d3f915a157a707bd966d56c
Parents: 4189872
Author: Samuel Chong <sa...@gmail.com>
Authored: Thu Nov 17 11:54:34 2016 +1100
Committer: Samuel Chong <sa...@gmail.com>
Committed: Thu Nov 17 11:54:34 2016 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py       | 30 ++++++++++++++++++++
 .../2.4/exchange_nic_vlans_response.xml         |  8 ++++++
 .../test/compute/test_dimensiondata_v2_4.py     | 13 +++++++++
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/84045320/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 60056b4..6f0a197 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -3690,6 +3690,36 @@ class DimensionDataNodeDriver(NodeDriver):
         response_code = findtext(response, 'responseCode', TYPES_URN)
         return response_code in ['IN_PROGRESS', 'OK']
 
+    def ex_exchange_nic_vlans(self, nic_id_1, nic_id_2):
+        """
+        Exchange NIC Vlans
+
+        :param    nic_id_1:  Nic ID 1
+        :type     nic_id_1: :``str``
+
+        :param    nic_id_2:  Nic ID 2
+        :type     nic_id_2: :``str``
+
+        :rtype: ``bool``
+        """
+
+        exchange_elem = ET.Element(
+            'urn:exchangeNicVlans',
+            {
+                'xmlns:urn': TYPES_URN,
+            })
+
+        ET.SubElement(exchange_elem, 'urn:nicId1').text = nic_id_1
+        ET.SubElement(exchange_elem, 'urn:nicId2').text = nic_id_2
+
+        response = self.connection.request_with_orgId_api_2(
+            'server/exchangeNicVlans',
+            method='POST',
+            data=ET.tostring(exchange_elem)).object
+
+        response_code = findtext(response, 'responseCode', TYPES_URN)
+        return response_code in ['IN_PROGRESS', 'OK']
+
     def _format_csv(self, http_response):
         text = http_response.read()
         lines = str.splitlines(ensure_string(text))

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84045320/libcloud/test/compute/fixtures/dimensiondata/2.4/exchange_nic_vlans_response.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/2.4/exchange_nic_vlans_response.xml b/libcloud/test/compute/fixtures/dimensiondata/2.4/exchange_nic_vlans_response.xml
new file mode 100644
index 0000000..d0e8315
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/2.4/exchange_nic_vlans_response.xml
@@ -0,0 +1,8 @@
+<urn:response requestId="na/2015-01-18T13:37:20/62f06368-c3fb-11e3-b29c-001517c4643e"
+xmlns:urn="urn:didata.com:api:cloud:types">
+    <urn:operation>EXCHANGE_NIC_VLANS</urn:operation>
+    <urn:responseCode>OK</urn:responseCode>
+    <urn:message>Request to exchange VLANs for Server with Id
+'1cec8cfb-69e7-4de9-8404-debf116f5242' has been accepted and is being
+processed.</urn:message>
+</urn:response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84045320/libcloud/test/compute/test_dimensiondata_v2_4.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata_v2_4.py b/libcloud/test/compute/test_dimensiondata_v2_4.py
index 7a2ba63..d835b5c 100644
--- a/libcloud/test/compute/test_dimensiondata_v2_4.py
+++ b/libcloud/test/compute/test_dimensiondata_v2_4.py
@@ -2039,6 +2039,12 @@ class DimensionData_v2_4_Tests(unittest.TestCase, TestCaseMixin):
             tagkey_name_value_dictionaries=tag_dictionaries)
         self.assertTrue(success)
 
+    def test_exchange_nic_vlans(self):
+        success = self.driver.ex_exchange_nic_vlans(
+                  nic_id_1='a4b4b42b-ccb5-416f-b052-ce7cb7fdff12',
+                  nic_id_2='b39d09b8-ea65-424a-8fa6-c6f5a98afc69')
+        self.assertTrue(success)
+
 class InvalidRequestError(Exception):
     def __init__(self, tag):
         super(InvalidRequestError, self).__init__("Invalid Request - %s" % tag)
@@ -3302,5 +3308,12 @@ class DimensionDataMockHttp(StorageMockHttp, MockHttp):
         )
         return httplib.OK, body, {}, httplib.responses[httplib.OK]
 
+    def _caas_2_4_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_exchangeNicVlans(
+        self, method, url, body, headers):
+        body = self.fixtures.load(
+            '2.4/exchange_nic_vlans_response.xml'
+        )
+        return httplib.OK, body, {}, httplib.responses[httplib.OK]
+
 if __name__ == '__main__':
     sys.exit(unittest.main())