Merge "Python3: do not use urllib.urlencode"

This commit is contained in:
Jenkins 2015-07-03 08:35:43 +00:00 committed by Gerrit Code Review
commit f3fe4c22f5
7 changed files with 23 additions and 15 deletions

View File

@ -14,11 +14,11 @@
# under the License. # under the License.
import functools import functools
import urllib
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import six import six
from six.moves.urllib import parse
from webob import exc from webob import exc
from neutron.common import constants from neutron.common import constants
@ -60,7 +60,7 @@ def get_previous_link(request, items, id_key):
marker = items[0][id_key] marker = items[0][id_key]
params['marker'] = marker params['marker'] = marker
params['page_reverse'] = True params['page_reverse'] = True
return "%s?%s" % (request.path_url, urllib.urlencode(params)) return "%s?%s" % (request.path_url, parse.urlencode(params))
def get_next_link(request, items, id_key): def get_next_link(request, items, id_key):
@ -70,7 +70,7 @@ def get_next_link(request, items, id_key):
marker = items[-1][id_key] marker = items[-1][id_key]
params['marker'] = marker params['marker'] = marker
params.pop('page_reverse', None) params.pop('page_reverse', None)
return "%s?%s" % (request.path_url, urllib.urlencode(params)) return "%s?%s" % (request.path_url, parse.urlencode(params))
def get_limit_and_marker(request): def get_limit_and_marker(request):

View File

@ -16,12 +16,12 @@
from six.moves import http_client as httplib from six.moves import http_client as httplib
import urllib
import httplib2 import httplib2
from keystoneclient.v2_0 import client as keyclient from keystoneclient.v2_0 import client as keyclient
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from six.moves.urllib import parse
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.common import utils from neutron.common import utils
@ -158,7 +158,7 @@ class RequestHandler(object):
serverurl = SDNVE_URL % (controller_ip, self.port, self.base_url) serverurl = SDNVE_URL % (controller_ip, self.port, self.base_url)
myurl = serverurl + url myurl = serverurl + url
if params and isinstance(params, dict): if params and isinstance(params, dict):
myurl += '?' + urllib.urlencode(params, doseq=1) myurl += '?' + parse.urlencode(params, doseq=1)
try: try:
LOG.debug("Sending request to SDN-VE. url: " LOG.debug("Sending request to SDN-VE. url: "

View File

@ -14,7 +14,8 @@
# under the License. # under the License.
import json import json
import urllib
from six.moves.urllib import parse
from neutron.tests.tempest.common import service_client from neutron.tests.tempest.common import service_client
@ -95,7 +96,7 @@ class IdentityV3ClientJSON(service_client.ServiceClient):
"""Get the list of users.""" """Get the list of users."""
url = 'users' url = 'users'
if params: if params:
url += '?%s' % urllib.urlencode(params) url += '?%s' % parse.urlencode(params)
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
@ -134,7 +135,7 @@ class IdentityV3ClientJSON(service_client.ServiceClient):
def list_projects(self, params=None): def list_projects(self, params=None):
url = "projects" url = "projects"
if params: if params:
url += '?%s' % urllib.urlencode(params) url += '?%s' % parse.urlencode(params)
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)

View File

@ -14,7 +14,8 @@
# under the License. # under the License.
import json import json
import urllib
from six.moves.urllib import parse
from neutron.tests.tempest.common import service_client from neutron.tests.tempest.common import service_client
@ -64,7 +65,7 @@ class RegionClientJSON(service_client.ServiceClient):
"""List regions.""" """List regions."""
url = 'regions' url = 'regions'
if params: if params:
url += '?%s' % urllib.urlencode(params) url += '?%s' % parse.urlencode(params)
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)

View File

@ -12,8 +12,8 @@
import json import json
import time import time
import urllib
from six.moves.urllib import parse
from tempest_lib.common.utils import misc from tempest_lib.common.utils import misc
from tempest_lib import exceptions as lib_exc from tempest_lib import exceptions as lib_exc
@ -98,7 +98,7 @@ class NetworkClientJSON(service_client.ServiceClient):
def _list(**filters): def _list(**filters):
uri = self.get_uri(plural_name) uri = self.get_uri(plural_name)
if filters: if filters:
uri += '?' + urllib.urlencode(filters, doseq=1) uri += '?' + parse.urlencode(filters, doseq=1)
resp, body = self.get(uri) resp, body = self.get(uri)
result = {plural_name: self.deserialize_list(body)} result = {plural_name: self.deserialize_list(body)}
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
@ -124,7 +124,7 @@ class NetworkClientJSON(service_client.ServiceClient):
plural = self.pluralize(resource_name) plural = self.pluralize(resource_name)
uri = '%s/%s' % (self.get_uri(plural), resource_id) uri = '%s/%s' % (self.get_uri(plural), resource_id)
if fields: if fields:
uri += '?' + urllib.urlencode(fields, doseq=1) uri += '?' + parse.urlencode(fields, doseq=1)
resp, body = self.get(uri) resp, body = self.get(uri)
body = self.deserialize_single(body) body = self.deserialize_single(body)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)

View File

@ -20,13 +20,13 @@ import os
import re import re
import sys import sys
import time import time
import urllib
import uuid import uuid
import fixtures import fixtures
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
import six import six
from six.moves.urllib import parse
import testscenarios import testscenarios
import testtools import testtools
@ -590,7 +590,7 @@ class NegativeAutoTest(BaseTestCase):
if not json_dict: if not json_dict:
return url, None return url, None
elif method in ["GET", "HEAD", "PUT", "DELETE"]: elif method in ["GET", "HEAD", "PUT", "DELETE"]:
return "%s?%s" % (url, urllib.urlencode(json_dict)), None return "%s?%s" % (url, parse.urlencode(json_dict)), None
else: else:
return url, json.dumps(json_dict) return url, json.dumps(json_dict)

