router: Use plural form for storage of ``--fixed_ip`` argument

The variable already takes multiple values, let's make it obvious
just by reading the code.

Related-Bug: #2002687
Change-Id: I294ee710d989d7a3a54331fca424e84708a2faab
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
This commit is contained in:
Frode Nordahl 2024-03-05 15:56:49 +01:00
parent f696aee81d
commit 58ad3cefa7
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
2 changed files with 11 additions and 9 deletions

View File

@ -99,9 +99,9 @@ def _get_external_gateway_attrs(client_manager, parsed_args):
gateway_info['enable_snat'] = False
if parsed_args.enable_snat:
gateway_info['enable_snat'] = True
if parsed_args.fixed_ip:
if parsed_args.fixed_ips:
ips = []
for ip_spec in parsed_args.fixed_ip:
for ip_spec in parsed_args.fixed_ips:
if ip_spec.get('subnet', False):
subnet_name_id = ip_spec.pop('subnet')
if subnet_name_id:
@ -379,6 +379,7 @@ class CreateRouter(command.ShowOne, common.NeutronCommandWithExtraArgs):
metavar='subnet=<subnet>,ip-address=<ip-address>',
action=parseractions.MultiKeyValueAction,
optional_keys=['subnet', 'ip-address'],
dest='fixed_ips',
help=_(
"Desired IP and/or subnet (name or ID) "
"on external gateway: "
@ -449,7 +450,7 @@ class CreateRouter(command.ShowOne, common.NeutronCommandWithExtraArgs):
if (
parsed_args.disable_snat
or parsed_args.enable_snat
or parsed_args.fixed_ip
or parsed_args.fixed_ips
) and not parsed_args.external_gateway:
msg = _(
"You must specify '--external-gateway' in order "
@ -797,6 +798,7 @@ class SetRouter(common.NeutronCommandWithExtraArgs):
metavar='subnet=<subnet>,ip-address=<ip-address>',
action=parseractions.MultiKeyValueAction,
optional_keys=['subnet', 'ip-address'],
dest='fixed_ips',
help=_(
"Desired IP and/or subnet (name or ID) "
"on external gateway: "
@ -870,7 +872,7 @@ class SetRouter(common.NeutronCommandWithExtraArgs):
if (
parsed_args.disable_snat
or parsed_args.enable_snat
or parsed_args.fixed_ip
or parsed_args.fixed_ips
) and not parsed_args.external_gateway:
msg = _(
"You must specify '--external-gateway' in order "

View File

@ -230,7 +230,7 @@ class TestCreateRouter(TestRouter):
('ha', False),
('external_gateway', _network.name),
('enable_snat', True),
('fixed_ip', [{'ip-address': '2001:db8::1'}]),
('fixed_ips', [{'ip-address': '2001:db8::1'}]),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -1297,7 +1297,7 @@ class TestSetRouter(TestRouter):
self._router.id,
]
verifylist = [
('fixed_ip', [{'subnet': "'abc'"}]),
('fixed_ips', [{'subnet': "'abc'"}]),
('router', self._router.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -1336,7 +1336,7 @@ class TestSetRouter(TestRouter):
verifylist = [
('router', self._router.id),
('external_gateway', self._network.id),
('fixed_ip', [{'subnet': "'abc'"}]),
('fixed_ips', [{'subnet': "'abc'"}]),
('enable_snat', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -1370,7 +1370,7 @@ class TestSetRouter(TestRouter):
verifylist = [
('router', self._router.id),
('external_gateway', self._network.id),
('fixed_ip', [{'ip-address': "10.0.1.1"}]),
('fixed_ips', [{'ip-address': "10.0.1.1"}]),
('enable_snat', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -1404,7 +1404,7 @@ class TestSetRouter(TestRouter):
verifylist = [
('router', self._router.id),
('external_gateway', self._network.id),
('fixed_ip', [{'subnet': "'abc'", 'ip-address': "10.0.1.1"}]),
('fixed_ips', [{'subnet': "'abc'", 'ip-address': "10.0.1.1"}]),
('enable_snat', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)