diff --git a/gbp_test.sh b/gbp_test.sh index 37c4d39..c4c3638 100755 --- a/gbp_test.sh +++ b/gbp_test.sh @@ -25,12 +25,10 @@ fi echo "NOTE: User should be admin in order to perform all operations." sleep 3 -FORMAT=" --request-format xml" - # test the CRUD of network ptg=$ptg_name -gbp policy-target-group-create $FORMAT $NOAUTH $ptg || die "fail to create ptg $ptg" -temp=`gbp policy-target-group-list $FORMAT -- --name $ptg --fields id | wc -l` +gbp policy-target-group-create $NOAUTH $ptg || die "fail to create ptg $ptg" +temp=`gbp policy-target-group-list -- --name $ptg --fields id | wc -l` echo $temp if [ $temp -ne 5 ]; then die "PTGs with name $ptg is not unique or found" @@ -38,13 +36,13 @@ fi ptg_id=`gbp gbp-list -- --name $ptg --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2` echo "ID of PTG with name $ptg is $ptg_id" -gbp policy-target-group-show $FORMAT $ptg || die "fail to show PTG $ptg" -gbp policy-target-group-show $FORMAT $ptg_id || die "fail to show PTG $ptg_id" +gbp policy-target-group-show $ptg || die "fail to show PTG $ptg" +gbp policy-target-group-show $ptg_id || die "fail to show PTG $ptg_id" -gbp policy-target-group-update $FORMAT $ptg --description "desc" || die "fail to update PTG $ptg" -gbp policy-target-group-update $FORMAT $ptg_id --description "new" || die "fail to update PTG $ptg_id" +gbp policy-target-group-update $ptg --description "desc" || die "fail to update PTG $ptg" +gbp policy-target-group-update $ptg_id --description "new" || die "fail to update PTG $ptg_id" -gbp policy-target-group-list $FORMAT -c id -- --id fakeid || die "fail to list PTGs with column selection on empty list" +gbp policy-target-group-list -c id -- --id fakeid || die "fail to list PTGs with column selection on empty list" cleanup echo "Success! :)" diff --git a/gbpclient/tests/unit/test_cli20.py b/gbpclient/tests/unit/test_cli20.py index a19612d..2679679 100644 --- a/gbpclient/tests/unit/test_cli20.py +++ b/gbpclient/tests/unit/test_cli20.py @@ -20,7 +20,6 @@ from gbpclient import gbpshell from gbpclient.v2_0 import client as gbpclient API_VERSION = neutron_test_cli20.API_VERSION -FORMAT = neutron_test_cli20.FORMAT TOKEN = neutron_test_cli20.TOKEN ENDURL = neutron_test_cli20.ENDURL capture_std_streams = neutron_test_cli20.capture_std_streams @@ -86,25 +85,18 @@ class CLITestV20Base(neutron_test_cli20.CLITestV20Base): {self.id_field: myid}, } if name: ress[resource].update({'name': name}) - self.client.format = self.format resstr = self.client.serialize(ress) # url method body resource_plural = self.client.get_resource_plural(cmd_resource) path = getattr(self.client, resource_plural + "_path") if parent_id: path = path % parent_id - # Work around for LP #1217791. XML deserializer called from - # MyComparator does not decodes XML string correctly. - if self.format == 'json': - mox_body = MyComparator(body, self.client) - else: - mox_body = self.client.serialize(body) + mox_body = MyComparator(body, self.client) self.client.httpclient.request( - end_url(path, format=self.format), 'POST', + end_url(path), 'POST', body=mox_body, headers=mox.ContainsKeyValue( 'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr)) - args.extend(['--request-format', self.format]) self.mox.ReplayAll() cmd_parser = cmd.get_parser('create_' + resource) gbpshell.run_command(cmd, cmd_parser, args) diff --git a/gbpclient/v2_0/client.py b/gbpclient/v2_0/client.py index bd8089c..fcd4c77 100644 --- a/gbpclient/v2_0/client.py +++ b/gbpclient/v2_0/client.py @@ -75,24 +75,6 @@ def exception_handler_v20(status_code, error_content): message=msg) -class APIParamsCall(object): - """A Decorator to add support for format and tenant overriding - and filters - """ - def __init__(self, function): - self.function = function - - def __get__(self, instance, owner): - def with_params(*args, **kwargs): - _format = instance.format - if 'format' in kwargs: - instance.format = kwargs['format'] - ret = self.function(instance, *args, **kwargs) - instance.format = _format - return ret - return with_params - - class Client(clientV2_0.Client): """Client for the GBP API. @@ -193,30 +175,25 @@ class Client(clientV2_0.Client): # 8192 Is the default max URI len for eventlet.wsgi.server MAX_URI_LEN = 8192 - @APIParamsCall def list_extensions(self, **_params): """Fetch a list of all exts on server side.""" return self.get(self.extensions_path, params=_params) - @APIParamsCall def show_extension(self, ext_alias, **_params): """Fetch a list of all exts on server side.""" return self.get(self.extension_path % ext_alias, params=_params) - @APIParamsCall def list_policy_targets(self, retrieve_all=True, **_params): """Fetches a list of all policy targets for a tenant.""" # Pass filters in "params" argument to do_request return self.list('policy_targets', self.policy_targets_path, retrieve_all, **_params) - @APIParamsCall def show_policy_target(self, policy_target, **_params): """Fetches information of a certain policy target.""" return self.get(self.policy_target_path % (policy_target), params=_params) - @APIParamsCall def list_application_policy_groups(self, retrieve_all=True, **_params): """Fetches a list of all application_policy_groups for a tenant.""" # Pass filters in "params" argument to do_request @@ -224,19 +201,16 @@ class Client(clientV2_0.Client): self.application_policy_groups_path, retrieve_all, **_params) - @APIParamsCall def show_application_policy_group( self, application_policy_group, **_params): """Fetches information of a certain application_policy_group.""" return self.get(self.application_policy_group_path % ( application_policy_group), params=_params) - @APIParamsCall def create_application_policy_group(self, body=None): """Creates a new application_policy_group.""" return self.post(self.application_policy_groups_path, body=body) - @APIParamsCall def update_application_policy_group( self, application_policy_group, body=None): """Updates a application_policy_group.""" @@ -244,28 +218,23 @@ class Client(clientV2_0.Client): self.application_policy_group_path % (application_policy_group), body=body) - @APIParamsCall def delete_application_policy_group(self, application_policy_group): """Deletes the specified application_policy_group.""" return self.delete( self.application_policy_group_path % (application_policy_group)) - @APIParamsCall def create_policy_target(self, body=None): """Creates a new policy target.""" return self.post(self.policy_targets_path, body=body) - @APIParamsCall def update_policy_target(self, policy_target, body=None): """Updates a policy target.""" return self.put(self.policy_target_path % (policy_target), body=body) - @APIParamsCall def delete_policy_target(self, policy_target): """Deletes the specified policy target.""" return self.delete(self.policy_target_path % (policy_target)) - @APIParamsCall def list_policy_target_groups(self, retrieve_all=True, **_params): """Fetches a list of all policy target_groups for a tenant.""" # Pass filters in "params" argument to do_request @@ -273,58 +242,48 @@ class Client(clientV2_0.Client): self.policy_target_groups_path, retrieve_all, **_params) - @APIParamsCall def show_policy_target_group(self, policy_target_group, **_params): """Fetches information of a certain policy target_group.""" return self.get(self.policy_target_group_path % (policy_target_group), params=_params) - @APIParamsCall def create_policy_target_group(self, body=None): """Creates a new policy target_group.""" return self.post(self.policy_target_groups_path, body=body) - @APIParamsCall def update_policy_target_group(self, policy_target_group, body=None): """Updates a policy target_group.""" return self.put(self.policy_target_group_path % (policy_target_group), body=body) - @APIParamsCall def delete_policy_target_group(self, policy_target_group): """Deletes the specified policy target_group.""" return self.delete( self.policy_target_group_path % (policy_target_group)) - @APIParamsCall def list_l2_policies(self, retrieve_all=True, **_params): """Fetches a list of all l2_policies for a tenant.""" # Pass filters in "params" argument to do_request return self.list('l2_policies', self.l2_policies_path, retrieve_all, **_params) - @APIParamsCall def show_l2_policy(self, l2_policy, **_params): """Fetches information of a certain l2_policy.""" return self.get(self.l2_policy_path % (l2_policy), params=_params) - @APIParamsCall def create_l2_policy(self, body=None): """Creates a new l2_policy.""" return self.post(self.l2_policies_path, body=body) - @APIParamsCall def update_l2_policy(self, l2_policy, body=None): """Updates a l2_policy.""" return self.put(self.l2_policy_path % (l2_policy), body=body) - @APIParamsCall def delete_l2_policy(self, l2_policy): """Deletes the specified l2_policy.""" return self.delete(self.l2_policy_path % (l2_policy)) - @APIParamsCall def list_network_service_policies(self, retrieve_all=True, **_params): """Fetches a list of all network_service_policies for a tenant.""" # Pass filters in "params" argument to do_request @@ -332,32 +291,27 @@ class Client(clientV2_0.Client): self.network_service_policies_path, retrieve_all, **_params) - @APIParamsCall def show_network_service_policy(self, network_service_policy, **_params): """Fetches information of a certain network_service_policy.""" return self.get( self.network_service_policy_path % (network_service_policy), params=_params) - @APIParamsCall def create_network_service_policy(self, body=None): """Creates a new network_service_policy.""" return self.post(self.network_service_policies_path, body=body) - @APIParamsCall def update_network_service_policy(self, network_service_policy, body=None): """Updates a network_service_policy.""" return self.put( self.network_service_policy_path % (network_service_policy), body=body) - @APIParamsCall def delete_network_service_policy(self, network_service_policy): """Deletes the specified network_service_policy.""" return self.delete( self.network_service_policy_path % (network_service_policy)) - @APIParamsCall def list_external_policies(self, retrieve_all=True, **_params): """Fetches a list of all external_policies for a tenant.""" # Pass filters in "params" argument to do_request @@ -365,32 +319,27 @@ class Client(clientV2_0.Client): self.external_policies_path, retrieve_all, **_params) - @APIParamsCall def show_external_policy(self, external_policy, **_params): """Fetches information of a certain external_policy.""" return self.get( self.external_policy_path % (external_policy), params=_params) - @APIParamsCall def create_external_policy(self, body=None): """Creates a new external_policy.""" return self.post(self.external_policies_path, body=body) - @APIParamsCall def update_external_policy(self, external_policy, body=None): """Updates a external_policy.""" return self.put( self.external_policy_path % (external_policy), body=body) - @APIParamsCall def delete_external_policy(self, external_policy): """Deletes the specified external_policy.""" return self.delete( self.external_policy_path % (external_policy)) - @APIParamsCall def list_external_segments(self, retrieve_all=True, **_params): """Fetches a list of all external_segments for a tenant.""" # Pass filters in "params" argument to do_request @@ -398,32 +347,27 @@ class Client(clientV2_0.Client): self.external_segments_path, retrieve_all, **_params) - @APIParamsCall def show_external_segment(self, external_segment, **_params): """Fetches information of a certain external_segment.""" return self.get( self.external_segment_path % (external_segment), params=_params) - @APIParamsCall def create_external_segment(self, body=None): """Creates a new external_segment.""" return self.post(self.external_segments_path, body=body) - @APIParamsCall def update_external_segment(self, external_segment, body=None): """Updates a external_segment.""" return self.put( self.external_segment_path % (external_segment), body=body) - @APIParamsCall def delete_external_segment(self, external_segment): """Deletes the specified external_segment.""" return self.delete( self.external_segment_path % (external_segment)) - @APIParamsCall def list_nat_pools(self, retrieve_all=True, **_params): """Fetches a list of all nat_pools for a tenant.""" # Pass filters in "params" argument to do_request @@ -431,169 +375,139 @@ class Client(clientV2_0.Client): self.nat_pools_path, retrieve_all, **_params) - @APIParamsCall def show_nat_pool(self, nat_pool, **_params): """Fetches information of a certain nat_pool.""" return self.get(self.nat_pool_path % (nat_pool), params=_params) - @APIParamsCall def create_nat_pool(self, body=None): """Creates a new nat_pool.""" return self.post(self.nat_pools_path, body=body) - @APIParamsCall def update_nat_pool(self, nat_pool, body=None): """Updates a nat_pool.""" return self.put(self.nat_pool_path % (nat_pool), body=body) - @APIParamsCall def delete_nat_pool(self, nat_pool): """Deletes the specified nat_pool.""" return self.delete(self.nat_pool_path % (nat_pool)) - @APIParamsCall def list_l3_policies(self, retrieve_all=True, **_params): """Fetches a list of all l3_policies for a tenant.""" # Pass filters in "params" argument to do_request return self.list('l3_policies', self.l3_policies_path, retrieve_all, **_params) - @APIParamsCall def show_l3_policy(self, l3_policy, **_params): """Fetches information of a certain l3_policy.""" return self.get(self.l3_policy_path % (l3_policy), params=_params) - @APIParamsCall def create_l3_policy(self, body=None): """Creates a new l3_policy.""" return self.post(self.l3_policies_path, body=body) - @APIParamsCall def update_l3_policy(self, l3_policy, body=None): """Updates a l3_policy.""" return self.put(self.l3_policy_path % (l3_policy), body=body) - @APIParamsCall def delete_l3_policy(self, l3_policy): """Deletes the specified l3_policy.""" return self.delete(self.l3_policy_path % (l3_policy)) - @APIParamsCall def list_policy_classifiers(self, retrieve_all=True, **_params): """Fetches a list of all policy_classifiers for a tenant.""" # Pass filters in "params" argument to do_request return self.list('policy_classifiers', self.policy_classifiers_path, retrieve_all, **_params) - @APIParamsCall def show_policy_classifier(self, policy_classifier, **_params): """Fetches information of a certain policy_classifier.""" return self.get(self.policy_classifier_path % (policy_classifier), params=_params) - @APIParamsCall def create_policy_classifier(self, body=None): """Creates a new policy_classifier.""" return self.post(self.policy_classifiers_path, body=body) - @APIParamsCall def update_policy_classifier(self, policy_classifier, body=None): """Updates a policy_classifier.""" return self.put(self.policy_classifier_path % (policy_classifier), body=body) - @APIParamsCall def delete_policy_classifier(self, policy_classifier): """Deletes the specified policy_classifier.""" return self.delete(self.policy_classifier_path % (policy_classifier)) - @APIParamsCall def list_policy_actions(self, retrieve_all=True, **_params): """Fetches a list of all policy_actions for a tenant.""" # Pass filters in "params" argument to do_request return self.list('policy_actions', self.policy_actions_path, retrieve_all, **_params) - @APIParamsCall def show_policy_action(self, policy_action, **_params): """Fetches information of a certain policy_action.""" return self.get(self.policy_action_path % (policy_action), params=_params) - @APIParamsCall def create_policy_action(self, body=None): """Creates a new policy_action.""" return self.post(self.policy_actions_path, body=body) - @APIParamsCall def update_policy_action(self, policy_action, body=None): """Updates a policy_action.""" return self.put(self.policy_action_path % (policy_action), body=body) - @APIParamsCall def delete_policy_action(self, policy_action): """Deletes the specified policy_action.""" return self.delete(self.policy_action_path % (policy_action)) - @APIParamsCall def list_policy_rules(self, retrieve_all=True, **_params): """Fetches a list of all policy_rules for a tenant.""" # Pass filters in "params" argument to do_request return self.list('policy_rules', self.policy_rules_path, retrieve_all, **_params) - @APIParamsCall def show_policy_rule(self, policy_rule, **_params): """Fetches information of a certain policy_rule.""" return self.get(self.policy_rule_path % (policy_rule), params=_params) - @APIParamsCall def create_policy_rule(self, body=None): """Creates a new policy_rule.""" return self.post(self.policy_rules_path, body=body) - @APIParamsCall def update_policy_rule(self, policy_rule, body=None): """Updates a policy_rule.""" return self.put(self.policy_rule_path % (policy_rule), body=body) - @APIParamsCall def delete_policy_rule(self, policy_rule): """Deletes the specified policy_rule.""" return self.delete(self.policy_rule_path % (policy_rule)) - @APIParamsCall def list_policy_rule_sets(self, retrieve_all=True, **_params): """Fetches a list of all Policy Rule Sets for a tenant.""" # Pass filters in "params" argument to do_request return self.list('policy_rule_sets', self.policy_rule_sets_path, retrieve_all, **_params) - @APIParamsCall def show_policy_rule_set(self, policy_rule_set, **_params): """Fetches information of a certain Policy Rule Set.""" return self.get(self.policy_rule_set_path % (policy_rule_set), params=_params) - @APIParamsCall def create_policy_rule_set(self, body=None): """Creates a new Policy Rule Set.""" return self.post(self.policy_rule_sets_path, body=body) - @APIParamsCall def update_policy_rule_set(self, policy_rule_set, body=None): """Updates a Policy Rule Set.""" return self.put(self.policy_rule_set_path % (policy_rule_set), body=body) - @APIParamsCall def delete_policy_rule_set(self, policy_rule_set): """Deletes the specified Policy Rule Set.""" return self.delete(self.policy_rule_set_path % (policy_rule_set)) - @APIParamsCall def list_service_profiles(self, retrieve_all=True, **_params): """Fetches a list of all service profiles for a tenant.""" @@ -602,29 +516,24 @@ class Client(clientV2_0.Client): return self.list('service_profiles', self.service_profiles_path, retrieve_all, **_params) - @APIParamsCall def show_service_profile(self, service_profile, **_params): """Fetches information of a certain service profile.""" return self.get(self.service_profile_path % (service_profile), params=_params) - @APIParamsCall def create_service_profile(self, body=None): """Creates a new service profile.""" return self.post(self.service_profiles_path, body=body) - @APIParamsCall def update_service_profile(self, service_profile, body=None): """Updates a service profile.""" return self.put(self.service_profile_path % (service_profile), body=body) - @APIParamsCall def delete_service_profile(self, service_profile): """Deletes the specified service profile.""" return self.delete(self.service_profile_path % (service_profile)) - @APIParamsCall def list_servicechain_nodes(self, retrieve_all=True, **_params): """Fetches a list of all service chain nodes for a tenant.""" @@ -633,29 +542,24 @@ class Client(clientV2_0.Client): return self.list('servicechain_nodes', self.servicechain_nodes_path, retrieve_all, **_params) - @APIParamsCall def show_servicechain_node(self, servicechain_node, **_params): """Fetches information of a certain service chain node.""" return self.get(self.servicechain_node_path % (servicechain_node), params=_params) - @APIParamsCall def create_servicechain_node(self, body=None): """Creates a new service chain node.""" return self.post(self.servicechain_nodes_path, body=body) - @APIParamsCall def update_servicechain_node(self, servicechain_node, body=None): """Updates a service chain node.""" return self.put(self.servicechain_node_path % (servicechain_node), body=body) - @APIParamsCall def delete_servicechain_node(self, servicechain_node): """Deletes the specified service chain node.""" return self.delete(self.servicechain_node_path % (servicechain_node)) - @APIParamsCall def list_servicechain_specs(self, retrieve_all=True, **_params): """Fetches a list of all service chain specs for a tenant.""" # Pass filters in "params" argument to do_request @@ -663,29 +567,24 @@ class Client(clientV2_0.Client): return self.list('servicechain_specs', self.servicechain_specs_path, retrieve_all, **_params) - @APIParamsCall def show_servicechain_spec(self, servicechain_spec, **_params): """Fetches information of a certain service chain spec.""" return self.get(self.servicechain_spec_path % (servicechain_spec), params=_params) - @APIParamsCall def create_servicechain_spec(self, body=None): """Creates a new service chain spec.""" return self.post(self.servicechain_specs_path, body=body) - @APIParamsCall def update_servicechain_spec(self, servicechain_spec, body=None): """Updates a service chain spec.""" return self.put(self.servicechain_spec_path % (servicechain_spec), body=body) - @APIParamsCall def delete_servicechain_spec(self, servicechain_spec): """Deletes the specified service chain spec.""" return self.delete(self.servicechain_spec_path % (servicechain_spec)) - @APIParamsCall def list_servicechain_instances(self, retrieve_all=True, **_params): """Fetches a list of all service chain instances for a tenant.""" # Pass filters in "params" argument to do_request @@ -694,24 +593,20 @@ class Client(clientV2_0.Client): self.servicechain_instances_path, retrieve_all, **_params) - @APIParamsCall def show_servicechain_instance(self, servicechain_instance, **_params): """Fetches information of a certain service chain instance.""" return self.get(self.servicechain_instance_path % (servicechain_instance), params=_params) - @APIParamsCall def create_servicechain_instance(self, body=None): """Creates a new service chain instance.""" return self.post(self.servicechain_instances_path, body=body) - @APIParamsCall def update_servicechain_instance(self, servicechain_instance, body=None): """Updates a service chain instance.""" return self.put(self.servicechain_instance_path % (servicechain_instance), body=body) - @APIParamsCall def delete_servicechain_instance(self, servicechain_instance): """Deletes the specified service chain instance.""" return self.delete(self.servicechain_instance_path % diff --git a/requirements.txt b/requirements.txt index 585e429..4acb43b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr>=1.8 # Apache-2.0 +pbr!=2.1.0,>=2.0.0 # Apache-2.0 python-heatclient>=1.6.1 -python-neutronclient<6.3.0,>=5.1.0 -oslo.serialization>=1.10.0 # Apache-2.0 -oslo.utils>=3.18.0 # Apache-2.0 +python-neutronclient>=6.3.0 +oslo.serialization>=1.10.0,!=2.19.1 # Apache-2.0 +oslo.utils>=3.20.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index dff6d90..76df267 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,18 +3,17 @@ # process, which may cause wedges in the gate later. hacking<0.11,>=0.10.0 -coverage>=4.0 # Apache-2.0 +coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD +httpretty>=0.8.0,!=0.8.1,!=0.8.2,!=0.8.3 mox3!=0.19.0,>=0.7.0 # Apache-2.0 mock>=2.0 # BSD -httpretty>=0.8.0,!=0.8.1,!=0.8.2,!=0.8.3 -oslosphinx>=4.7.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0 -python-openstackclient>=3.3.0 # Apache-2.0 +python-openstackclient>=3.11.0 # Apache-2.0 python-subunit>=0.0.18 # Apache-2.0/BSD -reno>=1.8.0 # Apache-2.0 +reno!=2.3.1,>=1.8.0 # Apache-2.0 requests-mock>=1.1 # Apache-2.0 -sphinx!=1.3b1,<1.4,>=1.2.1 # BSD +sphinx>=1.6.2 # BSD testrepository>=0.0.18 # Apache-2.0/BSD testtools>=1.4.0 # MIT testscenarios>=0.4 # Apache-2.0/BSD