Merge "[apic-mapping] Allowed VM Name extension for L3 Policy CLI"

This commit is contained in:
Jenkins 2016-10-13 01:28:27 +00:00 committed by Gerrit Code Review
commit 5da2e116da
2 changed files with 41 additions and 2 deletions

View File

@ -514,6 +514,10 @@ class CreateL3Policy(neutronV20.CreateCommand):
parser.add_argument(
'name', metavar='NAME',
help=_('Name of L3 policy to create (required argument)'))
parser.add_argument(
'--allowed-vm-names', type=utils.str2list,
help=_('Comma separated list of allowed VM name regexes, each '
'regex can be up to 255 characters.'))
n_utils.add_boolean_argument(
parser, '--shared', dest='shared',
help=_('Enable or disable resource sharing, default is False'))
@ -539,7 +543,8 @@ 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'])
'subnet_prefix_length', 'shared',
'allowed_vm_names'])
return body
@ -580,6 +585,10 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
parser.add_argument(
'--name',
help=_('New name of the L3 Policy'))
parser.add_argument(
'--allowed-vm-names', type=utils.str2list,
help=_('Comma separated list of allowed VM name regexes, each '
'regex can be up to 255 characters.'))
n_utils.add_boolean_argument(
parser, '--shared', dest='shared',
help=_('Enable or disable resource sharing'))
@ -607,7 +616,8 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
neutronV20.update_dict(parsed_args, body[self.resource],
['name', 'tenant_id', 'description',
'ip_version', 'ip_pool', 'routers',
'subnet_prefix_length', 'shared'])
'subnet_prefix_length', 'shared',
'allowed_vm_names'])
return body

View File

@ -96,6 +96,23 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
external_segments=
expected_external_segments)
def test_create_l3_policy_with_allowed_vm_names(self):
resource = 'l3_policy'
cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
name = 'name'
tenant_id = 'mytenant'
my_id = 'someid'
allowed_vm_names = "^safe_vm*,good_vm*"
args = ['--tenant-id', tenant_id,
'--allowed-vm-names', allowed_vm_names,
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,
allowed_vm_names=['^safe_vm*', 'good_vm*'])
def test_list_l3_policies(self):
resource = 'l3_policies'
cmd = gbp.ListL3Policy(test_cli20.MyApp(sys.stdout), None)
@ -178,6 +195,18 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
}
self._test_update_resource(resource, cmd, my_id, args, params)
def test_update_l3_policy_with_allowed_vm_names(self):
resource = 'l3_policy'
cmd = gbp.UpdateL3Policy(test_cli20.MyApp(sys.stdout), None)
my_id = 'someid'
allowed_vm_names = "bad_vm*,^worse_vm*"
args = ['--allowed-vm-names', allowed_vm_names,
my_id]
params = {
'allowed_vm_names': ['bad_vm*', '^worse_vm*'],
}
self._test_update_resource(resource, cmd, my_id, args, params)
def test_delete_l3_policy_name(self):
resource = 'l3_policy'
cmd = gbp.DeleteL3Policy(test_cli20.MyApp(sys.stdout), None)