From notifications-return-14874-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Wed Oct 31 04:11:18 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 306961807A3 for ; Wed, 31 Oct 2018 04:11:17 +0100 (CET) Received: (qmail 10432 invoked by uid 500); 31 Oct 2018 03:11:16 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 9558 invoked by uid 500); 31 Oct 2018 03:11:13 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 9549 invoked by uid 99); 31 Oct 2018 03:11:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2018 03:11:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 94E08E0A96; Wed, 31 Oct 2018 03:11:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anthonyshaw@apache.org To: commits@libcloud.apache.org Date: Wed, 31 Oct 2018 03:11:24 -0000 Message-Id: <8c9ab6c3c40746e3bc0ce03d41f49aad@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [13/51] [abbrv] libcloud git commit: added 'xsi:nil': 'true' to compute/drivers/nttcis module in edit_ip_address_list 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 Authored: Sun Sep 9 13:28:20 2018 -0400 Committer: mitch 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')