added more tests to tests and test directory. nttcis module for drs uses a decorator to list/filter consistency groups Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1935b5f2 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1935b5f2 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1935b5f2 Branch: refs/heads/trunk Commit: 1935b5f2cff2d8e1d44ead7ab0686dd70d00c93d Parents: 3d3289d Author: mitch Authored: Mon Nov 5 17:21:30 2018 -0500 Committer: mitch Committed: Mon Nov 5 17:21:30 2018 -0500 ---------------------------------------------------------------------- libcloud/common/nttcis.py | 31 +++--- libcloud/compute/drivers/nttcis.py | 109 ------------------- libcloud/drs/drivers/nttcis.py | 51 ++++++++- .../drs/fixtures/nttcis/list_cg_by_params.xml | 25 +++++ libcloud/test/drs/test_nttcis.py | 13 +++ tests/lib_list_test.py | 19 +++- 6 files changed, 115 insertions(+), 133 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/1935b5f2/libcloud/common/nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py index a26695a..78dc73f 100644 --- a/libcloud/common/nttcis.py +++ b/libcloud/common/nttcis.py @@ -744,13 +744,13 @@ class NttCisPublicIpBlock(object): self.status)) -""" class NttCisServerCpuSpecification(object): - + """ A class that represents the specification of the CPU(s) for a node - + """ def __init__(self, cpu_count, cores_per_socket, performance): + """ Instantiate a new :class:`NttCisServerCpuSpecification` :param cpu_count: The number of CPUs @@ -762,7 +762,7 @@ class NttCisServerCpuSpecification(object): :param performance: The performance type, e.g. HIGHPERFORMANCE :type performance: ``str`` - + """ self.cpu_count = cpu_count self.cores_per_socket = cores_per_socket self.performance = performance @@ -772,13 +772,14 @@ class NttCisServerCpuSpecification(object): 'cpu_count=%s, cores_per_socket=%s, ' 'performance=%s>') % (self.cpu_count, self.cores_per_socket, self.performance)) -""" -""" + + class NttCisServerDisk(object): - + """ A class that represents the disk on a server - + """ def __init__(self, id=None, scsi_id=None, size_gb=None, speed=None, state=None): + """ Instantiate a new :class:`DimensionDataServerDisk` :param id: The id of the disk @@ -795,7 +796,7 @@ class NttCisServerDisk(object): :param state: State of the disk (i.e. PENDING) :type state: ``str`` - + """ self.id = id self.scsi_id = scsi_id self.size_gb = size_gb @@ -809,11 +810,11 @@ class NttCisServerDisk(object): class NttCisScsiController(object): - + """ A class that represents the disk on a server - + """ def __init__(self, id, adapter_type, bus_number, state): - + """ Instantiate a new :class:`DimensionDataServerDisk` :param id: The id of the controller @@ -830,7 +831,7 @@ class NttCisScsiController(object): :param state: State of the disk (i.e. PENDING) :type state: ``str`` - + """ self.id = id self.adapter_type = adapter_type self.bus_number = bus_number @@ -840,7 +841,6 @@ class NttCisScsiController(object): return ((' + + sdk_test2_cg + A test consistency group + + DRS-ProdEng-East-ND1 + + + DRS-ProdEng-West-ND1 + + + + src-sdk-test + + + tgt-sdk-test + + + 2018-10-31T16:02:05.000Z + DRS_MODE + + 0 + NORMAL + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/libcloud/blob/1935b5f2/libcloud/test/drs/test_nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/test/drs/test_nttcis.py b/libcloud/test/drs/test_nttcis.py index 9e99d49..7431a25 100644 --- a/libcloud/test/drs/test_nttcis.py +++ b/libcloud/test/drs/test_nttcis.py @@ -48,6 +48,11 @@ def test_get_consistency_group(driver): assert cg.id == "3710c093-7dcc-4a21-bd07-af9f4d93b6b5" +def test_get_consistency_group_by_name(driver): + cgs = driver.list_consistency_groups(name="skd_test2_cg") + assert cgs[0].id == "3710c093-7dcc-4a21-bd07-af9f4d93b6b5" + + class NttCisMockHttp(MockHttp): fixtures = DRSFileFixtures('nttcis') @@ -85,3 +90,11 @@ class NttCisMockHttp(MockHttp): headers): body = self.fixtures.load("get_consistency_group.xml") return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_consistencyGroup_name(self, + method, + url, + body, + headers): + body = self.fixtures.load("list_cg_by_params.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/1935b5f2/tests/lib_list_test.py ---------------------------------------------------------------------- diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py index 0563f9a..81e88a5 100644 --- a/tests/lib_list_test.py +++ b/tests/lib_list_test.py @@ -394,10 +394,23 @@ def test_list_health_monitors(compute_driver, lbdriver): def test_list_consistency_groups(drsdriver): cgs = drsdriver.list_consistency_groups() - return cgs + for cg in cgs: + print(cg.name) -def test_get_consistency_group(drsdriver): +def test_list_cg_by_src_net_domain(drsdriver): + nd = "f9d6a249-c922-4fa1-9f0f-de5b452c4026" + cgs = drsdriver.list_consistency_groups(source_network_domain_id=nd) + assert cgs[0].name == "sdk_test2_cg" + + +def test_list_cg_by_name(drsdriver): + name = "sdk_test2_cg" + cg = drsdriver.list_consistency_groups(name=name) + assert cg[0].id == "3710c093-7dcc-4a21-bd07-af9f4d93b6b5" + + +def test_get_consistency_group_by_id(drsdriver): cgs = drsdriver.list_consistency_groups() cg_id = [i for i in cgs if i.name == "sdk_test2_cg"][0].id cg = drsdriver.get_consistency_group(cg_id) @@ -408,4 +421,4 @@ 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) - print(cg_id) \ No newline at end of file + assert hasattr(snaps, 'journalUsageGb') \ No newline at end of file