Skip to content

Commit 53ba053

Browse files
committed
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
1 parent 2a64a64 commit 53ba053

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

doc/source/command-objects/router.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Create new router
6464
[--project <project> [--project-domain <project-domain>]]
6565
[--enable | --disable]
6666
[--distributed]
67-
[--ha]
67+
[--ha | --no-ha]
6868
[--description <description>]
6969
[--availability-zone-hint <availability-zone>]
7070
<name>
@@ -94,6 +94,10 @@ Create new router
9494
9595
Create a highly available router
9696
97+
.. option:: --no-ha
98+
99+
Create a legacy router
100+
97101
.. option:: --description <description>
98102
99103
Set router description

openstackclient/network/v2/router.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,17 @@ def get_parser(self, prog_name):
183183
default=False,
184184
help=_("Create a distributed router")
185185
)
186-
parser.add_argument(
186+
ha_group = parser.add_mutually_exclusive_group()
187+
ha_group.add_argument(
187188
'--ha',
188189
action='store_true',
189190
help=_("Create a highly available router")
190191
)
192+
ha_group.add_argument(
193+
'--no-ha',
194+
action='store_true',
195+
help=_("Create a legacy router")
196+
)
191197
parser.add_argument(
192198
'--description',
193199
metavar='<description>',
@@ -216,7 +222,9 @@ def take_action(self, parsed_args):
216222

217223
attrs = _get_attrs(self.app.client_manager, parsed_args)
218224
if parsed_args.ha:
219-
attrs['ha'] = parsed_args.ha
225+
attrs['ha'] = True
226+
if parsed_args.no_ha:
227+
attrs['ha'] = False
220228
obj = client.create_router(**attrs)
221229

222230
display_columns, columns = _get_columns(obj)

openstackclient/tests/unit/network/v2/test_router.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,17 @@ def test_create_default_options(self):
181181
self.assertEqual(self.columns, columns)
182182
self.assertEqual(self.data, data)
183183

184-
def test_create_with_ha_option(self):
184+
def _test_create_with_ha_options(self, option, ha):
185185
arglist = [
186-
'--ha',
186+
option,
187187
self.new_router.name,
188188
]
189189
verifylist = [
190190
('name', self.new_router.name),
191191
('enable', True),
192192
('distributed', False),
193-
('ha', True),
193+
('ha', ha),
194+
('no_ha', not ha),
194195
]
195196
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
196197

@@ -199,11 +200,17 @@ def test_create_with_ha_option(self):
199200
self.network.create_router.assert_called_once_with(**{
200201
'admin_state_up': True,
201202
'name': self.new_router.name,
202-
'ha': True,
203+
'ha': ha,
203204
})
204205
self.assertEqual(self.columns, columns)
205206
self.assertEqual(self.data, data)
206207

208+
def test_create_with_ha_option(self):
209+
self._test_create_with_ha_options('--ha', True)
210+
211+
def test_create_with_no_ha_option(self):
212+
self._test_create_with_ha_options('--no-ha', False)
213+
207214
def test_create_with_AZ_hints(self):
208215
arglist = [
209216
self.new_router.name,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
Add ``--no-ha`` option to the ``router create`` command
5+
[Bug `1675514 <https://bugs.launchpad.net/python-openstackclient/+bug/1675514>`_]

0 commit comments

Comments
 (0)