Router gw port subnet extension

Change-Id: I008a3abfed281ef4367743e72c6aac20fc0bec40
(cherry picked from commit e8d361ef65ba0755d05cab8393ed7dd96a6b316e)
(cherry picked from commit 3d794f7083b4825168c016e172333454b8083e5f)
This commit is contained in:
Christopher Collins 2023-11-16 10:58:01 -08:00 committed by Thomas Bachman
parent fd7d10f9de
commit 995d0d76b3
2 changed files with 47 additions and 4 deletions
gbpclient
gbp/v2_0
tests/unit

@ -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):

@ -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)