Add default-quota to subnet pool commands
Add --default-quota option to subnet pool create and set commands.
Setting default-quota back to None may break the current Neutron
behavior, therefore support for Unset command is not provided in
this patch.
Neutron API:
a0e0e8b668/neutron/api/v2/attributes.py (L239)
Closes-Bug: #1667294
Change-Id: Ia4e7c23a49e91a090133c729353cdb8e62bc5674
This commit is contained in:
parent
e54fcd0a5c
commit
eb793dc8c6
@ -24,6 +24,7 @@ Create subnet pool
|
|||||||
[--address-scope <address-scope>]
|
[--address-scope <address-scope>]
|
||||||
[--default | --no-default]
|
[--default | --no-default]
|
||||||
[--share | --no-share]
|
[--share | --no-share]
|
||||||
|
[--default-quota <num-ip-addresses>]
|
||||||
--pool-prefix <pool-prefix> [...]
|
--pool-prefix <pool-prefix> [...]
|
||||||
<name>
|
<name>
|
||||||
|
|
||||||
@ -73,7 +74,12 @@ Create subnet pool
|
|||||||
|
|
||||||
Set this subnet pool as not shared
|
Set this subnet pool as not shared
|
||||||
|
|
||||||
.. describe:: --pool-prefix <pool-prefix>
|
.. option:: --default-quota <num-ip-addresses>
|
||||||
|
|
||||||
|
Set default quota for subnet pool as the number of
|
||||||
|
IP addresses allowed in a subnet
|
||||||
|
|
||||||
|
.. option:: --pool-prefix <pool-prefix>
|
||||||
|
|
||||||
Set subnet pool prefixes (in CIDR notation)
|
Set subnet pool prefixes (in CIDR notation)
|
||||||
(repeat option to set multiple prefixes)
|
(repeat option to set multiple prefixes)
|
||||||
@ -169,6 +175,7 @@ Set subnet pool properties
|
|||||||
[--address-scope <address-scope> | --no-address-scope]
|
[--address-scope <address-scope> | --no-address-scope]
|
||||||
[--default | --no-default]
|
[--default | --no-default]
|
||||||
[--description <description>]
|
[--description <description>]
|
||||||
|
[--default-quota <num-ip-addresses>]
|
||||||
<subnet-pool>
|
<subnet-pool>
|
||||||
|
|
||||||
.. option:: --name <name>
|
.. option:: --name <name>
|
||||||
@ -213,6 +220,11 @@ Set subnet pool properties
|
|||||||
|
|
||||||
Set subnet pool description
|
Set subnet pool description
|
||||||
|
|
||||||
|
.. option:: --default-quota <num-ip-addresses>
|
||||||
|
|
||||||
|
Set default quota for subnet pool as the number of
|
||||||
|
IP addresses allowed in a subnet
|
||||||
|
|
||||||
.. _subnet_pool_set-subnet-pool:
|
.. _subnet_pool_set-subnet-pool:
|
||||||
.. describe:: <subnet-pool>
|
.. describe:: <subnet-pool>
|
||||||
|
|
||||||
|
@ -89,6 +89,9 @@ def _get_attrs(client_manager, parsed_args):
|
|||||||
if parsed_args.description is not None:
|
if parsed_args.description is not None:
|
||||||
attrs['description'] = parsed_args.description
|
attrs['description'] = parsed_args.description
|
||||||
|
|
||||||
|
if parsed_args.default_quota is not None:
|
||||||
|
attrs['default_quota'] = int(parsed_args.default_quota)
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
@ -182,6 +185,12 @@ class CreateSubnetPool(command.ShowOne):
|
|||||||
metavar='<description>',
|
metavar='<description>',
|
||||||
help=_("Set subnet pool description")
|
help=_("Set subnet pool description")
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--default-quota',
|
||||||
|
type=int,
|
||||||
|
metavar='<num-ip-addresses>',
|
||||||
|
help=_("Set default quota for subnet pool as the number of"
|
||||||
|
"IP addresses allowed in a subnet")),
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -369,7 +378,12 @@ class SetSubnetPool(command.Command):
|
|||||||
metavar='<description>',
|
metavar='<description>',
|
||||||
help=_("Set subnet pool description")
|
help=_("Set subnet pool description")
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--default-quota',
|
||||||
|
type=int,
|
||||||
|
metavar='<num-ip-addresses>',
|
||||||
|
help=_("Set default quota for subnet pool as the number of"
|
||||||
|
"IP addresses allowed in a subnet")),
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
@ -165,7 +165,7 @@ class SubnetPoolTests(common.NetworkTests):
|
|||||||
self.assertIn(name2, names)
|
self.assertIn(name2, names)
|
||||||
|
|
||||||
def test_subnet_pool_set_show(self):
|
def test_subnet_pool_set_show(self):
|
||||||
"""Test create, set, show, delete"""
|
"""Test create, delete, set, show, unset"""
|
||||||
|
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
new_name = name + "_"
|
new_name = name + "_"
|
||||||
@ -173,11 +173,15 @@ class SubnetPoolTests(common.NetworkTests):
|
|||||||
'--default-prefix-length 16 ' +
|
'--default-prefix-length 16 ' +
|
||||||
'--min-prefix-length 16 ' +
|
'--min-prefix-length 16 ' +
|
||||||
'--max-prefix-length 32 ' +
|
'--max-prefix-length 32 ' +
|
||||||
'--description aaaa ',
|
'--description aaaa ' +
|
||||||
|
'--default-quota 10 ',
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.addCleanup(self.openstack, 'subnet pool delete ' + new_name)
|
self.addCleanup(
|
||||||
|
self.openstack,
|
||||||
|
'subnet pool delete ' + cmd_output['id'],
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name,
|
name,
|
||||||
cmd_output["name"],
|
cmd_output["name"],
|
||||||
@ -202,6 +206,10 @@ class SubnetPoolTests(common.NetworkTests):
|
|||||||
32,
|
32,
|
||||||
cmd_output["max_prefixlen"],
|
cmd_output["max_prefixlen"],
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
10,
|
||||||
|
cmd_output["default_quota"],
|
||||||
|
)
|
||||||
|
|
||||||
# Test set
|
# Test set
|
||||||
cmd_output = self.openstack(
|
cmd_output = self.openstack(
|
||||||
@ -212,7 +220,8 @@ class SubnetPoolTests(common.NetworkTests):
|
|||||||
'--default-prefix-length 8 ' +
|
'--default-prefix-length 8 ' +
|
||||||
'--min-prefix-length 8 ' +
|
'--min-prefix-length 8 ' +
|
||||||
'--max-prefix-length 16 ' +
|
'--max-prefix-length 16 ' +
|
||||||
name
|
'--default-quota 20 ' +
|
||||||
|
name,
|
||||||
)
|
)
|
||||||
self.assertOutput('', cmd_output)
|
self.assertOutput('', cmd_output)
|
||||||
|
|
||||||
@ -244,6 +253,28 @@ class SubnetPoolTests(common.NetworkTests):
|
|||||||
16,
|
16,
|
||||||
cmd_output["max_prefixlen"],
|
cmd_output["max_prefixlen"],
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
20,
|
||||||
|
cmd_output["default_quota"],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test unset
|
||||||
|
# NOTE(dtroyer): The unset command --default-quota option DOES NOT
|
||||||
|
# WORK after a default quota has been set once on a
|
||||||
|
# pool. The error appears to be in a lower layer,
|
||||||
|
# once that is fixed add a test for subnet pool unset
|
||||||
|
# --default-quota.
|
||||||
|
# The unset command of --pool-prefixes also doesnt work
|
||||||
|
# right now. It would be fixed in a separate patch once
|
||||||
|
# the lower layer is fixed.
|
||||||
|
# cmd_output = self.openstack(
|
||||||
|
# '--debug ' +
|
||||||
|
# 'subnet pool unset ' +
|
||||||
|
# ' --pool-prefix 10.110.0.0/16 ' +
|
||||||
|
# new_name,
|
||||||
|
# )
|
||||||
|
# self.assertOutput('', cmd_output)
|
||||||
|
# self.assertNone(cmd_output["prefixes"])
|
||||||
|
|
||||||
def _subnet_pool_create(self, cmd, name, is_type_ipv4=True):
|
def _subnet_pool_create(self, cmd, name, is_type_ipv4=True):
|
||||||
"""Make a random subnet pool
|
"""Make a random subnet pool
|
||||||
|
@ -270,6 +270,27 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_create_with_default_quota(self):
|
||||||
|
arglist = [
|
||||||
|
'--pool-prefix', '10.0.10.0/24',
|
||||||
|
'--default-quota', '10',
|
||||||
|
self._subnet_pool.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('prefixes', ['10.0.10.0/24']),
|
||||||
|
('default_quota', 10),
|
||||||
|
('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(**{
|
||||||
|
'name': self._subnet_pool.name,
|
||||||
|
'prefixes': ['10.0.10.0/24'],
|
||||||
|
'default_quota': 10,
|
||||||
|
})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
|
||||||
class TestDeleteSubnetPool(TestSubnetPool):
|
class TestDeleteSubnetPool(TestSubnetPool):
|
||||||
|
|
||||||
@ -567,7 +588,9 @@ class TestListSubnetPool(TestSubnetPool):
|
|||||||
class TestSetSubnetPool(TestSubnetPool):
|
class TestSetSubnetPool(TestSubnetPool):
|
||||||
|
|
||||||
# The subnet_pool to set.
|
# The subnet_pool to set.
|
||||||
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool(
|
||||||
|
{'default_quota': 10},
|
||||||
|
)
|
||||||
|
|
||||||
_address_scope = network_fakes.FakeAddressScope.create_one_address_scope()
|
_address_scope = network_fakes.FakeAddressScope.create_one_address_scope()
|
||||||
|
|
||||||
@ -794,6 +817,23 @@ class TestSetSubnetPool(TestSubnetPool):
|
|||||||
self._subnet_pool, **attrs)
|
self._subnet_pool, **attrs)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_set_with_default_quota(self):
|
||||||
|
arglist = [
|
||||||
|
'--default-quota', '20',
|
||||||
|
self._subnet_pool.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('default_quota', 20),
|
||||||
|
('subnet_pool', self._subnet_pool.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
self.network.update_subnet_pool.assert_called_once_with(
|
||||||
|
self._subnet_pool,
|
||||||
|
**{'default_quota': 20, }
|
||||||
|
)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
|
||||||
class TestShowSubnetPool(TestSubnetPool):
|
class TestShowSubnetPool(TestSubnetPool):
|
||||||
|
|
||||||
|
6
releasenotes/notes/bug-1667294-f92efa49627eb00a.yaml
Normal file
6
releasenotes/notes/bug-1667294-f92efa49627eb00a.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--default-quota`` option to ``subnet pool create``
|
||||||
|
and ``subnet pool set`` commands.
|
||||||
|
[Bug `1667294 <https://bugs.launchpad.net/python-openstackclient/+bug/1667294>`_]
|
Loading…
Reference in New Issue
Block a user