started drs code
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/bc64b1fc Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/bc64b1fc Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/bc64b1fc Branch: refs/heads/trunk Commit: bc64b1fcc7842131d5711cb8b17ac312b9f93065 Parents: 14d29cd Author: mitch <[email protected]> Authored: Tue Oct 9 13:06:00 2018 -0400 Committer: mitch <[email protected]> Committed: Tue Oct 9 13:06:00 2018 -0400 ---------------------------------------------------------------------- libcloud/base.py | 7 +++++ libcloud/common/nttcis.py | 8 +++++ libcloud/compute/drivers/nttcis.py | 3 +- libcloud/drs/base.py | 42 +++++++++++++++++++++++-- libcloud/drs/drivers/__init__.py | 18 +++++++++++ libcloud/drs/drivers/nttcis.py | 32 ++++++------------- libcloud/drs/types.py | 43 ++++++++++++++++++++++++++ libcloud/loadbalancer/drivers/__init__.py | 3 +- libcloud/loadbalancer/drivers/nttcis.py | 3 +- tests/conftest.py | 11 +++++-- tests/lib_create_test.py | 6 +++- tests/lib_edit_test.py | 6 ++++ 12 files changed, 150 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/base.py ---------------------------------------------------------------------- diff --git a/libcloud/base.py b/libcloud/base.py index 94e9f17..dead087 100644 --- a/libcloud/base.py +++ b/libcloud/base.py @@ -25,6 +25,9 @@ from libcloud.container.providers import get_driver as get_container_driver from libcloud.dns.providers import Provider as DnsProvider from libcloud.dns.providers import get_driver as get_dns_driver +from libcloud.drs.providers import Provider as DrsProvider +from libcloud.drs.providers import get_driver as get_drs_driver + from libcloud.loadbalancer.providers import Provider as LoadBalancerProvider from libcloud.loadbalancer.providers import get_driver as \ get_loadbalancer_driver @@ -46,6 +49,9 @@ class DriverType(object): """ DNS service provider driver """ DNS = DnsProvider + """ DRS service provider driver """ + DRS = DrsProvider + """ Load balancer provider-driver """ LOADBALANCER = LoadBalancerProvider @@ -58,6 +64,7 @@ DriverTypeFactoryMap = { DriverType.COMPUTE: get_compute_driver, DriverType.CONTAINER: get_container_driver, DriverType.DNS: get_dns_driver, + DriverType.DRS: get_drs_driver, DriverType.LOADBALANCER: get_loadbalancer_driver, DriverType.STORAGE: get_storage_driver } http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/common/nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/common/nttcis.py b/libcloud/common/nttcis.py index 23a4db5..4c2977a 100644 --- a/libcloud/common/nttcis.py +++ b/libcloud/common/nttcis.py @@ -1916,3 +1916,11 @@ class NttCisNic(object): 'network_adapter_name=%s>' % (self.private_ip_v4, self.vlan, self.network_adapter_name)) + +class ConsistencyGroup(object): + """ + A representation of Consistency Groups in NTTC-CIS + """ + def __init__(self, description, name=None, journal_size_gb=None, + sourceServer=None, targetServer=None): + pass \ No newline at end of file http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/compute/drivers/nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py index e1b5ec1..9290295 100644 --- a/libcloud/compute/drivers/nttcis.py +++ b/libcloud/compute/drivers/nttcis.py @@ -4973,8 +4973,7 @@ class NttCisNodeDriver(NodeDriver): 'expiry_time': findtext(element, 'expiryTime', TYPES_URN), 'type': findtext(element, 'type', TYPES_URN), 'state': findtext(element, 'state', TYPES_URN), - 'server_config': self.to_snapshot_conf_elems( - findtext(element, 'serverConfig', TYPES_URN)) + } def _to_ipv4_addresses(self, object): http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/drs/base.py ---------------------------------------------------------------------- diff --git a/libcloud/drs/base.py b/libcloud/drs/base.py index 520254c..905d4fb 100644 --- a/libcloud/drs/base.py +++ b/libcloud/drs/base.py @@ -1,6 +1,26 @@ + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# 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 + + class DRSConsistencyGroup(object): """ - Provide a common interface for handling Load Balancers. + Provide a common interface for handling DRS. """ def __init__(self, id, name, description, journalSizeGB, serverPairSourceServerId, serverPairtargetServerId, @@ -35,4 +55,22 @@ class DRSConsistencyGroup(object): self.serverPairSourceServerId = serverPairSourceServerId self.serverPairtargetServerId = serverPairtargetServerId self.driver = driver - self.extra = extra or {} \ No newline at end of file + self.extra = extra or {} + + +class Driver(BaseDriver): + """ + A base Driver class to derive from + + This class is always subclassed by a specific driver. + """ + + name = None + website = None + + connectionCls = ConnectionKey + + def __init__(self, key, secret=None, secure=True, host=None, + port=None, **kwargs): + super(Driver, self).__init__(key=key, secret=secret, secure=secure, + host=host, port=port, **kwargs) http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/drs/drivers/__init__.py ---------------------------------------------------------------------- diff --git a/libcloud/drs/drivers/__init__.py b/libcloud/drs/drivers/__init__.py index e69de29..f2f9f29 100644 --- a/libcloud/drs/drivers/__init__.py +++ b/libcloud/drs/drivers/__init__.py @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__all__ = [ + 'nttcis' +] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/drs/drivers/nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/drs/drivers/nttcis.py b/libcloud/drs/drivers/nttcis.py index e0c94a6..3467277 100644 --- a/libcloud/drs/drivers/nttcis.py +++ b/libcloud/drs/drivers/nttcis.py @@ -1,23 +1,10 @@ from libcloud.utils.py3 import ET from libcloud.common.nttcis import NttCisConnection -from libcloud.common.nttcis import NttCisPool -from libcloud.common.nttcis import NttCisPoolMember -from libcloud.common.nttcis import NttCisVirtualListener -from libcloud.common.nttcis import NttCisVIPNode -from libcloud.common.nttcis import NttCisDefaultHealthMonitor -from libcloud.common.nttcis import NttCisPersistenceProfile -from libcloud.common.nttcis import \ - NttCisVirtualListenerCompatibility -from libcloud.common.nttcis import NttCisDefaultiRule from libcloud.common.nttcis import API_ENDPOINTS from libcloud.common.nttcis import DEFAULT_REGION -from libcloud.common.nttcis import TYPES_URN -from libcloud.utils.misc import reverse_dict -from libcloud.utils.xml import fixxpath, findtext, findall -from libcloud.loadbalancer.types import State -from libcloud.loadbalancer.base import Algorithm, Driver, LoadBalancer -from libcloud.loadbalancer.base import Member -from libcloud.loadbalancer.types import Provider +from libcloud.drs.types import Provider +from libcloud.drs.base import Driver +from libcloud.common.types import LibcloudError class NttCisDRSDriver(Driver): @@ -43,9 +30,10 @@ class NttCisDRSDriver(Driver): if region is not None: self.selected_region = API_ENDPOINTS[region] - super(NttCisDRSDriver, self).__init__(key=key, secret=secret, - secure=secure, host=host, - port=port, - api_version=api_version, - region=region, - **kwargs) + super(NttCisDRSDriver, self).__init__(key=key, + secret=secret, + secure=secure, host=host, + port=port, + api_version=api_version, + region=region, + **kwargs) http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/drs/types.py ---------------------------------------------------------------------- diff --git a/libcloud/drs/types.py b/libcloud/drs/types.py new file mode 100644 index 0000000..b902f74 --- /dev/null +++ b/libcloud/drs/types.py @@ -0,0 +1,43 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__all__ = [ + "Provider", + "LibcloudDRSError", + "LibcloudDRSImmutableError", + +] + +from libcloud.common.types import LibcloudError + + +class LibcloudDRSError(LibcloudError): + pass + + +class LibcloudDRSImmutableError(LibcloudDRSError): + pass + + +class Provider(object): + """ + Defines for each of the supported providers + + Non-Dummy drivers are sorted in alphabetical order. Please preserve this + ordering when adding new drivers. + + :cvar ALIYUN_SLB: Aliyun SLB loadbalancer driver + """ + NTTCIS = 'nttcis' http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/loadbalancer/drivers/__init__.py ---------------------------------------------------------------------- diff --git a/libcloud/loadbalancer/drivers/__init__.py b/libcloud/loadbalancer/drivers/__init__.py index f4fdb86..0affb14 100644 --- a/libcloud/loadbalancer/drivers/__init__.py +++ b/libcloud/loadbalancer/drivers/__init__.py @@ -15,5 +15,6 @@ __all__ = [ 'rackspace', - 'gogrid' + 'gogrid', + 'nttcis' ] http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/libcloud/loadbalancer/drivers/nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/loadbalancer/drivers/nttcis.py b/libcloud/loadbalancer/drivers/nttcis.py index 7f8dcea..ab370b5 100644 --- a/libcloud/loadbalancer/drivers/nttcis.py +++ b/libcloud/loadbalancer/drivers/nttcis.py @@ -23,7 +23,6 @@ from libcloud.common.nttcis import NttCisDefaultHealthMonitor from libcloud.common.nttcis import NttCisPersistenceProfile from libcloud.common.nttcis import \ NttCisVirtualListenerCompatibility -from libcloud.common.nttcis import Node from libcloud.common.nttcis import NttCisDefaultiRule from libcloud.common.nttcis import API_ENDPOINTS from libcloud.common.nttcis import DEFAULT_REGION @@ -38,7 +37,7 @@ from libcloud.loadbalancer.types import Provider class NttCisLBDriver(Driver): """ - NttCis node driver. + NttCis LB driver. """ selected_region = None http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/tests/conftest.py ---------------------------------------------------------------------- diff --git a/tests/conftest.py b/tests/conftest.py index c736040..af680de 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,10 +19,17 @@ def compute_driver_na(): @pytest.fixture(scope="module") def lbdriver(): cd = libcloud.get_driver(libcloud.DriverType.COMPUTE, libcloud.DriverType.COMPUTE.NTTCIS) - compute_driver = cd('mitchgeo-test', 'Snmpv2c!', region='dd-eu') + compute_driver = cd('mitchgeo-test', 'Snmpv2c!', region='eu') net_domain_name = 'sdk_test_1' net_domains = compute_driver.ex_list_network_domains(location='EU6') net_domain_id = [d for d in net_domains if d.name == net_domain_name][0].id cls = libcloud.get_driver(libcloud.DriverType.LOADBALANCER, libcloud.DriverType.LOADBALANCER.NTTCIS) lbdriver = cls('mitchgeo-test', net_domain_id, 'Snmpv2c!', region='dd-eu') - return lbdriver \ No newline at end of file + return lbdriver + + [email protected](scope="module") +def drs_driver(): + drs = libcloud.get_driver(libcloud.DriverType.DRS, libcloud.DriverType.DRS.NTTCIS) + drsdriver = drs('mitchgeo-test', 'Snmpv2c!', region='eu') + return drsdriver http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/tests/lib_create_test.py ---------------------------------------------------------------------- diff --git a/tests/lib_create_test.py b/tests/lib_create_test.py index 2bf9ab9..486a6a5 100644 --- a/tests/lib_create_test.py +++ b/tests/lib_create_test.py @@ -270,4 +270,8 @@ def test_create_preivew_server(compute_driver): def test_migrate_preview_server(compute_driver): preview_id = "a598375f-40f4-4745-9556-ef8a8625734d" result = compute_driver.ex_migrate_preview_server(preview_id) - assert result is True \ No newline at end of file + assert result is True + + +def test_create_cg(drs_driver): + pass \ No newline at end of file http://git-wip-us.apache.org/repos/asf/libcloud/blob/bc64b1fc/tests/lib_edit_test.py ---------------------------------------------------------------------- diff --git a/tests/lib_edit_test.py b/tests/lib_edit_test.py index 079e7d7..a18a7f4 100644 --- a/tests/lib_edit_test.py +++ b/tests/lib_edit_test.py @@ -522,3 +522,9 @@ def test_remove_tag_from_asset(compute_driver, compute_driver_na): asset = [nd for nd in network_domains if nd.name == net_domain_name][0] result = compute_driver.ex_remove_tag_from_asset(asset, tag_key) assert result is True + + +def test_clean_failed(compute_driver): + failed_id = "da4d163b-06c7-42df-b670-fe48969aa749 " + result = compute_driver.ex_clean_failed_deployment(failed_id) + print(result) \ No newline at end of file
