libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [09/51] [abbrv] libcloud git commit: fixed drivers/nttcis.py which could not find disks as the CC API had changed.
Date Wed, 31 Oct 2018 03:11:20 GMT
fixed drivers/nttcis.py which could not find disks as the CC API had changed.


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

Branch: refs/heads/trunk
Commit: b4a7e98d2056d9b4f0f3d9b4535e9aaf10215dc7
Parents: db96211
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Thu Aug 16 16:12:42 2018 -0400
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Thu Aug 16 16:12:42 2018 -0400

----------------------------------------------------------------------
 libcloud/compute/drivers/nttcis.py | 40 +++++++++++++++++++++++++++++----
 tests/lib_edit_test.py             | 12 +++++++++-
 tests/lib_list_test.py             | 25 +++++++++++++++++++++
 3 files changed, 72 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b4a7e98d/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index 5775e63..8512f4e 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -733,8 +733,7 @@ class NttCisNodeDriver(NodeDriver):
                    ex_ipv6=None, ex_ipv4=None, ex_vlan=None,
                    ex_image=None, ex_deployed=None,
                    ex_started=None, ex_state=None,
-                   ex_network=None, ex_network_domain=None,
-                   ex_snaphots=None):
+                   ex_network_domain=None, ex_snaphots=None):
         """
         List nodes deployed for your organization.
 
@@ -789,7 +788,6 @@ class NttCisNodeDriver(NodeDriver):
                 ipv4=ex_ipv4, vlan=ex_vlan,
                 image=ex_image, deployed=ex_deployed,
                 started=ex_started, state=ex_state,
-                network=ex_network,
                 network_domain=ex_network_domain):
             node_list.extend(nodes)
 
@@ -838,6 +836,26 @@ class NttCisNodeDriver(NodeDriver):
                      driver=self.connection.driver),
         ]
 
+    def list_datacenter_properties(self, location: str=None) -> list:
+        """
+        return a list of available sizes
+            Currently, the size of the node is dictated by the chosen OS base
+            image, they cannot be set explicitly.
+
+        @inherits: :class:`NodeDriver.list_sizes`
+        """
+
+        return [
+            NodeSize(id=1,
+                     name="default",
+                     ram=0,
+                     disk=0,
+                     bandwidth=0,
+                     price=0,
+                     driver=self.connection.driver),
+        ]
+
+
     def list_locations(self, ex_id=None):
         """
         List locations (datacenters) available for instantiating servers and
@@ -4556,6 +4574,8 @@ class NttCisNodeDriver(NodeDriver):
             api_version=api_version)
 
     def _to_disks(self, object):
+        for child in object.iter():
+            print(child.tag, child.attrib)
         disk_elements = object.findall(fixxpath('disk', TYPES_URN))
         return [self._to_disk(el) for el in disk_elements]
 
@@ -4604,9 +4624,21 @@ class NttCisNodeDriver(NodeDriver):
         has_network_info \
             = element.find(fixxpath('networkInfo', TYPES_URN)) is not None
         cpu_spec = self._to_cpu_spec(element.find(fixxpath('cpu', TYPES_URN)))
-        disks = self._to_disks(element)
 
         has_snapshot = element.find(fixxpath('snapshotService', TYPES_URN)) is not None
+        has_scsi = element.find(fixxpath('scsiController', TYPES_URN)) is not None
+        has_sata = element.find(fixxpath('sataController', TYPES_URN)) is not None
+        has_ide = element.find(fixxpath('ideController')) is not None
+        disks = []
+        if has_scsi:
+            for scsi in element.findall(fixxpath('scsiController', TYPES_URN)):
+                disks.extend(self._to_disks(scsi))
+        if has_sata:
+            for sata in element.findall(fixxpath('sataController', TYPES_URN)):
+                disks.extend(self._to_disks(sata))
+        if has_ide:
+            for ide in element.findall(fixxpath('ideController', TYPES_URN)):
+                disks.extend(self._to_snapshot(ide))
 
         # Vmware Tools
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/b4a7e98d/tests/lib_edit_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_edit_test.py b/tests/lib_edit_test.py
index 8c6596f..222ce6e 100644
--- a/tests/lib_edit_test.py
+++ b/tests/lib_edit_test.py
@@ -84,12 +84,22 @@ def test_edit_metadata_fails(compute_driver):
 
 
 def test_reconfigure_node(compute_driver):
-    node = compute_driver.ex_get_node_by_id('040fefdb-78be-4b17-8ef9-86820bad67d9 ')
+    node = compute_driver.ex_get_node_by_id('040fefdb-78be-4b17-8ef9-86820bad67d9')
     cpu_performance = 'HIGHPERFORMANCE'
     result = compute_driver.ex_reconfigure_node(node, cpu_performance=cpu_performance)
     assert result is True
 
 
+def test_add_disk(compute_driver):
+    node = compute_driver.ex_get_node_by_id('803e5e00-b22a-450a-8827-066ff15ec977')
+    print(node)
+
+
+def test_remove_disk(compute_driver):
+    node = compute_driver.ex_get_node_by_id('803e5e00-b22a-450a-8827-066ff15ec977')
+    print(node)
+
+
 def test_list_locations(compute_driver):
     locations = compute_driver.list_locations()
     for location in locations:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/b4a7e98d/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index 9a090ae..fec88dc 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -52,6 +52,24 @@ def test_list_node_ipv4(compute_driver):
     assert isinstance(nodes, list) and len(nodes) > 0
 
 
+def test_list_images(compute_driver):
+    images = compute_driver.list_images(location='EU6')
+    print()
+    for image in images:
+        print(image.id, image.name)
+    assert isinstance(images, list) and len(images) > 0
+
+
+def test_list_node_by_image(compute_driver):
+    nodes = compute_driver.list_nodes(ex_image='81a36aa0-555c-4735-b965-4b64fcf0ac8f')
+    print()
+    for node in nodes:
+        print(node.extra['networkDomainId'], node.extra['datacenterId'], node.uuid, node.state,
node.name, node.extra['cpu'],
+              [disk for disk in node.extra['disks']], node.extra['memoryMb'], node.extra['OS_displayName'],
+              node.private_ips, node.extra['ipv6'])
+    assert isinstance(nodes, list) and len(nodes) > 0
+
+
 """
     requires retrieving vlan Id first
 """
@@ -245,6 +263,13 @@ def test_list_snapshots(compute_driver):
         print(snapshot)
         assert 'expiry_time' in snapshot
 
+"""
+def test_list_sizes(compute_driver):
+    properties = compute_driver.list_locations()
+    for property in properties:
+        print(property)
+"""
+
 
 def test_images(compute_driver):
     images = compute_driver.list_images()


Mime
View raw message