Replace basestring with six.string_types
basestring type is gone in Python 3, use six.string_types to make Cinder code compatible with Python 3. This patch was generated by the basestring operation of the sixer tool: https://pypi.python.org/pypi/sixer Blueprint cinder-python3 Change-Id: Ie1aedf1cbb9d3e54a996321cd586b875e69ac85a
This commit is contained in:
parent
fc1fd07d06
commit
49d930579b
@ -15,6 +15,7 @@
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
@ -222,7 +223,7 @@ class VolumeAdminController(AdminController):
|
||||
except KeyError:
|
||||
raise exc.HTTPBadRequest(explanation=_("Must specify 'host'"))
|
||||
force_host_copy = params.get('force_host_copy', False)
|
||||
if isinstance(force_host_copy, basestring):
|
||||
if isinstance(force_host_copy, six.string_types):
|
||||
try:
|
||||
force_host_copy = strutils.bool_from_string(force_host_copy,
|
||||
strict=True)
|
||||
|
@ -266,7 +266,7 @@ class VolumeActionsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
force = params.get('force', False)
|
||||
if isinstance(force, basestring):
|
||||
if isinstance(force, six.string_types):
|
||||
try:
|
||||
force = strutils.bool_from_string(force, strict=False)
|
||||
except ValueError:
|
||||
@ -337,7 +337,7 @@ class VolumeActionsController(wsgi.Controller):
|
||||
msg = _("Must specify readonly in request.")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
if isinstance(readonly_flag, basestring):
|
||||
if isinstance(readonly_flag, six.string_types):
|
||||
try:
|
||||
readonly_flag = strutils.bool_from_string(readonly_flag,
|
||||
strict=True)
|
||||
@ -382,7 +382,7 @@ class VolumeActionsController(wsgi.Controller):
|
||||
msg = _("Must specify bootable in request.")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
if isinstance(bootable, basestring):
|
||||
if isinstance(bootable, six.string_types):
|
||||
try:
|
||||
bootable = strutils.bool_from_string(bootable,
|
||||
strict=True)
|
||||
|
@ -208,7 +208,7 @@ class TemplateElement(object):
|
||||
def __getitem__(self, idx):
|
||||
"""Retrieve a child node by index or name."""
|
||||
|
||||
if isinstance(idx, basestring):
|
||||
if isinstance(idx, six.string_types):
|
||||
# Allow access by node name
|
||||
return self._childmap[idx]
|
||||
else:
|
||||
|
@ -22,6 +22,7 @@ import copy
|
||||
from oslo_context import context
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from cinder.i18n import _
|
||||
from cinder import policy
|
||||
@ -69,7 +70,7 @@ class RequestContext(context.RequestContext):
|
||||
self.remote_address = remote_address
|
||||
if not timestamp:
|
||||
timestamp = timeutils.utcnow()
|
||||
elif isinstance(timestamp, basestring):
|
||||
elif isinstance(timestamp, six.string_types):
|
||||
timestamp = timeutils.parse_isotime(timestamp)
|
||||
self.timestamp = timestamp
|
||||
self.quota_class = quota_class
|
||||
|
@ -1387,7 +1387,7 @@ def volume_get_all_by_host(context, host, filters=None):
|
||||
# now be either form below:
|
||||
# Host
|
||||
# Host#Pool
|
||||
if host and isinstance(host, basestring):
|
||||
if host and isinstance(host, six.string_types):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
host_attr = getattr(models.Volume, 'host')
|
||||
|
@ -400,13 +400,13 @@ def _convert_timestamps_to_datetimes(image_meta):
|
||||
# NOTE(bcwaldon): used to store non-string data in glance metadata
|
||||
def _json_loads(properties, attr):
|
||||
prop = properties[attr]
|
||||
if isinstance(prop, basestring):
|
||||
if isinstance(prop, six.string_types):
|
||||
properties[attr] = jsonutils.loads(prop)
|
||||
|
||||
|
||||
def _json_dumps(properties, attr):
|
||||
prop = properties[attr]
|
||||
if not isinstance(prop, basestring):
|
||||
if not isinstance(prop, six.string_types):
|
||||
properties[attr] = jsonutils.dumps(prop)
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from cinder import context
|
||||
from cinder import db
|
||||
@ -593,7 +594,7 @@ class QuotaEngine(object):
|
||||
if not quota_driver_class:
|
||||
quota_driver_class = CONF.quota_driver
|
||||
|
||||
if isinstance(quota_driver_class, basestring):
|
||||
if isinstance(quota_driver_class, six.string_types):
|
||||
quota_driver_class = importutils.import_object(quota_driver_class)
|
||||
|
||||
self._resources = {}
|
||||
|
@ -19,6 +19,7 @@ import re
|
||||
from eventlet import greenthread
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from cinder import utils
|
||||
|
||||
@ -78,7 +79,7 @@ def fake_execute(*cmd_parts, **kwargs):
|
||||
LOG.debug('Faked command matched %s' % fake_replier[0])
|
||||
break
|
||||
|
||||
if isinstance(reply_handler, basestring):
|
||||
if isinstance(reply_handler, six.string_types):
|
||||
# If the reply handler is a string, return it as stdout
|
||||
reply = reply_handler, ''
|
||||
else:
|
||||
|
@ -18,6 +18,7 @@ import re
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder.i18n import _, _LE
|
||||
@ -380,7 +381,7 @@ class CLIResponse(object):
|
||||
vs = []
|
||||
for k in keys:
|
||||
v = a.get(k, None)
|
||||
if isinstance(v, basestring) or v is None:
|
||||
if isinstance(v, six.string_types) or v is None:
|
||||
v = [v]
|
||||
if isinstance(v, list):
|
||||
vs.append(v)
|
||||
@ -414,7 +415,7 @@ class CLIResponse(object):
|
||||
else:
|
||||
yield []
|
||||
|
||||
if isinstance(self.raw, basestring):
|
||||
if isinstance(self.raw, six.string_types):
|
||||
stdout, stderr = self.raw, ''
|
||||
else:
|
||||
stdout, stderr = self.raw
|
||||
|
@ -34,6 +34,7 @@ import time
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder.i18n import _, _LE, _LW, _LI
|
||||
@ -375,7 +376,7 @@ class V6000Common(object):
|
||||
start = time.time()
|
||||
done = False
|
||||
|
||||
if isinstance(success_msgs, basestring):
|
||||
if isinstance(success_msgs, six.string_types):
|
||||
success_msgs = [success_msgs]
|
||||
|
||||
while not done:
|
||||
@ -435,7 +436,7 @@ class V6000Common(object):
|
||||
request_needed = True
|
||||
verify_needed = True
|
||||
|
||||
if isinstance(request_success_msgs, basestring):
|
||||
if isinstance(request_success_msgs, six.string_types):
|
||||
request_success_msgs = [request_success_msgs]
|
||||
|
||||
rargs = rargs if rargs else []
|
||||
|
Loading…
Reference in New Issue
Block a user