Merge "Enable to create legacy router"

This commit is contained in:
Jenkins 2017-04-05 17:00:49 +00:00 committed by Gerrit Code Review
commit 27f96a3a7a
4 changed files with 31 additions and 7 deletions

View File

@ -64,7 +64,7 @@ Create new router
[--project <project> [--project-domain <project-domain>]]
[--enable | --disable]
[--distributed]
[--ha]
[--ha | --no-ha]
[--description <description>]
[--availability-zone-hint <availability-zone>]
<name>
@ -94,6 +94,10 @@ Create new router
Create a highly available router
.. option:: --no-ha
Create a legacy router
.. option:: --description <description>
Set router description

View File

@ -183,11 +183,17 @@ class CreateRouter(command.ShowOne):
default=False,
help=_("Create a distributed router")
)
parser.add_argument(
ha_group = parser.add_mutually_exclusive_group()
ha_group.add_argument(
'--ha',
action='store_true',
help=_("Create a highly available router")
)
ha_group.add_argument(
'--no-ha',
action='store_true',
help=_("Create a legacy router")
)
parser.add_argument(
'--description',
metavar='<description>',
@ -216,7 +222,9 @@ class CreateRouter(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args)
if parsed_args.ha:
attrs['ha'] = parsed_args.ha
attrs['ha'] = True
if parsed_args.no_ha:
attrs['ha'] = False
obj = client.create_router(**attrs)
display_columns, columns = _get_columns(obj)

View File

@ -181,16 +181,17 @@ class TestCreateRouter(TestRouter):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_create_with_ha_option(self):
def _test_create_with_ha_options(self, option, ha):
arglist = [
'--ha',
option,
self.new_router.name,
]
verifylist = [
('name', self.new_router.name),
('enable', True),
('distributed', False),
('ha', True),
('ha', ha),
('no_ha', not ha),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -199,11 +200,17 @@ class TestCreateRouter(TestRouter):
self.network.create_router.assert_called_once_with(**{
'admin_state_up': True,
'name': self.new_router.name,
'ha': True,
'ha': ha,
})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_create_with_ha_option(self):
self._test_create_with_ha_options('--ha', True)
def test_create_with_no_ha_option(self):
self._test_create_with_ha_options('--no-ha', False)
def test_create_with_AZ_hints(self):
arglist = [
self.new_router.name,

View File

@ -0,0 +1,5 @@
---
features:
- |
Add ``--no-ha`` option to the ``router create`` command
[Bug `1675514 <https://bugs.launchpad.net/python-openstackclient/+bug/1675514>`_]