Add new share and default parms to subnet pool cmds
Add the "share" and "default" parms to subnet pool create command. Add the "default" and "no-default" parms to subnet pool set command. Note that "share" can not be modified once subnet pool has been created, so do not add this to the set command. Change-Id: I1eecad69527a1cde7fb234669f4aff2be2db491e Partial-Bug: #1544591 Partial-Bug: #1544586
This commit is contained in:
parent
3f2ed7d19f
commit
48ebc49f20
@ -19,6 +19,8 @@ Create subnet pool
|
||||
[--max-prefix-length <max-prefix-length>]
|
||||
[--project <project> [--project-domain <project-domain>]]
|
||||
[--address-scope <address-scope>]
|
||||
[--default | --no-default]
|
||||
[--share | --no-share]
|
||||
<name>
|
||||
|
||||
.. option:: --pool-prefix <pool-prefix>
|
||||
@ -52,6 +54,22 @@ Create subnet pool
|
||||
Set address scope associated with the subnet pool (name or ID),
|
||||
prefixes must be unique across address scopes
|
||||
|
||||
.. option:: --default
|
||||
|
||||
Set this as a default subnet pool
|
||||
|
||||
.. option:: --no-default
|
||||
|
||||
Set this as a non-default subnet pool
|
||||
|
||||
.. option:: --share
|
||||
|
||||
Set this subnet pool as shared
|
||||
|
||||
.. option:: --no-share
|
||||
|
||||
Set this subnet pool as not shared
|
||||
|
||||
.. _subnet_pool_create-name:
|
||||
.. describe:: <name>
|
||||
|
||||
@ -103,6 +121,7 @@ Set subnet pool properties
|
||||
[--min-prefix-length <min-prefix-length>]
|
||||
[--max-prefix-length <max-prefix-length>]
|
||||
[--address-scope <address-scope> | --no-address-scope]
|
||||
[--default | --no-default]
|
||||
<subnet-pool>
|
||||
|
||||
.. option:: --name <name>
|
||||
@ -135,6 +154,14 @@ Set subnet pool properties
|
||||
|
||||
Remove address scope associated with the subnet pool
|
||||
|
||||
.. option:: --default
|
||||
|
||||
Set this as a default subnet pool
|
||||
|
||||
.. option:: --no-default
|
||||
|
||||
Set this as a non-default subnet pool
|
||||
|
||||
.. _subnet_pool_set-subnet-pool:
|
||||
.. describe:: <subnet-pool>
|
||||
|
||||
|
@ -55,6 +55,16 @@ def _get_attrs(client_manager, parsed_args):
|
||||
if 'no_address_scope' in parsed_args and parsed_args.no_address_scope:
|
||||
attrs['address_scope_id'] = None
|
||||
|
||||
if parsed_args.default:
|
||||
attrs['is_default'] = True
|
||||
if parsed_args.no_default:
|
||||
attrs['is_default'] = False
|
||||
|
||||
if 'share' in parsed_args and parsed_args.share:
|
||||
attrs['shared'] = True
|
||||
if 'no_share' in parsed_args and parsed_args.no_share:
|
||||
attrs['shared'] = False
|
||||
|
||||
# "subnet pool set" command doesn't support setting project.
|
||||
if 'project' in parsed_args and parsed_args.project is not None:
|
||||
identity_client = client_manager.identity
|
||||
@ -97,6 +107,20 @@ def _add_prefix_options(parser):
|
||||
)
|
||||
|
||||
|
||||
def _add_default_options(parser):
|
||||
default_group = parser.add_mutually_exclusive_group()
|
||||
default_group.add_argument(
|
||||
'--default',
|
||||
action='store_true',
|
||||
help=_("Set this as a default subnet pool"),
|
||||
)
|
||||
default_group.add_argument(
|
||||
'--no-default',
|
||||
action='store_true',
|
||||
help=_("Set this as a non-default subnet pool"),
|
||||
)
|
||||
|
||||
|
||||
class CreateSubnetPool(command.ShowOne):
|
||||
"""Create subnet pool"""
|
||||
|
||||
@ -121,6 +145,18 @@ class CreateSubnetPool(command.ShowOne):
|
||||
"(name or ID), prefixes must be unique across address "
|
||||
"scopes")
|
||||
)
|
||||
_add_default_options(parser)
|
||||
shared_group = parser.add_mutually_exclusive_group()
|
||||
shared_group.add_argument(
|
||||
'--share',
|
||||
action='store_true',
|
||||
help=_("Set this subnet pool as shared"),
|
||||
)
|
||||
shared_group.add_argument(
|
||||
'--no-share',
|
||||
action='store_true',
|
||||
help=_("Set this subnet pool as not shared"),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -176,6 +212,8 @@ class ListSubnetPool(command.Lister):
|
||||
'Prefixes',
|
||||
'Default Prefix Length',
|
||||
'Address Scope',
|
||||
'Default Subnet Pool',
|
||||
'Shared',
|
||||
)
|
||||
columns = (
|
||||
'id',
|
||||
@ -183,6 +221,8 @@ class ListSubnetPool(command.Lister):
|
||||
'prefixes',
|
||||
'default_prefixlen',
|
||||
'address_scope_id',
|
||||
'is_default',
|
||||
'shared',
|
||||
)
|
||||
else:
|
||||
headers = (
|
||||
@ -232,6 +272,8 @@ class SetSubnetPool(command.Command):
|
||||
action='store_true',
|
||||
help=_("Remove address scope associated with the subnet pool")
|
||||
)
|
||||
_add_default_options(parser)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -221,6 +221,32 @@ class TestCreateSubnetPool(TestSubnetPool):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
|
||||
def test_create_default_and_shared_options(self):
|
||||
arglist = [
|
||||
'--pool-prefix', '10.0.10.0/24',
|
||||
'--default',
|
||||
'--share',
|
||||
self._subnet_pool.name,
|
||||
]
|
||||
verifylist = [
|
||||
('prefixes', ['10.0.10.0/24']),
|
||||
('default', True),
|
||||
('share', True),
|
||||
('name', self._subnet_pool.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = (self.cmd.take_action(parsed_args))
|
||||
|
||||
self.network.create_subnet_pool.assert_called_once_with(**{
|
||||
'is_default': True,
|
||||
'name': self._subnet_pool.name,
|
||||
'prefixes': ['10.0.10.0/24'],
|
||||
'shared': True,
|
||||
})
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
|
||||
|
||||
class TestDeleteSubnetPool(TestSubnetPool):
|
||||
|
||||
@ -267,6 +293,8 @@ class TestListSubnetPool(TestSubnetPool):
|
||||
columns_long = columns + (
|
||||
'Default Prefix Length',
|
||||
'Address Scope',
|
||||
'Default Subnet Pool',
|
||||
'Shared',
|
||||
)
|
||||
|
||||
data = []
|
||||
@ -285,6 +313,8 @@ class TestListSubnetPool(TestSubnetPool):
|
||||
utils.format_list(pool.prefixes),
|
||||
pool.default_prefixlen,
|
||||
pool.address_scope_id,
|
||||
pool.is_default,
|
||||
pool.shared,
|
||||
))
|
||||
|
||||
def setUp(self):
|
||||
@ -474,6 +504,62 @@ class TestSetSubnetPool(TestSubnetPool):
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
def test_set_default(self):
|
||||
arglist = [
|
||||
'--default',
|
||||
self._subnet_pool.name,
|
||||
]
|
||||
verifylist = [
|
||||
('default', True),
|
||||
('subnet_pool', self._subnet_pool.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
attrs = {
|
||||
'is_default': True
|
||||
}
|
||||
self.network.update_subnet_pool.assert_called_once_with(
|
||||
self._subnet_pool, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_set_no_default(self):
|
||||
arglist = [
|
||||
'--no-default',
|
||||
self._subnet_pool.name,
|
||||
]
|
||||
verifylist = [
|
||||
('no_default', True),
|
||||
('subnet_pool', self._subnet_pool.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
attrs = {
|
||||
'is_default': False,
|
||||
}
|
||||
self.network.update_subnet_pool.assert_called_once_with(
|
||||
self._subnet_pool, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_set_no_default_conflict(self):
|
||||
arglist = [
|
||||
'--default',
|
||||
'--no-default',
|
||||
self._subnet_pool.name,
|
||||
]
|
||||
verifylist = [
|
||||
('default', True),
|
||||
('no_default', True),
|
||||
('subnet_pool', self._subnet_pool.name),
|
||||
]
|
||||
|
||||
# Exclusive arguments will conflict here.
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
|
||||
class TestShowSubnetPool(TestSubnetPool):
|
||||
|
||||
|
6
releasenotes/notes/bug-1544586-0fe19a567d3e31fc.yaml
Normal file
6
releasenotes/notes/bug-1544586-0fe19a567d3e31fc.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- Add ``--share`` and ``--default`` options to ``subnet pool create``
|
||||
and ``--default`` option to ``subnet pool set``
|
||||
[Bug `1544586 <https://bugs.launchpad.net/python-openstackclient/+bug/1544586>`_]
|
||||
[Bug `1544591 <https://bugs.launchpad.net/python-openstackclient/+bug/1544591>`_]
|
Loading…
Reference in New Issue
Block a user