Merge "Router gw port subnet extension"

This commit is contained in:
Zuul
2024-05-24 02:21:58 +00:00
committed by Gerrit Code Review
2 changed files with 47 additions and 4 deletions

View File

@@ -53,6 +53,10 @@ def _get_attrs_subnet_extension(client_manager, parsed_args, is_create=True):
attrs['apic:shared_between_vrfs'] = True attrs['apic:shared_between_vrfs'] = True
if parsed_args.apic_shared_between_vrfs_disable: if parsed_args.apic_shared_between_vrfs_disable:
attrs['apic:shared_between_vrfs'] = False 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 return attrs
@@ -75,6 +79,8 @@ subnet_sdk.Subnet.apic_advertised_externally = resource.Body(
'apic:advertised_externally') 'apic:advertised_externally')
subnet_sdk.Subnet.apic_shared_between_vrfs = resource.Body( subnet_sdk.Subnet.apic_shared_between_vrfs = resource.Body(
'apic:shared_between_vrfs') 'apic:shared_between_vrfs')
subnet_sdk.Subnet.apic_router_gw_ip_pool = resource.Body(
'apic:router_gw_ip_pool')
class CreateSubnetExtension(hooks.CommandHook): class CreateSubnetExtension(hooks.CommandHook):
@@ -163,6 +169,21 @@ class CreateSubnetExtension(hooks.CommandHook):
help=_("Set APIC shared between vrfs to false\n" help=_("Set APIC shared between vrfs to false\n"
"Default value for apic_shared_between_vrfs is False ") "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 return parser
def get_epilog(self): def get_epilog(self):
@@ -238,6 +259,21 @@ class SetSubnetExtension(hooks.CommandHook):
help=_("Set APIC shared between vrfs to false\n" help=_("Set APIC shared between vrfs to false\n"
"Default value for apic_shared_between_vrfs is False ") "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 return parser
def get_epilog(self): def get_epilog(self):

View File

@@ -54,7 +54,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base):
('apic_snat_subnet_only_enable', None), ('apic_snat_subnet_only_enable', None),
('apic_epg_subnet', False), ('apic_epg_subnet', False),
('apic_advertised_externally_disable', None), ('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) create_ext = subnet_ext.CreateSubnetExtension(self.app)
parsed_args = self.check_parser_ext( parsed_args = self.check_parser_ext(
@@ -78,7 +79,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base):
"--apic-snat-subnet-only-enable", "--apic-snat-subnet-only-enable",
"--apic-epg-subnet", "--apic-epg-subnet",
"--apic-advertised-externally-enable", "--apic-advertised-externally-enable",
"--apic-shared-between-vrfs-enable" "--apic-shared-between-vrfs-enable",
"--apic_router_gw_ip_pool_enable"
] ]
verifylist = [ verifylist = [
('name', self._subnet.name), ('name', self._subnet.name),
@@ -88,7 +90,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base):
('apic_snat_subnet_only_enable', True), ('apic_snat_subnet_only_enable', True),
('apic_epg_subnet', True), ('apic_epg_subnet', True),
('apic_advertised_externally_enable', 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) create_ext = subnet_ext.CreateSubnetExtension(self.app)
parsed_args = self.check_parser_ext( parsed_args = self.check_parser_ext(
@@ -105,7 +108,8 @@ class TestSubnetCreate(test_subnet.TestSubnet, test_cli20.CLITestV20Base):
'apic:snat_subnet_only': True, 'apic:snat_subnet_only': True,
'apic:epg_subnet': True, 'apic:epg_subnet': True,
'apic:advertised_externally': 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-snat-subnet-only-disable",
"--apic-advertised-externally-enable", "--apic-advertised-externally-enable",
"--apic-shared-between-vrfs-enable", "--apic-shared-between-vrfs-enable",
"--apic_router_gw_ip_pool_enable"
] ]
verifylist = [ verifylist = [
('subnet', self._subnet.name), ('subnet', self._subnet.name),
@@ -152,6 +157,7 @@ class TestSubnetSet(test_subnet.TestSubnet, test_cli20.CLITestV20Base):
('apic_snat_subnet_only_disable', True), ('apic_snat_subnet_only_disable', True),
('apic_advertised_externally_enable', 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)
] ]
set_ext = subnet_ext.SetSubnetExtension(self.app) set_ext = subnet_ext.SetSubnetExtension(self.app)
parsed_args = self.check_parser_ext( parsed_args = self.check_parser_ext(
@@ -163,6 +169,7 @@ class TestSubnetSet(test_subnet.TestSubnet, test_cli20.CLITestV20Base):
'apic:snat_subnet_only': False, 'apic:snat_subnet_only': False,
'apic:advertised_externally': True, 'apic:advertised_externally': True,
'apic:shared_between_vrfs': True, 'apic:shared_between_vrfs': True,
'apic:router_gw_ip_pool': True
} }
self.network.update_subnet.assert_called_with(self._subnet, **attrs) self.network.update_subnet.assert_called_with(self._subnet, **attrs)
self.assertIsNone(result) self.assertIsNone(result)