diff options
| author | Reedip <reedip.banerjee@nectechnologies.in> | 2016-10-08 13:39:36 +0530 |
|---|---|---|
| committer | Reedip <reedip.banerjee@nectechnologies.in> | 2016-10-16 05:05:23 +0000 |
| commit | bae09c3c3fac210f4839a8a51dfb51e2dad69aa7 (patch) | |
| tree | 9fc67c4d44bdc443472d4da0aa8814c6bf54f69a /openstackclient | |
| parent | a58bacc619a92e6dcc3977ae9aff979e584dae2f (diff) | |
| download | python-openstackclient-bae09c3c3fac210f4839a8a51dfb51e2dad69aa7.tar.gz | |
Add support make a router HA
Currently router set CLI does not provide the
support make a router highly available. The following
patch enables the same.
Checking for setting a router as HA is left on the
neutron server itself.
Partially-Implements: blueprint network-commands-options
Change-Id: I0d0548cf037a14e5ccb2f732918ee9d1f63f43b4
Closes-Bug:#1631492
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/network/v2/router.py | 22 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_router.py | 6 |
2 files changed, 23 insertions, 5 deletions
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index 64bb8819..193bf6e9 100644 --- a/openstackclient/network/v2/router.py +++ b/openstackclient/network/v2/router.py @@ -433,11 +433,19 @@ class SetRouter(command.Command): action='store_true', help=argparse.SUPPRESS, ) - - # TODO(tangchen): Support setting 'ha' property in 'router set' - # command. It appears that changing the ha state is supported by - # neutron under certain conditions. - + routes_ha = parser.add_mutually_exclusive_group() + routes_ha.add_argument( + '--ha', + action='store_true', + help=_("Set the router as highly available " + "(disabled router only)") + ) + routes_ha.add_argument( + '--no-ha', + action='store_true', + help=_("Clear high availablability attribute of the router " + "(disabled router only)") + ) # TODO(tangchen): Support setting 'external_gateway_info' property in # 'router set' command. @@ -451,6 +459,10 @@ class SetRouter(command.Command): attrs = _get_attrs(self.app.client_manager, parsed_args) # Get the route attributes. + if parsed_args.ha: + attrs['ha'] = True + elif parsed_args.no_ha: + attrs['ha'] = False if parsed_args.no_route: attrs['routes'] = [] elif parsed_args.clear_routes: diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py index d85561bc..bc448d13 100644 --- a/openstackclient/tests/unit/network/v2/test_router.py +++ b/openstackclient/tests/unit/network/v2/test_router.py @@ -529,6 +529,7 @@ class TestSetRouter(TestRouter): '--enable', '--distributed', '--name', 'noob', + '--no-ha', '--description', 'router', ] verifylist = [ @@ -537,6 +538,7 @@ class TestSetRouter(TestRouter): ('distributed', True), ('name', 'noob'), ('description', 'router'), + ('no_ha', True), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -546,6 +548,7 @@ class TestSetRouter(TestRouter): 'admin_state_up': True, 'distributed': True, 'name': 'noob', + 'ha': False, 'description': 'router', } self.network.update_router.assert_called_once_with( @@ -557,11 +560,13 @@ class TestSetRouter(TestRouter): self._router.name, '--disable', '--centralized', + '--ha', ] verifylist = [ ('router', self._router.name), ('disable', True), ('centralized', True), + ('ha', True), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -570,6 +575,7 @@ class TestSetRouter(TestRouter): attrs = { 'admin_state_up': False, 'distributed': False, + 'ha': True, } self.network.update_router.assert_called_once_with( self._router, **attrs) |
