Add --ha option to os router create command

This patch added --ha option which the 'os router create'
command was missed.

Change-Id: I77635fb17af32beb0d8ed9aa080ef79285719fdc
Closes-Bug: #1610161
This commit is contained in:
Nam Nguyen Hoai 2016-08-09 14:31:34 +07:00
parent 15069ef50e
commit e2fc436d53
4 changed files with 43 additions and 3 deletions

View File

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

View File

@ -94,7 +94,6 @@ def _get_attrs(client_manager, parsed_args):
).id
attrs['tenant_id'] = project_id
# TODO(tangchen): Support getting 'ha' property.
# TODO(tangchen): Support getting 'external_gateway_info' property.
return attrs
@ -180,10 +179,15 @@ class CreateRouter(command.ShowOne):
default=False,
help=_("Create a distributed router")
)
parser.add_argument(
'--ha',
action='store_true',
help=_("Create a highly available router")
)
parser.add_argument(
'--description',
metavar='<description>',
help=_('Set router description')
help=_("Set router description")
)
parser.add_argument(
'--project',
@ -207,6 +211,8 @@ class CreateRouter(command.ShowOne):
client = self.app.client_manager.network
attrs = _get_attrs(self.app.client_manager, parsed_args)
if parsed_args.ha:
attrs['ha'] = parsed_args.ha
obj = client.create_router(**attrs)
columns = _get_columns(obj)

View File

@ -166,6 +166,7 @@ class TestCreateRouter(TestRouter):
('name', self.new_router.name),
('enable', True),
('distributed', False),
('ha', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -178,6 +179,29 @@ class TestCreateRouter(TestRouter):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_create_with_ha_option(self):
arglist = [
'--ha',
self.new_router.name,
]
verifylist = [
('name', self.new_router.name),
('enable', True),
('distributed', False),
('ha', True),
]
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,
'ha': True,
})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_create_with_AZ_hints(self):
arglist = [
self.new_router.name,
@ -189,6 +213,7 @@ class TestCreateRouter(TestRouter):
('availability_zone_hints', ['fake-az', 'fake-az2']),
('enable', True),
('distributed', False),
('ha', False)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)

View File

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