You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2018/12/13 11:26:21 UTC
[12/45] libcloud git commit: can list cg groups
can list cg groups
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f8c0da69
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f8c0da69
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f8c0da69
Branch: refs/heads/trunk
Commit: f8c0da694dc25bb3f2238a95e7d6968ecb6f9399
Parents: 82afeb4
Author: mitch <mi...@itaas.dimensiondata.com>
Authored: Wed Oct 31 13:24:05 2018 -0400
Committer: mitch <mi...@itaas.dimensiondata.com>
Committed: Wed Oct 31 13:24:05 2018 -0400
----------------------------------------------------------------------
libcloud/common/nttcis.py | 1 -
libcloud/drs/drivers/nttcis.py | 15 +++++++++++++++
libcloud/test/drs_ineligible.xml | 6 ++++++
tests/lib_create_test.py | 20 ++++++++++++++++----
tests/lib_list_test.py | 6 ++++++
5 files changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/f8c0da69/libcloud/common/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py
index 126530f..42866d1 100644
--- a/libcloud/common/nttcis.py
+++ b/libcloud/common/nttcis.py
@@ -2166,4 +2166,3 @@ def process_xml(xml):
cls = klass(attrs)
attrs = {}
return cls
-
http://git-wip-us.apache.org/repos/asf/libcloud/blob/f8c0da69/libcloud/drs/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/drivers/nttcis.py b/libcloud/drs/drivers/nttcis.py
index ab5f0de..4ae2891 100644
--- a/libcloud/drs/drivers/nttcis.py
+++ b/libcloud/drs/drivers/nttcis.py
@@ -2,6 +2,7 @@ from libcloud.utils.py3 import ET
from libcloud.common.nttcis import NttCisConnection
from libcloud.common.nttcis import API_ENDPOINTS
from libcloud.common.nttcis import DEFAULT_REGION
+from libcloud.common.nttcis import process_xml
from libcloud.drs.types import Provider
from libcloud.drs.base import Driver
from libcloud.common.nttcis import TYPES_URN
@@ -88,3 +89,17 @@ class NttCisDRSDriver(Driver):
data=ET.tostring(consistency_group_elm)).object
response_code = findtext(response, 'responseCode', TYPES_URN)
return response_code in ['IN_PROGRESS', 'OK']
+
+ def list_consistency_groups(self):
+ #params = {'networkDomainId': ex_network_domain_id}
+ response = self.connection.request_with_orgId_api_2(
+ 'consistencyGroup/consistencyGroup').object
+ cgs = self._to_consistency_groups(response)
+ return cgs
+
+ def _to_consistency_groups(self, object):
+ cgs = findall(object, 'consistencyGroup', TYPES_URN)
+ return [self._to_consistency_group(el) for el in cgs]
+
+ def _to_consistency_group(self, element):
+ return process_xml(ET.tostring(element))
http://git-wip-us.apache.org/repos/asf/libcloud/blob/f8c0da69/libcloud/test/drs_ineligible.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/drs_ineligible.xml b/libcloud/test/drs_ineligible.xml
new file mode 100644
index 0000000..a0ff44c
--- /dev/null
+++ b/libcloud/test/drs_ineligible.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<response xmlns="urn:didata.com:api:cloud:types" requestId="na_20181031T115504819-0400_9c995adf-a3e8-4b1e-9d1f-a34bf52b693d">
+ <operation>CREATE_CONSISTENCY_GROUP</operation>
+ <responseCode>INCOMPATIBLE_OPERATION</responseCode>
+ <message>The drsEligible flag for target Server aee58575-38e2-495f-89d3-854e6a886411 must be set.</message>
+</response>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/libcloud/blob/f8c0da69/tests/lib_create_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_create_test.py b/tests/lib_create_test.py
index a38f65b..aa0c7d0 100644
--- a/tests/lib_create_test.py
+++ b/tests/lib_create_test.py
@@ -245,18 +245,30 @@ def test_fail_create_drs(na_compute_driver, drsdriver):
src_id = nodes[0].id
nodes = na_compute_driver.list_nodes(ex_name="drs_test_2")
target_id = nodes[0].id
- with pytest.raises(NttCisAPIException)as excinfo:
+ with pytest.raises(NttCisAPIException) as excinfo:
result = drsdriver.create_consistency_group(
"sdk_cg", "100", src_id, target_id, description="A test consistency group")
exception_msg = excinfo.value.msg
assert exception_msg == 'DRS is not supported between source Data Center NA9 and target Data Center NA12.'
+def test_inelligble_drs(na_compute_driver, drsdriver):
+ nodes = na_compute_driver.list_nodes(ex_name='src-sdk-test')
+ src_id = nodes[0].id
+ nodes = na_compute_driver.list_nodes(ex_name="tgt-sdk-test")
+ target_id = nodes[0].id
+ with pytest.raises(NttCisAPIException) as excinfo:
+ drsdriver.create_consistency_group(
+ "sdk_test2_cg", "100", src_id, target_id, description="A test consistency group")
+ exception_msg = excinfo.value.msg
+ assert exception_msg == 'The drsEligible flag for target Server aee58575-38e2-495f-89d3-854e6a886411 must be set.'
+
+
def test_create_drs(na_compute_driver, drsdriver):
- nodes = na_compute_driver.list_nodes(ex_name='Src-Test-VM01')
+ nodes = na_compute_driver.list_nodes(ex_name='src-sdk-test')
src_id = nodes[0].id
- nodes = na_compute_driver.list_nodes(ex_name="Tgt-Test-VM01")
+ nodes = na_compute_driver.list_nodes(ex_name="tgt-sdk-test")
target_id = nodes[0].id
result = drsdriver.create_consistency_group(
- "sdk_test_cg", "100", src_id, target_id, description="A test consistency group")
+ "sdk_test2_cg", "100", src_id, target_id, description="A test consistency group")
assert result is True
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/libcloud/blob/f8c0da69/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index de39a33..ac26e44 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -391,3 +391,9 @@ def test_list_health_monitors(compute_driver, lbdriver):
for monitor in monitors:
print(monitor)
+
+def test_list_consistency_groups(drsdriver):
+ cgs = drsdriver.list_consistency_groups()
+ for cg in cgs:
+ print(vars(cg))
+ print()
\ No newline at end of file