libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [08/45] libcloud git commit: changed _to_nodes and _to_node and drivers/nttcis.py to handle node retrieval by process_xml
Date Thu, 13 Dec 2018 11:26:17 GMT
changed _to_nodes and _to_node and drivers/nttcis.py to handle node retrieval by process_xml


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

Branch: refs/heads/trunk
Commit: 81d57364270d58038f02895bc136f19044446b5f
Parents: a88fb2f
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Sun Oct 28 11:18:23 2018 -0400
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Sun Oct 28 11:18:23 2018 -0400

----------------------------------------------------------------------
 libcloud/common/nttcis.py          |  6 ++----
 libcloud/compute/drivers/nttcis.py | 10 +++++++---
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/81d57364/libcloud/common/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py
index 019aead..126530f 100644
--- a/libcloud/common/nttcis.py
+++ b/libcloud/common/nttcis.py
@@ -1942,7 +1942,6 @@ def processor(mapping, name=None):
 
     def add_items(key, value, name=None):
         if name in attrs:
-            print(attrs)
             attrs[name].update({key: value})
         elif name is not None:
             attrs[name] = value
@@ -2049,7 +2048,6 @@ def processor(mapping, name=None):
 
     if len(map_copy) == 0:
         return 1
-    #print(attrs)
     return process(mapping, name)
 
 
@@ -2080,7 +2078,6 @@ class XmlListConfig(list):
         for element in elem_list:
             if element is not None:
                 # treat like dict
-                #print(element.attrib, len(element))
                 if len(element) >= 0 or element[0].tag != element[1].tag:
                     self.append(XmlDictConfig(element))
                 # treat like list
@@ -2153,6 +2150,7 @@ class XmlDictConfig(dict):
 
 
 def process_xml(xml):
+    global attrs
     tree = etree.parse(BytesIO(xml))
     root = tree.getroot()
     elem = root.tag.split('}')[1].capitalize()
@@ -2166,6 +2164,6 @@ def process_xml(xml):
         processor(converted_xml)
     klass = class_factory(elem.capitalize(), attrs)
     cls = klass(attrs)
-
+    attrs = {}
     return cls
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/81d57364/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index c1266d9..a17286a 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -782,6 +782,9 @@ class NttCisNodeDriver(NodeDriver):
         :rtype: ``list`` of :class:`Node`
         """
         node_list = []
+        # This is a generator so we changed from the original
+        # and if nodes is not empty, ie, the stop iteration confdition
+        # Then set node_list to nodes and retrn.
         for nodes in self.ex_list_nodes_paginated(
                 location=ex_location,
                 name=ex_name, ipv6=ex_ipv6,
@@ -789,8 +792,8 @@ class NttCisNodeDriver(NodeDriver):
                 image=ex_image, deployed=ex_deployed,
                 started=ex_started, state=ex_state,
                 network_domain=ex_network_domain):
-            node_list.extend(nodes)
-
+            if nodes:
+                node_list = nodes
         return node_list
 
     def list_images(self, location=None):
@@ -5123,7 +5126,8 @@ class NttCisNodeDriver(NodeDriver):
         return [self._to_node(el) for el in node_elements]
 
     def _to_node(self, element):
-        return process_xml(element)
+        # Get all information at once and process in common/nttcis
+        return process_xml(ET.tostring(element))
         """    
         started = findtext(element, 'started', TYPES_URN)
         status = self._to_status(element.find(fixxpath('progress', TYPES_URN)))


Mime
View raw message