libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [08/11] libcloud git commit: Added support for reconfiguring a live node
Date Wed, 09 Dec 2015 10:19:26 GMT
Added support for reconfiguring a live node

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/41c02f51
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/41c02f51
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/41c02f51

Branch: refs/heads/trunk
Commit: 41c02f5109a31bd98ab80729d8e3d6a1a02476c6
Parents: a543be0
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Tue Dec 8 21:14:13 2015 +1100
Committer: Anthony Shaw <anthony.p.shaw@gmail.com>
Committed: Wed Dec 9 21:19:14 2015 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py       | 40 ++++++++++++++++++++
 ...bc_8dabe5a7d0e4_server_reconfigureServer.xml |  5 +++
 libcloud/test/compute/test_dimensiondata.py     | 15 ++++++++
 3 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/41c02f51/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 1221f71..de8384c 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -1312,6 +1312,46 @@ class DimensionDataNodeDriver(NodeDriver):
         response_code = findtext(result, 'result', GENERAL_NS)
         return response_code in ['IN_PROGRESS', 'SUCCESS']
 
+    def ex_reconfigure_node(self, node, memory_gb, cpu_count, cores_per_socket,
+                            cpu_performance):
+        """
+        Reconfigure the virtual hardware specification of a node
+
+        :param  node: The server to change
+        :type   node: :class:`Node`
+
+        :param  memory_gb: The amount of memory in GB (optional)
+        :type   memory_gb: ``int``
+
+        :param  cpu_count: The number of CPU (optional)
+        :type   cpu_count: ``int``
+
+        :param  cores_per_socket: Number of CPU cores per socket (optional)
+        :type   cores_per_socket: ``int``
+
+        :param  cpu_performance: CPU Performance type (optional)
+        :type   cpu_performance: ``str``
+
+        :rtype: ``bool``
+        """
+        update = ET.Element('reconfigureServer', {'xmlns': TYPES_URN})
+        update.set('id', node.id)
+        if memory_gb is not None:
+            ET.SubElement(update, 'memoryGb').text = str(memory_gb)
+        if cpu_count is not None:
+            ET.SubElement(update, 'cpuCount').text = str(cpu_count)
+        if cpu_performance is not None:
+            ET.SubElement(update, 'cpuSpeed').text = cpu_performance
+        if cores_per_socket is not None:
+            ET.SubElement(update, 'coresPerSocket').text = \
+                str(cores_per_socket)
+        result = self.connection.request_with_orgId_api_2(
+            'server/reconfigureServer',
+            method='POST',
+            data=ET.tostring(update)).object
+        response_code = findtext(result, 'responseCode', TYPES_URN)
+        return response_code in ['IN_PROGRESS', 'OK']
+
     def ex_clone_node_to_image(self, node, image_name, image_description=None):
         """
         Clone a server into a customer image.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/41c02f51/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_reconfigureServer.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_reconfigureServer.xml
b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_reconfigureServer.xml
new file mode 100644
index 0000000..e28e8d7
--- /dev/null
+++ b/libcloud/test/compute/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_reconfigureServer.xml
@@ -0,0 +1,5 @@
+<response xmlns="urn:didata.com:api:cloud:types" requestId="na9/2015-1130T12:07:27.838-05:00/1e22a049-d772-4c39-943c-5c773a7ac9ae">
+    <operation>RECONFIGURE_SERVER</operation>
+    <responseCode>OK</responseCode>
+    <message>Request to reconfigure Server 'Production Server' has been accepted and
is being processed.</message>
+</response>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/41c02f51/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index f8f3f44..6f06a0e 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -471,6 +471,11 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
         result = self.driver.ex_update_node(node, 'my new name', 'a description', 2, 4048)
         self.assertTrue(result)
 
+    def test_ex_reconfigure_node(self):
+        node = self.driver.list_nodes()[0]
+        result = self.driver.ex_reconfigure_node(node, 4, 4, 1,'HIGHPERFORMANCE')
+        self.assertTrue(result)
+    
 
 class InvalidRequestError(Exception):
     def __init__(self, tag):
@@ -947,5 +952,15 @@ class DimensionDataMockHttp(MockHttp):
             'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_image_customerImage.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_reconfigureServer(self, method,
url, body, headers):
+        request = ET.fromstring(body)
+        if request.tag != "{urn:didata.com:api:cloud:types}reconfigureServer":
+            raise InvalidRequestError(request.tag)
+        body = self.fixtures.load(
+            'caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_reconfigureServer.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


Mime
View raw message