From 80d73baae28b0e8ceb3fb129e94a44ab27374d6f Mon Sep 17 00:00:00 2001 From: Igor Duarte Cardoso Date: Wed, 18 Mar 2015 01:23:53 +0000 Subject: [PATCH] Adds --shared attribute to commands missing it This is the final commit of 2 towards closing GBP client bug #1403417. It shows the --shared option for commands that previously didn't show it, but should. The following resources have been fixed (for both create and update operations): * l2policy * l3policy * network-service-policy * policy-action * policy-classifier * policy-rule * policy-rule-set * policy-target-group Furthermore, the CLI tests have been updated to test --shared. As an extra, all (*_all_params) test methods updated with the new option have also been re-checked for potentially lacking options and, in that case, updated with the missing options. Change-Id: Ie4d88c56a2d3e7abd8b063faeac5933a96e37dde Closes-Bug: #1403417 --- gbpclient/gbp/v2_0/groupbasedpolicy.py | 83 +++++++++++++++---- gbpclient/tests/unit/test_cli20_l2policy.py | 43 ++++++++++ gbpclient/tests/unit/test_cli20_l3policy.py | 7 +- .../unit/test_cli20_networkservicepolicy.py | 28 +++++-- .../tests/unit/test_cli20_policyaction.py | 16 ++-- .../tests/unit/test_cli20_policyclassifier.py | 17 ++-- gbpclient/tests/unit/test_cli20_policyrule.py | 18 ++-- .../unit/test_cli20_policytargetgroup.py | 76 +++++++++++++++++ 8 files changed, 250 insertions(+), 38 deletions(-) diff --git a/gbpclient/gbp/v2_0/groupbasedpolicy.py b/gbpclient/gbp/v2_0/groupbasedpolicy.py index f679959..37a3f90 100644 --- a/gbpclient/gbp/v2_0/groupbasedpolicy.py +++ b/gbpclient/gbp/v2_0/groupbasedpolicy.py @@ -182,6 +182,9 @@ class CreatePolicyTargetGroup(neutronV20.CreateCommand): parser.add_argument( '--subnets', type=string.split, help=_('List of neutron subnet uuids')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -217,7 +220,7 @@ class CreatePolicyTargetGroup(neutronV20.CreateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', 'provided_policy_rule_sets', 'subnets', - 'consumed_policy_rule_sets']) + 'consumed_policy_rule_sets', 'shared']) return body @@ -254,6 +257,9 @@ class UpdatePolicyTargetGroup(neutronV20.UpdateCommand): parser.add_argument( '--subnets', type=string.split, help=_('List of neutron subnet uuids')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -289,7 +295,7 @@ class UpdatePolicyTargetGroup(neutronV20.UpdateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', 'provided_policy_rule_sets', 'subnets', - 'consumed_policy_rule_sets']) + 'consumed_policy_rule_sets', 'shared']) return body @@ -332,12 +338,15 @@ class CreateL2Policy(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of L2 Policy to create')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } neutronV20.update_dict(parsed_args, body[self.resource], - ['name', 'tenant_id', 'description']) + ['name', 'tenant_id', 'description', 'shared']) if parsed_args.l3_policy: body[self.resource]['l3_policy_id'] = \ neutronV20.find_resourceid_by_name_or_id( @@ -374,12 +383,15 @@ class UpdateL2Policy(neutronV20.UpdateCommand): parser.add_argument( '--name', metavar='NAME', help=_('New name of the L2 Policy')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } neutronV20.update_dict(parsed_args, body[self.resource], - ['name', 'tenant_id', 'description']) + ['name', 'tenant_id', 'description', 'shared']) if parsed_args.l3_policy: body[self.resource]['l3_policy_id'] = \ neutronV20.find_resourceid_by_name_or_id( @@ -439,6 +451,9 @@ class CreateL3Policy(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of L3 policy to create')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -457,7 +472,7 @@ class CreateL3Policy(neutronV20.CreateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', 'ip_version', 'ip_pool', - 'subnet_prefix_length']) + 'subnet_prefix_length', 'shared']) return body @@ -498,6 +513,9 @@ class UpdateL3Policy(neutronV20.UpdateCommand): parser.add_argument( '--name', metavar='NAME', help=_('New name of the L3 Policy')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -518,7 +536,7 @@ class UpdateL3Policy(neutronV20.UpdateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', 'ip_version', 'ip_pool', - 'subnet_prefix_length']) + 'subnet_prefix_length', 'shared']) return body @@ -561,13 +579,16 @@ class CreateNetworkServicePolicy(neutronV20.CreateCommand): type=utils.str2dict, help=_('Network service params for this network service policy' '(This option can be repeated).')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', - 'network_service_params']) + 'network_service_params', 'shared']) return body @@ -598,13 +619,16 @@ class UpdateNetworkServicePolicy(neutronV20.UpdateCommand): type=utils.str2dict, help=_('Network service params for this network service policy' '(This option can be repeated).')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', - 'network_service_params']) + 'network_service_params', 'shared']) return body @@ -650,13 +674,17 @@ class CreatePolicyClassifier(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of classifier to create')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', - 'protocol', 'port_range', 'direction']) + 'protocol', 'port_range', + 'direction', 'shared']) return body @@ -692,13 +720,17 @@ class UpdatePolicyClassifier(neutronV20.UpdateCommand): parser.add_argument( '--name', help=_('New name of the classifier')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', - 'protocol', 'port_range', 'direction']) + 'protocol', 'port_range', + 'direction', 'shared']) return body @@ -740,6 +772,9 @@ class CreatePolicyAction(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of action to create')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -752,7 +787,7 @@ class CreatePolicyAction(neutronV20.CreateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', - 'action_type']) + 'action_type', 'shared']) return body @@ -780,6 +815,9 @@ class UpdatePolicyAction(neutronV20.UpdateCommand): parser.add_argument( '--name', help=_('New name of the action')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -791,7 +829,8 @@ class UpdatePolicyAction(neutronV20.UpdateCommand): parsed_args.action_value)) neutronV20.update_dict(parsed_args, body[self.resource], - ['name', 'tenant_id', 'description']) + ['name', 'tenant_id', 'description', + 'shared']) return body @@ -837,6 +876,9 @@ class CreatePolicyRule(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of policy_rule to create')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -857,7 +899,7 @@ class CreatePolicyRule(neutronV20.CreateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'tenant_id', 'description', - 'enabled']) + 'enabled', 'shared']) return body @@ -885,6 +927,9 @@ class UpdatePolicyRule(neutronV20.UpdateCommand): parser.add_argument( '--actions', type=string.split, help=_('List of policy actions')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -905,7 +950,7 @@ class UpdatePolicyRule(neutronV20.UpdateCommand): neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'description', - 'enabled']) + 'enabled', 'shared']) return body @@ -946,6 +991,9 @@ class CreatePolicyRuleSet(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of policy rule set to create')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -965,7 +1013,7 @@ class CreatePolicyRuleSet(neutronV20.CreateCommand): elem) for elem in parsed_args.child_policy_rule_sets] neutronV20.update_dict(parsed_args, body[self.resource], - ['name', 'tenant_id', 'description']) + ['name', 'tenant_id', 'description', 'shared']) return body @@ -989,6 +1037,9 @@ class UpdatePolicyRuleSet(neutronV20.UpdateCommand): parser.add_argument( '--child-policy-rule-sets', type=string.split, help=_('List of child policy rule sets')) + parser.add_argument( + '--shared', type=bool, + help=_('Shared flag')) def args2body(self, parsed_args): body = {self.resource: {}, } @@ -1010,7 +1061,7 @@ class UpdatePolicyRuleSet(neutronV20.UpdateCommand): parsed_args.child_policy_rule_sets) neutronV20.update_dict(parsed_args, body[self.resource], ['name', 'description', 'policy_rules', - 'child_policy_rule_sets']) + 'child_policy_rule_sets', 'shared']) return body diff --git a/gbpclient/tests/unit/test_cli20_l2policy.py b/gbpclient/tests/unit/test_cli20_l2policy.py index f6c5ea0..9d3847e 100644 --- a/gbpclient/tests/unit/test_cli20_l2policy.py +++ b/gbpclient/tests/unit/test_cli20_l2policy.py @@ -39,6 +39,27 @@ class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base): position_names, position_values, tenant_id=tenant_id) + def test_create_l2_policy_with_all_params(self): + """l2-policy-create with all params.""" + resource = 'l2_policy' + cmd = gbp.CreateL2Policy(test_cli20.MyApp(sys.stdout), None) + my_id = 'my-id' + tenant_id = 'my-tenant' + name = 'my-name' + description = 'l2p description' + l3_policy_id = 'l3p' + shared = 'True' + args = [name, + '--tenant-id', tenant_id, + '--description', description, + '--l3-policy-id', l3_policy_id, + '--shared', shared] + position_names = ['name', 'description', 'l3_policy_id'] + position_values = [name, description, l3_policy_id] + self._test_create_resource(resource, cmd, name, my_id, args, + position_names, position_values, + tenant_id=tenant_id, shared=True) + def test_list_l2_policies(self): resource = 'l2_policies' cmd = gbp.ListL2Policy(test_cli20.MyApp(sys.stdout), None) @@ -58,6 +79,28 @@ class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base): '--tags', 'a', 'b'], {'name': 'myname', 'tags': ['a', 'b'], }) + def test_update_l2_policy_with_all_params(self): + """l2-policy-update.""" + resource = 'l2_policy' + cmd = gbp.UpdateL2Policy(test_cli20.MyApp(sys.stdout), None) + my_id = 'someid' + name = 'l2policy' + description = 'l2policy description' + l3_policy_id = 'l3p' + shared = 'True' + args = [my_id, + '--name', name, + '--description', description, + '--l3-policy-id', l3_policy_id, + '--shared', shared] + params = { + 'name': name, + 'description': description, + 'l3_policy_id': l3_policy_id, + 'shared': True + } + self._test_update_resource(resource, cmd, my_id, args, params) + def test_delete_l2_policy_name(self): resource = 'l2_policy' cmd = gbp.DeleteL2Policy(test_cli20.MyApp(sys.stdout), None) diff --git a/gbpclient/tests/unit/test_cli20_l3policy.py b/gbpclient/tests/unit/test_cli20_l3policy.py index 3442b74..02c0386 100644 --- a/gbpclient/tests/unit/test_cli20_l3policy.py +++ b/gbpclient/tests/unit/test_cli20_l3policy.py @@ -52,12 +52,14 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base): subnet_prefix_length = '24' 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' args = ['--tenant-id', tenant_id, '--description', description, '--ip-version', ip_version, '--ip-pool', ip_pool, '--subnet-prefix-length', subnet_prefix_length, '--external-segment', external_segment, + '--shared', shared, name] position_names = ['name', ] position_values = [name, ] @@ -69,7 +71,7 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base): ip_pool=ip_pool, subnet_prefix_length=24, external_segments= - expected_external_segments) + expected_external_segments, shared=True) def test_list_l3_policies(self): resource = 'l3_policies' @@ -101,12 +103,14 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base): subnet_prefix_length = '24' 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' args = ['--name', name, '--description', description, '--ip-version', ip_version, '--ip-pool', ip_pool, '--subnet-prefix-length', subnet_prefix_length, '--external-segment', external_segment, + '--shared', shared, my_id] params = { 'name': name, @@ -115,6 +119,7 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base): 'ip_pool': ip_pool, 'subnet_prefix_length': 24, 'external_segments': expected_external_segments, + 'shared': True } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_networkservicepolicy.py b/gbpclient/tests/unit/test_cli20_networkservicepolicy.py index 18f82d5..b65bda6 100644 --- a/gbpclient/tests/unit/test_cli20_networkservicepolicy.py +++ b/gbpclient/tests/unit/test_cli20_networkservicepolicy.py @@ -47,9 +47,11 @@ class CLITestV20NetworkServicePolicyJSON(test_cli20.CLITestV20Base): description = 'Mynsp' my_id = 'someid' network_svc_params = "type=ip_single,name=vip,value=self_subnet" + shared = 'True' args = ['--tenant_id', tenant_id, '--description', description, '--network-service-params', network_svc_params, + '--shared', shared, name] position_names = ['name', 'description', 'network_service_params'] net_params = [{"type": "ip_single", "name": "vip", @@ -57,7 +59,7 @@ class CLITestV20NetworkServicePolicyJSON(test_cli20.CLITestV20Base): position_values = [name, description, net_params] self._test_create_resource(resource, cmd, name, my_id, args, position_names, position_values, - tenant_id=tenant_id) + tenant_id=tenant_id, shared=True) def test_list_network_service_policies(self): """network-sercvice-policy-list.""" @@ -117,15 +119,29 @@ class CLITestV20NetworkServicePolicyJSON(test_cli20.CLITestV20Base): {'name': 'myname', 'tags': ['a', 'b'], }) def test_update_network_service_policy_with_allparams(self): + """network-service-policy-update with all params.""" resource = 'network_service_policy' - new_name = "new_name" cmd = gbp.UpdateNetworkServicePolicy(test_cli20.MyApp(sys.stdout), None) - body = { - 'name': new_name + name = 'nsp' + description = 'nsp description' + my_id = 'someid' + network_svc_params = "type=ip_single,name=vip,value=self_subnet" + shared = 'True' + args = [my_id, + '--name', name, + '--description', description, + '--network-service-params', network_svc_params, + '--shared', shared, + '--request-format', 'json'] + params = { + 'name': name, + 'description': description, + 'network_service_params': [{"type": "ip_single", "name": "vip", + "value": "self_subnet"}], + 'shared': True } - args = ['myid', '--name', new_name, '--request-format', 'json'] - self._test_update_resource(resource, cmd, 'myid', args, body) + self._test_update_resource(resource, cmd, my_id, args, params) def test_delete_network_service_policy(self): """network-service-policy-delete my-id.""" diff --git a/gbpclient/tests/unit/test_cli20_policyaction.py b/gbpclient/tests/unit/test_cli20_policyaction.py index dc922e7..5db728a 100644 --- a/gbpclient/tests/unit/test_cli20_policyaction.py +++ b/gbpclient/tests/unit/test_cli20_policyaction.py @@ -46,10 +46,12 @@ class CLITestV20PolicyActionJSON(test_cli20.CLITestV20Base): my_id = 'my-id' action_type = "allow" action_value = "1234" + shared = 'True' args = ['--tenant-id', tenant_id, '--description', description, '--action-type', action_type, '--action-value', action_value, + '--shared', shared, name] position_names = ['name', ] position_values = [name, ] @@ -58,7 +60,7 @@ class CLITestV20PolicyActionJSON(test_cli20.CLITestV20Base): tenant_id=tenant_id, description=description, action_type=action_type, - action_value=action_value) + action_value=action_value, shared=True) def test_list_policy_actions(self): """grouppolicy-policy-action-list.""" @@ -116,15 +118,19 @@ class CLITestV20PolicyActionJSON(test_cli20.CLITestV20Base): resource = 'policy_action' action_type = "allow" action_value = "1234" + shared = 'True' + my_id = 'someid' cmd = gbp.UpdatePolicyAction(test_cli20.MyApp(sys.stdout), None) body = { 'action_type': action_type, - 'action_value': action_value + 'action_value': action_value, + 'shared': True } - args = ['myid', + args = [my_id, '--action-type', action_type, - '--action-value', action_value, ] - self._test_update_resource(resource, cmd, 'myid', args, body) + '--action-value', action_value, + '--shared', shared, ] + self._test_update_resource(resource, cmd, my_id, args, body) def test_delete_policy_action(self): """grouppolicy-policy-action-delete my-id.""" diff --git a/gbpclient/tests/unit/test_cli20_policyclassifier.py b/gbpclient/tests/unit/test_cli20_policyclassifier.py index 32cc4a7..c9d9f71 100644 --- a/gbpclient/tests/unit/test_cli20_policyclassifier.py +++ b/gbpclient/tests/unit/test_cli20_policyclassifier.py @@ -47,11 +47,13 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): protocol = 'tcp' port_range = '10-80' direction = 'in' + shared = 'True' args = ['--tenant-id', tenant_id, '--description', description, '--protocol', protocol, '--port-range', port_range, '--direction', direction, + '--shared', shared, name] position_names = ['name', ] position_values = [name, ] @@ -61,7 +63,7 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): description=description, protocol=protocol, port_range=port_range, - direction=direction) + direction=direction, shared=True) def test_list_policy_classifiers(self): """grouppolicy-policy-classifier-list.""" @@ -122,15 +124,20 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): port_range = '10-80' direction = 'in' cmd = gbp.UpdatePolicyClassifier(test_cli20.MyApp(sys.stdout), None) + my_id = 'someid' + shared = 'True' body = { 'protocol': protocol, 'port_range': port_range, - 'direction': direction + 'direction': direction, + 'shared': True } - args = ['myid', '--protocol', protocol, + args = [my_id, + '--protocol', protocol, '--port-range', port_range, - '--direction', direction, ] - self._test_update_resource(resource, cmd, 'myid', args, body) + '--direction', direction, + '--shared', shared, ] + self._test_update_resource(resource, cmd, my_id, args, body) def test_delete_policy_classifier(self): """grouppolicy-policy-classifier-delete my-id.""" diff --git a/gbpclient/tests/unit/test_cli20_policyrule.py b/gbpclient/tests/unit/test_cli20_policyrule.py index c07beb9..1f10b61 100644 --- a/gbpclient/tests/unit/test_cli20_policyrule.py +++ b/gbpclient/tests/unit/test_cli20_policyrule.py @@ -48,11 +48,13 @@ class CLITestV20PolicyRuleJSON(test_cli20.CLITestV20Base): policy_classifier_id = 'pc-id' policy_actions_res = ["pa1", "pa2"] policy_actions_arg = "pa1 pa2" + shared = 'True' args = ['--tenant-id', tenant_id, '--description', description, '--enabled', "True", '--classifier', policy_classifier_id, '--actions', policy_actions_arg, + '--shared', shared, name] position_names = ['name', ] position_values = [name, ] @@ -62,7 +64,8 @@ class CLITestV20PolicyRuleJSON(test_cli20.CLITestV20Base): description=description, enabled=enabled, policy_classifier_id=policy_classifier_id, - policy_actions=policy_actions_res) + policy_actions=policy_actions_res, + shared=True) def test_list_policy_rules(self): """grouppolicy-policy-rule-list.""" @@ -122,16 +125,21 @@ class CLITestV20PolicyRuleJSON(test_cli20.CLITestV20Base): policy_classifier_id = 'pc-id' policy_actions_res = ["pa1", "pa2"] policy_actions_arg = "pa1 pa2" + my_id = 'someid' + shared = 'True' cmd = gbp.UpdatePolicyRule(test_cli20.MyApp(sys.stdout), None) body = { 'policy_classifier_id': policy_classifier_id, 'enabled': enabled, - 'policy_actions': policy_actions_res + 'policy_actions': policy_actions_res, + 'shared': True } - args = ['myid', '--enabled', "True", + args = [my_id, + '--enabled', "True", '--classifier', policy_classifier_id, - '--actions', policy_actions_arg, ] - self._test_update_resource(resource, cmd, 'myid', args, body) + '--actions', policy_actions_arg, + '--shared', shared, ] + self._test_update_resource(resource, cmd, my_id, args, body) def test_delete_policy_classifier(self): """grouppolicy-policy-rule-delete my-id.""" diff --git a/gbpclient/tests/unit/test_cli20_policytargetgroup.py b/gbpclient/tests/unit/test_cli20_policytargetgroup.py index aea8603..8280e42 100644 --- a/gbpclient/tests/unit/test_cli20_policytargetgroup.py +++ b/gbpclient/tests/unit/test_cli20_policytargetgroup.py @@ -40,6 +40,45 @@ class CLITestV20PolicyTargetGroupJSON(test_cli20.CLITestV20Base): position_names, position_values, tenant_id=tenant_id) + def test_create_policy_target_group_with_all_params(self): + """policy-target-group-create with all params.""" + resource = 'policy_target_group' + cmd = gbp.CreatePolicyTargetGroup(test_cli20.MyApp(sys.stdout), None) + my_id = 'my-id' + tenant_id = 'my-tenant' + name = 'my-name' + description = 'ptg description' + l2_policy_id = 'l2_policy_id' + provided_prs = "icmp-prs=false,web-prs=true" + consumed_prs = "ssh-prs=true,ftp-prs=false" + network_service_policy_id = 'network_service_policy_id' + shared = 'True' + args = [name, + '--tenant-id', tenant_id, + '--description', description, + '--l2-policy-id', l2_policy_id, + '--provided-policy-rule-sets', provided_prs, + '--consumed-policy-rule-sets', consumed_prs, + '--network-service-policy-id', network_service_policy_id, + '--shared', shared] + position_names = ['name', 'description', 'l2_policy_id', + 'provided_policy_rule_sets', + 'consumed_policy_rule_sets', + 'network_service_policy_id'] + provided_policy_rule_sets = { + 'icmp-prs': 'false', + 'web-prs': 'true'} + consumed_policy_rule_sets = { + 'ssh-prs': 'true', + 'ftp-prs': 'false'} + position_values = [name, description, l2_policy_id, + provided_policy_rule_sets, + consumed_policy_rule_sets, + network_service_policy_id] + self._test_create_resource(resource, cmd, name, my_id, args, + position_names, position_values, + tenant_id=tenant_id, shared=True) + def test_list_policy_target_groups(self): """policy-target-group-list.""" resource = 'policy_target_groups' @@ -62,6 +101,43 @@ class CLITestV20PolicyTargetGroupJSON(test_cli20.CLITestV20Base): '--tags', 'a', 'b'], {'name': 'myname', 'tags': ['a', 'b'], }) + def test_update_policy_target_group_with_all_params(self): + """policy-target-group-update.""" + resource = 'policy_target_group' + cmd = gbp.UpdatePolicyTargetGroup(test_cli20.MyApp(sys.stdout), None) + my_id = 'my-id' + name = 'ptg' + description = 'ptg description' + l2_policy_id = 'l2_policy_id' + provided_prs = "icmp-prs=false,web-prs=true" + consumed_prs = "ssh-prs=true,ftp-prs=false" + network_service_policy_id = 'network_service_policy_id' + shared = 'True' + args = [my_id, + '--name', name, + '--description', description, + '--l2-policy-id', l2_policy_id, + '--provided-policy-rule-sets', provided_prs, + '--consumed-policy-rule-sets', consumed_prs, + '--network-service-policy-id', network_service_policy_id, + '--shared', shared] + provided_policy_rule_sets = { + 'icmp-prs': 'false', + 'web-prs': 'true'} + consumed_policy_rule_sets = { + 'ssh-prs': 'true', + 'ftp-prs': 'false'} + params = { + 'name': name, + 'description': description, + 'l2_policy_id': l2_policy_id, + 'provided_policy_rule_sets': provided_policy_rule_sets, + 'consumed_policy_rule_sets': consumed_policy_rule_sets, + 'network_service_policy_id': network_service_policy_id, + 'shared': True + } + self._test_update_resource(resource, cmd, my_id, args, params) + def test_delete_policy_target_group_name(self): """policy-target-group-delete.""" resource = 'policy_target_group'