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:24 UTC
[15/45] libcloud git commit: commented out several classes in
common/nttcis module, added tests for get single cg
commented out several classes in common/nttcis module, added tests for get single cg
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/62e0aafc
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/62e0aafc
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/62e0aafc
Branch: refs/heads/trunk
Commit: 62e0aafc21d70b5b58618118154ec37e70e725d9
Parents: 0346c30
Author: mitch <mi...@itaas.dimensiondata.com>
Authored: Thu Nov 1 16:32:30 2018 -0400
Committer: mitch <mi...@itaas.dimensiondata.com>
Committed: Thu Nov 1 16:32:30 2018 -0400
----------------------------------------------------------------------
libcloud/common/nttcis.py | 51 ++++++++++++--------
libcloud/compute/drivers/nttcis.py | 35 +++++++-------
libcloud/drs/drivers/nttcis.py | 11 ++++-
.../fixtures/nttcis/get_consistency_group.xml | 27 +++++++++++
libcloud/test/drs/test_nttcis.py | 23 +++++++--
tests/lib_list_test.py | 9 +++-
6 files changed, 110 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/62e0aafc/libcloud/common/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py
index 42866d1..390b85e 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,32 +772,30 @@ 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):
- """
+
+ 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
:type id: ``str``
-
+
:param scsi_id: Representation for scsi
:type scsi_id: ``int``
-
+
:param size_gb: Size of the disk
:type size_gb: ``int``
-
+
:param speed: Speed of the disk (i.e. STANDARD)
:type speed: ``str``
-
+
: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
@@ -811,11 +809,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
@@ -832,7 +830,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
@@ -842,6 +840,7 @@ class NttCisScsiController(object):
return (('<NttCisScsiController: '
'id=%s, adapter_type=%s, bus_number=%s, state=%s')
% (self.id, self.adapter_type, self.bus_number, self.state))
+"""
class NttCisServerVMWareTools(object):
@@ -1936,6 +1935,13 @@ attrs = {}
def processor(mapping, name=None):
+ """
+ Closure that keeps the deepcopy of the original dict
+ converted to XML current.
+ :param mapping: The converted XML to dict/lists
+ :param name: (Optional) what becomes the class name if provided
+ :return: Nothing
+ """
mapping = mapping
map_copy = deepcopy(mapping)
@@ -1948,6 +1954,7 @@ def processor(mapping, name=None):
else:
attrs.update({key: value})
+ # trim the copy of the mapping
if key in map_copy:
del map_copy[key]
elif key in map_copy[name]:
@@ -2082,6 +2089,8 @@ class XmlListConfig(list):
self.append(XmlDictConfig(element))
# treat like list
elif element[0].tag == element[1].tag:
+ # property refers to an element used repeatedly
+ # in the XML for data centers only
if 'property' in element.tag:
self.append({element.attrib.get('name'): element.attrib.get('value')})
else:
http://git-wip-us.apache.org/repos/asf/libcloud/blob/62e0aafc/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index a17286a..d8b4aa3 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -30,9 +30,9 @@ from libcloud.common.nttcis import (NttCisConnection,
from libcloud.common.nttcis import NttCisNetwork
from libcloud.common.nttcis import NttCisNetworkDomain
from libcloud.common.nttcis import NttCisVlan
-from libcloud.common.nttcis import NttCisServerCpuSpecification
-from libcloud.common.nttcis import NttCisServerDisk
-from libcloud.common.nttcis import NttCisScsiController
+#from libcloud.common.nttcis import NttCisServerCpuSpecification
+#from libcloud.common.nttcis import NttCisServerDisk
+#from libcloud.common.nttcis import NttCisScsiController
from libcloud.common.nttcis import NttCisServerVMWareTools
from libcloud.common.nttcis import NttCisPublicIpBlock
from libcloud.common.nttcis import NttCisFirewallRule
@@ -4850,21 +4850,22 @@ class NttCisNodeDriver(NodeDriver):
location_id = element.get('datacenterId')
location = list(filter(lambda x: x.id == location_id,
locations))[0]
+ return process_xml(ET.tostring(element))
- return NttCisFirewallRule(
- id=element.get('id'),
- network_domain=network_domain,
- name=findtext(element, 'name', TYPES_URN),
- action=findtext(element, 'action', TYPES_URN),
- ip_version=findtext(element, 'ipVersion', TYPES_URN),
- protocol=findtext(element, 'protocol', TYPES_URN),
- enabled=findtext(element, 'enabled', TYPES_URN),
- source=self._to_firewall_address(
- element.find(fixxpath('source', TYPES_URN))),
- destination=self._to_firewall_address(
- element.find(fixxpath('destination', TYPES_URN))),
- location=location,
- status=findtext(element, 'state', TYPES_URN))
+ #return NttCisFirewallRule(
+ # id=element.get('id'),
+ # network_domain=network_domain,
+ # name=findtext(element, 'name', TYPES_URN),
+ # action=findtext(element, 'action', TYPES_URN),
+ # ip_version=findtext(element, 'ipVersion', TYPES_URN),
+ # protocol=findtext(element, 'protocol', TYPES_URN),
+ # enabled=findtext(element, 'enabled', TYPES_URN),
+ # source=self._to_firewall_address(
+ # element.find(fixxpath('source', TYPES_URN))),
+ # destination=self._to_firewall_address(
+ # element.find(fixxpath('destination', TYPES_URN))),
+ # location=location,
+ # status=findtext(element, 'state', TYPES_URN))
def _to_firewall_address(self, element):
ip = element.find(fixxpath('ip', TYPES_URN))
http://git-wip-us.apache.org/repos/asf/libcloud/blob/62e0aafc/libcloud/drs/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/drivers/nttcis.py b/libcloud/drs/drivers/nttcis.py
index 4ae2891..a2a66a4 100644
--- a/libcloud/drs/drivers/nttcis.py
+++ b/libcloud/drs/drivers/nttcis.py
@@ -97,9 +97,16 @@ class NttCisDRSDriver(Driver):
cgs = self._to_consistency_groups(response)
return cgs
+ def get_consistency_group(self, consistency_group_id):
+ response = self.connection.request_with_orgId_api_2(
+ "consistencyGroup/consistencyGroup/%s" % consistency_group_id
+ ).object
+ cg = self._to_process(response)
+ return cg
+
def _to_consistency_groups(self, object):
cgs = findall(object, 'consistencyGroup', TYPES_URN)
- return [self._to_consistency_group(el) for el in cgs]
+ return [self._to_process(el) for el in cgs]
- def _to_consistency_group(self, element):
+ def _to_process(self, element):
return process_xml(ET.tostring(element))
http://git-wip-us.apache.org/repos/asf/libcloud/blob/62e0aafc/libcloud/test/drs/fixtures/nttcis/get_consistency_group.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/drs/fixtures/nttcis/get_consistency_group.xml b/libcloud/test/drs/fixtures/nttcis/get_consistency_group.xml
new file mode 100644
index 0000000..bcbe931
--- /dev/null
+++ b/libcloud/test/drs/fixtures/nttcis/get_consistency_group.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<consistencyGroups xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="1" totalCount="1" pageSize="250">
+ <consistencyGroup id="3710c093-7dcc-4a21-bd07-af9f4d93b6b5">
+ <name>sdk_test2_cg</name>
+ <description>A test consistency group</description>
+ <journal sizeGb="100" extentCount="1"/>
+ <source datacenterId="NADRAASLAB01" networkDomainId="f9d6a249-c922-4fa1-9f0f-de5b452c4026">
+ <networkDomainName>DRS-ProdEng-East-ND1</networkDomainName>
+ </source>
+ <target datacenterId="NADRAASLAB02" networkDomainId="e46c8815-193f-402d-b8a5-682eaa646fb2">
+ <networkDomainName>DRS-ProdEng-West-ND1</networkDomainName>
+ </target>
+ <serverPair id="de9f0a6b-db84-4ffa-aacf-796f694c29f2" state="NORMAL">
+ <sourceServer id="032f3967-00e4-4780-b4ef-8587460f9dd4" primaryNicIpv4="192.168.12.8" primaryNicIpv6="2607:f480:111:1426:3dc9:25dc:4985:81b2">
+ <name>src-sdk-test</name>
+ </sourceServer>
+ <targetServer id="aee58575-38e2-495f-89d3-854e6a886411" primaryNicIpv4="192.168.22.7" primaryNicIpv6="2607:f480:211:1159:2dff:40ed:ee7c:4738">
+ <name>tgt-sdk-test</name>
+ </targetServer>
+ </serverPair>
+ <createTime>2018-10-31T16:02:05.000Z</createTime>
+ <operationStatus>DRS_MODE</operationStatus>
+ <drsInfrastructure enabled="true" status="ACTIVE" updateTime="2018-11-01T19:40:01.000Z"/>
+ <drsStatusCheckFailureCount>0</drsStatusCheckFailureCount>
+ <state>NORMAL</state>
+ </consistencyGroup>
+</consistencyGroups>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/libcloud/blob/62e0aafc/libcloud/test/drs/test_nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/test/drs/test_nttcis.py b/libcloud/test/drs/test_nttcis.py
index c460c74..9e99d49 100644
--- a/libcloud/test/drs/test_nttcis.py
+++ b/libcloud/test/drs/test_nttcis.py
@@ -43,6 +43,11 @@ def test_list_consistency_groups(driver):
assert hasattr(cgs[0], 'serverPair')
+def test_get_consistency_group(driver):
+ cg = driver.get_consistency_group("3710c093-7dcc-4a21-bd07-af9f4d93b6b5")
+ assert cg.id == "3710c093-7dcc-4a21-bd07-af9f4d93b6b5"
+
+
class NttCisMockHttp(MockHttp):
fixtures = DRSFileFixtures('nttcis')
@@ -66,9 +71,17 @@ class NttCisMockHttp(MockHttp):
return (httplib.BAD_REQUEST, body, {}, httplib.responses[httplib.OK])
def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_consistencyGroup(self,
- method,
- url,
- body,
- headers):
+ method,
+ url,
+ body,
+ headers):
body = self.fixtures.load("list_consistency_groups.xml")
- return (httplib.OK, body, {}, httplib.responses[httplib.OK])
\ No newline at end of file
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_consistencyGroup_3710c093_7dcc_4a21_bd07_af9f4d93b6b5(self,
+ method,
+ url,
+ body,
+ headers):
+ body = self.fixtures.load("get_consistency_group.xml")
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
http://git-wip-us.apache.org/repos/asf/libcloud/blob/62e0aafc/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index 5b519d7..77b50cd 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -394,4 +394,11 @@ def test_list_health_monitors(compute_driver, lbdriver):
def test_list_consistency_groups(drsdriver):
cgs = drsdriver.list_consistency_groups()
- return cgs
\ No newline at end of file
+ return cgs
+
+
+def test_get_consistency_group(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)
+ assert hasattr(cg, 'description')
\ No newline at end of file