Remove six of dir cinder/api/*

Replace the following items with Python 3 style code.

- six.string_types
- six.text_type
- six.moves
- six.PY3
- six.unichr

Change-Id: Ic46ec5f13a0dc1986d9c01e0d11df827d7e17bb0
This commit is contained in:
xuanyandong 2020-10-07 09:59:56 +08:00
parent 5a389d3fad
commit a85ce6c817
47 changed files with 88 additions and 109 deletions

View File

@ -12,7 +12,6 @@
from oslo_log import log as logging
from oslo_utils import strutils
import six
import webob
from webob import exc
@ -44,7 +43,7 @@ def _parse_is_public(is_public):
def is_none_string(val):
"""Check if a string represents a None value."""
if not isinstance(val, six.string_types):
if not isinstance(val, str):
return False
return val.lower() == 'none'
@ -129,7 +128,7 @@ def validate_integer(value, name, min_value=None, max_value=None):
value = strutils.validate_integer(value, name, min_value, max_value)
return value
except ValueError as e:
raise webob.exc.HTTPBadRequest(explanation=six.text_type(e))
raise webob.exc.HTTPBadRequest(explanation=str(e))
def walk_class_hierarchy(clazz, encountered=None):

View File

@ -17,10 +17,10 @@ import enum
import json
import os
import re
import urllib
from oslo_config import cfg
from oslo_log import log as logging
from six.moves import urllib
import webob
from cinder.api import api_utils

View File

@ -11,11 +11,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_utils import strutils
from six.moves import http_client
import webob
from cinder.api import common

View File

@ -16,10 +16,10 @@
# under the License.
"""The backups api."""
from http import client as http_client
from oslo_log import log as logging
from oslo_utils import strutils
from six.moves import http_client
from webob import exc
from cinder.api import api_utils

View File

@ -14,11 +14,10 @@
# under the License.
"""The cgsnapshots api."""
from http import client as http_client
from oslo_log import log as logging
from oslo_log import versionutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -66,7 +65,7 @@ class CgsnapshotsController(wsgi.Controller):
cgsnapshot = self._get_cgsnapshot(context, id)
self.group_snapshot_api.delete_group_snapshot(context, cgsnapshot)
except exception.InvalidGroupSnapshot as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
raise exc.HTTPBadRequest(explanation=str(e))
except (exception.GroupSnapshotNotFound,
exception.PolicyNotAuthorized):
# Exceptions will be handled at the wsgi level

View File

@ -14,11 +14,11 @@
# under the License.
"""The consistencygroups api."""
from http import client as http_client
from oslo_log import log as logging
from oslo_log import versionutils
from oslo_utils import strutils
from six.moves import http_client
import webob
from webob import exc

View File

@ -14,11 +14,10 @@
# under the License.
"""The QoS specs extension"""
from http import client as http_client
from oslo_log import log as logging
from oslo_utils import timeutils
import six
from six.moves import http_client
import webob
from cinder.api import api_utils
@ -98,20 +97,20 @@ class QoSSpecsController(wsgi.Controller):
self._notify_qos_specs_error(context,
'qos_specs.create',
notifier_err)
raise webob.exc.HTTPBadRequest(explanation=six.text_type(err))
raise webob.exc.HTTPBadRequest(explanation=str(err))
except exception.QoSSpecsExists as err:
notifier_err = dict(name=name, error_message=err)
self._notify_qos_specs_error(context,
'qos_specs.create',
notifier_err)
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
raise webob.exc.HTTPConflict(explanation=str(err))
except exception.QoSSpecsCreateFailed as err:
notifier_err = dict(name=name, error_message=err)
self._notify_qos_specs_error(context,
'qos_specs.create',
notifier_err)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return self._view_builder.detail(req, spec)
@ -145,7 +144,7 @@ class QoSSpecsController(wsgi.Controller):
'qos_specs.update',
notifier_err)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return body
@ -255,7 +254,7 @@ class QoSSpecsController(wsgi.Controller):
'qos_specs.associations',
notifier_err)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return self._view_builder.associations(req, associates)
@ -300,14 +299,14 @@ class QoSSpecsController(wsgi.Controller):
self._notify_qos_specs_error(context,
'qos_specs.associate',
notifier_err)
raise webob.exc.HTTPBadRequest(explanation=six.text_type(err))
raise webob.exc.HTTPBadRequest(explanation=str(err))
except exception.QoSSpecsAssociateFailed as err:
notifier_err = dict(id=id, error_message=err)
self._notify_qos_specs_error(context,
'qos_specs.associate',
notifier_err)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return webob.Response(status_int=http_client.ACCEPTED)
@ -350,7 +349,7 @@ class QoSSpecsController(wsgi.Controller):
'qos_specs.disassociate',
notifier_err)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return webob.Response(status_int=http_client.ACCEPTED)
@ -383,7 +382,7 @@ class QoSSpecsController(wsgi.Controller):
'qos_specs.disassociate_all',
notifier_err)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return webob.Response(status_int=http_client.ACCEPTED)

View File

@ -12,12 +12,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import timeutils
from six.moves import http_client
import webob.exc
from cinder.api import common

View File

@ -11,9 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from cinder.api import extensions

View File

@ -11,9 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
from cinder.api.contrib import resource_common_manage
from cinder.api import extensions

View File

@ -11,9 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from webob import exc

View File

@ -15,7 +15,8 @@
"""The volume types extra specs extension"""
from six.moves import http_client
from http import client as http_client
import webob
from cinder.api import extensions

View File

@ -14,10 +14,9 @@
# under the License.
"""The volume types manage extension."""
from http import client as http_client
from oslo_utils import strutils
import six
from six.moves import http_client
import webob
from cinder.api import extensions
@ -76,7 +75,7 @@ class VolumeTypesManageController(wsgi.Controller):
except exception.VolumeTypeExists as err:
self._notify_volume_type_error(
context, 'volume_type.create', err, volume_type=vol_type)
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
raise webob.exc.HTTPConflict(explanation=str(err))
except exception.VolumeTypeNotFoundByName as err:
self._notify_volume_type_error(
context, 'volume_type.create', err, name=name)
@ -128,12 +127,12 @@ class VolumeTypesManageController(wsgi.Controller):
except exception.VolumeTypeExists as err:
self._notify_volume_type_error(
context, 'volume_type.update', err, volume_type=vol_type)
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
raise webob.exc.HTTPConflict(explanation=str(err))
except exception.VolumeTypeUpdateFailed as err:
self._notify_volume_type_error(
context, 'volume_type.update', err, volume_type=vol_type)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return self._view_builder.show(req, vol_type)

View File

@ -11,14 +11,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from castellan import key_manager
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_utils import strutils
import six
from six.moves import http_client
import webob
from cinder.api import extensions
@ -247,13 +245,13 @@ class VolumeActionsController(wsgi.Controller):
except exception.InvalidVolume as error:
raise webob.exc.HTTPBadRequest(explanation=error.msg)
except ValueError as error:
raise webob.exc.HTTPBadRequest(explanation=six.text_type(error))
raise webob.exc.HTTPBadRequest(explanation=str(error))
except messaging.RemoteError as error:
msg = "%(err_type)s: %(err_msg)s" % {'err_type': error.exc_type,
'err_msg': error.value}
raise webob.exc.HTTPBadRequest(explanation=msg)
except Exception as error:
raise webob.exc.HTTPBadRequest(explanation=six.text_type(error))
raise webob.exc.HTTPBadRequest(explanation=str(error))
return {'os-volume_upload_image': response}
@wsgi.response(http_client.ACCEPTED)

View File

@ -13,8 +13,9 @@
# under the License.
"""The Volume Image Metadata API extension."""
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from cinder.api import common

View File

@ -11,10 +11,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from oslo_utils import strutils
from six.moves import http_client
from cinder.api import api_utils
from cinder.api import common

View File

@ -12,9 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from webob import exc

View File

@ -12,9 +12,8 @@
# under the License.
"""The volume type access extension."""
from http import client as http_client
import six
from six.moves import http_client
import webob
from cinder.api import extensions
@ -106,7 +105,7 @@ class VolumeTypeActionController(wsgi.Controller):
volume_types.add_volume_type_access(context, id, project)
# Not found exception will be handled at the wsgi level
except exception.VolumeTypeAccessExists as err:
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
raise webob.exc.HTTPConflict(explanation=str(err))
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.action('removeProjectAccess')

View File

@ -14,8 +14,8 @@
# under the License.
"""The volume types encryption extension."""
from http import client as http_client
from six.moves import http_client
import webob
from cinder.api import extensions

View File

@ -11,9 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from cinder.api import extensions

View File

@ -17,14 +17,13 @@ Common Auth Middleware.
"""
from http import client as http_client
import os
from oslo_config import cfg
from oslo_log import log as logging
from oslo_middleware import request_id
from oslo_serialization import jsonutils
from six.moves import http_client
import webob.dec
import webob.exc

View File

@ -13,10 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
import six
from six.moves import http_client
import webob.dec
import webob.exc
@ -73,7 +72,7 @@ class FaultWrapper(base_wsgi.Middleware):
# including those that are safe to expose, see bug 1021373
if safe:
msg = (inner.msg if isinstance(inner, exception.CinderException)
else six.text_type(inner))
else str(inner))
params = {'exception': inner.__class__.__name__,
'explanation': msg}
outer.explanation = _('%(exception)s: %(explanation)s') % params

View File

@ -16,6 +16,7 @@
from collections import abc
import functools
from http import client as http_client
import inspect
import math
import time
@ -25,8 +26,6 @@ from oslo_serialization import jsonutils
from oslo_utils import encodeutils
from oslo_utils import excutils
from oslo_utils import strutils
import six
from six.moves import http_client
import webob
import webob.exc
@ -328,7 +327,7 @@ class ActionDispatcher(object):
def dispatch(self, *args, **kwargs):
"""Find and call local method."""
action = kwargs.pop('action', 'default')
action_method = getattr(self, six.text_type(action), self.default)
action_method = getattr(self, str(action), self.default)
return action_method(*args, **kwargs)
def default(self, data):
@ -535,11 +534,11 @@ class ResponseObject(object):
response = webob.Response()
response.status_int = self.code
for hdr, value in self._headers.items():
response.headers[hdr] = six.text_type(value)
response.headers['Content-Type'] = six.text_type(content_type)
response.headers[hdr] = str(value)
response.headers['Content-Type'] = str(content_type)
if self.obj is not None:
body = serializer.serialize(self.obj)
if isinstance(body, six.text_type):
if isinstance(body, str):
body = body.encode('utf-8')
response.body = body
@ -592,13 +591,13 @@ class ResourceExceptionHandler(object):
return True
if isinstance(ex_value, exception.NotAuthorized):
msg = six.text_type(ex_value)
msg = str(ex_value)
raise Fault(webob.exc.HTTPForbidden(explanation=msg))
elif isinstance(ex_value, exception.VersionNotFoundForAPIMethod):
raise
elif isinstance(ex_value, (exception.Invalid, exception.NotFound)):
raise Fault(exception.ConvertedException(
code=ex_value.code, explanation=six.text_type(ex_value)))
code=ex_value.code, explanation=str(ex_value)))
elif isinstance(ex_value, TypeError):
LOG.exception('Exception handling resource:')
raise Fault(webob.exc.HTTPBadRequest())
@ -813,10 +812,10 @@ class Resource(wsgi.Application):
request.set_api_version_request(request.url)
except exception.InvalidAPIVersionString as e:
return Fault(webob.exc.HTTPBadRequest(
explanation=six.text_type(e)))
explanation=str(e)))
except exception.InvalidGlobalAPIVersion as e:
return Fault(webob.exc.HTTPNotAcceptable(
explanation=six.text_type(e)))
explanation=str(e)))
# Identify the action, its arguments, and the requested
# content type
@ -1114,8 +1113,7 @@ class ControllerMetaclass(type):
return result
@six.add_metaclass(ControllerMetaclass)
class Controller(object):
class Controller(object, metaclass=ControllerMetaclass):
"""Default controller."""
_view_builder_class = None
@ -1252,7 +1250,7 @@ class Controller(object):
'display_name', 'display_description']:
value = body.get(attribute)
if value is not None:
if isinstance(value, six.string_types):
if isinstance(value, str):
body[attribute] = value.strip()
if check_length:
try:
@ -1273,7 +1271,7 @@ class Controller(object):
:param remove_whitespaces: True if trimming whitespaces is needed
else False
"""
if isinstance(value, six.string_types) and remove_whitespaces:
if isinstance(value, str) and remove_whitespaces:
value = value.strip()
try:
utils.check_string_length(value, entity_name,
@ -1330,7 +1328,7 @@ class Fault(webob.exc.HTTPException):
}[content_type]
body = serializer.serialize(fault_data)
if isinstance(body, six.text_type):
if isinstance(body, str):
body = body.encode('utf-8')
self.wrapped_exc.body = body
self.wrapped_exc.content_type = content_type

View File

@ -19,13 +19,13 @@ Module dedicated functions/classes dealing with rate limiting requests.
import collections
import copy
from http import client as http_client
import math
import re
import time
from oslo_serialization import jsonutils
from oslo_utils import importutils
from six.moves import http_client
import webob.dec
import webob.exc

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from six.moves import http_client
import webob
from webob import exc

View File

@ -14,10 +14,10 @@
# under the License.
"""The volumes snapshots api."""
from http import client as http_client
from oslo_log import log as logging
from oslo_utils import strutils
from six.moves import http_client
import webob
from cinder.api import api_utils

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from cinder.api import common
from cinder import group as group_api
from cinder.objects import fields
@ -83,7 +81,7 @@ class ViewBuilder(common.ViewBuilder):
'metadata': self._get_volume_metadata(volume),
'links': self._get_links(request, volume['id']),
'user_id': volume.get('user_id'),
'bootable': six.text_type(volume.get('bootable')).lower(),
'bootable': str(volume.get('bootable')).lower(),
'encrypted': self._is_volume_encrypted(volume),
'replication_status': volume.get('replication_status'),
'consistencygroup_id': volume.get('consistencygroup_id'),

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from six.moves import http_client
import webob
from cinder.api import common

View File

@ -15,12 +15,12 @@
"""The volumes api."""
from http import client as http_client
from oslo_config import cfg
from oslo_log import log as logging
from oslo_log import versionutils
from oslo_utils import uuidutils
from six.moves import http_client
import webob
from webob import exc

View File

@ -11,9 +11,9 @@
# under the License.
"""The volumes attachments API."""
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from cinder.api import api_utils

View File

@ -12,9 +12,9 @@
# under the License.
"""The consistencygroups V3 API."""
from http import client as http_client
from oslo_log import log as logging
from six.moves import http_client
import webob
from webob import exc

View File

@ -14,9 +14,9 @@
# under the License.
"""The resource filters api."""
from http import client as http_client
from keystoneauth1 import exceptions as ks_exc
from six.moves import http_client
from webob import exc
from cinder.api import microversions as mv

View File

@ -14,10 +14,9 @@
# under the License.
"""The group_snapshots API."""
from http import client as http_client
from oslo_log import log as logging
import six
from six.moves import http_client
import webob
from webob import exc
@ -83,7 +82,7 @@ class GroupSnapshotsController(wsgi.Controller):
self.group_snapshot_api.delete_group_snapshot(context,
group_snapshot)
except exception.InvalidGroupSnapshot as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
raise exc.HTTPBadRequest(explanation=str(e))
except (exception.GroupSnapshotNotFound,
exception.PolicyNotAuthorized):
# Not found exception will be handled at the wsgi level

View File

@ -13,8 +13,8 @@
# under the License.
"""The group types specs controller"""
from http import client as http_client
from six.moves import http_client
import webob
from cinder.api import microversions as mv

View File

@ -13,10 +13,9 @@
# under the License.
"""The group type & group type specs controller."""
from http import client as http_client
from oslo_utils import strutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -81,7 +80,7 @@ class GroupTypesController(wsgi.Controller):
except exception.GroupTypeExists as err:
self._notify_group_type_error(
context, 'group_type.create', err, group_type=grp_type)
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
raise webob.exc.HTTPConflict(explanation=str(err))
except exception.GroupTypeNotFoundByName as err:
self._notify_group_type_error(
context, 'group_type.create', err, name=name)
@ -126,16 +125,16 @@ class GroupTypesController(wsgi.Controller):
except exception.GroupTypeNotFound as err:
self._notify_group_type_error(
context, 'group_type.update', err, id=id)
raise webob.exc.HTTPNotFound(explanation=six.text_type(err))
raise webob.exc.HTTPNotFound(explanation=str(err))
except exception.GroupTypeExists as err:
self._notify_group_type_error(
context, 'group_type.update', err, group_type=grp_type)
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
raise webob.exc.HTTPConflict(explanation=str(err))
except exception.GroupTypeUpdateFailed as err:
self._notify_group_type_error(
context, 'group_type.update', err, group_type=grp_type)
raise webob.exc.HTTPInternalServerError(
explanation=six.text_type(err))
explanation=str(err))
return self._view_builder.show(req, grp_type)

View File

@ -13,11 +13,11 @@
# under the License.
"""The groups controller."""
from http import client as http_client
from oslo_log import log as logging
from oslo_utils import strutils
from oslo_utils import uuidutils
from six.moves import http_client
import webob
from webob import exc

View File

@ -12,8 +12,8 @@
"""The messages API."""
from http import client as http_client
from six.moves import http_client
import webob
from cinder.api import common

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import http_client
from http import client as http_client
from cinder.api.contrib import snapshot_manage as snapshot_manage_v2
from cinder.api import microversions as mv

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import http_client
from http import client as http_client
from cinder.api.contrib import volume_manage as volume_manage_v2
from cinder.api import microversions as mv

View File

@ -16,10 +16,9 @@
"""The volume metadata V3 api."""
import hashlib
from http import client as http_client
from oslo_serialization import jsonutils
import six
from six.moves import http_client
import webob
from cinder.api import microversions as mv
@ -37,7 +36,6 @@ class Controller(volume_meta_v2.Controller):
context = req.environ['cinder.context']
metadata = self._get_metadata(context, volume_id)
data = jsonutils.dumps({"metadata": metadata})
if six.PY3:
data = data.encode('utf-8')
checksum = hashlib.md5(data).hexdigest()
return checksum in req.if_match.etags
@ -48,7 +46,6 @@ class Controller(volume_meta_v2.Controller):
metadata = super(Controller, self).index(req, volume_id)
if req_version.matches(mv.ETAGS):
data = jsonutils.dumps(metadata)
if six.PY3:
data = data.encode('utf-8')
resp = webob.Response()
resp.headers['Etag'] = hashlib.md5(data).hexdigest()

View File

@ -11,10 +11,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_log import log as logging
from oslo_utils import strutils
from six.moves import http_client
from webob import exc
from cinder.api import common

View File

@ -12,12 +12,11 @@
# under the License.
"""The volumes V3 api."""
from http import client as http_client
from oslo_log import log as logging
from oslo_log import versionutils
from oslo_utils import timeutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -242,7 +241,7 @@ class VolumeController(volumes_v2.VolumeController):
's_id': l_snap.id})
self.volume_api.revert_to_snapshot(context, volume, l_snap)
except (exception.InvalidVolume, exception.InvalidSnapshot) as e:
raise exc.HTTPConflict(explanation=six.text_type(e))
raise exc.HTTPConflict(explanation=str(e))
def _get_image_snapshot(self, context, image_uuid):
image_snapshot = None

View File

@ -12,10 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from http import client as http_client
from oslo_utils import strutils
from oslo_utils import timeutils
from six.moves import http_client
from cinder.api import microversions as mv
from cinder.api.openstack import wsgi

View File

@ -22,8 +22,6 @@ import copy
import re
import unicodedata
import six
from cinder.common import constants
@ -43,7 +41,7 @@ def _is_printable(char):
def _get_all_chars():
for i in range(0xFFFF):
yield six.unichr(i)
yield chr(i)
# build a regex that matches all printable characters. This allows

View File

@ -26,7 +26,6 @@ from oslo_serialization import base64
from oslo_utils import strutils
from oslo_utils import timeutils
from oslo_utils import uuidutils
import six
import webob.exc
from cinder.api import api_utils
@ -198,7 +197,7 @@ def _validate_progress(progress):
@jsonschema.FormatChecker.cls_checks('base64')
def _validate_base64_format(instance):
try:
if isinstance(instance, six.text_type):
if isinstance(instance, str):
instance = instance.encode('utf-8')
base64.decode_as_bytes(instance)
except TypeError:
@ -479,7 +478,7 @@ class _SchemaValidator(object):
except TypeError as ex:
# NOTE: If passing non string value to patternProperties parameter,
# TypeError happens. Here is for catching the TypeError.
detail = six.text_type(ex)
detail = str(ex)
raise exception.ValidationError(detail=detail)
def _number_from_str(self, param_value):

View File

@ -16,9 +16,9 @@
import copy
from http import client as http_client
from oslo_config import cfg
from six.moves import http_client
from cinder.api import extensions
from cinder.api import openstack

View File

@ -16,9 +16,9 @@
import copy
import re
import urllib
from oslo_config import cfg
from six.moves import urllib
versions_opts = [