Fixes python 3 urllib quote / unquote usage

Python 3's urllib module no longer contains quote / unquote. Instead,
they have been moved to urllib.parse.

six.moves.urllib will contain the parse submodule on both py2.7 and py3.

Enables some python3 unit tests.

Partially Implements: blueprint nova-python3-newton

Change-Id: I9c85e7179ef1178817cb1fe9aa8b574006e740f8
This commit is contained in:
Claudiu Belu 2016-02-11 01:36:31 +02:00
parent dbf9bf0703
commit 47d0e144da
8 changed files with 13 additions and 21 deletions

View File

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
from oslo_utils import netutils
from six.moves import urllib
import webob
from nova.api.openstack import common
@ -68,7 +67,7 @@ def _unquote_domain(domain):
but Routes tends to choke on them, so we need an extra level of
by-hand quoting here.
"""
return urllib.unquote(domain).replace('%2E', '.')
return urllib.parse.unquote(domain).replace('%2E', '.')
def _create_dns_entry(ip, name, domain):

View File

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
from oslo_utils import netutils
from six.moves import urllib
import webob
from nova.api.openstack import extensions
@ -65,7 +64,7 @@ def _unquote_domain(domain):
but Routes tends to choke on them, so we need an extra level of
by-hand quoting here.
"""
return urllib.unquote(domain).replace('%2E', '.')
return urllib.parse.unquote(domain).replace('%2E', '.')
def _create_dns_entry(ip, name, domain):

View File

@ -57,7 +57,6 @@ from __future__ import print_function
import argparse
import os
import sys
import urllib
import decorator
import netaddr
@ -1086,7 +1085,7 @@ class CellCommands(object):
is_parent = True
values = {'name': name,
'is_parent': is_parent,
'transport_url': urllib.unquote(str(transport_url)),
'transport_url': urlparse.unquote(str(transport_url)),
'weight_offset': float(woffset),
'weight_scale': float(wscale)}
ctxt = context.get_admin_context()

View File

@ -17,7 +17,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
from six.moves import urllib
from nova import exception
from nova.i18n import _
@ -32,7 +32,7 @@ class SecurityGroupBase(object):
def parse_cidr(self, cidr):
if cidr:
try:
cidr = urllib.unquote(cidr).decode()
cidr = urllib.parse.unquote(cidr).decode()
except Exception as e:
self.raise_invalid_cidr(cidr, e)

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
from six.moves import urllib
import nova.conf
from nova.tests.functional.api_sample_tests import api_sample_base
@ -35,7 +35,7 @@ class InstanceUsageAuditLogJsonTest(api_sample_base.ApiSampleTestBaseV21):
def test_show_instance_usage_audit_log(self):
response = self._do_get('os-instance_usage_audit_log/%s' %
urllib.quote('2012-07-05 10:00:00'))
urllib.parse.quote('2012-07-05 10:00:00'))
self._verify_response('inst-usage-audit-log-show-get-resp',
{}, response, 200)

View File

@ -14,9 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
import mock
from six.moves import urllib
import webob
from nova.api.openstack.compute import floating_ip_dns \
@ -48,7 +47,7 @@ def _quote_domain(domain):
by-hand quoting here. This function needs to duplicate the one in
python-novaclient/novaclient/v1_1/floating_ip_dns.py
"""
return urllib.quote(domain.replace('.', '%2E'))
return urllib.parse.quote(domain.replace('.', '%2E'))
def network_api_get_floating_ip(self, context, id):

View File

@ -14,9 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
from eventlet import tpool
from six.moves import urllib
try:
import rados
@ -168,7 +167,7 @@ class RBDDriver(object):
if not url.startswith(prefix):
reason = _('Not stored in rbd')
raise exception.ImageUnacceptable(image_id=url, reason=reason)
pieces = map(urllib.unquote, url[len(prefix):].split('/'))
pieces = map(urllib.parse.unquote, url[len(prefix):].split('/'))
if '' in pieces:
reason = _('Blank components')
raise exception.ImageUnacceptable(image_id=url, reason=reason)

View File

@ -23,8 +23,6 @@ nova.tests.unit.api.openstack.compute.test_extended_server_attributes.ExtendedSe
nova.tests.unit.api.openstack.compute.test_extended_server_attributes.ExtendedServerAttributesTestV23
nova.tests.unit.api.openstack.compute.test_floating_ip_dns.FloatingIPDNSDomainPolicyEnforcementV21
nova.tests.unit.api.openstack.compute.test_floating_ip_dns.FloatingIPDNSEntryPolicyEnforcementV21
nova.tests.unit.api.openstack.compute.test_floating_ip_dns.FloatingIpDNSTestV2
nova.tests.unit.api.openstack.compute.test_floating_ip_dns.FloatingIpDNSTestV21
nova.tests.unit.api.openstack.compute.test_hide_server_addresses.HideServerAddressesTestV2
nova.tests.unit.api.openstack.compute.test_hide_server_addresses.HideServerAddressesTestV21
nova.tests.unit.api.openstack.compute.test_keypairs.KeypairsTestV2
@ -102,7 +100,6 @@ nova.tests.unit.test_metadata.MetadataHandlerTestCase
nova.tests.unit.test_metadata.MetadataPasswordTestCase
nova.tests.unit.test_metadata.MetadataTestCase
nova.tests.unit.test_metadata.OpenStackMetadataTestCase
nova.tests.unit.test_nova_manage.CellCommandsTestCase
nova.tests.unit.test_pipelib.PipelibTest
nova.tests.unit.test_policy.AdminRolePolicyTestCase
nova.tests.unit.test_quota.QuotaIntegrationTestCase