Repository: libcloud
Updated Branches:
  refs/heads/trunk 4864e14e8 -> 0e4e0ada6


DimensionData: changing image to be NodeImage or str, upping code coverage in 
tests


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

Branch: refs/heads/trunk
Commit: ba3107c3cfcddbb140b007b4b8e8b54169a5f40b
Parents: 4864e14
Author: Jeffrey Dunham <[email protected]>
Authored: Sat Feb 6 01:44:58 2016 -0500
Committer: anthony-shaw <[email protected]>
Committed: Sun Feb 7 19:47:32 2016 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py   |  8 +++++--
 libcloud/test/compute/test_dimensiondata.py | 30 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/ba3107c3/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py 
b/libcloud/compute/drivers/dimensiondata.py
index 08fba95..543b9ff 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -94,7 +94,7 @@ class DimensionDataNodeDriver(NodeDriver):
         :type       name:   ``str``
 
         :keyword    image:  OS Image to boot on node. (required)
-        :type       image:  :class:`NodeImage`
+        :type       image:  :class:`NodeImage` or ``str``
 
         :keyword    auth:   Initial authentication information for the
                             node (required)
@@ -150,10 +150,14 @@ class DimensionDataNodeDriver(NodeDriver):
         server_elm = ET.Element('deployServer', {'xmlns': TYPES_URN})
         ET.SubElement(server_elm, "name").text = name
         ET.SubElement(server_elm, "description").text = ex_description
-        ET.SubElement(server_elm, "imageId").text = image.id
         ET.SubElement(server_elm, "start").text = str(ex_is_started).lower()
         ET.SubElement(server_elm, "administratorPassword").text = password
 
+        if isinstance(image, NodeImage):
+            ET.SubElement(server_elm, "imageId").text = image.id
+        else:
+            ET.SubElement(server_elm, "imageId").text = image
+
         if ex_cpu_specification is not None:
             cpu = ET.SubElement(server_elm, "cpu")
             cpu.set('speed', ex_cpu_specification.performance)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ba3107c3/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py 
b/libcloud/test/compute/test_dimensiondata.py
index 557b3ac..4986183 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -143,6 +143,16 @@ 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_response_STR(self):
+        rootPw = 'pass123'
+        image = self.driver.list_images()[0].id
+        network = self.driver.ex_list_networks()[0].id
+        node = self.driver.create_node(name='test2', image=image, auth=rootPw,
+                                       ex_description='test2 node', 
ex_network=network,
+                                       ex_is_started=False)
+        self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')
+        self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')
+
     def test_create_node_response_network_domain(self):
         rootPw = NodeAuthPassword('pass123')
         location = self.driver.ex_get_location_by_id('NA9')
@@ -163,6 +173,26 @@ 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_response_network_domain_STR(self):
+        rootPw = NodeAuthPassword('pass123')
+        location = self.driver.ex_get_location_by_id('NA9')
+        image = self.driver.list_images(location=location)[0]
+        network_domain = 
self.driver.ex_list_network_domains(location=location)[0].id
+        vlan = self.driver.ex_list_vlans(location=location)[0].id
+        cpu = DimensionDataServerCpuSpecification(
+            cpu_count=4,
+            cores_per_socket=1,
+            performance='HIGHPERFORMANCE'
+        )
+        node = self.driver.create_node(name='test2', image=image, auth=rootPw,
+                                       ex_description='test2 node',
+                                       ex_network_domain=network_domain,
+                                       ex_vlan=vlan,
+                                       ex_is_started=False, 
ex_cpu_specification=cpu,
+                                       ex_memory_gb=4)
+        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]

Reply via email to