diff --git a/doc/source/command-objects/router.rst b/doc/source/command-objects/router.rst index 9e8007af9..29131861d 100644 --- a/doc/source/command-objects/router.rst +++ b/doc/source/command-objects/router.rst @@ -64,7 +64,7 @@ Create new router [--project [--project-domain ]] [--enable | --disable] [--distributed] - [--ha] + [--ha | --no-ha] [--description ] [--availability-zone-hint ] @@ -94,6 +94,10 @@ Create new router Create a highly available router +.. option:: --no-ha + + Create a legacy router + .. option:: --description Set router description diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index f46c8696a..f322d5d1f 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='', @@ -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 b837afd1e..a4f91997c 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, diff --git a/releasenotes/notes/allow-to-create-legacy-router-cb4dcb44dde74684.yaml b/releasenotes/notes/allow-to-create-legacy-router-cb4dcb44dde74684.yaml new file mode 100644 index 000000000..77a8b5038 --- /dev/null +++ b/releasenotes/notes/allow-to-create-legacy-router-cb4dcb44dde74684.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add ``--no-ha`` option to the ``router create`` command + [Bug `1675514 `_]