summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNam Nguyen Hoai <namnh@vn.fujitsu.com>2016-08-09 14:31:34 +0700
committerNam Nguyen Hoai <namnh@vn.fujitsu.com>2016-10-01 14:55:23 +0700
commite2fc436d53f53d0993fc0b9dd29f402e6c7f8bc1 (patch)
tree701b0d3b158e00402f819e87b711986e20237378
parent15069ef50e609dca769d6a50f6af92b2c8211238 (diff)
downloadpython-openstackclient-e2fc436d53f53d0993fc0b9dd29f402e6c7f8bc1.tar.gz
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
-rw-r--r--doc/source/command-objects/router.rst6
-rw-r--r--openstackclient/network/v2/router.py10
-rw-r--r--openstackclient/tests/unit/network/v2/test_router.py25
-rw-r--r--releasenotes/notes/bug-1610161-7c34c7b735701bd4.yaml5
4 files changed, 43 insertions, 3 deletions
diff --git a/doc/source/command-objects/router.rst b/doc/source/command-objects/router.rst
index 13a75158..335de179 100644
--- a/doc/source/command-objects/router.rst
+++ b/doc/source/command-objects/router.rst
@@ -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
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py
index cb40d774..48a3a92c 100644
--- a/openstackclient/network/v2/router.py
+++ b/openstackclient/network/v2/router.py
@@ -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
@@ -181,9 +180,14 @@ class CreateRouter(command.ShowOne):
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)
diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py
index d12289e1..6a445862 100644
--- a/openstackclient/tests/unit/network/v2/test_router.py
+++ b/openstackclient/tests/unit/network/v2/test_router.py
@@ -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)
diff --git a/releasenotes/notes/bug-1610161-7c34c7b735701bd4.yaml b/releasenotes/notes/bug-1610161-7c34c7b735701bd4.yaml
new file mode 100644
index 00000000..9cdbba49
--- /dev/null
+++ b/releasenotes/notes/bug-1610161-7c34c7b735701bd4.yaml
@@ -0,0 +1,5 @@
+---
+features:
+ - |
+ Add ``--ha`` option to ``router create`` command.
+ [Bug `1610161 <https://bugs.launchpad.net/bugs/1610161>`_] \ No newline at end of file