libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [16/51] [abbrv] libcloud git commit: update tests in all test modules
Date Wed, 31 Oct 2018 03:11:27 GMT
update tests in all test modules


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f63a13dc
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f63a13dc
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f63a13dc

Branch: refs/heads/trunk
Commit: f63a13dcd953cf29348d358578f8e89552771185
Parents: 2e6156f
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Thu Sep 20 15:01:10 2018 -0400
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Thu Sep 20 15:01:10 2018 -0400

----------------------------------------------------------------------
 libcloud/compute/base.py                |  1 +
 libcloud/compute/drivers/nttcis.py      |  2 +-
 libcloud/loadbalancer/drivers/nttcis.py | 57 +++++++++++++++----
 tests/lib_create_test.py                | 26 ++++++++-
 tests/lib_edit_test.py                  | 82 +++++++++++++++++++++++++++-
 tests/lib_list_test.py                  |  9 +++
 6 files changed, 160 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63a13dc/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index f89ca7e..8d50e8a 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -179,6 +179,7 @@ class Node(UuidMixin):
         :param state: Node state.
         :type state: :class:`libcloud.compute.types.NodeState`
 
+
         :param public_ips: Public IP addresses associated with this node.
         :type public_ips: ``list``
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63a13dc/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index 57bcec5..61a9815 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -112,7 +112,7 @@ class NttCisNodeDriver(NodeDriver):
     selected_region = None
     connectionCls = NttCisConnection
     name = 'NTTC-CIS'
-    website = 'http://www.dimensiondata.com/'
+    website = 'https://www.us.ntt.com/en/services/cloud/enterprise-cloud.html'
     type = Provider.NTTCIS
     features = {'create_node': ['password']}
     api_version = 1.0

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63a13dc/libcloud/loadbalancer/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/loadbalancer/drivers/nttcis.py b/libcloud/loadbalancer/drivers/nttcis.py
index e066d1b..29e21bf 100644
--- a/libcloud/loadbalancer/drivers/nttcis.py
+++ b/libcloud/loadbalancer/drivers/nttcis.py
@@ -52,9 +52,12 @@ class NttCisLBDriver(Driver):
 
     _VALUE_TO_ALGORITHM_MAP = {
         'ROUND_ROBIN': Algorithm.ROUND_ROBIN,
-        'LEAST_CONNECTIONS': Algorithm.LEAST_CONNECTIONS,
-        'SHORTEST_RESPONSE': Algorithm.SHORTEST_RESPONSE,
-        'PERSISTENT_IP': Algorithm.PERSISTENT_IP
+        'LEAST_CONNECTIONS_MEMBER': Algorithm.LEAST_CONNECTIONS_MEMBER,
+        'LEAST_CONNECTIONS_NODE': Algorithm.LEAST_CONNECTIONS_NODE,
+        'OBSERVED_MEMBER': Algorithm.OBSERVED_MEMBER,
+        'OBSERVED_NODE': Algorithm.OBSERVED_NODE,
+        'PREDICTIVE_MEMBER': Algorithm.PREDICTIVE_MEMBER,
+        'PREDICTIVE_NODE': Algorithm.PREDICTIVE_NODE
     }
     _ALGORITHM_TO_VALUE_MAP = reverse_dict(_VALUE_TO_ALGORITHM_MAP)
 
@@ -146,7 +149,7 @@ class NttCisLBDriver(Driver):
             algor = Algorithm.__dict__[algorithm]
 
         # Create a pool first
-        al = self._ALGORITHM_TO_VALUE_MAP[algor]
+
         pool = self.ex_create_pool(
             network_domain_id=network_domain_id,
             name=name,
@@ -190,6 +193,28 @@ class NttCisLBDriver(Driver):
                    'listener_ip_address': ex_listener_ip_address}
         )
 
