Add support for default subnetpools API

Adds support for creating, viewing, and updating subnetpools with the
new 'is_default' property.

This feature will be used by OpenStack admins to manage the default
subnetpools used by their tenants.

This feature replaces the old configuration options for default subnetpools
so that the neutron service no longer needs to be restarted after changes.

Creating a new default subnetpool is achieved by adding the flag:
'--is-default True' to the subnetpool-create call. For example:

neutron subnetpool-create --pool-prefix 10.0.0.0/24 --is_default True

The above will result in the creation of a new default subnetpool, only if a
default does not already exist for the given IP version. Only one default may
exist for each IP version. Similarly, 'is-default True' and
'--is-default False' can be used when calling subnetpool-update.

This feature can only be used by the cloud admin. All users can see the
is_default value in subnetpool-list and subnetpool-show.

Includes release notes.

DocImpact

Change-Id: I80ad2a1407266eff5c66c75974d3cc467701a75e
Closes-Bug: 1508012
This commit is contained in:
John Davidge 2015-10-20 12:56:56 +01:00
parent f8c1f4ec8d
commit 047bbd9077
3 changed files with 36 additions and 2 deletions

@ -15,6 +15,7 @@
#
from neutronclient._i18n import _
from neutronclient.common import utils
from neutronclient.neutron import v2_0 as neutronV20
@ -32,12 +33,16 @@ def add_updatable_arguments(parser):
'--pool-prefix',
action='append', dest='prefixes',
help=_('Subnetpool prefixes (This option can be repeated).'))
utils.add_boolean_argument(
parser, '--is-default',
help=_('Specify whether this should be the default subnetpool '
'(True meaning default).'))
def updatable_args2body(parsed_args, body, for_create=True):
neutronV20.update_dict(parsed_args, body,
['name', 'prefixes', 'default_prefixlen',
'min_prefixlen', 'max_prefixlen'])
'min_prefixlen', 'max_prefixlen', 'is_default'])
class ListSubnetPool(neutronV20.ListCommand):
@ -45,7 +50,7 @@ class ListSubnetPool(neutronV20.ListCommand):
resource = 'subnetpool'
list_columns = ['id', 'name', 'prefixes',
'default_prefixlen', 'address_scope_id']
'default_prefixlen', 'address_scope_id', 'is_default']
pagination_support = True
sorting_support = True

@ -63,6 +63,26 @@ class CLITestV20SubnetPoolJSON(test_cli20.CLITestV20Base):
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
def test_create_subnetpool(self, default='false'):
# Create subnetpool: myname.
resource = 'subnetpool'
cmd = subnetpool.CreateSubnetPool(test_cli20.MyApp(sys.stdout), None)
name = 'myname'
myid = 'myid'
min_prefixlen = 30
prefix1 = '10.11.12.0/24'
prefix2 = '12.11.13.0/24'
args = [name, '--min-prefixlen', str(min_prefixlen),
'--pool-prefix', prefix1, '--pool-prefix', prefix2,
'--is-default', default]
position_names = ['name', 'min_prefixlen', 'prefixes', 'is_default']
position_values = [name, min_prefixlen, [prefix1, prefix2], default]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
def test_create_subnetpool_default(self):
self.test_create_subnetpool(default='true')
def test_create_subnetpool_with_unicode(self):
# Create subnetpool: u'\u7f51\u7edc'.
resource = 'subnetpool'

@ -0,0 +1,9 @@
---
features:
- |
CLI support for default subnetpools.
* The ``subnetpool-list`` and ``subnetpool-show`` command output includes
the ``is_default`` field.
* The ``subnetpool-create`` and ``subnetpool-update`` commands include a
``--is-default`` option.