diff --git a/sahara/service/coordinator.py b/sahara/service/coordinator.py index 282de87bea..c03179ce7b 100644 --- a/sahara/service/coordinator.py +++ b/sahara/service/coordinator.py @@ -100,7 +100,8 @@ class HashRing(Coordinator): @staticmethod def _hash(key): - return int(hashlib.md5(str(key)).hexdigest(), 16) # nosec + return int( + hashlib.md5(str(key).encode('utf-8')).hexdigest(), 16) # nosec def _build_ring(self): ring = {} diff --git a/sahara/service/validations/edp/job_binary_internal.py b/sahara/service/validations/edp/job_binary_internal.py index 9587bff96d..a92e3be69e 100644 --- a/sahara/service/validations/edp/job_binary_internal.py +++ b/sahara/service/validations/edp/job_binary_internal.py @@ -14,6 +14,7 @@ # limitations under the License. from oslo_config import cfg +import six import sahara.exceptions as e from sahara.i18n import _ @@ -31,7 +32,7 @@ def check_job_binary_internal(data, **kwargs): if not is_internal_db_enabled(): raise e.BadJobBinaryInternalException( _("Sahara internal db is disabled for storing job binaries.")) - if not (type(data) is str and len(data) > 0): + if not (isinstance(data, six.string_types) and len(data) > 0): raise e.BadJobBinaryInternalException() if "name" in kwargs: name = kwargs["name"] diff --git a/sahara/utils/api.py b/sahara/utils/api.py index 847264fceb..2fbe5fb917 100644 --- a/sahara/utils/api.py +++ b/sahara/utils/api.py @@ -18,6 +18,7 @@ import traceback import flask from oslo_log import log as logging from oslo_middleware import request_id as oslo_req_id +import six from werkzeug import datastructures from sahara import context @@ -53,7 +54,7 @@ class Rest(flask.Blueprint): return self._mroute('PATCH', rule, status_code) def _mroute(self, methods, rule, status_code=None, **kw): - if type(methods) is str: + if isinstance(methods, six.string_types): methods = [methods] return self.route(rule, methods=methods, status_code=status_code, **kw)