libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [02/11] libcloud git commit: Fix tags for deploy uncustomised image
Date Tue, 27 Dec 2016 08:26:44 GMT
Fix tags for deploy uncustomised image


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

Branch: refs/heads/trunk
Commit: e91e66c857dccebcc106542a88169f91f27dd9ba
Parents: 80ff417
Author: Samuel Chong <samuelchong1@gmail.com>
Authored: Wed Dec 21 13:27:21 2016 +1100
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Tue Dec 27 19:22:04 2016 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py | 50 ++++++++++++--------------
 1 file changed, 22 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e91e66c8/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index ec30bc1..1ce61dc 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -3915,8 +3915,7 @@ class DimensionDataNodeDriver(NodeDriver):
                             ex_tagname_value_pairs is
                             mutually exclusive. Use one or other.
 
-        :type       ex_tagname_value_pairs: ``list`` of dictionary of tag name
-        and value pair. Value can be None.
+        :type       ex_tagname_value_pairs: ``dict``.  Value can be None.
 
         :keyword    ex_tagname_value_pairs:
                             (Optional) up to 10 tag elements may be provided.
@@ -3926,8 +3925,7 @@ class DimensionDataNodeDriver(NodeDriver):
                             ex_tagname_value_pairs is
                             mutually exclusive. Use one or other.
 
-        :type       ex_tagname_value_pairs: ``list`` of dictionary of tag name
-        and value pair. Value can be None.
+        :type       ex_tagname_value_pairs: ``dict```.
 
         :return: The newly created :class:`Node`.
         :rtype: :class:`Node`
@@ -3945,30 +3943,30 @@ class DimensionDataNodeDriver(NodeDriver):
             print("Warning: ex_is_started input value is invalid. Default"
                   "to True")
 
-        server_elm = ET.Element('deployUncustomizedServer',
+        server_uncustomized_elm = ET.Element('deployUncustomizedServer',
                                 {'xmlns': TYPES_URN})
-        ET.SubElement(server_elm, "name").text = name
-        ET.SubElement(server_elm, "description").text = ex_description
+        ET.SubElement(server_uncustomized_elm, "name").text = name
+        ET.SubElement(server_uncustomized_elm, "description").text = ex_description
         image_id = self._image_to_image_id(image)
-        ET.SubElement(server_elm, "imageId").text = image_id
+        ET.SubElement(server_uncustomized_elm, "imageId").text = image_id
 
         if ex_cluster_id:
-            dns_elm = ET.SubElement(server_elm, "primaryDns")
+            dns_elm = ET.SubElement(server_uncustomized_elm, "primaryDns")
             dns_elm.text = ex_cluster_id
 
         if ex_is_started is not None:
-            ET.SubElement(server_elm, "start").text = str(
+            ET.SubElement(server_uncustomized_elm, "start").text = str(
                 ex_is_started).lower()
 
         if ex_cpu_specification is not None:
-            cpu = ET.SubElement(server_elm, "cpu")
+            cpu = ET.SubElement(server_uncustomized_elm, "cpu")
             cpu.set('speed', ex_cpu_specification.performance)
             cpu.set('count', str(ex_cpu_specification.cpu_count))
             cpu.set('coresPerSocket',
                     str(ex_cpu_specification.cores_per_socket))
 
         if ex_memory_gb is not None:
-            ET.SubElement(server_elm, "memoryGb").text = str(ex_memory_gb)
+            ET.SubElement(server_uncustomized_elm, "memoryGb").text = str(ex_memory_gb)
 
         if (ex_primary_nic_private_ipv4 is None and
                 ex_primary_nic_vlan is None):
@@ -3983,7 +3981,7 @@ class DimensionDataNodeDriver(NodeDriver):
                              "ex_primary_nic_vlan "
                              "be specified. Not both.")
 
-        network_elm = ET.SubElement(server_elm, "networkInfo")
+        network_elm = ET.SubElement(server_uncustomized_elm, "networkInfo")
 
         net_domain_id = self._network_domain_to_network_domain_id(
             ex_network_domain)
@@ -4039,7 +4037,7 @@ class DimensionDataNodeDriver(NodeDriver):
 
         if isinstance(ex_disks, (list, tuple)):
             for disk in ex_disks:
-                disk_elm = ET.SubElement(server_elm, 'disk')
+                disk_elm = ET.SubElement(server_uncustomized_elm, 'disk')
                 disk_elm.set('scsiId', disk.scsi_id)
                 disk_elm.set('speed', disk.speed)
         elif ex_disks is not None:
@@ -4053,39 +4051,35 @@ class DimensionDataNodeDriver(NodeDriver):
 
         # Tag by ID
         if ex_tagid_value_pairs is not None:
-            if not isinstance(ex_tagid_value_pairs, (list, tuple)):
+            if not isinstance(ex_tagid_value_pairs, dict):
                 raise ValueError(
-                    "ex_tagid_value_pairs should be a list of tag ID and "
-                    "value dictionary."
+                    "ex_tagid_value_pairs must be a dictionary."
                 )
 
-            tag_elem = ET.SubElement(server_elm, 'tagById')
-
             for k, v in ex_tagid_value_pairs.items():
+                tag_elem = ET.SubElement(server_uncustomized_elm, 'tagById')
                 ET.SubElement(tag_elem, 'tagKeyId').text = k
 
                 if v is not None:
                     ET.SubElement(tag_elem, 'value').text = v
 
         if ex_tagname_value_pairs is not None:
-            if not isinstance(ex_tagname_value_pairs, (list, tuple)):
+            if not isinstance(ex_tagname_value_pairs, dict):
                 raise ValueError(
-                    "ex_tagname_value_pairs should be a list of tag ID and "
-                    "value dictionary."
+                    "ex_tagname_value_pairs must be a dictionary"
                 )
 
-            tag_elem = ET.SubElement(server_elm, 'tag')
-
-            for k, v in ex_tagid_value_pairs.items():
-                ET.SubElement(tag_elem, 'tagKeyName').text = k
+            for k, v in ex_tagname_value_pairs.items():
+                tag_name_elem = ET.SubElement(server_uncustomized_elm, 'tag')
+                ET.SubElement(tag_name_elem, 'tagKeyName').text = k
 
                 if v is not None:
-                    ET.SubElement(tag_elem, 'value').text = v
+                    ET.SubElement(tag_name_elem, 'value').text = v
 
         response = self.connection.request_with_orgId_api_2(
             'server/deployUncustomizedServer',
             method='POST',
-            data=ET.tostring(server_elm)).object
+            data=ET.tostring(server_uncustomized_elm)).object
 
         node_id = None
         for info in findall(response, 'info', TYPES_URN):


Mime
View raw message