Explicit address_scope & subnetpools for L3P

Implements blueprint: bp/address-scope-mapping

Change-Id: I74fa0204e75e56b3a2b42d49af851fd5540fc7b1
This commit is contained in:
Sumit Naiksatam 2016-10-20 22:23:55 -07:00
parent 5da2e116da
commit 42bbf31cc7
2 changed files with 79 additions and 2 deletions

View File

@ -499,6 +499,24 @@ class CreateL3Policy(neutronV20.CreateCommand):
'--subnet-prefix-length',
type=int,
help=_('Subnet prefix length, default is 24'))
parser.add_argument(
'--address-scope-v4-id',
help=_('Neutron Address-scope v4 UUID '
'(if not specified, new Neutron Address-scope is '
'created implicitly based on ip_version)'))
parser.add_argument(
'--address-scope-v6-id',
help=_('Neutron Address-scope v6 UUID '
'(if not specified, new Neutron Address-scope is '
'created implicitly based on ip_version)'))
parser.add_argument(
'--subnetpools-v4', type=utils.str2list,
help=_('Comma separated list of Neutron Subnetpool v4 UUIDs '
'if ip_version and address scope is v4'))
parser.add_argument(
'--subnetpools-v6', type=utils.str2list,
help=_('Comma separated list of Neutron Subnetpool v6 UUIDs '
'if ip_version and address scope is v6'))
parser.add_argument(
'--external-segment',
action='append', dest='external_segments', type=utils.str2dict,
@ -542,8 +560,10 @@ class CreateL3Policy(neutronV20.CreateCommand):
neutronV20.update_dict(parsed_args, body[self.resource],
['name', 'tenant_id', 'description',
'ip_version', 'ip_pool', 'routers',
'subnet_prefix_length', 'shared',
'ip_version', 'ip_pool',
'address_scope_v4_id', 'address_scope_v6_id',
'subnetpools_v4', 'subnetpools_v6',
'routers', 'subnet_prefix_length', 'shared',
'allowed_vm_names'])
return body
@ -579,6 +599,14 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
# '(this option can be repeated)'))
help=_('New comma separated list of External Segments'
'(this option can be repeated)'))
parser.add_argument(
'--subnetpools-v4', type=utils.str2list,
help=_('New comma separated list of Neutron Subnetpool v4 UUIDs '
'if ip_version and address scope is v4'))
parser.add_argument(
'--subnetpools-v6', type=utils.str2list,
help=_('New comma separated list of Neutron Subnetpool v6 UUIDs '
'if ip_version and address scope is v6'))
parser.add_argument(
'--routers', type=utils.str2list,
help=_('New comma separated list of Neutron Router UUIDs'))
@ -616,6 +644,7 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
neutronV20.update_dict(parsed_args, body[self.resource],
['name', 'tenant_id', 'description',
'ip_version', 'ip_pool', 'routers',
'subnetpools_v4', 'subnetpools_v6',
'subnet_prefix_length', 'shared',
'allowed_vm_names'])

View File

@ -50,6 +50,8 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
ip_version = '4'
ip_pool = '172.16.0.0/12'
subnet_prefix_length = '24'
address_scope_v4_id = 'ascpid'
subnetpools_v4 = 'sp1,sp2'
external_segment = 'seg_uuid1=1.1.1.0:2.2.2.0'
expected_external_segments = {'seg_uuid1': ['1.1.1.0', '2.2.2.0']}
routers = 'uuid1,uuid2'
@ -59,6 +61,8 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
'--ip-version', ip_version,
'--ip-pool', ip_pool,
'--subnet-prefix-length', subnet_prefix_length,
'--address-scope-v4-id', address_scope_v4_id,
'--subnetpools-v4', subnetpools_v4,
'--external-segment', external_segment,
'--routers', routers,
'--shared', shared,
@ -72,10 +76,39 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
ip_version=4,
ip_pool=ip_pool,
subnet_prefix_length=24,
address_scope_v4_id=address_scope_v4_id,
subnetpools_v4=['sp1', 'sp2'],
routers=['uuid1', 'uuid2'],
external_segments=
expected_external_segments, shared=shared)
def test_create_l3_policy_with_ipv6(self):
"""l3-policy-create with ipv6 params."""
resource = 'l3_policy'
cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
name = 'myname'
tenant_id = 'mytenant'
description = 'My L3 Policy'
my_id = 'someid'
ip_version = '6'
address_scope_v6_id = 'ascpid'
subnetpools_v6 = 'sp1,sp2'
args = ['--tenant-id', tenant_id,
'--description', description,
'--ip-version', ip_version,
'--address-scope-v6-id', address_scope_v6_id,
'--subnetpools-v6', subnetpools_v6,
name]
position_names = ['name', ]
position_values = [name, ]
self._test_create_resource(resource, cmd, name, my_id, args,
position_names, position_values,
tenant_id=tenant_id,
description=description,
ip_version=6,
address_scope_v6_id=address_scope_v6_id,
subnetpools_v6=['sp1', 'sp2'])
def test_create_l3_policy_with_external_segment(self):
"""l3-policy-create with all params."""
resource = 'l3_policy'
@ -142,10 +175,12 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
external_segment = 'seg_uuid1=1.1.1.0:2.2.2.0'
expected_external_segments = {'seg_uuid1': ['1.1.1.0', '2.2.2.0']}
shared = 'true'
subnetpools_v4 = 'sp1,sp2'
routers = 'uuid1,uuid2'
args = ['--name', name,
'--description', description,
'--subnet-prefix-length', subnet_prefix_length,
'--subnetpools-v4', subnetpools_v4,
'--external-segment', external_segment,
'--routers', routers,
'--shared', shared,
@ -154,6 +189,7 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
'name': name,
'description': description,
'subnet_prefix_length': 24,
'subnetpools_v4': ['sp1', 'sp2'],
'external_segments': expected_external_segments,
'routers': routers,
'routers': ['uuid1', 'uuid2'],
@ -161,6 +197,18 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
}
self._test_update_resource(resource, cmd, my_id, args, params)
def test_update_l3_policy_ipv6_subnetpools(self):
resource = 'l3_policy'
cmd = gbp.UpdateL3Policy(test_cli20.MyApp(sys.stdout), None)
my_id = 'someid'
subnetpools_v6 = 'sp1,sp2'
args = ['--subnetpools-v6', subnetpools_v6,
my_id]
params = {
'subnetpools_v6': ['sp1', 'sp2'],
}
self._test_update_resource(resource, cmd, my_id, args, params)
def test_update_l3_policy_unset_external_segment(self):
resource = 'l3_policy'
cmd = gbp.UpdateL3Policy(test_cli20.MyApp(sys.stdout), None)