Fixes BadRequest when no --pool-prefix given
--pool-prefix is made required on subnetpool creation. Closes-bug: #1536479 Change-Id: I3d183e45e9b96bc08011c36f45ec2b7a9c01b627
This commit is contained in:
parent
a0a29df3e6
commit
08759b853a
@ -13,7 +13,6 @@ Create subnet pool
|
||||
.. code:: bash
|
||||
|
||||
os subnet pool create
|
||||
[--pool-prefix <pool-prefix> [...]]
|
||||
[--default-prefix-length <default-prefix-length>]
|
||||
[--min-prefix-length <min-prefix-length>]
|
||||
[--max-prefix-length <max-prefix-length>]
|
||||
@ -21,13 +20,9 @@ Create subnet pool
|
||||
[--address-scope <address-scope>]
|
||||
[--default | --no-default]
|
||||
[--share | --no-share]
|
||||
--pool-prefix <pool-prefix> [...]
|
||||
<name>
|
||||
|
||||
.. option:: --pool-prefix <pool-prefix>
|
||||
|
||||
Set subnet pool prefixes (in CIDR notation)
|
||||
(repeat option to set multiple prefixes)
|
||||
|
||||
.. option:: --default-prefix-length <default-prefix-length>
|
||||
|
||||
Set subnet pool default prefix length
|
||||
@ -70,6 +65,11 @@ Create subnet pool
|
||||
|
||||
Set this subnet pool as not shared
|
||||
|
||||
.. describe:: --pool-prefix <pool-prefix>
|
||||
|
||||
Set subnet pool prefixes (in CIDR notation)
|
||||
(repeat option to set multiple prefixes)
|
||||
|
||||
.. _subnet_pool_create-name:
|
||||
.. describe:: <name>
|
||||
|
||||
|
@ -78,12 +78,13 @@ def _get_attrs(client_manager, parsed_args):
|
||||
return attrs
|
||||
|
||||
|
||||
def _add_prefix_options(parser):
|
||||
def _add_prefix_options(parser, for_create=False):
|
||||
parser.add_argument(
|
||||
'--pool-prefix',
|
||||
metavar='<pool-prefix>',
|
||||
dest='prefixes',
|
||||
action='append',
|
||||
required=for_create,
|
||||
help=_("Set subnet pool prefixes (in CIDR notation) "
|
||||
"(repeat option to set multiple prefixes)")
|
||||
)
|
||||
@ -131,7 +132,7 @@ class CreateSubnetPool(command.ShowOne):
|
||||
metavar='<name>',
|
||||
help=_("Name of the new subnet pool")
|
||||
)
|
||||
_add_prefix_options(parser)
|
||||
_add_prefix_options(parser, for_create=True)
|
||||
parser.add_argument(
|
||||
'--project',
|
||||
metavar='<project>',
|
||||
|
@ -113,6 +113,17 @@ class TestCreateSubnetPool(TestSubnetPool):
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
def test_create_no_pool_prefix(self):
|
||||
"""Make sure --pool-prefix is a required argument"""
|
||||
arglist = [
|
||||
self._subnet_pool.name,
|
||||
]
|
||||
verifylist = [
|
||||
('name', self._subnet_pool.name),
|
||||
]
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
def test_create_default_options(self):
|
||||
arglist = [
|
||||
'--pool-prefix', '10.0.10.0/24',
|
||||
@ -138,6 +149,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
||||
'--default-prefix-length', self._subnet_pool.default_prefixlen,
|
||||
'--max-prefix-length', self._subnet_pool.max_prefixlen,
|
||||
'--min-prefix-length', self._subnet_pool.min_prefixlen,
|
||||
'--pool-prefix', '10.0.10.0/24',
|
||||
self._subnet_pool.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -145,6 +157,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
||||
('max_prefix_length', self._subnet_pool.max_prefixlen),
|
||||
('min_prefix_length', self._subnet_pool.min_prefixlen),
|
||||
('name', self._subnet_pool.name),
|
||||
('prefixes', ['10.0.10.0/24']),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -154,7 +167,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
||||
'default_prefixlen': self._subnet_pool.default_prefixlen,
|
||||
'max_prefixlen': self._subnet_pool.max_prefixlen,
|
||||
'min_prefixlen': self._subnet_pool.min_prefixlen,
|
||||
'prefixes': [],
|
||||
'prefixes': ['10.0.10.0/24'],
|
||||
'name': self._subnet_pool.name,
|
||||
})
|
||||
self.assertEqual(self.columns, columns)
|
||||
|
5
releasenotes/notes/bug-1536479-d1f03ed2177d06ed.yaml
Normal file
5
releasenotes/notes/bug-1536479-d1f03ed2177d06ed.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
``--pool-prefix`` option made required for ``subnet pool create``
|
||||
[Bug `1536479 <https://bugs.launchpad.net/bugs/1536479>`_]
|
Loading…
Reference in New Issue
Block a user