libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [06/51] [abbrv] libcloud git commit: Can now find and list snapshots when enabled on a server
Date Wed, 31 Oct 2018 03:11:17 GMT
Can now find and list snapshots when enabled on a server


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

Branch: refs/heads/trunk
Commit: 3ebd1dbcd20dc9c2349992875ce8d58af2472bf7
Parents: e49ef2b
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Mon Aug 6 12:34:00 2018 -0400
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Mon Aug 6 12:34:00 2018 -0400

----------------------------------------------------------------------
 libcloud/common/nttcis.py          | 11 ++++++-----
 libcloud/compute/drivers/nttcis.py |  6 ++++++
 libcloud/utils/xml.py              |  2 +-
 tests/libtest.py                   |  4 +---
 4 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ebd1dbc/libcloud/common/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py
index 4506dad..6e2375c 100644
--- a/libcloud/common/nttcis.py
+++ b/libcloud/common/nttcis.py
@@ -855,11 +855,12 @@ class NttCisSnapshot(object):
         self.expiry_time = expiry_time
         self.action = action
 
-    def create_snapshot(self):
-        pass
-
-
-
+    def __repr__(self):
+        return (('<NttCisSnapshots '
+                 'id=%s, start_time=%s, '
+                 'end_time=%s, self.type=%s, '
+                 'self.expiry_timne=%s, self.state=%s>')
+                % (self.id, self.start_time, self.end_time, self.type, self.expiry_time,
self.state))
 
 
 class NttCisFirewallRule(object):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ebd1dbc/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index 7f2ddca..42272a3 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -46,6 +46,7 @@ from libcloud.common.nttcis import NttCisNic
 from libcloud.common.nttcis import NetworkDomainServicePlan
 from libcloud.common.nttcis import NttCisTagKey
 from libcloud.common.nttcis import NttCisTag
+from libcloud.common.nttcis import NttCisSnapshot
 from libcloud.common.nttcis import API_ENDPOINTS, DEFAULT_REGION
 from libcloud.common.nttcis import TYPES_URN
 from libcloud.common.nttcis import SERVER_NS, NETWORK_NS, GENERAL_NS
@@ -4485,6 +4486,8 @@ class NttCisNodeDriver(NodeDriver):
         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
+
         # Vmware Tools
 
         # Version 2.3 or earlier
@@ -4518,6 +4521,9 @@ class NttCisNodeDriver(NodeDriver):
                 if has_network_info else None,
             'datacenterId': element.get('datacenterId'),
             'deployedTime': findtext(element, 'createTime', TYPES_URN),
+            'window': (element.find(fixxpath('snapshotService/window', TYPES_URN)).get('dayOfWeek'),
+                       element.find(fixxpath('snapshotService/window', TYPES_URN)).get('startHour'))
+                       if has_snapshot else None,
             'cpu': cpu_spec,
             'memoryMb': int(findtext(
                 element,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ebd1dbc/libcloud/utils/xml.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/xml.py b/libcloud/utils/xml.py
index c2c1321..6a5d984 100644
--- a/libcloud/utils/xml.py
+++ b/libcloud/utils/xml.py
@@ -25,7 +25,7 @@ def fixxpath(xpath, namespace=None):
     # ElementTree wants namespaces in its xpaths, so here we add them.
     if not namespace:
         return xpath
-
+    path = '/'.join(['{%s}%s' % (namespace, e) for e in xpath.split('/')])
     return '/'.join(['{%s}%s' % (namespace, e) for e in xpath.split('/')])
 
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ebd1dbc/tests/libtest.py
----------------------------------------------------------------------
diff --git a/tests/libtest.py b/tests/libtest.py
index e354944..4b95b6b 100644
--- a/tests/libtest.py
+++ b/tests/libtest.py
@@ -8,7 +8,7 @@ def test_list_node_all(compute_driver):
     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'])
+              node.private_ips, node.extra['ipv6'], node.extra['window'])
     assert isinstance(nodes, list) and len(nodes) > 0
 
 
@@ -238,8 +238,6 @@ def test_get_node(lbdriver):
     print(node.name, node.ip, node.connection_limit, node.connection_rate_limit)
     assert isinstance(node, object)
 
-def test_sap_shots(compute_driver):
-    pass
 
 def test_images(compute_driver):
     images = compute_driver.list_images()


Mime
View raw message