From a0db645ee777fa11bbd62359da79b7d8ade037c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Seren?= Date: Thu, 13 May 2021 14:32:18 +0200 Subject: [PATCH] Bugfix: Handling of --apic-nat-type "" Change-Id: I874a60950de672d3cf3f30c84731e285acb0c870 --- gbpclient/gbp/v2_0/network.py | 4 ++-- gbpclient/tests/unit/test_network.py | 29 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/gbpclient/gbp/v2_0/network.py b/gbpclient/gbp/v2_0/network.py index 69f0080..f5db5f6 100644 --- a/gbpclient/gbp/v2_0/network.py +++ b/gbpclient/gbp/v2_0/network.py @@ -82,8 +82,8 @@ def _get_attrs_network_extension(client_manager, parsed_args): attrs['apic:policy_enforcement_pref' ] = parsed_args.apic_policy_enforcement_pref if parsed_args.external: - if 'apic_nat_type' in parsed_args and \ - parsed_args.apic_nat_type: + if ('apic_nat_type' in parsed_args and + parsed_args.apic_nat_type is not None): attrs['apic:nat_type'] = parsed_args.apic_nat_type if parsed_args.apic_external_cidrs: attrs['apic:external_cidrs' diff --git a/gbpclient/tests/unit/test_network.py b/gbpclient/tests/unit/test_network.py index 3ed20c8..67f2568 100644 --- a/gbpclient/tests/unit/test_network.py +++ b/gbpclient/tests/unit/test_network.py @@ -133,6 +133,35 @@ class TestNetworkCreate(test_network.TestNetwork, test_cli20.CLITestV20Base): 'apic:policy_enforcement_pref': 'enforced', }) + def test_create_no_nat_option(self): + arglist = [ + self._network.name, + "--external", + "--apic-distinguished-names", 'ExternalNetwork=test1', + "--apic-nat-type", "", + "--apic-external-cidrs", '20.20.20.0/8', + ] + verifylist = [ + ('name', self._network.name), + ('external', True), + ('apic_distinguished_names', [{'ExternalNetwork': 'test1'}]), + ('apic_nat_type', ""), + ('apic_external_cidrs', '20.20.20.0/8'), + ] + create_ext = network_ext.CreateNetworkExtension(self.app) + parsed_args = self.check_parser_ext( + self.cmd, arglist, verifylist, create_ext) + columns, data = self.cmd.take_action(parsed_args) + + self.network.create_network.assert_called_once_with(**{ + 'admin_state_up': True, + 'name': self._network.name, + 'router:external': True, + 'apic:distinguished_names': {"ExternalNetwork": "test1"}, + 'apic:external_cidrs': ['20.20.20.0/8'], + 'apic:nat_type': '', + }) + # Tests for network set with APIC extensions #