View File

@ -117,6 +117,7 @@ commands = python -m testtools.run \
neutron.tests.unit.plugins.oneconvergence.test_nvsd_agent \ neutron.tests.unit.plugins.oneconvergence.test_nvsd_agent \
neutron.tests.unit.plugins.oneconvergence.test_plugin_helper \ neutron.tests.unit.plugins.oneconvergence.test_plugin_helper \
neutron.tests.unit.plugins.oneconvergence.test_nvsdlib \ neutron.tests.unit.plugins.oneconvergence.test_nvsdlib \
neutron.tests.unit.plugins.ibm.test_sdnve_agent \
neutron.tests.unit.plugins.ibm.test_sdnve_api \ neutron.tests.unit.plugins.ibm.test_sdnve_api \
neutron.tests.unit.plugins.ml2.test_db \ neutron.tests.unit.plugins.ml2.test_db \
neutron.tests.unit.plugins.ml2.test_driver_context \ neutron.tests.unit.plugins.ml2.test_driver_context \
@ -131,6 +132,7 @@ commands = python -m testtools.run \
neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent \ neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent \
neutron.tests.unit.plugins.ml2.drivers.test_type_vxlan \ neutron.tests.unit.plugins.ml2.drivers.test_type_vxlan \
neutron.tests.unit.plugins.ml2.drivers.test_type_gre \ neutron.tests.unit.plugins.ml2.drivers.test_type_gre \
neutron.tests.unit.plugins.ml2.drivers.test_helpers \
neutron.tests.unit.plugins.ml2.drivers.arista.test_mechanism_arista \ neutron.tests.unit.plugins.ml2.drivers.arista.test_mechanism_arista \
neutron.tests.unit.plugins.ml2.drivers.test_type_local \ neutron.tests.unit.plugins.ml2.drivers.test_type_local \
neutron.tests.unit.plugins.ml2.drivers.mechanism_logger \ neutron.tests.unit.plugins.ml2.drivers.mechanism_logger \
@ -138,12 +140,14 @@ commands = python -m testtools.run \
neutron.tests.unit.plugins.ml2.drivers.cisco.apic.base \ neutron.tests.unit.plugins.ml2.drivers.cisco.apic.base \
neutron.tests.unit.plugins.ml2.drivers.cisco.apic.test_apic_topology \ neutron.tests.unit.plugins.ml2.drivers.cisco.apic.test_apic_topology \
neutron.tests.unit.plugins.ml2.drivers.test_type_flat \ neutron.tests.unit.plugins.ml2.drivers.test_type_flat \
neutron.tests.unit.plugins.ml2.drivers.test_type_vlan \
neutron.tests.unit.plugins.ml2.drivers.mechanism_test \ neutron.tests.unit.plugins.ml2.drivers.mechanism_test \
neutron.tests.unit.plugins.ml2.drivers.l2pop.rpc_manager.l2population_rpc_base \ neutron.tests.unit.plugins.ml2.drivers.l2pop.rpc_manager.l2population_rpc_base \
neutron.tests.unit.plugins.ml2.extensions.fake_extension \ neutron.tests.unit.plugins.ml2.extensions.fake_extension \
neutron.tests.unit.plugins.ml2.drivers.l2pop.rpc_manager.test_l2population_rpc \ neutron.tests.unit.plugins.ml2.drivers.l2pop.rpc_manager.test_l2population_rpc \
neutron.tests.unit.plugins.cisco.n1kv.fake_client \ neutron.tests.unit.plugins.cisco.n1kv.fake_client \
neutron.tests.unit.plugins.cisco.test_network_db \ neutron.tests.unit.plugins.cisco.test_network_db \
neutron.tests.unit.scheduler.test_dhcp_agent_scheduler \
neutron.tests.unit.db.test_l3_dvr_db \ neutron.tests.unit.db.test_l3_dvr_db \
neutron.tests.unit.db.test_migration \ neutron.tests.unit.db.test_migration \
neutron.tests.unit.db.test_agents_db \ neutron.tests.unit.db.test_agents_db \
@ -177,8 +181,10 @@ commands = python -m testtools.run \
neutron.tests.unit.agent.linux.test_ipset_manager \ neutron.tests.unit.agent.linux.test_ipset_manager \
neutron.tests.unit.agent.linux.test_iptables_firewall \ neutron.tests.unit.agent.linux.test_iptables_firewall \
neutron.tests.unit.agent.linux.test_ebtables_manager \ neutron.tests.unit.agent.linux.test_ebtables_manager \
neutron.tests.unit.agent.linux.test_iptables_firewall \
neutron.tests.unit.agent.linux.test_ebtables_driver \ neutron.tests.unit.agent.linux.test_ebtables_driver \
neutron.tests.unit.agent.linux.test_polling \ neutron.tests.unit.agent.linux.test_polling \
neutron.tests.unit.agent.linux.test_ip_lib \
neutron.tests.unit.agent.linux.test_ip_monitor \ neutron.tests.unit.agent.linux.test_ip_monitor \
neutron.tests.unit.agent.linux.test_iptables_manager \ neutron.tests.unit.agent.linux.test_iptables_manager \
neutron.tests.unit.agent.linux.test_external_process \ neutron.tests.unit.agent.linux.test_external_process \