commit a85ce6c8179cd0f57849c6fe5076b2a9be27e7df Author: xuanyandong Date: Wed Oct 7 09:59:56 2020 +0800 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 diff --git a/cinder/api/api_utils.py b/cinder/api/api_utils.py index d60bfd4..0fcba43 100644 --- a/cinder/api/api_utils.py +++ b/cinder/api/api_utils.py @@ -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): diff --git a/cinder/api/common.py b/cinder/api/common.py index 1723fc0..6b1099c 100644 --- a/cinder/api/common.py +++ b/cinder/api/common.py @@ -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 diff --git a/cinder/api/contrib/admin_actions.py b/cinder/api/contrib/admin_actions.py index 30424e9..931ec85 100644 --- a/cinder/api/contrib/admin_actions.py +++ b/cinder/api/contrib/admin_actions.py @@ -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 diff --git a/cinder/api/contrib/backups.py b/cinder/api/contrib/backups.py index 12df523..130644a 100644 --- a/cinder/api/contrib/backups.py +++ b/cinder/api/contrib/backups.py @@ -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 diff --git a/cinder/api/contrib/cgsnapshots.py b/cinder/api/contrib/cgsnapshots.py index e89f3d2..194c0b9 100644 --- a/cinder/api/contrib/cgsnapshots.py +++ b/cinder/api/contrib/cgsnapshots.py @@ -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 diff --git a/cinder/api/contrib/consistencygroups.py b/cinder/api/contrib/consistencygroups.py index 6f313c6..223c114 100644 --- a/cinder/api/contrib/consistencygroups.py +++ b/cinder/api/contrib/consistencygroups.py @@ -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 diff --git a/cinder/api/contrib/qos_specs_manage.py b/cinder/api/contrib/qos_specs_manage.py index 4a9479b..94412d3 100644 --- a/cinder/api/contrib/qos_specs_manage.py +++ b/cinder/api/contrib/qos_specs_manage.py @@ -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) diff --git a/cinder/api/contrib/services.py b/cinder/api/contrib/services.py index 81aab9d..4216742 100644 --- a/cinder/api/contrib/services.py +++ b/cinder/api/contrib/services.py @@ -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 diff --git a/cinder/api/contrib/snapshot_actions.py b/cinder/api/contrib/snapshot_actions.py index bd481cd..f463158 100644 --- a/cinder/api/contrib/snapshot_actions.py +++ b/cinder/api/contrib/snapshot_actions.py @@ -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 diff --git a/cinder/api/contrib/snapshot_manage.py b/cinder/api/contrib/snapshot_manage.py index b234540..f7ff4c5 100644 --- a/cinder/api/contrib/snapshot_manage.py +++ b/cinder/api/contrib/snapshot_manage.py @@ -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 diff --git a/cinder/api/contrib/snapshot_unmanage.py b/cinder/api/contrib/snapshot_unmanage.py index 1a4ba93..bf3e68a 100644 --- a/cinder/api/contrib/snapshot_unmanage.py +++ b/cinder/api/contrib/snapshot_unmanage.py @@ -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 diff --git a/cinder/api/contrib/types_extra_specs.py b/cinder/api/contrib/types_extra_specs.py index b9d5a49..27260bf 100644 --- a/cinder/api/contrib/types_extra_specs.py +++ b/cinder/api/contrib/types_extra_specs.py @@ -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 diff --git a/cinder/api/contrib/types_manage.py b/cinder/api/contrib/types_manage.py index a43b97f..2b38e8d 100644 --- a/cinder/api/contrib/types_manage.py +++ b/cinder/api/contrib/types_manage.py @@ -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) diff --git a/cinder/api/contrib/volume_actions.py b/cinder/api/contrib/volume_actions.py index 0db41c5..c39213c 100644 --- a/cinder/api/contrib/volume_actions.py +++ b/cinder/api/contrib/volume_actions.py @@ -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) diff --git a/cinder/api/contrib/volume_image_metadata.py b/cinder/api/contrib/volume_image_metadata.py index 2b7026b..25067af 100644 --- a/cinder/api/contrib/volume_image_metadata.py +++ b/cinder/api/contrib/volume_image_metadata.py @@ -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 diff --git a/cinder/api/contrib/volume_manage.py b/cinder/api/contrib/volume_manage.py index a9a46c0..d84b1d8 100644 --- a/cinder/api/contrib/volume_manage.py +++ b/cinder/api/contrib/volume_manage.py @@ -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 diff --git a/cinder/api/contrib/volume_transfer.py b/cinder/api/contrib/volume_transfer.py index 6e126ba..296a997 100644 --- a/cinder/api/contrib/volume_transfer.py +++ b/cinder/api/contrib/volume_transfer.py @@ -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 diff --git a/cinder/api/contrib/volume_type_access.py b/cinder/api/contrib/volume_type_access.py index 55fe944..9d4605d 100644 --- a/cinder/api/contrib/volume_type_access.py +++ b/cinder/api/contrib/volume_type_access.py @@ -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') diff --git a/cinder/api/contrib/volume_type_encryption.py b/cinder/api/contrib/volume_type_encryption.py index a1e8d31..8a78c66 100644 --- a/cinder/api/contrib/volume_type_encryption.py +++ b/cinder/api/contrib/volume_type_encryption.py @@ -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 diff --git a/cinder/api/contrib/volume_unmanage.py b/cinder/api/contrib/volume_unmanage.py index e6f5141..3259f31 100644 --- a/cinder/api/contrib/volume_unmanage.py +++ b/cinder/api/contrib/volume_unmanage.py @@ -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 diff --git a/cinder/api/middleware/auth.py b/cinder/api/middleware/auth.py index 1c277a8..f349050 100644 --- a/cinder/api/middleware/auth.py +++ b/cinder/api/middleware/auth.py @@ -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 diff --git a/cinder/api/middleware/fault.py b/cinder/api/middleware/fault.py index 463e857..b4cff73 100644 --- a/cinder/api/middleware/fault.py +++ b/cinder/api/middleware/fault.py @@ -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 diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 447d9f1..8559993 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -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 diff --git a/cinder/api/v2/limits.py b/cinder/api/v2/limits.py index 1066943..6d890d2 100644 --- a/cinder/api/v2/limits.py +++ b/cinder/api/v2/limits.py @@ -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 diff --git a/cinder/api/v2/snapshot_metadata.py b/cinder/api/v2/snapshot_metadata.py index 8a4da48..0776fed 100644 --- a/cinder/api/v2/snapshot_metadata.py +++ b/cinder/api/v2/snapshot_metadata.py @@ -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 diff --git a/cinder/api/v2/snapshots.py b/cinder/api/v2/snapshots.py index 66be31b..d29d223 100644 --- a/cinder/api/v2/snapshots.py +++ b/cinder/api/v2/snapshots.py @@ -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 diff --git a/cinder/api/v2/views/volumes.py b/cinder/api/v2/views/volumes.py index cc533d7..e69a03a 100644 --- a/cinder/api/v2/views/volumes.py +++ b/cinder/api/v2/views/volumes.py @@ -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'), diff --git a/cinder/api/v2/volume_metadata.py b/cinder/api/v2/volume_metadata.py index ea5b885..07df112 100644 --- a/cinder/api/v2/volume_metadata.py +++ b/cinder/api/v2/volume_metadata.py @@ -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 diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index 931cbbc..b59e8d0 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -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 diff --git a/cinder/api/v3/attachments.py b/cinder/api/v3/attachments.py index 0e6da5c..0280faf 100644 --- a/cinder/api/v3/attachments.py +++ b/cinder/api/v3/attachments.py @@ -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 diff --git a/cinder/api/v3/consistencygroups.py b/cinder/api/v3/consistencygroups.py index a076c18..03df311 100644 --- a/cinder/api/v3/consistencygroups.py +++ b/cinder/api/v3/consistencygroups.py @@ -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 diff --git a/cinder/api/v3/default_types.py b/cinder/api/v3/default_types.py index faf4fd2..d03ef5f 100644 --- a/cinder/api/v3/default_types.py +++ b/cinder/api/v3/default_types.py @@ -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 diff --git a/cinder/api/v3/group_snapshots.py b/cinder/api/v3/group_snapshots.py index d552a24..de8aa11 100644 --- a/cinder/api/v3/group_snapshots.py +++ b/cinder/api/v3/group_snapshots.py @@ -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 diff --git a/cinder/api/v3/group_specs.py b/cinder/api/v3/group_specs.py index abeeeeb..b1dae03 100644 --- a/cinder/api/v3/group_specs.py +++ b/cinder/api/v3/group_specs.py @@ -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 diff --git a/cinder/api/v3/group_types.py b/cinder/api/v3/group_types.py index 37f6351..2c7dab6 100644 --- a/cinder/api/v3/group_types.py +++ b/cinder/api/v3/group_types.py @@ -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) diff --git a/cinder/api/v3/groups.py b/cinder/api/v3/groups.py index 81fe3b6..2893907 100644 --- a/cinder/api/v3/groups.py +++ b/cinder/api/v3/groups.py @@ -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 diff --git a/cinder/api/v3/messages.py b/cinder/api/v3/messages.py index 51387c0..eb6791a 100644 --- a/cinder/api/v3/messages.py +++ b/cinder/api/v3/messages.py @@ -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 diff --git a/cinder/api/v3/snapshot_manage.py b/cinder/api/v3/snapshot_manage.py index a4aca61..dc3a867 100644 --- a/cinder/api/v3/snapshot_manage.py +++ b/cinder/api/v3/snapshot_manage.py @@ -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 diff --git a/cinder/api/v3/volume_manage.py b/cinder/api/v3/volume_manage.py index aa07a47..1551128 100644 --- a/cinder/api/v3/volume_manage.py +++ b/cinder/api/v3/volume_manage.py @@ -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 diff --git a/cinder/api/v3/volume_metadata.py b/cinder/api/v3/volume_metadata.py index 810afa7..e9edc53 100644 --- a/cinder/api/v3/volume_metadata.py +++ b/cinder/api/v3/volume_metadata.py @@ -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,8 +36,7 @@ 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') + data = data.encode('utf-8') checksum = hashlib.md5(data).hexdigest() return checksum in req.if_match.etags @@ -48,8 +46,7 @@ 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') + data = data.encode('utf-8') resp = webob.Response() resp.headers['Etag'] = hashlib.md5(data).hexdigest() resp.body = data diff --git a/cinder/api/v3/volume_transfer.py b/cinder/api/v3/volume_transfer.py index 9106ca4..cea38a9 100644 --- a/cinder/api/v3/volume_transfer.py +++ b/cinder/api/v3/volume_transfer.py @@ -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 diff --git a/cinder/api/v3/volumes.py b/cinder/api/v3/volumes.py index 5d97df4..e5357d4 100644 --- a/cinder/api/v3/volumes.py +++ b/cinder/api/v3/volumes.py @@ -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 diff --git a/cinder/api/v3/workers.py b/cinder/api/v3/workers.py index 41e2b7d..c586b06 100644 --- a/cinder/api/v3/workers.py +++ b/cinder/api/v3/workers.py @@ -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 diff --git a/cinder/api/validation/parameter_types.py b/cinder/api/validation/parameter_types.py index f174b58..bfb8d53 100644 --- a/cinder/api/validation/parameter_types.py +++ b/cinder/api/validation/parameter_types.py @@ -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 diff --git a/cinder/api/validation/validators.py b/cinder/api/validation/validators.py index df810d4..7369c1f 100644 --- a/cinder/api/validation/validators.py +++ b/cinder/api/validation/validators.py @@ -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): diff --git a/cinder/api/versions.py b/cinder/api/versions.py index 93f988b..7a7dced 100644 --- a/cinder/api/versions.py +++ b/cinder/api/versions.py @@ -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 diff --git a/cinder/api/views/versions.py b/cinder/api/views/versions.py index 0e92785..83f783d 100644 --- a/cinder/api/views/versions.py +++ b/cinder/api/views/versions.py @@ -16,9 +16,9 @@ import copy import re +import urllib from oslo_config import cfg -from six.moves import urllib versions_opts = [