libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [21/45] libcloud git commit: added addtional tests and the functionality to choose snapshots by filtering create times
Date Thu, 13 Dec 2018 11:26:30 GMT
added addtional tests and the functionality to choose snapshots by filtering create times


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

Branch: refs/heads/trunk
Commit: 3e83d4beb4380ff36061b20fae991175f91e2f84
Parents: 9c76b41
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Thu Nov 8 09:20:00 2018 -0500
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Thu Nov 8 09:20:00 2018 -0500

----------------------------------------------------------------------
 libcloud/drs/drivers/nttcis.py                  | 53 +++++++++++-
 .../fixtures/nttcis/drs_snapshots_by_min.xml    | 90 ++++++++++++++++++++
 libcloud/test/drs/test_nttcis.py                | 48 ++++++++---
 tests/lib_list_test.py                          | 23 ++++-
 4 files changed, 198 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3e83d4be/libcloud/drs/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/drivers/nttcis.py b/libcloud/drs/drivers/nttcis.py
index b0930c8..13490ae 100644
--- a/libcloud/drs/drivers/nttcis.py
+++ b/libcloud/drs/drivers/nttcis.py
@@ -116,7 +116,7 @@ class NttCisDRSDriver(DRSDriver):
     def list_consistency_groups(self, params={}):
         """
         Functions takes a named parameter that must be one of the following
-        :param params: A dictionary composed of one of the follwing keys and a value
+        :param params: A dictionary composed of one of the following keys and a value
                        * target_data_center_id=
                        * source_network_domain_id=
                        * target_network_domain_id=
@@ -148,8 +148,50 @@ class NttCisDRSDriver(DRSDriver):
         cg = self._to_process(response)
         return cg
 
-    def list_consistency_group_snapshots(self, consistency_group_id):
-        params = {"consistencyGroupId": consistency_group_id}
+    def list_consistency_group_snapshots(self, consistency_group_id,
+                                         create_time_min=None,
+                                         create_time_max=None):
+        """
+        Optional parameters identify the date of creation of Consistency Group
+        snapshots in *XML Schema (XSD) date time format. Best used as a
+        combination of createTime.MIN and createTime.MAX. If neither is
+        provided then all snapshots up to the possible maximum of 1014
+        will be returned. If MIN is provided by itself, all snapshots
+        between the time specified by MIN and the point in time of
+        execution will be returned. If MAX is provided by itself,
+        then all snapshots up to that point in time (up to the
+        maximum number of 1014) will be returned. MIN and MAX are
+        inclusive for this API function
+
+        :param consistency_group_id: The id of consistency group
+        :type consistency_group_id: ``str``
+        :param create_time_min: (Optional) in form YYYY-MM-DDT00:00.00.00Z or
+                                           substitute time offset for Z, i.e,
+                                           -05:00
+        :type create_time_min: ``str``
+        :param create_time_max: (Optional) in form YYYY-MM-DDT00:00:00.000Z or
+                                           substitute time offset for Z, i.e,
+                                           -05:00
+        :type create_time_max: ``str``
+        :return: `list` of :class" `NttCisSnapshots`
+        """
+
+        if create_time_min is None and create_time_max is None:
+            params = {"consistencyGroupId": consistency_group_id}
+        elif create_time_min and create_time_max:
+            params = {"consistencyGroupId": consistency_group_id,
+                      "createTime.MIN": create_time_min,
+                      "createTime.MAX": create_time_max
+                      }
+        elif create_time_min or create_time_max:
+            if create_time_max is not None:
+                params = {"consistencyGroupId": consistency_group_id,
+                          "createTime.MAX": create_time_max
+                          }
+            elif create_time_min is not None:
+                params = {"consistencyGroupId": consistency_group_id,
+                          "createTime.MIN": create_time_min
+                          }
         paged_result = self.connection.request_with_orgId_api_2(
             'consistencyGroup/snapshot',
             method='GET',
@@ -165,7 +207,7 @@ class NttCisDRSDriver(DRSDriver):
         :type consistency_group_id: ``str``
         :param size_gb: Gb in 100 Gb increments
         :type size_gb: ``str``
-        :return:
+        :return: ``bool``
         """
 
         expand_elm = ET.Element("expandJournal", {"id": consistency_group_id,
@@ -178,6 +220,9 @@ class NttCisDRSDriver(DRSDriver):
         response_code = findtext(response, 'responseCode', TYPES_URN)
         return response_code in ['IN_PROGRESS', 'OK']
 
+    def start_failover_preview(self, consistency_group_id, snapshot_id):
+        pass
+
     def _to_consistency_groups(self, object):
         cgs = findall(object, 'consistencyGroup', TYPES_URN)
         return [self._to_process(el) for el in cgs]

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3e83d4be/libcloud/test/drs/fixtures/nttcis/drs_snapshots_by_min.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/drs/fixtures/nttcis/drs_snapshots_by_min.xml b/libcloud/test/drs/fixtures/nttcis/drs_snapshots_by_min.xml
new file mode 100644
index 0000000..99c6ced
--- /dev/null
+++ b/libcloud/test/drs/fixtures/nttcis/drs_snapshots_by_min.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<consistencyGroupSnapshots xmlns="urn:didata.com:api:cloud:types" totalCount="87" journalUsageGb="0.22"
protectionWindow="P0Y0M7DT4H47M26.177S" predictedProtectionWindow="P91Y3M21DT22H2M36.211S">
+    <snapshot id="140736" createTime="2018-11-07T15:58:53.916-05:00" sizeKb="0"/>
+    <snapshot id="140731" createTime="2018-11-07T15:58:50.873-05:00" sizeKb="5"/>
+    <snapshot id="140601" createTime="2018-11-07T15:57:31.642-05:00" sizeKb="54"/>
+    <snapshot id="139321" createTime="2018-11-07T15:44:32.220-05:00" sizeKb="54"/>
+    <snapshot id="138041" createTime="2018-11-07T15:31:32.329-05:00" sizeKb="54"/>
+    <snapshot id="136761" createTime="2018-11-07T15:18:32.749-05:00" sizeKb="54"/>
+    <snapshot id="135481" createTime="2018-11-07T15:05:32.688-05:00" sizeKb="75"/>
+    <snapshot id="134183" createTime="2018-11-07T14:52:32.661-05:00" sizeKb="54"/>
+    <snapshot id="132903" createTime="2018-11-07T14:39:32.389-05:00" sizeKb="54"/>
+    <snapshot id="131623" createTime="2018-11-07T14:26:32.069-05:00" sizeKb="54"/>
+    <snapshot id="130343" createTime="2018-11-07T14:13:32.825-05:00" sizeKb="27"/>
+    <snapshot id="129703" createTime="2018-11-07T14:07:02.931-05:00" sizeKb="55"/>
+    <snapshot id="129041" createTime="2018-11-07T14:00:33.348-05:00" sizeKb="54"/>
+    <snapshot id="127761" createTime="2018-11-07T13:47:33.123-05:00" sizeKb="54"/>
+    <snapshot id="126481" createTime="2018-11-07T13:34:33.073-05:00" sizeKb="54"/>
+    <snapshot id="125201" createTime="2018-11-07T13:21:33.622-05:00" sizeKb="54"/>
+    <snapshot id="123921" createTime="2018-11-07T13:08:34.110-05:00" sizeKb="43"/>
+    <snapshot id="123268" createTime="2018-11-07T13:02:04.173-05:00" sizeKb="249"/>
+    <snapshot id="122516" createTime="2018-11-07T12:55:34.213-05:00" sizeKb="54"/>
+    <snapshot id="121236" createTime="2018-11-07T12:42:34.018-05:00" sizeKb="54"/>
+    <snapshot id="119956" createTime="2018-11-07T12:29:34.921-05:00" sizeKb="54"/>
+    <snapshot id="118676" createTime="2018-11-07T12:16:34.703-05:00" sizeKb="54"/>
+    <snapshot id="117396" createTime="2018-11-07T12:03:35.038-05:00" sizeKb="82"/>
+    <snapshot id="116094" createTime="2018-11-07T11:50:34.781-05:00" sizeKb="54"/>
+    <snapshot id="114814" createTime="2018-11-07T11:37:34.411-05:00" sizeKb="54"/>
+    <snapshot id="113534" createTime="2018-11-07T11:24:34.562-05:00" sizeKb="54"/>
+    <snapshot id="112254" createTime="2018-11-07T11:11:34.661-05:00" sizeKb="33"/>
+    <snapshot id="111606" createTime="2018-11-07T11:05:04.533-05:00" sizeKb="117"/>
+    <snapshot id="110911" createTime="2018-11-07T10:58:34.802-05:00" sizeKb="139"/>
+    <snapshot id="109579" createTime="2018-11-07T10:45:35.381-05:00" sizeKb="61"/>
+    <snapshot id="108285" createTime="2018-11-07T10:32:35.296-05:00" sizeKb="72"/>
+    <snapshot id="106985" createTime="2018-11-07T10:19:35.070-05:00" sizeKb="54"/>
+    <snapshot id="105705" createTime="2018-11-07T10:06:34.828-05:00" sizeKb="75"/>
+    <snapshot id="104407" createTime="2018-11-07T09:53:35.075-05:00" sizeKb="54"/>
+    <snapshot id="103127" createTime="2018-11-07T09:40:35.476-05:00" sizeKb="54"/>
+    <snapshot id="101847" createTime="2018-11-07T09:27:35.646-05:00" sizeKb="54"/>
+    <snapshot id="100567" createTime="2018-11-07T09:14:35.570-05:00" sizeKb="27"/>
+    <snapshot id="99927" createTime="2018-11-07T09:08:05.453-05:00" sizeKb="53"/>
+    <snapshot id="99261" createTime="2018-11-07T09:01:35.363-05:00" sizeKb="62"/>
+    <snapshot id="97971" createTime="2018-11-07T08:48:35.423-05:00" sizeKb="54"/>
+    <snapshot id="96691" createTime="2018-11-07T08:35:35.499-05:00" sizeKb="54"/>
+    <snapshot id="95411" createTime="2018-11-07T08:22:35.176-05:00" sizeKb="54"/>
+    <snapshot id="94131" createTime="2018-11-07T08:09:35.704-05:00" sizeKb="63"/>
+    <snapshot id="92840" createTime="2018-11-07T07:56:35.594-05:00" sizeKb="54"/>
+    <snapshot id="91560" createTime="2018-11-07T07:43:35.557-05:00" sizeKb="57"/>
+    <snapshot id="90275" createTime="2018-11-07T07:30:36.714-05:00" sizeKb="57"/>
+    <snapshot id="88991" createTime="2018-11-07T07:17:36.518-05:00" sizeKb="61"/>
+    <snapshot id="87703" createTime="2018-11-07T07:04:36.925-05:00" sizeKb="75"/>
+    <snapshot id="86404" createTime="2018-11-07T06:51:36.594-05:00" sizeKb="54"/>
+    <snapshot id="85124" createTime="2018-11-07T06:38:36.944-05:00" sizeKb="54"/>
+    <snapshot id="83844" createTime="2018-11-07T06:25:37.281-05:00" sizeKb="54"/>
+    <snapshot id="82564" createTime="2018-11-07T06:12:37.253-05:00" sizeKb="27"/>
+    <snapshot id="81924" createTime="2018-11-07T06:06:07.098-05:00" sizeKb="48"/>
+    <snapshot id="81266" createTime="2018-11-07T05:59:37.367-05:00" sizeKb="54"/>
+    <snapshot id="79986" createTime="2018-11-07T05:46:37.421-05:00" sizeKb="54"/>
+    <snapshot id="78706" createTime="2018-11-07T05:33:38.322-05:00" sizeKb="54"/>
+    <snapshot id="77426" createTime="2018-11-07T05:20:38.384-05:00" sizeKb="54"/>
+    <snapshot id="76146" createTime="2018-11-07T05:07:38.985-05:00" sizeKb="62"/>
+    <snapshot id="75475" createTime="2018-11-07T05:01:09.065-05:00" sizeKb="32"/>
+    <snapshot id="74826" createTime="2018-11-07T04:54:38.976-05:00" sizeKb="54"/>
+    <snapshot id="73546" createTime="2018-11-07T04:41:38.697-05:00" sizeKb="54"/>
+    <snapshot id="72266" createTime="2018-11-07T04:28:39.145-05:00" sizeKb="54"/>
+    <snapshot id="70986" createTime="2018-11-07T04:15:39.114-05:00" sizeKb="55"/>
+    <snapshot id="69702" createTime="2018-11-07T04:02:39.563-05:00" sizeKb="83"/>
+    <snapshot id="68403" createTime="2018-11-07T03:49:39.577-05:00" sizeKb="27"/>
+    <snapshot id="67763" createTime="2018-11-07T03:43:09.797-05:00" sizeKb="51"/>
+    <snapshot id="67102" createTime="2018-11-07T03:36:39.935-05:00" sizeKb="58"/>
+    <snapshot id="65820" createTime="2018-11-07T03:23:39.859-05:00" sizeKb="37"/>
+    <snapshot id="65170" createTime="2018-11-07T03:17:09.938-05:00" sizeKb="372"/>
+    <snapshot id="64341" createTime="2018-11-07T03:10:39.796-05:00" sizeKb="27"/>
+    <snapshot id="63701" createTime="2018-11-07T03:04:10.126-05:00" sizeKb="50"/>
+    <snapshot id="63042" createTime="2018-11-07T02:57:40.014-05:00" sizeKb="54"/>
+    <snapshot id="61762" createTime="2018-11-07T02:44:40.619-05:00" sizeKb="54"/>
+    <snapshot id="60466" createTime="2018-11-07T02:31:31.343-05:00" sizeKb="54"/>
+    <snapshot id="59186" createTime="2018-11-07T02:18:31.853-05:00" sizeKb="55"/>
+    <snapshot id="57902" createTime="2018-11-07T02:05:31.526-05:00" sizeKb="83"/>
+    <snapshot id="56598" createTime="2018-11-07T01:52:31.345-05:00" sizeKb="54"/>
+    <snapshot id="55318" createTime="2018-11-07T01:39:31.367-05:00" sizeKb="54"/>
+    <snapshot id="54038" createTime="2018-11-07T01:26:31.545-05:00" sizeKb="54"/>
+    <snapshot id="52758" createTime="2018-11-07T01:13:31.876-05:00" sizeKb="27"/>
+    <snapshot id="52118" createTime="2018-11-07T01:07:01.827-05:00" sizeKb="55"/>
+    <snapshot id="51456" createTime="2018-11-07T01:00:31.835-05:00" sizeKb="59"/>
+    <snapshot id="50167" createTime="2018-11-07T00:47:32.638-05:00" sizeKb="54"/>
+    <snapshot id="48887" createTime="2018-11-07T00:34:33.021-05:00" sizeKb="54"/>
+    <snapshot id="47607" createTime="2018-11-07T00:21:33.155-05:00" sizeKb="54"/>
+    <snapshot id="46327" createTime="2018-11-07T00:08:33.145-05:00" sizeKb="42"/>
+    <snapshot id="45670" createTime="2018-11-07T00:02:03.027-05:00" sizeKb="48"/>
+</consistencyGroupSnapshots>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3e83d4be/libcloud/test/drs/test_nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/test/drs/test_nttcis.py b/libcloud/test/drs/test_nttcis.py
index a7e939c..9f9bf50 100644
--- a/libcloud/test/drs/test_nttcis.py
+++ b/libcloud/test/drs/test_nttcis.py
@@ -1,20 +1,10 @@
 import pytest
-
-
-import sys
-from types import GeneratorType
 from libcloud.utils.py3 import httplib
-from libcloud.utils.py3 import ET
-from libcloud.common.types import InvalidCredsError
-from libcloud.common.nttcis import NttCisAPIException, NetworkDomainServicePlan
-from libcloud.common.nttcis import TYPES_URN
+from libcloud.common.nttcis import NttCisAPIException
 from libcloud.drs.drivers.nttcis import NttCisDRSDriver as NttCis
-from libcloud.compute.drivers.nttcis import NttCisNic
-from libcloud.compute.base import Node, NodeAuthPassword, NodeLocation
 from libcloud.test import MockHttp, unittest
 from libcloud.test.file_fixtures import DRSFileFixtures
 from libcloud.test.secrets import NTTCIS_PARAMS
-from libcloud.utils.xml import fixxpath, findtext, findall
 
 
 @pytest.fixture()
@@ -60,6 +50,22 @@ def test_expand_journal(driver):
     assert result is True
 
 
+def test_list_snapshots(driver):
+    cg_id = "3710c093-7dcc-4a21-bd07-af9f4d93b6b5"
+    result = driver.list_consistency_group_snapshots(cg_id)
+    assert hasattr(result, 'snapshot')
+    assert len(result.snapshot) == 11
+
+
+def test_list_snapshots_with_min(driver):
+    NttCisMockHttp.type = "WITH_MIN"
+    cg_id = "3710c093-7dcc-4a21-bd07-af9f4d93b6b5"
+    result = driver.list_consistency_group_snapshots(
+        cg_id, create_time_min="2018-11-07T00:00:00.000-05:00")
+    assert hasattr(result, 'snapshot')
+    assert len(result.snapshot) == 87
+
+
 def test_start_failover_preview(driver):
     pass
 
@@ -76,6 +82,10 @@ class NttCisMockHttp(MockHttp):
         body = self.fixtures.load('oec_0_9_myaccount.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _oec_0_9_myaccount_WITH_MIN(self, method, url, body, headers):
+        body = self.fixtures.load('oec_0_9_myaccount.xml')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_createConsistencyGroup_INPROGRESS(self,
                                                                                         
                 method,
                                                                                         
                 url,
@@ -116,4 +126,20 @@ class NttCisMockHttp(MockHttp):
                                                                                         
                                     body,
                                                                                         
                                     headers):
         body = self.fixtures.load("expand_cg.xml")
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_snapshot(self,
+                                                                                        
                                     method,
+                                                                                        
                                     url,
+                                                                                        
                                     body,
+                                                                                        
                                     headers):
+        body = self.fixtures.load("drs_snapshots.xml")
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_snapshot_WITH_MIN(self,
+                                                                                 method,
+                                                                                 url,
+                                                                                 body,
+                                                                                 headers):
+        body = self.fixtures.load("drs_snapshots_by_min.xml")
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3e83d4be/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index 81e88a5..b218a07 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -421,4 +421,25 @@ def test_get_snapshots(drsdriver):
     cgs = drsdriver.list_consistency_groups()
     cg_id = [i for i in cgs if i.name == "sdk_test2_cg"][0].id
     snaps = drsdriver.list_consistency_group_snapshots(cg_id)
-    assert hasattr(snaps, 'journalUsageGb')
\ No newline at end of file
+    assert hasattr(snaps, 'journalUsageGb')
+
+
+def test_get_snapshots_by_min_max(drsdriver):
+    cgs = drsdriver.list_consistency_groups()
+    cg_id = [i for i in cgs if i.name == "sdk_test2_cg"][0].id
+    snaps = drsdriver.list_consistency_group_snapshots(
+        cg_id,
+        create_time_min="2018-11-06T00:00:00.000Z",
+        create_time_max="2018-11-07T00:00:00.000Z")
+    for snap in snaps.snapshot:
+        print(snap)
+
+
+def test_get_snapshots_by_min(drsdriver):
+    cgs = drsdriver.list_consistency_groups()
+    cg_id = [i for i in cgs if i.name == "sdk_test2_cg"][0].id
+    snaps = drsdriver.list_consistency_group_snapshots(
+        cg_id,
+        create_time_min="2018-11-07T00:00:00.000-05:00")
+    for snap in snaps.snapshot:
+        print(snap)
\ No newline at end of file


Mime
View raw message