From e8d361ef65ba0755d05cab8393ed7dd96a6b316e Mon Sep 17 00:00:00 2001 From: Christopher Collins Date: Thu, 16 Nov 2023 10:58:01 -0800 Subject: [PATCH] Router gw port subnet extension Change-Id: I008a3abfed281ef4367743e72c6aac20fc0bec40 --- gbpclient/gbp/v2_0/subnet.py | 36 +++++++++++++++++++++++++++++ gbpclient/tests/unit/test_subnet.py | 15 ++++++++---- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/gbpclient/gbp/v2_0/subnet.py b/gbpclient/gbp/v2_0/subnet.py index 8c41eb1..8edeb96 100644 --- a/gbpclient/gbp/v2_0/subnet.py +++ b/gbpclient/gbp/v2_0/subnet.py @@ -53,6 +53,10 @@ def _get_attrs_subnet_extension(client_manager, parsed_args, is_create=True): attrs['apic:shared_between_vrfs'] = True if parsed_args.apic_shared_between_vrfs_disable: attrs['apic:shared_between_vrfs'] = False + if parsed_args.apic_router_gw_ip_pool_enable: + attrs['apic:router_gw_ip_pool'] = True + if parsed_args.apic_router_gw_ip_pool_disable: + attrs['apic:router_gw_ip_pool'] = False return attrs @@ -75,6 +79,8 @@ subnet_sdk.Subnet.apic_advertised_externally = resource.Body( 'apic:advertised_externally') subnet_sdk.Subnet.apic_shared_between_vrfs = resource.Body( 'apic:shared_between_vrfs') +subnet_sdk.Subnet.apic_router_gw_ip_pool = resource.Body( + 'apic:router_gw_ip_pool') class CreateSubnetExtension(hooks.CommandHook): @@ -163,6 +169,21 @@ class CreateSubnetExtension(hooks.CommandHook): help=_("Set APIC shared between vrfs to false\n" "Default value for apic_shared_between_vrfs is False ") ) + parser.add_argument( + '--apic_router_gw_ip_pool_enable', + action='store_true', + default=None, + dest='apic_router_gw_ip_pool_enable', + help=_("Set APIC router gw ip pool to true\n" + "Default value for apic_router_gw_ip_pool is False ") + ) + parser.add_argument( + '--apic_router_gw_ip_pool_disable', + action='store_true', + dest='apic_router_gw_ip_pool_disable', + help=_("Set APIC router gw ip pool to false\n" + "Default value for apic_router_gw_ip_pool is False ") + ) return parser def get_epilog(self): @@ -238,6 +259,21 @@ class SetSubnetExtension(hooks.CommandHook): help=_("Set APIC shared between vrfs to false\n" "Default value for apic_shared_between_vrfs is False ") ) + parser.add_argument( + '--apic_router_gw_ip_pool_enable', + action='store_true', + default=None, + dest='apic_router_gw_ip_pool_enable', + help=_("Set APIC router gw ip pool to true\n" + "Default value for apic_router_gw_ip_pool is False ") + ) + parser.add_argument( + '--apic_router_gw_ip_pool_disable', + action='store_true', + dest='apic_router_gw_ip_pool_disable', + help=_("Set APIC router gw ip pool to false\n" + "Default value for apic_router_gw_ip_pool is False ") + ) return parser def get_epilog(self): diff --git a/gbpclient/tests/unit/test_subnet.py b/gbpclient/tests/unit/test_subnet.py index 0bcd8b3..28d6fbf 100644 --- a/gbpclient/tests/unit/test_subnet.py +++ b/gbpclient/tests/unit/test_subnet.py @@ -54,7 +54,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base): ('apic_snat_subnet_only_enable', None), ('apic_epg_subnet', False), ('apic_advertised_externally_disable', None), - ('apic_shared_between_vrfs_enable', None) + ('apic_shared_between_vrfs_enable', None), + ('apic_router_gw_ip_pool_enable', None), ] create_ext = subnet_ext.CreateSubnetExtension(self.app) parsed_args = self.check_parser_ext( @@ -78,7 +79,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base): "--apic-snat-subnet-only-enable", "--apic-epg-subnet", "--apic-advertised-externally-enable", - "--apic-shared-between-vrfs-enable" + "--apic-shared-between-vrfs-enable", + "--apic_router_gw_ip_pool_enable" ] verifylist = [ ('name', self._subnet.name), @@ -88,7 +90,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base): ('apic_snat_subnet_only_enable', True), ('apic_epg_subnet', True), ('apic_advertised_externally_enable', True), - ('apic_shared_between_vrfs_enable', True) + ('apic_shared_between_vrfs_enable', True), + ('apic_router_gw_ip_pool_enable', True) ] create_ext = subnet_ext.CreateSubnetExtension(self.app) parsed_args = self.check_parser_ext( @@ -105,7 +108,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base): 'apic:snat_subnet_only': True, 'apic:epg_subnet': True, 'apic:advertised_externally': True, - 'apic:shared_between_vrfs': True + 'apic:shared_between_vrfs': True, + 'apic:router_gw_ip_pool': True }) @@ -145,6 +149,7 @@ class TestSubnetSet(test_subnet.TestSubnet, test_cli20.CLITestV20Base): "--apic-snat-subnet-only-disable", "--apic-advertised-externally-enable", "--apic-shared-between-vrfs-enable", + "--apic_router_gw_ip_pool_enable" ] verifylist = [ ('subnet', self._subnet.name), @@ -152,6 +157,7 @@ class TestSubnetSet(test_subnet.TestSubnet, test_cli20.CLITestV20Base): ('apic_snat_subnet_only_disable', True), ('apic_advertised_externally_enable', True), ('apic_shared_between_vrfs_enable', True), + ('apic_router_gw_ip_pool_enable', True) ] set_ext = subnet_ext.SetSubnetExtension(self.app) parsed_args = self.check_parser_ext( @@ -163,6 +169,7 @@ class TestSubnetSet(test_subnet.TestSubnet, test_cli20.CLITestV20Base): 'apic:snat_subnet_only': False, 'apic:advertised_externally': True, 'apic:shared_between_vrfs': True, + 'apic:router_gw_ip_pool': True } self.network.update_subnet.assert_called_with(self._subnet, **attrs) self.assertIsNone(result)