Add use_default_subnetpool to subnet create requests

Change-Id: I7dcbc8477b2ffa776a9bb272b896a5adfca860ae
Depends-On: Ifff57c0485e4727f352b2cc2bd1bdaabd0f1606b
Closes-Bug: #1547705
This commit is contained in:
Carl Baldwin 2016-02-19 23:28:49 +00:00 committed by Carl Baldwin
parent f18aea286b
commit e0667e96cf
2 changed files with 25 additions and 0 deletions

View File

@ -187,6 +187,10 @@ class CreateSubnet(neutronV20.CreateCommand):
'--subnetpool', metavar='SUBNETPOOL',
help=_('ID or name of subnetpool from which this subnet '
'will obtain a CIDR.'))
parser.add_argument(
'--use-default-subnetpool',
action='store_true',
help=_('Use default subnetpool for ip_version, if it exists.'))
parser.add_argument(
'--prefixlen', metavar='PREFIX_LENGTH',
help=_('Prefix length for subnet allocation from subnetpool.'))
@ -199,6 +203,8 @@ class CreateSubnet(neutronV20.CreateCommand):
if parsed_args.prefixlen:
body['prefixlen'] = parsed_args.prefixlen
ip_version = parsed_args.ip_version
if parsed_args.use_default_subnetpool:
body['use_default_subnetpool'] = True
if parsed_args.subnetpool:
if parsed_args.subnetpool == 'None':
_subnetpool_id = None

View File

@ -290,6 +290,25 @@ class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
position_names, position_values,
tenant_id='tenantid')
def test_create_subnet_with_use_default_subnetpool(self):
# Create subnet: --tenant-id tenantid --use-default-subnetpool \
# netid cidr.
resource = 'subnet'
cmd = subnet.CreateSubnet(test_cli20.MyApp(sys.stdout), None)
name = 'myname'
myid = 'myid'
netid = 'netid'
cidr = 'prefixvalue'
args = ['--tenant_id', 'tenantid',
'--use-default-subnetpool',
netid, cidr]
position_names = ['ip_version', 'use_default_subnetpool', 'network_id',
'cidr']
position_values = [4, True, netid, cidr]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values,
tenant_id='tenantid')
def test_create_subnet_with_disable_dhcp(self):
# Create subnet: --tenant-id tenantid --disable-dhcp netid cidr.
resource = 'subnet'