libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [13/51] [abbrv] libcloud git commit: added 'xsi:nil': 'true' to compute/drivers/nttcis module in edit_ip_address_list
Date Wed, 31 Oct 2018 03:11:24 GMT
added 'xsi:nil': 'true' to compute/drivers/nttcis module in edit_ip_address_list


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

Branch: refs/heads/trunk
Commit: 1bffad07ac73d0e99f70612a50a77944a3ff848e
Parents: fd68cc6
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Sun Sep 9 13:28:20 2018 -0400
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Sun Sep 9 13:28:20 2018 -0400

----------------------------------------------------------------------
 libcloud/compute/drivers/nttcis.py | 41 ++++++++++++++++++--------------
 tests/lib_edit_test.py             | 42 ++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1bffad07/libcloud/compute/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py
index 0f79bca..2e88b2c 100644
--- a/libcloud/compute/drivers/nttcis.py
+++ b/libcloud/compute/drivers/nttcis.py
@@ -3603,11 +3603,11 @@ class NttCisNodeDriver(NodeDriver):
         response_code = findtext(response, 'responseCode', TYPES_URN)
         return response_code in ['IN_PROGRESS', 'OK']
 
-    def ex_edit_ip_address_list(self, ex_ip_address_list, description,
-                                ip_address_collection,
+    def ex_edit_ip_address_list(self, ex_ip_address_list, description=None,
+                                ip_address_collection=None,
                                 child_ip_address_lists=None):
         """
-        Edit IP Address List. IP Address list.
+        Edit IP Address List. IP Address list.  Bear in mind you cannot add ip addresses
to 
 
         >>> from pprint import pprint
         >>> from libcloud.compute.types import Provider
@@ -3659,6 +3659,7 @@ class NttCisNodeDriver(NodeDriver):
         :return: a list of NttCisIpAddressList objects
         :rtype: ``list`` of :class:`NttCisIpAddressList`
         """
+
         edit_ip_address_list = ET.Element(
             'editIpAddressList',
             {'xmlns': TYPES_URN,
@@ -3666,24 +3667,28 @@ class NttCisNodeDriver(NodeDriver):
                  ex_ip_address_list),
              'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance"
              })
+        if description is not None:
+            if description != 'nil':
+                ET.SubElement(
+                    edit_ip_address_list,
+                    'description'
+                ).text = description
+            else:
+                ET.SubElement(edit_ip_address_list, 'description',  {'xsi:nil': 'true'})
 
-        ET.SubElement(
-            edit_ip_address_list,
-            'description'
-        ).text = description
-
-        for ip in ip_address_collection:
-            ip_address = ET.SubElement(
-                edit_ip_address_list,
-                'ipAddress',
-            )
-            ip_address.set('begin', ip.begin)
+        if ip_address_collection is not None:
+            for ip in ip_address_collection:
+                ip_address = ET.SubElement(
+                    edit_ip_address_list,
+                    'ipAddress',
+                )
+                ip_address.set('begin', ip.begin)
 
-            if ip.end:
-                ip_address.set('end', ip.end)
+                if ip.end:
+                    ip_address.set('end', ip.end)
 
-            if ip.prefix_size:
-                ip_address.set('prefixSize', ip.prefix_size)
+                if ip.prefix_size:
+                    ip_address.set('prefixSize', ip.prefix_size)
 
         if child_ip_address_lists is not None:
             ET.SubElement(

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1bffad07/tests/lib_edit_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_edit_test.py b/tests/lib_edit_test.py
index 49a3f80..e4c3337 100644
--- a/tests/lib_edit_test.py
+++ b/tests/lib_edit_test.py
@@ -1,7 +1,7 @@
 import pytest
 import libcloud
 from libcloud import loadbalancer
-from libcloud.common.nttcis import NttCisAPIException, NttCisVlan
+from libcloud.common.nttcis import NttCisIpAddress, NttCisVlan
 from tests.lib_create_test import test_deploy_vlan
 
 
@@ -240,6 +240,17 @@ def test_edit_firewall_rule(compute_driver):
     assert result is True
 
 
+def test_delete_firewall_rule(compute_driver):
+    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]
+    rule_name = 'sdk_test_firewall_rule_2'
+    rules = compute_driver.ex_list_firewall_rules(net_domain[0])
+    rule = [rule for rule in rules if rule.name == rule_name]
+    result = compute_driver.ex_delete_firewall_rule(rule[0])
+    assert result is True
+
+
 def test_create_anti_affinity_rule(compute_driver):
     server1 = compute_driver.ex_get_node_by_id("d0425097-202f-4bba-b268-c7a73b8da129")
     server2 = compute_driver.ex_get_node_by_id("803e5e00-b22a-450a-8827-066ff15ec977")
@@ -261,6 +272,35 @@ def test_delete_port_list(compute_driver):
     assert result is True
 
 
+def test_edit_address_list(compute_driver):
+    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]
+    addr_list = compute_driver.ex_get_ip_address_list(net_domain[0], 'sdk_test_address_list')
+    assert addr_list[0].ip_version == 'IPV4'
+    ip_address_1 = NttCisIpAddress(begin='190.2.2.100')
+    ip_address_2 = NttCisIpAddress(begin='190.2.2.106', end='190.2.2.108')
+    ip_address_3 = NttCisIpAddress(begin='190.2.2.0', prefix_size='24')
+    ip_address_4 = NttCisIpAddress(begin='10.2.0.0', prefix_size='24')
+    ip_address_collection = [ip_address_1, ip_address_2, ip_address_3, ip_address_4]
+
+    result = compute_driver.ex_edit_ip_address_list("d32aa8d4-831b-4fd6-95da-c639768834f0",
+                                                    ip_address_collection=ip_address_collection)
+    assert result is True
+
+
+def test_edit_address_list_2(compute_driver):
+    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]
+    # An ip address list object can be used as an argument or the id of the address list
+    addr_list = compute_driver.ex_get_ip_address_list(net_domain[0], 'sdk_test_address_list')
+
+    result = compute_driver.ex_edit_ip_address_list("d32aa8d4-831b-4fd6-95da-c639768834f0",
+                                                    description='nil')
+    assert result is True
+
+
 def test_delete_address_list(compute_driver):
     domain_name = 'sdk_test_1'
     domains = compute_driver.ex_list_network_domains(location='EU6')


Mime
View raw message