diff --git a/gbpclient/gbp/v2_0/groupbasedpolicy.py b/gbpclient/gbp/v2_0/groupbasedpolicy.py index 70d3538..ac88abf 100644 --- a/gbpclient/gbp/v2_0/groupbasedpolicy.py +++ b/gbpclient/gbp/v2_0/groupbasedpolicy.py @@ -13,6 +13,7 @@ import logging +from neutronclient.common import utils as n_utils from neutronclient.i18n import _ from neutronclient.neutron import v2_0 as neutronV20 from oslo.serialization import jsonutils @@ -171,8 +172,8 @@ class CreatePolicyTargetGroup(neutronV20.CreateCommand): parser.add_argument( '--subnets', type=utils.str2list, help=_('Comma separated list of Neutron Subnet UUIDs')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -249,8 +250,8 @@ class UpdatePolicyTargetGroup(neutronV20.UpdateCommand): '--subnets', type=utils.str2list, help=_('New comma separated list of Neutron Subnet UUIDs ' '(to unset use "")')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -334,8 +335,8 @@ class CreateL2Policy(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of L2 Policy to create (required argument)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -379,8 +380,8 @@ class UpdateL2Policy(neutronV20.UpdateCommand): parser.add_argument( '--name', help=_('New name of the L2 Policy')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -453,8 +454,8 @@ class CreateL3Policy(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of L3 policy to create (required argument)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -519,8 +520,8 @@ class UpdateL3Policy(neutronV20.UpdateCommand): parser.add_argument( '--name', help=_('New name of the L3 Policy')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -591,8 +592,8 @@ class CreateNetworkServicePolicy(neutronV20.CreateCommand): type=utils.str2dict, help=_('Params for this Network Service ' 'Policy (this option can be repeated)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -631,8 +632,8 @@ class UpdateNetworkServicePolicy(neutronV20.UpdateCommand): type=utils.str2dict, help=_('New params for this Network Service ' 'Policy (this option can be repeated)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -671,23 +672,25 @@ class CreatePolicyClassifier(neutronV20.CreateCommand): def add_known_arguments(self, parser): parser.add_argument( '--description', - help=_('Description of the policy classifier')) + help=_('A description for the policy classifier')) parser.add_argument( '--protocol', - choices=['tcp', 'udp', 'icmp'], - help=_('Protocol')) + choices=['tcp', 'udp', 'icmp', ''], + help=_('A protocol value. When not set, all protocols are ' + 'matched')) parser.add_argument( '--port-range', - help=_('Port range')) + help=_('A port range value in the format p1[:p2]. ' + 'When not set all ports are matched')) parser.add_argument( '--direction', choices=['in', 'out', 'bi', ''], - help=_('Direction')) + help=_('A direction value. When not set defaults to \'bi\'')) parser.add_argument( 'name', metavar='NAME', - help=_('Name of classifier to create (required argument)')) - parser.add_argument( - '--shared', type=bool, + help=_('A name for classifier to create (required argument)')) + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -698,6 +701,9 @@ class CreatePolicyClassifier(neutronV20.CreateCommand): 'protocol', 'port_range', 'direction', 'shared']) + if 'direction' not in body[self.resource]: + body[self.resource]['direction'] = 'bi' + return body @@ -717,23 +723,25 @@ class UpdatePolicyClassifier(neutronV20.UpdateCommand): def add_known_arguments(self, parser): parser.add_argument( '--description', - help=_('New description of the policy classifier')) + help=_('New description for the policy classifier')) parser.add_argument( '--protocol', - choices=['tcp', 'udp', 'icmp'], - help=_('New Protocol')) + choices=['tcp', 'udp', 'icmp', ''], + help=_('New protocol value ' + '(use empty string \'\' to unset and match all protocols)')) parser.add_argument( '--port-range', - help=_('New Port range')) + help=_('New port range value in the format p1[:p2] ' + '(use empty string \'\' to unset)')) parser.add_argument( '--direction', choices=['in', 'out', 'bi', ''], - help=_('New Direction')) + help=_('New direction value')) parser.add_argument( '--name', help=_('New name of the classifier')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -744,6 +752,12 @@ class UpdatePolicyClassifier(neutronV20.UpdateCommand): 'protocol', 'port_range', 'direction', 'shared']) + if parsed_args.protocol == '': + body[self.resource]['protocol'] = None + + if parsed_args.port_range == '': + body[self.resource]['port_range'] = None + return body @@ -784,8 +798,8 @@ class CreatePolicyAction(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of action to create (required argument)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -827,8 +841,8 @@ class UpdatePolicyAction(neutronV20.UpdateCommand): parser.add_argument( '--name', help=_('New name of the action')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -876,8 +890,8 @@ class CreatePolicyRule(neutronV20.CreateCommand): parser.add_argument( '--description', help=_('Description of the policy_rule')) - parser.add_argument( - '--enabled', type=bool, + n_utils.add_boolean_argument( + parser, '--enabled', dest='enabled', help=_('Enable flag, default is True ' '(if False, this Policy Rule is ignored)')) parser.add_argument( @@ -889,8 +903,8 @@ class CreatePolicyRule(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of Policy Rule to create (required argument)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -937,8 +951,8 @@ class UpdatePolicyRule(neutronV20.UpdateCommand): parser.add_argument( '--description', help=_('New description of the Policy Rule')) - parser.add_argument( - '--enabled', type=bool, + n_utils.add_boolean_argument( + parser, '--enabled', dest='enabled', help=_('Enable flag (if False, this Policy Rule is ignored)')) parser.add_argument( '--classifier', @@ -947,8 +961,8 @@ class UpdatePolicyRule(neutronV20.UpdateCommand): '--actions', type=utils.str2list, help=_('New comma separated list of Policy Actions ' '(to unset use "")')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -1013,8 +1027,8 @@ class CreatePolicyRuleSet(neutronV20.CreateCommand): parser.add_argument( 'name', metavar='NAME', help=_('Name of Policy Rule Set to create (required argument)')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -1067,8 +1081,8 @@ class UpdatePolicyRuleSet(neutronV20.UpdateCommand): '--child-policy-rule-sets', type=utils.str2list, help=_('New comma separated list of child Policy Rule Sets ' '(to unset use "")')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -1134,8 +1148,8 @@ class CreateExternalPolicy(neutronV20.CreateCommand): parser.add_argument( '--consumed-policy-rule-sets', type=utils.str2dict, help=_('Comma separated list of Policy Rule Sets')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -1204,8 +1218,8 @@ class UpdateExternalPolicy(neutronV20.UpdateCommand): '--consumed-policy-rule-sets', type=utils.str2dict, help=_('New comma separated list of Policy Rule Sets ' '(to unset use "")')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -1288,11 +1302,12 @@ class CreateExternalSegment(neutronV20.CreateCommand): action='append', dest='external_routes', type=utils.str2dict, help=_('If no nexthop, use format: destination=CIDR,nexthop ' '(this option can be repeated)')) - parser.add_argument( - '--port-address-translation', type=bool, + n_utils.add_boolean_argument( + parser, '--port-address-translation', + dest='port_address_translation', help=_('Enable port-based address translation, default is False')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -1340,11 +1355,12 @@ class UpdateExternalSegment(neutronV20.UpdateCommand): action='append', dest='external_routes', type=utils.str2dict, help=_('If no nexthop, use format: destination=CIDR,nexthop ' '(this option can be repeated)')) - parser.add_argument( - '--port-address-translation', type=bool, + n_utils.add_boolean_argument( + parser, '--port-address-translation', + dest='port_address_translation', help=_('Enable or disable port-based address translation')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): @@ -1410,8 +1426,8 @@ class CreateNatPool(neutronV20.CreateCommand): parser.add_argument( '--external-segment', help=_('External Segment')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing, default is False')) def args2body(self, parsed_args): @@ -1453,8 +1469,8 @@ class UpdateNatPool(neutronV20.UpdateCommand): parser.add_argument( '--external-segment', help=_('New External Segment')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Enable or disable resource sharing')) def args2body(self, parsed_args): diff --git a/gbpclient/gbp/v2_0/servicechain.py b/gbpclient/gbp/v2_0/servicechain.py index 6381d20..5f566ff 100644 --- a/gbpclient/gbp/v2_0/servicechain.py +++ b/gbpclient/gbp/v2_0/servicechain.py @@ -21,6 +21,7 @@ import os from heatclient.common import template_utils from neutronclient.common import exceptions as exc +from neutronclient.common import utils as n_utils from neutronclient.i18n import _ from neutronclient.neutron import v2_0 as neutronV20 @@ -176,8 +177,8 @@ class CreateServiceProfile(neutronV20.CreateCommand): parser.add_argument( '--description', help=_('Description of the Service Profile.')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Shared flag')) parser.add_argument( '--vendor', @@ -214,8 +215,8 @@ class UpdateServiceProfile(neutronV20.UpdateCommand): parser.add_argument( '--description', help=_('Description of the Service Profile.')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Shared flag')) parser.add_argument( '--vendor', @@ -286,8 +287,8 @@ class CreateServiceChainNode(neutronV20.CreateCommand): parser.add_argument( '--config', help=_('Service Configuration for the Service Chain Node.')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Shared flag')) parser.add_argument( '--template-file', @@ -336,8 +337,8 @@ class UpdateServiceChainNode(neutronV20.UpdateCommand): parser.add_argument( '--config', help=_('Service Configuration for the Service Chain Node.')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Shared flag')) def args2body(self, parsed_args): @@ -394,8 +395,8 @@ class CreateServiceChainSpec(neutronV20.CreateCommand): parser.add_argument( '--nodes', metavar='NODES', type=utils.str2list, help=_('Comma separated list of Service Chain Nodes')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Shared flag')) def args2body(self, parsed_args): @@ -424,8 +425,8 @@ class UpdateServiceChainSpec(neutronV20.UpdateCommand): '--nodes', type=utils.str2list, help=_('New comma separated list of Service Chain Nodes ' '(to unset use "")')) - parser.add_argument( - '--shared', type=bool, + n_utils.add_boolean_argument( + parser, '--shared', dest='shared', help=_('Shared flag')) def args2body(self, parsed_args): diff --git a/gbpclient/tests/unit/test_cli20_externalpolicy.py b/gbpclient/tests/unit/test_cli20_externalpolicy.py index 71b5e86..5150eb9 100644 --- a/gbpclient/tests/unit/test_cli20_externalpolicy.py +++ b/gbpclient/tests/unit/test_cli20_externalpolicy.py @@ -51,7 +51,7 @@ class CLITestV20ExternalPolicyJSON(test_cli20.CLITestV20Base): provided_policy_rule_sets = "prs1=true,prs2=true" consumed_policy_rule_sets = "prs3=true,prs4=true" external_segments = "ES1,ES2" - shared = 'True' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, '--provided-policy-rule-sets', provided_policy_rule_sets, @@ -71,7 +71,7 @@ class CLITestV20ExternalPolicyJSON(test_cli20.CLITestV20Base): {'prs3': 'true', 'prs4': 'true'}, external_segments= ['ES1', 'ES2'], - shared=True) + shared=shared) def test_list_external_policies(self): """external-policy-list.""" @@ -104,7 +104,7 @@ class CLITestV20ExternalPolicyJSON(test_cli20.CLITestV20Base): provided_policy_rule_sets = "prs1=true,prs2=true" consumed_policy_rule_sets = "prs3=true,prs4=true" external_segments = "ES1,ES2" - shared = 'True' + shared = 'true' args = ['--name', name, '--description', description, '--provided-policy-rule-sets', provided_policy_rule_sets, @@ -118,7 +118,7 @@ class CLITestV20ExternalPolicyJSON(test_cli20.CLITestV20Base): 'provided_policy_rule_sets': {'prs1': 'true', 'prs2': 'true'}, 'consumed_policy_rule_sets': {'prs3': 'true', 'prs4': 'true'}, 'external_segments': ['ES1', 'ES2'], - 'shared': True + 'shared': shared } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_externalsegment.py b/gbpclient/tests/unit/test_cli20_externalsegment.py index a1271aa..301d793 100644 --- a/gbpclient/tests/unit/test_cli20_externalsegment.py +++ b/gbpclient/tests/unit/test_cli20_externalsegment.py @@ -53,8 +53,8 @@ class CLITestV20ExternalSegmentJSON(test_cli20.CLITestV20Base): external_route = 'destination=172.16.1.0/24,nexthop=192.168.0.10' expected_external_routes = [{'destination': '172.16.1.0/24', 'nexthop': '192.168.0.10'}] - port_address_translation = 'True' - shared = 'True' + port_address_translation = 'true' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, '--ip-version', ip_version, @@ -72,8 +72,9 @@ class CLITestV20ExternalSegmentJSON(test_cli20.CLITestV20Base): ip_version=4, cidr=cidr, external_routes=expected_external_routes, - port_address_translation=True, - shared=True) + port_address_translation= + port_address_translation, + shared=shared) def test_create_external_segment_with_external_route_no_nexthop(self): """external-segment-create with all params.""" @@ -126,8 +127,8 @@ class CLITestV20ExternalSegmentJSON(test_cli20.CLITestV20Base): external_route = 'destination=172.16.1.0/24,nexthop=192.168.0.10' expected_external_routes = [{'destination': '172.16.1.0/24', 'nexthop': '192.168.0.10'}] - port_address_translation = 'True' - shared = 'True' + port_address_translation = 'true' + shared = 'true' args = ['--name', name, '--description', description, '--external-route', external_route, @@ -138,8 +139,8 @@ class CLITestV20ExternalSegmentJSON(test_cli20.CLITestV20Base): 'name': name, 'description': description, 'external_routes': expected_external_routes, - 'port_address_translation': True, - 'shared': True + 'port_address_translation': port_address_translation, + 'shared': shared } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_l2policy.py b/gbpclient/tests/unit/test_cli20_l2policy.py index 9d3847e..17da512 100644 --- a/gbpclient/tests/unit/test_cli20_l2policy.py +++ b/gbpclient/tests/unit/test_cli20_l2policy.py @@ -48,7 +48,7 @@ class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base): name = 'my-name' description = 'l2p description' l3_policy_id = 'l3p' - shared = 'True' + shared = 'true' args = [name, '--tenant-id', tenant_id, '--description', description, @@ -58,7 +58,7 @@ class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base): 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) + tenant_id=tenant_id, shared=shared) def test_list_l2_policies(self): resource = 'l2_policies' @@ -87,7 +87,7 @@ class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base): name = 'l2policy' description = 'l2policy description' l3_policy_id = 'l3p' - shared = 'True' + shared = 'true' args = [my_id, '--name', name, '--description', description, @@ -97,7 +97,7 @@ class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base): 'name': name, 'description': description, 'l3_policy_id': l3_policy_id, - 'shared': True + 'shared': shared } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_l3policy.py b/gbpclient/tests/unit/test_cli20_l3policy.py index 610a896..f1df4c9 100644 --- a/gbpclient/tests/unit/test_cli20_l3policy.py +++ b/gbpclient/tests/unit/test_cli20_l3policy.py @@ -53,7 +53,7 @@ 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']} routers = 'uuid1,uuid2' - shared = 'True' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, '--ip-version', ip_version, @@ -74,7 +74,7 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base): subnet_prefix_length=24, routers=['uuid1', 'uuid2'], external_segments= - expected_external_segments, shared=True) + expected_external_segments, shared=shared) def test_create_l3_policy_with_external_segment(self): """l3-policy-create with all params.""" @@ -124,7 +124,7 @@ 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' + shared = 'true' routers = 'uuid1,uuid2' args = ['--name', name, '--description', description, @@ -140,7 +140,7 @@ class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base): 'external_segments': expected_external_segments, 'routers': routers, 'routers': ['uuid1', 'uuid2'], - 'shared': True + 'shared': shared } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_natpool.py b/gbpclient/tests/unit/test_cli20_natpool.py index d3bf441..7da3a46 100644 --- a/gbpclient/tests/unit/test_cli20_natpool.py +++ b/gbpclient/tests/unit/test_cli20_natpool.py @@ -51,7 +51,7 @@ class CLITestV20NatPoolJSON(test_cli20.CLITestV20Base): ip_version = '4' ip_pool = '192.168.0.0/24' external_segment_id = "segmentid" - shared = 'True' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, '--ip-version', ip_version, @@ -68,7 +68,7 @@ class CLITestV20NatPoolJSON(test_cli20.CLITestV20Base): ip_version=4, ip_pool=ip_pool, external_segment_id=external_segment_id, - shared=True) + shared=shared) def test_list_nat_pools(self): """nat-pool-list.""" @@ -99,7 +99,7 @@ class CLITestV20NatPoolJSON(test_cli20.CLITestV20Base): description = 'My Nat Pool' my_id = 'someid' external_segment_id = "segmentid" - shared = 'True' + shared = 'true' args = ['--name', name, '--description', description, '--external-segment', external_segment_id, @@ -109,7 +109,7 @@ class CLITestV20NatPoolJSON(test_cli20.CLITestV20Base): 'name': name, 'description': description, 'external_segment_id': external_segment_id, - 'shared': True + 'shared': shared } 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 b65bda6..819365e 100644 --- a/gbpclient/tests/unit/test_cli20_networkservicepolicy.py +++ b/gbpclient/tests/unit/test_cli20_networkservicepolicy.py @@ -47,7 +47,7 @@ class CLITestV20NetworkServicePolicyJSON(test_cli20.CLITestV20Base): description = 'Mynsp' my_id = 'someid' network_svc_params = "type=ip_single,name=vip,value=self_subnet" - shared = 'True' + shared = 'true' args = ['--tenant_id', tenant_id, '--description', description, '--network-service-params', network_svc_params, @@ -59,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, shared=True) + tenant_id=tenant_id, shared=shared) def test_list_network_service_policies(self): """network-sercvice-policy-list.""" @@ -127,7 +127,7 @@ class CLITestV20NetworkServicePolicyJSON(test_cli20.CLITestV20Base): description = 'nsp description' my_id = 'someid' network_svc_params = "type=ip_single,name=vip,value=self_subnet" - shared = 'True' + shared = 'true' args = [my_id, '--name', name, '--description', description, @@ -139,7 +139,7 @@ class CLITestV20NetworkServicePolicyJSON(test_cli20.CLITestV20Base): 'description': description, 'network_service_params': [{"type": "ip_single", "name": "vip", "value": "self_subnet"}], - 'shared': True + 'shared': shared } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_policyaction.py b/gbpclient/tests/unit/test_cli20_policyaction.py index 5db728a..b2e9d58 100644 --- a/gbpclient/tests/unit/test_cli20_policyaction.py +++ b/gbpclient/tests/unit/test_cli20_policyaction.py @@ -46,7 +46,7 @@ class CLITestV20PolicyActionJSON(test_cli20.CLITestV20Base): my_id = 'my-id' action_type = "allow" action_value = "1234" - shared = 'True' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, '--action-type', action_type, @@ -60,7 +60,7 @@ class CLITestV20PolicyActionJSON(test_cli20.CLITestV20Base): tenant_id=tenant_id, description=description, action_type=action_type, - action_value=action_value, shared=True) + action_value=action_value, shared=shared) def test_list_policy_actions(self): """grouppolicy-policy-action-list.""" @@ -118,13 +118,13 @@ class CLITestV20PolicyActionJSON(test_cli20.CLITestV20Base): resource = 'policy_action' action_type = "allow" action_value = "1234" - shared = 'True' + shared = 'true' my_id = 'someid' cmd = gbp.UpdatePolicyAction(test_cli20.MyApp(sys.stdout), None) body = { 'action_type': action_type, 'action_value': action_value, - 'shared': True + 'shared': shared } args = [my_id, '--action-type', action_type, diff --git a/gbpclient/tests/unit/test_cli20_policyclassifier.py b/gbpclient/tests/unit/test_cli20_policyclassifier.py index c9d9f71..ce16b79 100644 --- a/gbpclient/tests/unit/test_cli20_policyclassifier.py +++ b/gbpclient/tests/unit/test_cli20_policyclassifier.py @@ -26,15 +26,16 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): resource = 'policy_classifier' cmd = gbp.CreatePolicyClassifier(test_cli20.MyApp(sys.stdout), None) name = 'my-name' + direction = 'bi' tenant_id = 'my-tenant' my_id = 'my-id' - args = ['--tenant-id', tenant_id, + args = ['--tenant-id', tenant_id, '--direction', direction, 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) + tenant_id=tenant_id, direction=direction) def test_create_policy_classifier_with_all_params(self): """grouppolicy-policy-classifier-create with all params.""" @@ -47,7 +48,7 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): protocol = 'tcp' port_range = '10-80' direction = 'in' - shared = 'True' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, '--protocol', protocol, @@ -63,7 +64,7 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): description=description, protocol=protocol, port_range=port_range, - direction=direction, shared=True) + direction=direction, shared=shared) def test_list_policy_classifiers(self): """grouppolicy-policy-classifier-list.""" @@ -125,12 +126,12 @@ class CLITestV20PolicyClassifierJSON(test_cli20.CLITestV20Base): direction = 'in' cmd = gbp.UpdatePolicyClassifier(test_cli20.MyApp(sys.stdout), None) my_id = 'someid' - shared = 'True' + shared = 'true' body = { 'protocol': protocol, 'port_range': port_range, 'direction': direction, - 'shared': True + 'shared': shared } args = [my_id, '--protocol', protocol, diff --git a/gbpclient/tests/unit/test_cli20_policyrule.py b/gbpclient/tests/unit/test_cli20_policyrule.py index 0df0589..49d15b8 100644 --- a/gbpclient/tests/unit/test_cli20_policyrule.py +++ b/gbpclient/tests/unit/test_cli20_policyrule.py @@ -44,14 +44,14 @@ class CLITestV20PolicyRuleJSON(test_cli20.CLITestV20Base): tenant_id = 'my-tenant' description = 'My PolicyRule' my_id = 'my-id' - enabled = True + enabled = "true" policy_classifier_id = 'pc-id' policy_actions_res = ["pa1", "pa2"] policy_actions_arg = "pa1,pa2" - shared = 'True' + shared = 'true' args = ['--tenant-id', tenant_id, '--description', description, - '--enabled', "True", + '--enabled', enabled, '--classifier', policy_classifier_id, '--actions', policy_actions_arg, '--shared', shared, @@ -65,7 +65,7 @@ class CLITestV20PolicyRuleJSON(test_cli20.CLITestV20Base): enabled=enabled, policy_classifier_id=policy_classifier_id, policy_actions=policy_actions_res, - shared=True) + shared=shared) def test_list_policy_rules(self): """grouppolicy-policy-rule-list.""" @@ -121,21 +121,21 @@ class CLITestV20PolicyRuleJSON(test_cli20.CLITestV20Base): def test_update_policy_rule_with_allparams(self): resource = 'policy_rule' - enabled = True + enabled = "true" policy_classifier_id = 'pc-id' policy_actions_res = ["pa1", "pa2"] policy_actions_arg = "pa1,pa2" my_id = 'someid' - shared = 'True' + 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, - 'shared': True + 'shared': shared } args = [my_id, - '--enabled', "True", + '--enabled', enabled, '--classifier', policy_classifier_id, '--actions', policy_actions_arg, '--shared', shared, ] diff --git a/gbpclient/tests/unit/test_cli20_policytargetgroup.py b/gbpclient/tests/unit/test_cli20_policytargetgroup.py index 0062bdf..3125417 100644 --- a/gbpclient/tests/unit/test_cli20_policytargetgroup.py +++ b/gbpclient/tests/unit/test_cli20_policytargetgroup.py @@ -52,7 +52,7 @@ class CLITestV20PolicyTargetGroupJSON(test_cli20.CLITestV20Base): 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' + shared = 'true' args = [name, '--tenant-id', tenant_id, '--description', description, @@ -77,7 +77,7 @@ class CLITestV20PolicyTargetGroupJSON(test_cli20.CLITestV20Base): network_service_policy_id] self._test_create_resource(resource, cmd, name, my_id, args, position_names, position_values, - tenant_id=tenant_id, shared=True) + tenant_id=tenant_id, shared=shared) def test_list_policy_target_groups(self): """policy-target-group-list.""" @@ -112,7 +112,7 @@ class CLITestV20PolicyTargetGroupJSON(test_cli20.CLITestV20Base): 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' + shared = 'true' args = [my_id, '--name', name, '--description', description, @@ -134,7 +134,7 @@ class CLITestV20PolicyTargetGroupJSON(test_cli20.CLITestV20Base): '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 + 'shared': shared } self._test_update_resource(resource, cmd, my_id, args, params) diff --git a/gbpclient/tests/unit/test_cli20_service_profile.py b/gbpclient/tests/unit/test_cli20_service_profile.py index 540c02d..82bc697 100644 --- a/gbpclient/tests/unit/test_cli20_service_profile.py +++ b/gbpclient/tests/unit/test_cli20_service_profile.py @@ -47,7 +47,7 @@ class CLITestV20ServiceProfileJSON(test_cli20.CLITestV20Base): name = 'my-name' description = 'My Service Profile' tenant_id = 'my-tenant' - shared = 'True' + shared = 'true' vendor = 'vendor' insertion_mode = 'some mode' service_type = 'servicetype1' @@ -67,7 +67,7 @@ class CLITestV20ServiceProfileJSON(test_cli20.CLITestV20Base): position_names, position_values, description=description, tenant_id=tenant_id, - shared=True, + shared=shared, vendor=vendor, insertion_mode=insertion_mode, service_type=service_type, @@ -138,7 +138,7 @@ class CLITestV20ServiceProfileJSON(test_cli20.CLITestV20Base): None) name = 'new-name' description = 'My Updated Service Profile' - shared = 'True' + shared = 'true' vendor = 'open-source' insertion_mode = 'another mode' service_type = 'servicetype2' @@ -146,7 +146,7 @@ class CLITestV20ServiceProfileJSON(test_cli20.CLITestV20Base): body = { 'name': name, 'description': description, - 'shared': True, + 'shared': shared, 'vendor': vendor, 'insertion_mode': insertion_mode, 'service_type': service_type, diff --git a/gbpclient/tests/unit/test_cli20_servicechain_node.py b/gbpclient/tests/unit/test_cli20_servicechain_node.py index 7b85f75..a1f34b6 100644 --- a/gbpclient/tests/unit/test_cli20_servicechain_node.py +++ b/gbpclient/tests/unit/test_cli20_servicechain_node.py @@ -51,7 +51,7 @@ class CLITestV20ServiceChainNodeJSON(test_cli20.CLITestV20Base): description = 'My Service Chain Node' service_profile_id = 'my-service-profile' my_id = 'my-id' - shared = 'True' + shared = 'true' args = ['--servicetype', service_type, '--config', config, '--tenant-id', tenant_id, @@ -67,7 +67,7 @@ class CLITestV20ServiceChainNodeJSON(test_cli20.CLITestV20Base): tenant_id=tenant_id, description=description, service_profile_id=service_profile_id, - shared=True) + shared=shared) def test_list_servicechain_nodes(self): """service-chain-node-list.""" @@ -132,16 +132,17 @@ class CLITestV20ServiceChainNodeJSON(test_cli20.CLITestV20Base): resource = 'servicechain_node' cmd = servicechain.UpdateServiceChainNode(test_cli20.MyApp(sys.stdout), None) + shared = 'true' body = { 'name': 'new_name', 'description': 'new_description', 'service_profile_id': 'new_service_profile_id', - 'shared': True, + 'shared': shared, } args = ['myid', '--name', 'new_name', '--description', 'new_description', '--service-profile', 'new_service_profile_id', - '--shared', 'True'] + '--shared', shared] self._test_update_resource(resource, cmd, 'myid', args, body) # REVISIT(rkukura): Not sure why the following two methods are diff --git a/gbpclient/tests/unit/test_cli20_servicechain_spec.py b/gbpclient/tests/unit/test_cli20_servicechain_spec.py index e4290c9..bc6397d 100644 --- a/gbpclient/tests/unit/test_cli20_servicechain_spec.py +++ b/gbpclient/tests/unit/test_cli20_servicechain_spec.py @@ -50,7 +50,7 @@ class CLITestV20ServiceChainSpecJSON(test_cli20.CLITestV20Base): tenant_id = 'my-tenant' description = 'My Service Chain Spec' my_id = 'my-id' - shared = 'True' + shared = 'true' args = ['--nodes', nodes_arg, '--tenant-id', tenant_id, '--description', description, @@ -61,7 +61,7 @@ class CLITestV20ServiceChainSpecJSON(test_cli20.CLITestV20Base): self._test_create_resource(resource, cmd, name, my_id, args, position_names, position_values, nodes=nodes_res, tenant_id=tenant_id, - description=description, shared=True) + description=description, shared=shared) def test_list_servicechain_specs(self): """service-chain-spec-list.""" @@ -126,18 +126,19 @@ class CLITestV20ServiceChainSpecJSON(test_cli20.CLITestV20Base): resource = 'servicechain_spec' cmd = servicechain.UpdateServiceChainSpec(test_cli20.MyApp(sys.stdout), None) + shared = 'true' nodes_arg = 'node1,node2' nodes_res = ['node1', 'node2'] body = { 'name': 'new_name', 'description': 'new_description', 'nodes': nodes_res, - 'shared': True, + 'shared': shared } args = ['myid', '--name', 'new_name', '--description', 'new_description', '--nodes', nodes_arg, - '--shared', 'True'] + '--shared', shared] self._test_update_resource(resource, cmd, 'myid', args, body) def test_update_servicechain_node_unset_nodes(self):