+    def ex_update_listener(self, virtual_listener: NttCisVirtualListener, **kwargs) ->
NttCisVirtualListener:
+        """
+        Update a current virtual listener.
+        :param virtual_listener: The listener to be updated
+        :return: The edited version of the listener
+        """
+        edit_listener_elm = ET.Element('editVirtualListener', {'xmlns': TYPES_URN,
+                                                               'id': virtual_listener.id,
+                                                               'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance"})
+        for k, v in kwargs.items():
+            if v is None:
+                ET.SubElement(edit_listener_elm, k, {'xsi:nil': 'true'})
+            else:
+                ET.SubElement(edit_listener_elm, k).text = v
+
+        result = self.connection.request_with_orgId_api_2(
+            'networkDomainVip/editVirtualListener',
+            method='POST',
+            data=ET.tostring(edit_listener_elm)).object
+        response_code = findtext(result, 'responseCode', TYPES_URN)
+        return response_code in ['IN_PROGRESS', 'OK']
+
     def list_balancers(self, ex_network_domain_id=None):
         """
         List all loadbalancers inside a geography or in given network.
@@ -375,7 +400,6 @@ class NttCisLBDriver(Driver):
         if port is not None:
             ET.SubElement(create_pool_m, "port").text = str(port)
         ET.SubElement(create_pool_m, "status").text = 'ENABLED'
-        test = ET.tostring(create_pool_m)
         response = self.connection.request_with_orgId_api_2(
             'networkDomainVip/addPoolMember',
             method='POST',
@@ -402,10 +426,13 @@ class NttCisLBDriver(Driver):
                        network_domain_id,
                        name,
                        ip,
-                       ex_description,
+                       ex_description=None,
                        connection_limit=25000,
                        connection_rate_limit=2000):
         """
+        Inconsistent use of objects.
+        Either always pass an object and have the method get the id, or always pass the id.
+
         Create a new node
 
         :param network_domain_id: Network Domain ID (required)
@@ -434,8 +461,9 @@ class NttCisLBDriver(Driver):
         ET.SubElement(create_node_elm, "networkDomainId") \
             .text = network_domain_id
         ET.SubElement(create_node_elm, "name").text = name
-        ET.SubElement(create_node_elm, "description").text \
-            = str(ex_description)
+        if ex_description is not None:
+            ET.SubElement(create_node_elm, "description").text \
+                = str(ex_description)
         ET.SubElement(create_node_elm, "ipv4Address").text = ip
         ET.SubElement(create_node_elm, "status").text = 'ENABLED'
         ET.SubElement(create_node_elm, "connectionLimit") \
@@ -473,13 +501,16 @@ class NttCisLBDriver(Driver):
         :rtype: ``NttCisNode``
         """
         create_node_elm = ET.Element('editNode', {'xmlns': TYPES_URN})
+        create_node_elm.set('id', node.id)
+        ET.SubElement(create_node_elm, 'healthMonitorId') \
+            .text = node.health_monitor_id
         ET.SubElement(create_node_elm, "connectionLimit") \
             .text = str(node.connection_limit)
         ET.SubElement(create_node_elm, "connectionRateLimit") \
             .text = str(node.connection_rate_limit)
 
         self.connection.request_with_orgId_api_2(
-            action='networkDomainVip/createNode',
+            action='networkDomainVip/editNode',
             method='POST',
             data=ET.tostring(create_node_elm)).object
         return node
@@ -772,9 +803,11 @@ class NttCisLBDriver(Driver):
         :rtype: ``bool``
         """
         create_node_elm = ET.Element('editPool', {'xmlns': TYPES_URN})
-
+        create_node_elm.set('id', pool.id)
         ET.SubElement(create_node_elm, "loadBalanceMethod") \
             .text = str(pool.load_balance_method)
+        ET.SubElement(create_node_elm, 'healthMonitorId').text \
+            = pool.health_monitor_id
         ET.SubElement(create_node_elm, "serviceDownAction") \
             .text = pool.service_down_action
         ET.SubElement(create_node_elm, "slowRampTime").text \
@@ -966,7 +999,7 @@ class NttCisLBDriver(Driver):
         return self.connection.wait_for_state(state, func, poll_interval,
                                               timeout, *args, **kwargs)
 
-    def ex_get_default_health_monitors(self, network_domain_id):
+    def ex_get_default_health_monitors(self, network_domain):
         """
         Get the default health monitors available for a network domain
 
@@ -977,7 +1010,7 @@ class NttCisLBDriver(Driver):
         """
         result = self.connection.request_with_orgId_api_2(
             action='networkDomainVip/defaultHealthMonitor',
-            params={'networkDomainId': network_domain_id},
+            params={'networkDomainId': network_domain.id},
             method='GET').object
         return self._to_health_monitors(result)
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63a13dc/tests/lib_create_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_create_test.py b/tests/lib_create_test.py
index fa52697..2dadb90 100644
--- a/tests/lib_create_test.py
+++ b/tests/lib_create_test.py
@@ -206,7 +206,7 @@ def test_create_load_balancer(lbdriver, compute_driver):
     port = '80'
     listener_port = '8000'
     protocol = 'TCP'
-    algorithm = 'LEAST_CONNECTIONS'
+    algorithm = 'LEAST_CONNECTIONS_MEMBER'
     members = [m for m in members]
     ex_listener_ip_address = "168.128.13.127"
     lb = lbdriver.create_balancer(name, listener_port=listener_port, port=port, protocol=protocol,
@@ -214,7 +214,27 @@ def test_create_load_balancer(lbdriver, compute_driver):
                                   ex_listener_ip_address=ex_listener_ip_address)
 
 
+def test_create_vip_node(compute_driver, lbdriver):
+    node_address = '10.1.1.7'
+    node_name = "web1"
+    domain_name = 'sdk_test_1'
+    domains = compute_driver.ex_list_network_domains(location='EU6')
+    net_domain = [d for d in domains if d.name == domain_name][0]
+    node = lbdriver.ex_create_node(net_domain.id, node_name, node_address)
+    print(node)
+
+
+def test_add_pool_member(compute_driver, lbdriver):
+    pool_name = 'sdk_test_balancer'
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    pools = lbdriver.ex_get_pools(ex_network_domain_id=network_domain.id)
+    pool = [p for p in pools if p.name == pool_name][0]
+    node = lbdriver.ex_get_node("eca8dac3-1417-4fdf-83c3-2b7b848ab171")
+    result = lbdriver.ex_create_pool_member(pool, node, port=80)
+    print(result)
 
-def test_create_pool(lbdriver):
-    pass
 
+def test_create_server_monitor(compute_driver):
+    pass
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63a13dc/tests/lib_edit_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_edit_test.py b/tests/lib_edit_test.py
index ffccd6c..32984ee 100644
--- a/tests/lib_edit_test.py
+++ b/tests/lib_edit_test.py
@@ -2,7 +2,7 @@ import pytest
 import libcloud
 from libcloud import loadbalancer
 from libcloud.compute.drivers.nttcis import NttCisPort
-from libcloud.common.nttcis import NttCisIpAddress, NttCisVlan
+from libcloud.common.nttcis import NttCisIpAddress, NttCisVlan, NttCisVIPNode
 from tests.lib_create_test import test_deploy_vlan
 
 
@@ -370,3 +370,83 @@ def test_delete_nat_rule(compute_driver):
     rule = compute_driver.ex_get_nat_rule(network_domain, '74f0897f-5536-4c17-84b0-d52b1fb3aea6')
     result = compute_driver.ex_delete_nat_rule(rule)
     assert result is True
+
+
+def test_update_health_monitor(compute_driver, lbdriver):
+    pool_name = 'sdk_test_balancer'
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    pools = lbdriver.ex_get_pools(ex_network_domain_id=network_domain.id)
+    pool = [p for p in pools if p.name == pool_name][0]
+    pool.health_monitor_id = '9f79487a-1b6d-11e5-8d4f-180373fb68df'
+    result = lbdriver.ex_update_pool(pool)
+    assert result is True
+
+
+def test_update_node_monitor(compute_driver, lbdriver):
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    nodes = lbdriver.ex_get_nodes(ex_network_domain_id=network_domain.id)
+    #pool = [p for p in pools if p.name == pool_name][0]
+    health_monitor_id = '9f79a126-1b6d-11e5-8d4f-180373fb68df'
+    for node in nodes:
+        node.health_monitor_id = health_monitor_id
+        result = lbdriver.ex_update_node(node)
+        assert isinstance(result, NttCisVIPNode)
+
+
+def test_remove_node(compute_driver, lbdriver):
+    node_name = 'web1'
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    nodes = lbdriver.ex_get_nodes(ex_network_domain_id=network_domain.id)
+    node = [n for n in nodes if n.name == node_name][0]
+    pool_name = "sdk_test_balancer"
+    pools = lbdriver.ex_get_pools(ex_network_domain_id=network_domain.id)
+    pool = [p for p in pools if p.name == pool_name][0]
+    pool_members = lbdriver.ex_get_pool_members(pool.id)
+    pool_member = [pm for pm in pool_members if pm.node_id == node.id][0]
+    result = lbdriver.ex_destroy_pool_member(pool_member)
+    assert result is True
+
+
+def test_delete_node(compute_driver, lbdriver):
+    node_name = 'web1'
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    nodes = lbdriver.ex_get_nodes(ex_network_domain_id=network_domain.id)
+    node = [n for n in nodes if n.name == node_name][0]
+    result = lbdriver.ex_destroy_node(node.id)
+    assert result is True
+
+
+def test_remove_pool(compute_driver, lbdriver):
+    listener_name = "sdk_test_balancer"
+    listeners = lbdriver.list_balancers(ex_network_domain_id=lbdriver.network_domain_id)
+    listener = [l for l in listeners if l.name == listener_name][0]
+    pool_id = None
+    result = lbdriver.ex_update_listener(listener, poolId=pool_id)
+    assert result is True
+
+
+def test_delete_pool(compute_driver, lbdriver):
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    pool_name = "sdk_test_balancer"
+    pools = lbdriver.ex_get_pools(ex_network_domain_id=network_domain.id)
+    pool = [p for p in pools if p.name == pool_name][0]
+    result = lbdriver.ex_destroy_pool(pool)
+    assert result is True
+
+
+def test_delete_listener(compute_driver, lbdriver):
+    listener_name = "sdk_test_balancer"
+    listeners = lbdriver.list_balancers(ex_network_domain_id=lbdriver.network_domain_id)
+    listener = [l for l in listeners if l.name == listener_name][0]
+    result = lbdriver.destroy_balancer(listener)
+    assert result is True

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63a13dc/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index 55d958e..7b896f4 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -379,3 +379,12 @@ def test_get_customer_image(compute_driver):
     image = compute_driver.ex_get_image_by_id(imagee_id)
     print(image, image.extra)
 
+
+def test_list_health_monitors(compute_driver, lbdriver):
+    network_domain_name = "sdk_test_1"
+    network_domains = compute_driver.ex_list_network_domains(location='EU6')
+    network_domain = [nd for nd in network_domains if nd.name == network_domain_name][0]
+    monitors = lbdriver.ex_get_default_health_monitors(network_domain)
+    for monitor in monitors:
+        print(monitor)
+


Mime
View raw message