Router flavor_id can be a name
Change-Id: I72fc21a1adb4790a2a51e9b37744ee1ee3d01f32 Partial-Bug: #2020823
This commit is contained in:
parent
25f2e22429
commit
2e7ba5e3dd
@ -13,6 +13,7 @@
|
||||
|
||||
"""Router action implementations"""
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import copy
|
||||
import json
|
||||
@ -198,6 +199,8 @@ def _get_external_gateway_attrs(client_manager, parsed_args):
|
||||
|
||||
def _get_attrs(client_manager, parsed_args):
|
||||
attrs = {}
|
||||
n_client = client_manager.network
|
||||
|
||||
if parsed_args.name is not None:
|
||||
attrs['name'] = parsed_args.name
|
||||
if parsed_args.enable:
|
||||
@ -229,7 +232,8 @@ def _get_attrs(client_manager, parsed_args):
|
||||
|
||||
# "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
|
||||
flavor = n_client.find_flavor(parsed_args.flavor_id)
|
||||
attrs['flavor_id'] = flavor.id
|
||||
|
||||
for attr in ('enable_default_route_bfd', 'enable_default_route_ecmp'):
|
||||
value = getattr(parsed_args, attr, None)
|
||||
@ -560,10 +564,15 @@ class CreateRouter(command.ShowOne, common.NeutronCommandWithExtraArgs):
|
||||
action='store_false',
|
||||
help=_("Disable IPv6 NDP proxy on external gateway"),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--flavor',
|
||||
metavar='<flavor-id>',
|
||||
help=_("Associate the router to a flavor (by name or ID"),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--flavor-id',
|
||||
metavar='<flavor-id>',
|
||||
help=_("Associate the router to a flavor by ID"),
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
_parser_add_bfd_ecmp_arguments(parser)
|
||||
|
||||
|
@ -384,13 +384,15 @@ 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):
|
||||
def test_create_with_flavor_id_or_name(self):
|
||||
_flavor = network_fakes.create_one_network_flavor()
|
||||
self.network_client.find_flavor = mock.Mock(return_value=_flavor)
|
||||
arglist = [
|
||||
self.new_router.name,
|
||||
'--flavor-id',
|
||||
_flavor.id,
|
||||
]
|
||||
arglist_with_name = [self.new_router.name, '--flavor-id', _flavor.name]
|
||||
verifylist = [
|
||||
('name', self.new_router.name),
|
||||
('enable', True),
|
||||
@ -410,6 +412,28 @@ class TestCreateRouter(TestRouter):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
self.network_client.create_router.reset_mock()
|
||||
verifylist_w_name = [
|
||||
('name', self.new_router.name),
|
||||
('enable', True),
|
||||
('distributed', False),
|
||||
('ha', False),
|
||||
('flavor_id', _flavor.name),
|
||||
]
|
||||
parsed_args_w_name = self.check_parser(
|
||||
self.cmd, arglist_with_name, verifylist_w_name
|
||||
)
|
||||
columns, data = self.cmd.take_action(parsed_args_w_name)
|
||||
self.network_client.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)
|
||||
|
||||
def test_create_with_enable_default_route_bfd(self):
|
||||
self.network_client.find_extension = mock.Mock(
|
||||
return_value=network_fakes.create_one_extension(
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
The ``router create --flavor-id`` parameter has been deprecated
|
||||
in favour of the ``--flavor`` parameter, which accepts both
|
||||
flavor names and flavor IDs.
|
Loading…
Reference in New Issue
Block a user