Add the flavor-id option to router create

The --flavor-id option is added to the router create command. The
flavor_id attribute has been supported by the Neutron API for router
POST operations since a long time ago [0].

Partial-Bug: #2020823

[0] https://review.opendev.org/c/openstack/neutron-lib/+/494289

Change-Id: If88499533a92c09e67b0827d1d64156682a3bb8e
This commit is contained in:
Miguel Lavalle 2023-08-15 19:47:32 -05:00
parent 7dc1276f40
commit f8f174c458
3 changed files with 38 additions and 0 deletions
openstackclient
network/v2
tests/unit/network/v2
releasenotes/notes

@ -139,6 +139,9 @@ def _get_attrs(client_manager, parsed_args):
ips.append(ip_spec)
gateway_info['external_fixed_ips'] = ips
attrs['external_gateway_info'] = gateway_info
# "router set" command doesn't support setting flavor_id.
if 'flavor_id' in parsed_args and parsed_args.flavor_id is not None:
attrs['flavor_id'] = parsed_args.flavor_id
return attrs
@ -399,6 +402,11 @@ class CreateRouter(command.ShowOne, common.NeutronCommandWithExtraArgs):
action='store_false',
help=_("Disable IPv6 NDP proxy on external gateway"),
)
parser.add_argument(
'--flavor-id',
metavar='<flavor-id>',
help=_("Associate the router to a flavor by ID"),
)
return parser

@ -379,6 +379,32 @@ class TestCreateRouter(TestRouter):
def test_create_with_no_tag(self):
self._test_create_with_tag(add_tags=False)
def test_create_with_flavor_id(self):
_flavor = network_fakes.create_one_network_flavor()
arglist = [
self.new_router.name,
'--flavor-id',
_flavor.id,
]
verifylist = [
('name', self.new_router.name),
('enable', True),
('distributed', False),
('ha', False),
('flavor_id', _flavor.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.network.create_router.assert_called_once_with(
**{
'admin_state_up': True,
'name': self.new_router.name,
'flavor_id': _flavor.id,
}
)
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.data, data)
class TestDeleteRouter(TestRouter):
# The routers to delete.

@ -0,0 +1,4 @@
---
features:
- |
Add the ``--flavor-id`` option to the ``router create`` command.