summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/router.py13
-rw-r--r--openstackclient/tests/unit/network/v2/test_router.py29
2 files changed, 37 insertions, 5 deletions
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py
index f322d5d1..0da91baa 100644
--- a/openstackclient/network/v2/router.py
+++ b/openstackclient/network/v2/router.py
@@ -78,8 +78,7 @@ def _get_attrs(client_manager, parsed_args):
attrs['admin_state_up'] = True
if parsed_args.disable:
attrs['admin_state_up'] = False
- # centralized is available only for SetRouter and not for CreateRouter
- if 'centralized' in parsed_args and parsed_args.centralized:
+ if parsed_args.centralized:
attrs['distributed'] = False
if parsed_args.distributed:
attrs['distributed'] = True
@@ -176,13 +175,17 @@ class CreateRouter(command.ShowOne):
action='store_true',
help=_("Disable router")
)
- parser.add_argument(
+ distribute_group = parser.add_mutually_exclusive_group()
+ distribute_group.add_argument(
'--distributed',
- dest='distributed',
action='store_true',
- default=False,
help=_("Create a distributed router")
)
+ distribute_group.add_argument(
+ '--centralized',
+ action='store_true',
+ help=_("Create a centralized router")
+ )
ha_group = parser.add_mutually_exclusive_group()
ha_group.add_argument(
'--ha',
diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py
index a4f91997..02e0be94 100644
--- a/openstackclient/tests/unit/network/v2/test_router.py
+++ b/openstackclient/tests/unit/network/v2/test_router.py
@@ -211,6 +211,35 @@ class TestCreateRouter(TestRouter):
def test_create_with_no_ha_option(self):
self._test_create_with_ha_options('--no-ha', False)
+ def _test_create_with_distributed_options(self, option, distributed):
+ arglist = [
+ option,
+ self.new_router.name,
+ ]
+ verifylist = [
+ ('name', self.new_router.name),
+ ('enable', True),
+ ('distributed', distributed),
+ ('centralized', not distributed),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = (self.cmd.take_action(parsed_args))
+
+ self.network.create_router.assert_called_once_with(**{
+ 'admin_state_up': True,
+ 'name': self.new_router.name,
+ 'distributed': distributed,
+ })
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data, data)
+
+ def test_create_with_distributed_option(self):
+ self._test_create_with_distributed_options('--distributed', True)
+
+ def test_create_with_centralized_option(self):
+ self._test_create_with_distributed_options('--centralized', False)
+
def test_create_with_AZ_hints(self):
arglist = [
self.new_router.name,