diff options
| author | Cedric Brandily <zzelle@gmail.com> | 2017-03-23 15:24:38 +0100 |
|---|---|---|
| committer | Cedric Brandily <zzelle@gmail.com> | 2017-03-31 13:01:00 +0000 |
| commit | 53ba05325ad5e580e62addb7f4b405b96ad01d80 (patch) | |
| tree | 34296e42004b8ac34d11fdd5177fe1ceb0d7835c /openstackclient | |
| parent | 2a64a6404681e0cea5896a02573a8be03dd1a7d3 (diff) | |
| download | python-openstackclient-53ba05325ad5e580e62addb7f4b405b96ad01d80.tar.gz | |
Enable to create legacy router
Some deployments create by default HA routers, this change enables to
force the creation of a legacy router using:
openstack router create --no-ha ...
Closes-Bug: #1675514
Change-Id: I78f7dc3640a2acfdaf085e0e387b30373e8415f1
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/network/v2/router.py | 12 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_router.py | 15 |
2 files changed, 21 insertions, 6 deletions
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index f46c8696..f322d5d1 100644 --- a/openstackclient/network/v2/router.py +++ b/openstackclient/network/v2/router.py @@ -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) diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py index b837afd1..a4f91997 100644 --- a/openstackclient/tests/unit/network/v2/test_router.py +++ b/openstackclient/tests/unit/network/v2/test_router.py @@ -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, |
