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:32 UTC
[23/45] libcloud git commit: fixed drs examples in
docs/examples/drs/nttcis;
added imports for MutableSequence and Mapping based on python vesions in
libcloud/common/nttcis;
fixed drs examples in docs/examples/drs/nttcis; added imports for MutableSequence and Mapping based on python vesions in libcloud/common/nttcis;
added code blocks for dynamic class creation from xml as opposed to pick and choose properties from xml in common/nttcis; firewall rules are dynamic
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/bc4482a5
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/bc4482a5
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/bc4482a5
Branch: refs/heads/trunk
Commit: bc4482a5c1497a86a4267451513f033893e58cfa
Parents: 8ed60c7
Author: mitch <mi...@itaas.dimensiondata.com>
Authored: Tue Nov 13 11:28:39 2018 -0500
Committer: mitch <mi...@itaas.dimensiondata.com>
Committed: Tue Nov 13 11:28:39 2018 -0500
----------------------------------------------------------------------
.pylintrc | 36 ---------
.pylintrc.bak | 36 +++++++++
.../drs/nttcis/add_consistency_group.py | 5 +-
.../drs/nttcis/list_snapshots_by_create_time.py | 2 +-
libcloud/common/nttcis.py | 77 +++++++++++---------
libcloud/compute/drivers/nttcis.py | 46 ++++++------
libcloud/compute/types.py | 1 +
libcloud/drs/base.py | 25 ++++---
libcloud/drs/drivers/__init__.py | 2 +-
libcloud/drs/drivers/nttcis.py | 14 ++--
libcloud/drs/providers.py | 5 +-
libcloud/drs/types.py | 2 +-
libcloud/test/compute/test_nttcis.py | 27 +++----
tests/lib_list_test.py | 22 +-----
14 files changed, 148 insertions(+), 152 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/.pylintrc
----------------------------------------------------------------------
diff --git a/.pylintrc b/.pylintrc
deleted file mode 100644
index 21b7711..0000000
--- a/.pylintrc
+++ /dev/null
@@ -1,36 +0,0 @@
-[MASTER]
-# Add <file or directory> to the black list. It should be a base name, not a
-# path. You may set this option multiple times.
-ignore=test
-ignore=constants
-
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-
-[MESSAGES CONTROL]
-disable=redefined-builtin,too-many-arguments,too-few-public-methods,missing-docstring,invalid-name,abstract-method,no-self-use
-
-
-[TYPECHECK]
-# List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E0201 when accessed. Python regular
-# expressions are accepted.
-generated-members=async_request,objects
-
-[VARIABLES]
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching names used for dummy variables (i.e. not used).
-dummy-variables-rgx=_|dummy
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/.pylintrc.bak
----------------------------------------------------------------------
diff --git a/.pylintrc.bak b/.pylintrc.bak
new file mode 100644
index 0000000..21b7711
--- /dev/null
+++ b/.pylintrc.bak
@@ -0,0 +1,36 @@
+[MASTER]
+# Add <file or directory> to the black list. It should be a base name, not a
+# path. You may set this option multiple times.
+ignore=test
+ignore=constants
+
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+disable=redefined-builtin,too-many-arguments,too-few-public-methods,missing-docstring,invalid-name,abstract-method,no-self-use
+
+
+[TYPECHECK]
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=async_request,objects
+
+[VARIABLES]
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching names used for dummy variables (i.e. not used).
+dummy-variables-rgx=_|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/docs/examples/drs/nttcis/add_consistency_group.py
----------------------------------------------------------------------
diff --git a/docs/examples/drs/nttcis/add_consistency_group.py b/docs/examples/drs/nttcis/add_consistency_group.py
index 9194b24..89fdbfc 100644
--- a/docs/examples/drs/nttcis/add_consistency_group.py
+++ b/docs/examples/drs/nttcis/add_consistency_group.py
@@ -11,7 +11,8 @@ def create_drs(compute_driver, drs_driver):
consistency_group_name = "sdk_test_cg"
journal_size_gb = "100"
result = drs_driver.create_consistency_group(
- consistency_group_name, journal_size_gb, src_id, target_id, description="A test consistency group")
+ consistency_group_name, journal_size_gb, src_id, target_id,
+ description="A test consistency group")
assert result is True
@@ -23,4 +24,4 @@ if __name__ == "__main__":
cls = libcloud.get_driver(libcloud.DriverType.DRS,
libcloud.DriverType.DRS.NTTCIS)
drsdriver = cls('my_user', 'my_pass', region='na')
- create_drs(computedriver, drsdriver)
\ No newline at end of file
+ create_drs(computedriver, drsdriver)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/docs/examples/drs/nttcis/list_snapshots_by_create_time.py
----------------------------------------------------------------------
diff --git a/docs/examples/drs/nttcis/list_snapshots_by_create_time.py b/docs/examples/drs/nttcis/list_snapshots_by_create_time.py
index f3fb7bc..81f8167 100644
--- a/docs/examples/drs/nttcis/list_snapshots_by_create_time.py
+++ b/docs/examples/drs/nttcis/list_snapshots_by_create_time.py
@@ -20,4 +20,4 @@ if __name__ == "__main__":
drsdriver = cls('my_user', 'my_pass', region='na')
objs = get_snapshots_by_min_max(drsdriver)
for obj in objs.snapshot:
- print(obj)
\ No newline at end of file
+ print(obj)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/common/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py
index d257bf8..2908dfc 100644
--- a/libcloud/common/nttcis.py
+++ b/libcloud/common/nttcis.py
@@ -15,12 +15,15 @@
"""
NTTCIS Common Components
"""
+import xml.etree.ElementTree as etree
from copy import deepcopy
-from collections.abc import MutableSequence, Mapping
from base64 import b64encode
from time import sleep
-from lxml import etree
from io import BytesIO
+try:
+ from collections.abc import MutableSequence, Mapping
+except ImportError:
+ from collections import MutableSequence, Mapping
# TODO: use disutils.version when Travis CI fixed the pylint issue with version
# from distutils.version import LooseVersion
from libcloud.utils.py3 import httplib
@@ -778,22 +781,23 @@ 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``
"""
@@ -1924,8 +1928,13 @@ class NttCisNic(object):
% (self.private_ip_v4, self.vlan, self.network_adapter_name))
+# Dynamically create classes from returned XML. Leaves the API as the
+# single authoritative source.
+
+
+class ClassFactory(object):
+ pass
-##### Testing new concept below this line
attrs = {}
@@ -1961,7 +1970,8 @@ def processor(mapping, name=None):
def handle_map(map, name):
tmp = {}
types = [type(x) for x in map.values()]
- if XmlListConfig not in types and XmlDictConfig not in types and dict not in types:
+ if XmlListConfig not in types and \
+ XmlDictConfig not in types and dict not in types:
return map
elif XmlListConfig in types:
@@ -1981,7 +1991,6 @@ def processor(mapping, name=None):
def handle_seq(seq, name):
tmp = {}
- tmp_list = []
if isinstance(seq, list):
tmp = []
for _ in seq:
@@ -1989,9 +1998,7 @@ def processor(mapping, name=None):
tmp.append(cls)
return tmp
for k, v in seq.items():
- if isinstance(v, Mapping):
- result1 = handle_map(v, k)
- elif isinstance(v, MutableSequence):
+ if isinstance(v, MutableSequence):
for _ in v:
if isinstance(_, Mapping):
types = [type(x) for x in _.values()]
@@ -2002,7 +2009,8 @@ def processor(mapping, name=None):
else:
tmp.update({k: result})
else:
- tmp_list = [build_class(k.capitalize(), i) for i in v]
+ tmp_list = [build_class(k.capitalize(), i)
+ for i in v]
tmp[k] = tmp_list
print()
elif isinstance(v, str):
@@ -2030,7 +2038,6 @@ def processor(mapping, name=None):
cls = build_class(k1.capitalize(), result)
add_items(k1, cls, k1)
elif isinstance(v1, list):
- tmp = {}
tmp1 = {}
tmp2 = {}
tmp2[k1] = []
@@ -2041,14 +2048,10 @@ def processor(mapping, name=None):
tmp1[k1 + str(i)] = build_class(k1, result)
tmp2[k1].append(tmp1[k1 + str(i)])
if tmp2:
- #cls = build_class(k1.capitalize(), tmp2)
add_items(k1, tmp2[k1], k1)
elif isinstance(v1, str):
add_items(k1, v1)
-
-
-
if len(map_copy) == 0:
return 1
return process(mapping, name)
@@ -2059,21 +2062,24 @@ def class_factory(cls_name, attrs):
def __init__(self, *args, **kwargs):
for key in attrs:
setattr(self, key, attrs[key])
+ if cls_name == "NttCisServer":
+ self.state = self._get_state()
def __iter__(self):
for name in self.__dict__:
yield getattr(self, name)
def __repr__(self):
- values = ', '.join('{}={!r}'.format(*i) for i in zip(self.__dict__, self))
+ values = ', '.join('{}={!r}'.format(*i)
+ for i in zip(self.__dict__, self))
return '{}({})'.format(self.__class__.__name__, values)
cls_attrs = dict(
- __init__=__init__,
- __iter__=__iter__,
- __repr__=__repr__)
+ __init__=__init__,
+ __iter__=__iter__,
+ __repr__=__repr__)
- return type("NttCis{}".format(cls_name), (object,), cls_attrs)
+ return type("NttCis{}".format(cls_name), (ClassFactory,), cls_attrs)
class XmlListConfig(list):
@@ -2088,7 +2094,8 @@ class XmlListConfig(list):
# 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')})
+ self.append({element.attrib.get('name'):
+ element.attrib.get('value')})
else:
self.append(element.attrib)
elif element.text:
@@ -2102,11 +2109,10 @@ class XmlDictConfig(dict):
def __init__(self, parent_element):
if parent_element.items():
if 'property' in parent_element.tag:
- self.update({parent_element.attrib.get('name'): parent_element.attrib.get('value')})
+ self.update({parent_element.attrib.get('name'):
+ parent_element.attrib.get('value')})
else:
self.update(dict(parent_element.items()))
-
- c_elems = parent_element.items()
for element in parent_element:
if len(element) > 0:
# treat like dict - we assume that if the first two tags
@@ -2120,7 +2126,8 @@ class XmlDictConfig(dict):
# here, we put the list in dictionary; the key is the
# tag name the list elements all share in common, and
# the value is the list itself
- elem_dict = {element[0].tag.split('}')[1]: XmlListConfig(element)}
+ elem_dict = {element[0].tag.split('}')[1]:
+ XmlListConfig(element)}
# if the tag has attributes, add those to the dict
if element.items():
@@ -2131,12 +2138,13 @@ class XmlDictConfig(dict):
# good idea -- time will tell. It works for the way we are
# currently doing XML configuration files...
elif element.items():
- # It is possible to have duplicate element tags. If so, convert to a dict of lists
+ # It is possible to have duplicate element tags.
+ # If so, convert to a dict of lists
if element.tag.split('}')[1] in self:
if isinstance(self[element.tag.split('}')[1]], list):
- self[element.tag.split('}')[1]].append(dict(element.items()))
- #tmp_list.append(element.tag.split('}')[1])
+ self[element.tag.split('}')[1]].\
+ append(dict(element.items()))
else:
tmp_list = list()
tmp_dict = dict()
@@ -2149,7 +2157,8 @@ class XmlDictConfig(dict):
tmp_list.append(dict(element.items()))
self[element.tag.split('}')[1]] = tmp_list
else:
- self.update({element.tag.split('}')[1]: dict(element.items())})
+ self.update({element.tag.split('}')[1]:
+ dict(element.items())})
# finally, if there are no child tags and no attributes, extract
# the text
else:
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index cfe5619..0fc651d 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
@@ -53,7 +53,6 @@ from libcloud.common.nttcis import NttCisTag
from libcloud.common.nttcis import API_ENDPOINTS, DEFAULT_REGION
from libcloud.common.nttcis import TYPES_URN
from libcloud.common.nttcis import NETWORK_NS, GENERAL_NS
-from libcloud.common.nttcis import process_xml
from libcloud.utils.py3 import urlencode, ensure_string
from libcloud.utils.xml import fixxpath, findtext, findall
from libcloud.utils.py3 import basestring
@@ -4825,22 +4824,23 @@ 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))
+ # For future dynamic rule creation
+ # 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))
def _to_firewall_address(self, element):
ip = element.find(fixxpath('ip', TYPES_URN))
@@ -5104,8 +5104,8 @@ class NttCisNodeDriver(NodeDriver):
def _to_node(self, element):
# Get all information at once and process in common/nttcis
- return process_xml(ET.tostring(element))
- """
+ # Below, future to dynamically generate classes
+ # return process_xml(ET.tostring(element))
started = findtext(element, 'started', TYPES_URN)
status = self._to_status(element.find(fixxpath('progress', TYPES_URN)))
dd_state = findtext(element, 'state', TYPES_URN)
@@ -5211,7 +5211,7 @@ class NttCisNodeDriver(NodeDriver):
driver=self.connection.driver,
extra=extra)
return n
- """
+
def _to_status(self, element):
if element is None:
return NttCisStatus()
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/compute/types.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/types.py b/libcloud/compute/types.py
index 9b75144..63b68c4 100644
--- a/libcloud/compute/types.py
+++ b/libcloud/compute/types.py
@@ -89,6 +89,7 @@ class Provider(Type):
:cvar NEPHOSCALE: NephoScale driver
:cvar NIMBUS: Nimbus
:cvar NINEFOLD: Ninefold
+ :cvar NTTC-CIS: NTT Communications CIS
:cvar OPENNEBULA: OpenNebula.org
:cvar OPSOURCE: Opsource Cloud
:cvar OUTSCALE_INC: Outscale INC driver.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/drs/base.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/base.py b/libcloud/drs/base.py
index b5ee738..38d5c5c 100644
--- a/libcloud/drs/base.py
+++ b/libcloud/drs/base.py
@@ -14,8 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from libcloud.common.base import ConnectionKey, BaseDriver
-from libcloud.common.types import LibcloudError
+from libcloud.common.base import ConnectionKey
+from libcloud.common.base import BaseDriver
+
+__all__ = [
+ 'DRSConsistencyGroup',
+ 'DRSDriver',
+]
class DRSConsistencyGroup(object):
@@ -23,7 +28,8 @@ class DRSConsistencyGroup(object):
Provide a common interface for handling DRS.
"""
- def __init__(self, id, name, description, journalSizeGB, serverPairSourceServerId, serverPairtargetServerId,
+ def __init__(self, id, name, description, journalSizeGB,
+ serverPairSourceServerId, serverPairtargetServerId,
driver, extra=None):
"""
:param id: Load balancer ID.
@@ -65,15 +71,15 @@ class DRSDriver(BaseDriver):
This class is always subclassed by a specific driver.
"""
- name = None
- website = None
-
connectionCls = ConnectionKey
+ name = None
+ type = None
+ port = None
def __init__(self, key, secret=None, secure=True, host=None,
port=None, **kwargs):
super(DRSDriver, self).__init__(key=key, secret=secret, secure=secure,
- host=host, port=port, **kwargs)
+ host=host, port=port, **kwargs)
def create_consistency_group(self, name, journal_sz_gb,
source_server_id, target_server_id):
@@ -105,7 +111,8 @@ class DRSDriver(BaseDriver):
"""
Return a :class:`ConsistencyGroup` object.
- :param consistency_group_id: id of a consistency group you want to fetch
+ :param consistency_group_id: id of a consistency group you want
+ to fetch
:type consistency_group_id: ``str``
:rtype: :class:`ConsistencyGroup`
@@ -191,4 +198,4 @@ class DRSDriver(BaseDriver):
"""
raise NotImplementedError(
- 'initiate_failover not implemented for this driver')
\ No newline at end of file
+ 'initiate_failover not implemented for this driver')
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/drs/drivers/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/drivers/__init__.py b/libcloud/drs/drivers/__init__.py
index f2f9f29..2473c57 100644
--- a/libcloud/drs/drivers/__init__.py
+++ b/libcloud/drs/drivers/__init__.py
@@ -15,4 +15,4 @@
__all__ = [
'nttcis'
-]
\ No newline at end of file
+]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/drs/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/drivers/nttcis.py b/libcloud/drs/drivers/nttcis.py
index 363d737..c5695d1 100644
--- a/libcloud/drs/drivers/nttcis.py
+++ b/libcloud/drs/drivers/nttcis.py
@@ -9,7 +9,6 @@ from libcloud.drs.types import Provider
from libcloud.drs.base import DRSDriver
from libcloud.common.nttcis import TYPES_URN
from libcloud.utils.xml import fixxpath, findtext, findall
-from libcloud.common.types import LibcloudError
def get_params(func):
@@ -21,7 +20,7 @@ def get_params(func):
old_key = k
matches = re.findall(r'_(\w)', k)
for match in matches:
- k = k.replace('_'+match, match.upper())
+ k = k.replace('_' + match, match.upper())
del kwargs[old_key]
kwargs[k] = v
params = kwargs
@@ -34,13 +33,13 @@ def get_params(func):
class NttCisDRSDriver(DRSDriver):
"""
- NttCis node driver.
+ NttCis DRS driver.
"""
selected_region = None
connectionCls = NttCisConnection
name = 'NTTC-CIS DRS Consistencty Groups'
- website = 'https://cloud.nttcis.com/'
+ website = 'https://www.us.ntt.com/en/services/cloud/enterprise-cloud.html'
type = Provider.NTTCIS
api_version = 1.0
@@ -73,7 +72,7 @@ class NttCisDRSDriver(DRSDriver):
kwargs['region'] = self.selected_region
return kwargs
- def create_consistency_group(self, name, journal_size_gb ,
+ def create_consistency_group(self, name, journal_size_gb,
source_server_id, target_server_id,
description=None):
"""
@@ -97,7 +96,7 @@ class NttCisDRSDriver(DRSDriver):
ET.SubElement(consistency_group_elm, "name").text = name
if description is not None:
ET.SubElement(
- consistency_group_elm,"description").text = description
+ consistency_group_elm, "description").text = description
ET.SubElement(
consistency_group_elm, "journalSizeGb").text = journal_size_gb
server_pair = ET.SubElement(consistency_group_elm, "serverPair")
@@ -116,7 +115,8 @@ 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 following 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=
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/drs/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/providers.py b/libcloud/drs/providers.py
index 2a31efa..9aadaae 100644
--- a/libcloud/drs/providers.py
+++ b/libcloud/drs/providers.py
@@ -14,7 +14,6 @@
# limitations under the License.
from libcloud.drs.types import Provider
-#from libcloud.drs.types import OLD_CONSTANT_TO_NEW_MAPPING
from libcloud.common.providers import get_driver as _get_provider_driver
from libcloud.common.providers import set_driver as _set_provider_driver
@@ -31,10 +30,10 @@ DRIVERS = {
def get_driver(provider):
- #deprecated_constants = OLD_CONSTANT_TO_NEW_MAPPING
+ # deprecated_constants = OLD_CONSTANT_TO_NEW_MAPPING
return _get_provider_driver(drivers=DRIVERS, provider=provider)
def set_driver(provider, module, klass):
return _set_provider_driver(drivers=DRIVERS, provider=provider,
- module=module, klass=klass)
\ No newline at end of file
+ module=module, klass=klass)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/drs/types.py
----------------------------------------------------------------------
diff --git a/libcloud/drs/types.py b/libcloud/drs/types.py
index b902f74..39c6368 100644
--- a/libcloud/drs/types.py
+++ b/libcloud/drs/types.py
@@ -38,6 +38,6 @@ class Provider(object):
Non-Dummy drivers are sorted in alphabetical order. Please preserve this
ordering when adding new drivers.
- :cvar ALIYUN_SLB: Aliyun SLB loadbalancer driver
+ :cvar NTTCIS: NTT Communications CIS DRS driver
"""
NTTCIS = 'nttcis'
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/libcloud/test/compute/test_nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_nttcis.py b/libcloud/test/compute/test_nttcis.py
index 61a4756..d5c7b6b 100644
--- a/libcloud/test/compute/test_nttcis.py
+++ b/libcloud/test/compute/test_nttcis.py
@@ -12,11 +12,12 @@ from libcloud.common.nttcis import NttCisTag, NttCisTagKey
from libcloud.common.nttcis import NttCisIpAddress, \
NttCisIpAddressList, NttCisChildIpAddressList, \
NttCisPortList, NttCisPort, NttCisChildPortList
+from libcloud.common.nttcis import ClassFactory
from libcloud.common.nttcis import TYPES_URN
from libcloud.compute.drivers.nttcis import NttCisNodeDriver 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 import MockHttp
from libcloud.test.file_fixtures import ComputeFileFixtures
from libcloud.test.secrets import NTTCIS_PARAMS
from libcloud.utils.xml import fixxpath, findtext, findall
@@ -73,29 +74,29 @@ def test_node_extras(driver):
assert isinstance(ret[0].extra['cpu'], NttCisServerCpuSpecification)
assert isinstance(ret[0].extra['disks'], list)
assert isinstance(ret[0].extra['disks'][0], NttCisServerDisk)
- assert ret[0].extra['disks'][0].size_gb == 50
+ assert ret[0].extra['disks'][0].size_gb, 10
assert isinstance(ret[1].extra['disks'], list)
assert isinstance(ret[1].extra['disks'][0], NttCisServerDisk)
- assert ret[1].extra['disks'][0].size_gb == 50
+ assert ret[1].extra['disks'][0].size_gb, 10
def test_server_states(driver):
NttCisMockHttp.type = None
ret = driver.list_nodes()
- assert (ret[0].state == 'running')
- assert (ret[1].state == 'starting')
- assert (ret[2].state == 'stopping')
- assert (ret[3].state == 'reconfiguring')
- assert (ret[4].state == 'running')
- assert (ret[5].state == 'terminated')
- assert (ret[6].state == 'stopped')
+ assert ret[0].state == 'running'
+ assert ret[1].state == 'starting'
+ assert ret[2].state == 'stopping'
+ assert ret[3].state == 'reconfiguring'
+ assert ret[4].state == 'running'
+ assert ret[5].state == 'terminated'
+ assert ret[6].state == 'stopped'
assert len(ret) == 7
def test_list_nodes_response_PAGINATED(driver):
NttCisMockHttp.type = 'PAGINATED'
ret = driver.list_nodes()
- assert len(ret) == 9
+ assert len(ret) == 7
def test_paginated_mcp2_call_EMPTY(driver):
@@ -143,7 +144,6 @@ def test_list_nodes_response_strings_ALLFILTERS(driver):
node = ret[3]
assert isinstance(node.extra['disks'], list)
assert isinstance(node.extra['disks'][0], NttCisServerDisk)
- assert node.size.id == '1'
assert node.image.id == '3ebf3c0f-90fe-4a8b-8585-6e65b316592c'
assert node.image.name == 'WIN2008S/32'
disk = node.extra['disks'][0]
@@ -424,7 +424,6 @@ def test_create_node_primary_ipv4(driver):
assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87'
assert node.extra['status'].action == 'DEPLOY_SERVER'
-
def test_create_node_both_primary_nic_and_vlan_fail(driver):
rootPw = NodeAuthPassword('pass123')
image = driver.list_images()[0]
@@ -518,7 +517,6 @@ def test_create_node_ipv4_gateway(driver):
assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87'
assert node.extra['status'].action == 'DEPLOY_SERVER'
-
def test_create_node_network_domain_no_vlan_no_ipv4_fail(driver):
rootPw = NodeAuthPassword('pass123')
image = driver.list_images()[0]
@@ -549,7 +547,6 @@ def test_create_node_mcp2_additional_nics_legacy(driver):
assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87'
assert node.extra['status'].action == 'DEPLOY_SERVER'
-
def test_create_node_bad_additional_nics_ipv4(driver):
rootPw = NodeAuthPassword('pass123')
image = driver.list_images()[0]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc4482a5/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index b218a07..c6395c4 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -82,6 +82,7 @@ def test_list_node_by_image(compute_driver):
requires retrieving vlan Id first
"""
+
def test_list_node_vlan(compute_driver):
nodes = compute_driver.list_nodes(ex_vlan='eb05a24e-85a6-46e3-a7c9-f1765737476d')
print()
@@ -170,26 +171,7 @@ def test_list_firewall_rules(compute_driver):
rules = compute_driver.ex_list_firewall_rules('6aafcf08-cb0b-432c-9c64-7371265db086')
print()
for rule in rules:
- print("id {}, name {}, action {}. location {}, ip ver {}, protocol {}, any ip {}, ip {}, prefix {},"
- " port range {} {} , src address {}, src port list {}, dest. any__ip {}, dest address {}, "
- "dest prefix {}, dest port range {} {}, dest address list id {}"
- ", dest port list id {}".format(
- rule.id, rule.name, rule.action,
- rule.location.name, rule.ip_version,
- rule.protocol, rule.source.any_ip,
- rule.source.ip_address,
- rule.source.ip_prefix_size,
- rule.source.port_begin, rule.source.port_end,
- rule.source.address_list_id,
- rule.source.port_list_id,
- rule.destination.any_ip,
- rule.destination.ip_address,
- rule.destination.ip_prefix_size,
- rule.destination.port_begin,
- rule.destination.port_end,
- rule.destination.address_list_id,
- rule.destination.port_list_id,
- ))
+ print(rule)
def test_list_address_lists(compute_driver):