Remove usage of module py3kcompat

Module py3kcompat was removed from oslo-incubator. We need remove its
usage in client side firstly. This make us move smoothly when sync
oslo-incubator code.

Change-Id: I8b07c32c9852e747579a23685f3c8a07ac13ec01
Partial-Bug: #1280033
This commit is contained in:
Eric Guo 2014-02-14 08:43:12 +08:00 committed by ChangBo Guo(gcb)
parent bd72fb0a2e
commit d44e598692
14 changed files with 41 additions and 30 deletions

View File

@ -30,9 +30,10 @@ try:
except ImportError:
import simplejson as json
from six.moves.urllib import parse
from novaclient import exceptions
from novaclient.openstack.common.gettextutils import _
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient import service_catalog
from novaclient import utils
@ -325,7 +326,7 @@ class HTTPClient(object):
extract_token=False)
def authenticate(self):
magic_tuple = urlutils.urlsplit(self.auth_url)
magic_tuple = parse.urlsplit(self.auth_url)
scheme, netloc, path, query, frag = magic_tuple
port = magic_tuple.port
if port is None:
@ -343,7 +344,7 @@ class HTTPClient(object):
# TODO(sandy): Assume admin endpoint is 35357 for now.
# Ideally this is going to have to be provided by the service catalog.
new_netloc = netloc.replace(':%d' % port, ':%d' % (35357,))
admin_url = urlutils.urlunsplit(
admin_url = parse.urlunsplit(
(scheme, new_netloc, path, query, frag))
auth_url = self.auth_url

View File

@ -17,10 +17,10 @@
from datetime import datetime
import six
from six.moves.urllib import parse
from novaclient import client as base_client
from novaclient import exceptions
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient.openstack.common import strutils
from novaclient.tests import fakes
from novaclient.tests import utils
@ -64,7 +64,7 @@ class FakeHTTPClient(base_client.HTTPClient):
assert 'body' in kwargs
# Call the method
args = urlutils.parse_qsl(urlutils.urlparse(url)[4])
args = parse.parse_qsl(parse.urlparse(url)[4])
kwargs.update(args)
munged_url = url.rsplit('?', 1)[0]
munged_url = munged_url.strip('/').replace('/', '_').replace('.', '_')

View File

@ -14,9 +14,10 @@
migration interface
"""
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.gettextutils import _
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient import utils
@ -47,7 +48,7 @@ class MigrationManager(base.ManagerWithFind):
# order, then the encoded string will be consistent in Python 2&3.
new_opts = sorted(opts.items(), key=lambda x: x[0])
query_string = "?%s" % urlutils.urlencode(new_opts) if new_opts else ""
query_string = "?%s" % parse.urlencode(new_opts) if new_opts else ""
return self._list("/os-migrations%s" % query_string, "migrations")

View File

@ -16,10 +16,11 @@
Flavor interface.
"""
from six.moves.urllib import parse
from novaclient import base
from novaclient import exceptions
from novaclient.openstack.common.gettextutils import _
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient.openstack.common import strutils
from novaclient import utils
@ -112,7 +113,7 @@ class FlavorManager(base.ManagerWithFind):
# and flavors from their own projects only.
if not is_public:
qparams['is_public'] = is_public
query_string = "?%s" % urlutils.urlencode(qparams) if qparams else ""
query_string = "?%s" % parse.urlencode(qparams) if qparams else ""
detail = ""
if detailed:

View File

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
def _quote_domain(domain):
@ -24,7 +25,7 @@ def _quote_domain(domain):
but Routes tends to choke on them, so we need an extra level of
by-hand quoting here.
"""
return urlutils.quote(domain.replace('.', '%2E'))
return parse.quote(domain.replace('.', '%2E'))
class FloatingIPDNSDomain(base.Resource):
@ -101,7 +102,7 @@ class FloatingIPDNSEntryManager(base.Manager):
def get_for_ip(self, domain, ip):
"""Return a list of entries for the given domain and ip or name."""
qparams = {'ip': ip}
params = "?%s" % urlutils.urlencode(qparams)
params = "?%s" % parse.urlencode(qparams)
return self._list("/os-floating-ip-dns/%s/entries%s" %
(_quote_domain(domain), params),

View File

@ -17,8 +17,9 @@
Hypervisors interface (1.1 extension).
"""
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
class Hypervisor(base.Resource):
@ -48,7 +49,7 @@ class HypervisorManager(base.ManagerWithFind):
"""
target = 'servers' if servers else 'search'
url = ('/os-hypervisors/%s/%s' %
(urlutils.quote(hypervisor_match, safe=''), target))
(parse.quote(hypervisor_match, safe=''), target))
return self._list(url, 'hypervisors')
def get(self, hypervisor):

View File

@ -15,8 +15,10 @@
"""
Image interface.
"""
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
class Image(base.Resource):
@ -63,7 +65,7 @@ class ImageManager(base.ManagerWithFind):
detail = '/detail'
if limit:
params['limit'] = int(limit)
query = '?%s' % urlutils.urlencode(params) if params else ''
query = '?%s' % parse.urlencode(params) if params else ''
return self._list('/images%s%s' % (detail, query), 'images')
def delete(self, image):

View File

@ -12,8 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
class Limits(base.Resource):
@ -94,6 +95,6 @@ class LimitsManager(base.Manager):
opts['reserved'] = 1
if tenant_id:
opts['tenant_id'] = tenant_id
query_string = "?%s" % urlutils.urlencode(opts) if opts else ""
query_string = "?%s" % parse.urlencode(opts) if opts else ""
return self._get("/limits%s" % query_string, "limits")

View File

@ -18,9 +18,9 @@ Security group interface (1.1 extension).
"""
import six
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
class SecurityGroup(base.Resource):
@ -90,7 +90,7 @@ class SecurityGroupManager(base.ManagerWithFind):
qparams = dict((k, v) for (k, v) in six.iteritems(search_opts) if v)
query_string = '?%s' % urlutils.urlencode(qparams) if qparams else ''
query_string = '?%s' % parse.urlencode(qparams) if qparams else ''
return self._list('/os-security-groups%s' % query_string,
'security_groups')

View File

@ -22,10 +22,10 @@ Server interface.
import base64
import six
from six.moves.urllib import parse
from novaclient import base
from novaclient import crypto
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient.openstack.common import strutils
from novaclient.v1_1.security_groups import SecurityGroup
@ -573,7 +573,7 @@ class ServerManager(base.BootingManagerWithFind):
# order, then the encoded string will be consistent in Python 2&3.
if qparams:
new_qparams = sorted(qparams.items(), key=lambda x: x[0])
query_string = "?%s" % urlutils.urlencode(new_qparams)
query_string = "?%s" % parse.urlencode(new_qparams)
else:
query_string = ""

View File

@ -18,9 +18,9 @@ Volume interface (1.1 extension).
"""
import six
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
class Volume(base.Resource):
@ -89,7 +89,7 @@ class VolumeManager(base.ManagerWithFind):
qparams = dict((k, v) for (k, v) in six.iteritems(search_opts) if v)
query_string = '?%s' % urlutils.urlencode(qparams) if qparams else ''
query_string = '?%s' % parse.urlencode(qparams) if qparams else ''
if detailed is True:
return self._list("/volumes/detail%s" % query_string, "volumes")

View File

@ -17,7 +17,8 @@
Hypervisors interface
"""
from novaclient.openstack.common.py3kcompat import urlutils
from six.moves.urllib import parse
from novaclient.v1_1 import hypervisors
@ -35,7 +36,7 @@ class HypervisorManager(hypervisors.HypervisorManager):
:param servers: If True, server information is also retrieved.
"""
url = ('/os-hypervisors/search?query=%s' %
urlutils.quote(hypervisor_match, safe=''))
parse.quote(hypervisor_match, safe=''))
return self._list(url, 'hypervisors')
def servers(self, hypervisor):

View File

@ -16,8 +16,10 @@
"""
Image interface.
"""
from six.moves.urllib import parse
from novaclient import base
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient.openstack.common import strutils
@ -100,5 +102,5 @@ class ImageManager(base.ManagerWithFind):
detail = '/detail'
if limit:
params['limit'] = int(limit)
query = '?%s' % urlutils.urlencode(params) if params else ''
query = '?%s' % parse.urlencode(params) if params else ''
return self._list('/v1/images%s%s' % (detail, query), 'images')

View File

@ -22,10 +22,10 @@ Server interface.
import base64
import six
from six.moves.urllib import parse
from novaclient import base
from novaclient import crypto
from novaclient.openstack.common.py3kcompat import urlutils
from novaclient.openstack.common import strutils
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'
@ -507,7 +507,7 @@ class ServerManager(base.BootingManagerWithFind):
# order, then the encoded string will be consistent in Python 2&3.
if qparams:
new_qparams = sorted(qparams.items(), key=lambda x: x[0])
query_string = "?%s" % urlutils.urlencode(new_qparams)
query_string = "?%s" % parse.urlencode(new_qparams)
else:
query_string = ""