diff --git a/doc/source/command-objects/router.rst b/doc/source/command-objects/router.rst index 9e8007af92..29131861d5 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 f46c8696ab..f322d5d1f2 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 b837afd1e4..a4f91997c4 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 0000000000..77a8b50385 --- /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 `_]