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
This commit is contained in:
parent
6ad1ab0c72
commit
b49bef7dd9
|
@ -20,7 +20,6 @@ Pluggable Weighing support
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder.scheduler import base_handler
|
from cinder.scheduler import base_handler
|
||||||
|
|
||||||
|
@ -67,8 +66,7 @@ class WeighedObject(object):
|
||||||
return "<WeighedObject '%s': %s>" % (self.obj, self.weight)
|
return "<WeighedObject '%s': %s>" % (self.obj, self.weight)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseWeigher(object, metaclass=abc.ABCMeta):
|
||||||
class BaseWeigher(object):
|
|
||||||
"""Base class for pluggable weighers.
|
"""Base class for pluggable weighers.
|
||||||
|
|
||||||
The attributes maxval and minval can be specified to set up the maximum
|
The attributes maxval and minval can be specified to set up the maximum
|
||||||
|
|
|
@ -17,7 +17,6 @@ import operator
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pyparsing
|
import pyparsing
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
@ -40,7 +39,7 @@ class EvalConstant(object):
|
||||||
|
|
||||||
def eval(self):
|
def eval(self):
|
||||||
result = self.value
|
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)):
|
re.match(r"^[a-zA-Z_]+\.[a-zA-Z_]+$", result)):
|
||||||
(which_dict, entry) = result.split('.')
|
(which_dict, entry) = result.split('.')
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder.scheduler.evaluator import evaluator
|
from cinder.scheduler.evaluator import evaluator
|
||||||
from cinder.scheduler import filters
|
from cinder.scheduler import filters
|
||||||
|
@ -120,7 +119,7 @@ class DriverFilter(filters.BaseBackendFilter):
|
||||||
|
|
||||||
if ('filter_function' in backend_caps and
|
if ('filter_function' in backend_caps and
|
||||||
backend_caps['filter_function'] is not None):
|
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', {})
|
qos_specs = filter_properties.get('qos_specs', {})
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder.scheduler import filters
|
from cinder.scheduler import filters
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ class JsonFilter(filters.BaseBackendFilter):
|
||||||
for arg in query[1:]:
|
for arg in query[1:]:
|
||||||
if isinstance(arg, list):
|
if isinstance(arg, list):
|
||||||
arg = self._process_filter(arg, backend_state)
|
arg = self._process_filter(arg, backend_state)
|
||||||
elif isinstance(arg, six.string_types):
|
elif isinstance(arg, str):
|
||||||
arg = self._parse_string(arg, backend_state)
|
arg = self._parse_string(arg, backend_state)
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
cooked_args.append(arg)
|
cooked_args.append(arg)
|
||||||
|
|
|
@ -21,6 +21,7 @@ Scheduler Service
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import functools
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -31,7 +32,6 @@ from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder.backup import rpcapi as backup_rpcapi
|
from cinder.backup import rpcapi as backup_rpcapi
|
||||||
from cinder import context
|
from cinder import context
|
||||||
|
@ -74,7 +74,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
def append_operation_type(name=None):
|
def append_operation_type(name=None):
|
||||||
def _decorator(schedule_function):
|
def _decorator(schedule_function):
|
||||||
@six.wraps(schedule_function)
|
@functools.wraps(schedule_function)
|
||||||
def inject_operation_decorator(*args, **kwargs):
|
def inject_operation_decorator(*args, **kwargs):
|
||||||
|
|
||||||
request_spec = kwargs.get('request_spec', None)
|
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.
|
# TODO(harlowja): move into a task that just does this later.
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = ("Failed to schedule_%(method)s: %(ex)s" %
|
msg = ("Failed to schedule_%(method)s: %(ex)s" %
|
||||||
{'method': method, 'ex': six.text_type(ex)})
|
{'method': method, 'ex': ex})
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
|
|
||||||
volume_state = updates['volume_state']
|
volume_state = updates['volume_state']
|
||||||
|
@ -515,7 +515,7 @@ class SchedulerManager(manager.CleanableManager, manager.Manager):
|
||||||
msg=None):
|
msg=None):
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = ("Failed to schedule_%(method)s: %(ex)s" %
|
msg = ("Failed to schedule_%(method)s: %(ex)s" %
|
||||||
{'method': method, 'ex': six.text_type(ex)})
|
{'method': method, 'ex': ex})
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
|
|
||||||
model_update = dict(status=state)
|
model_update = dict(status=state)
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder.scheduler.evaluator import evaluator
|
from cinder.scheduler.evaluator import evaluator
|
||||||
from cinder.scheduler import weights
|
from cinder.scheduler import weights
|
||||||
|
@ -124,7 +123,7 @@ class GoodnessWeigher(weights.BaseHostWeigher):
|
||||||
|
|
||||||
if ('goodness_function' in host_caps and
|
if ('goodness_function' in host_caps and
|
||||||
host_caps['goodness_function'] is not None):
|
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 {}
|
qos_specs = weight_properties.get('qos_specs', {}) or {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue