Browse Source

Remove six of dir cinder/scheduler/*

Replace the following items with Python 3 style code.

- six.add_metaclass
- six.string_types
- six.text_type
- six.wraps

Change-Id: I1a1d9bf7e26e436bc93fe0091ecaae8ca5593c42
Implements: blueprint six-removal
changes/26/756526/2
xuanyandong 10 months ago
parent
commit
b49bef7dd9
  1. 4
      cinder/scheduler/base_weight.py
  2. 3
      cinder/scheduler/evaluator/evaluator.py
  3. 3
      cinder/scheduler/filters/driver_filter.py
  4. 3
      cinder/scheduler/filters/json_filter.py
  5. 8
      cinder/scheduler/manager.py
  6. 3
      cinder/scheduler/weights/goodness.py

4
cinder/scheduler/base_weight.py

@ -20,7 +20,6 @@ Pluggable Weighing support
import abc
from oslo_log import log as logging
import six
from cinder.scheduler import base_handler
@ -67,8 +66,7 @@ class WeighedObject(object):
return "<WeighedObject '%s': %s>" % (self.obj, self.weight)
@six.add_metaclass(abc.ABCMeta)
class BaseWeigher(object):
class BaseWeigher(object, metaclass=abc.ABCMeta):
"""Base class for pluggable weighers.
The attributes maxval and minval can be specified to set up the maximum

3
cinder/scheduler/evaluator/evaluator.py

@ -17,7 +17,6 @@ import operator
import re
import pyparsing
import six
from cinder import exception
from cinder.i18n import _
@ -40,7 +39,7 @@ class EvalConstant(object):
def eval(self):
result = self.value
if (isinstance(result, six.string_types) and
if (isinstance(result, str) and
re.match(r"^[a-zA-Z_]+\.[a-zA-Z_]+$", result)):
(which_dict, entry) = result.split('.')
try:

3
cinder/scheduler/filters/driver_filter.py

@ -14,7 +14,6 @@
# under the License.
from oslo_log import log as logging
import six
from cinder.scheduler.evaluator import evaluator
from cinder.scheduler import filters
@ -120,7 +119,7 @@ class DriverFilter(filters.BaseBackendFilter):
if ('filter_function' in backend_caps and
backend_caps['filter_function'] is not None):
filter_function = six.text_type(backend_caps['filter_function'])
filter_function = str(backend_caps['filter_function'])
qos_specs = filter_properties.get('qos_specs', {})

3
cinder/scheduler/filters/json_filter.py

@ -16,7 +16,6 @@
import operator
from oslo_serialization import jsonutils
import six
from cinder.scheduler import filters
@ -127,7 +126,7 @@ class JsonFilter(filters.BaseBackendFilter):
for arg in query[1:]:
if isinstance(arg, list):
arg = self._process_filter(arg, backend_state)
elif isinstance(arg, six.string_types):
elif isinstance(arg, str):
arg = self._parse_string(arg, backend_state)
if arg is not None:
cooked_args.append(arg)

8
cinder/scheduler/manager.py

@ -21,6 +21,7 @@ Scheduler Service
import collections
from datetime import datetime
import functools
import eventlet
from oslo_config import cfg
@ -31,7 +32,6 @@ from oslo_utils import excutils
from oslo_utils import importutils
from oslo_utils import timeutils
from oslo_utils import versionutils
import six
from cinder.backup import rpcapi as backup_rpcapi
from cinder import context
@ -74,7 +74,7 @@ LOG = logging.getLogger(__name__)
def append_operation_type(name=None):
def _decorator(schedule_function):
@six.wraps(schedule_function)
@functools.wraps(schedule_function)
def inject_operation_decorator(*args, **kwargs):
request_spec = kwargs.get('request_spec', None)
@ -485,7 +485,7 @@ class SchedulerManager(manager.CleanableManager, manager.Manager):
# TODO(harlowja): move into a task that just does this later.
if not msg:
msg = ("Failed to schedule_%(method)s: %(ex)s" %
{'method': method, 'ex': six.text_type(ex)})
{'method': method, 'ex': ex})
LOG.error(msg)
volume_state = updates['volume_state']
@ -515,7 +515,7 @@ class SchedulerManager(manager.CleanableManager, manager.Manager):
msg=None):
if not msg:
msg = ("Failed to schedule_%(method)s: %(ex)s" %
{'method': method, 'ex': six.text_type(ex)})
{'method': method, 'ex': ex})
LOG.error(msg)
model_update = dict(status=state)

3
cinder/scheduler/weights/goodness.py

@ -13,7 +13,6 @@
# under the License.
from oslo_log import log as logging
import six
from cinder.scheduler.evaluator import evaluator
from cinder.scheduler import weights
@ -124,7 +123,7 @@ class GoodnessWeigher(weights.BaseHostWeigher):
if ('goodness_function' in host_caps and
host_caps['goodness_function'] is not None):
goodness_function = six.text_type(host_caps['goodness_function'])
goodness_function = str(host_caps['goodness_function'])
qos_specs = weight_properties.get('qos_specs', {}) or {}

Loading…
Cancel
Save