From: Sebastian Wagner Date: Tue, 18 Sep 2018 13:57:53 +0000 (+0200) Subject: mgr/orchestrator: Fix Python 3 issues X-Git-Tag: v14.0.1~46^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=92e2a5707819282af9fee99d72b1fe4a4b00fbf2;p=ceph-ci.git mgr/orchestrator: Fix Python 3 issues * `Exception.message` is deprecated. * Use relative imports. * `filter` returns an iterator in Py3 * `urlparse` moved. * `s/log.warn/log.warning` * Dockerfile: install Py3 versions. Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/orchestrator_cli/__init__.py b/src/pybind/mgr/orchestrator_cli/__init__.py index 86b0c90fe4b..1f586a2b54f 100644 --- a/src/pybind/mgr/orchestrator_cli/__init__.py +++ b/src/pybind/mgr/orchestrator_cli/__init__.py @@ -1,2 +1,2 @@ -from module import OrchestratorCli +from .module import OrchestratorCli diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 8c406333425..b727efcfd26 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -268,7 +268,7 @@ class OrchestratorCli(MgrModule): except NoOrchestrator: return -errno.ENODEV, "", "No orchestrator configured" except ImportError as e: - return -errno.ENOENT, "", e.message + return -errno.ENOENT, "", str(e) except NotImplementedError: return -errno.EINVAL, "", "Command not found" diff --git a/src/pybind/mgr/progress/__init__.py b/src/pybind/mgr/progress/__init__.py index bd1113bf1b2..0f7dab556dc 100644 --- a/src/pybind/mgr/progress/__init__.py +++ b/src/pybind/mgr/progress/__init__.py @@ -1,2 +1,2 @@ -from module import * +from .module import * diff --git a/src/pybind/mgr/rook/__init__.py b/src/pybind/mgr/rook/__init__.py index 286a1101277..b9f08fc8007 100644 --- a/src/pybind/mgr/rook/__init__.py +++ b/src/pybind/mgr/rook/__init__.py @@ -1,2 +1,2 @@ -from module import RookOrchestrator +from .module import RookOrchestrator diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index dafd1191aa8..ec695ad1969 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -17,7 +17,7 @@ except ImportError: client = None config = None -from rook_cluster import RookCluster, ApplyException +from .rook_cluster import RookCluster all_completions = [] @@ -276,8 +276,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): global all_completions self.wait(all_completions) - all_completions = filter(lambda x: not x.is_complete, - all_completions) + all_completions = [c for c in all_completions if not c.is_complete] self._shutdown.wait(5) diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index b911b513ca5..7095a24948c 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -7,7 +7,7 @@ call methods. This module is runnable outside of ceph-mgr, useful for testing. """ -import urlparse +from six.moves.urllib import parse import logging import json @@ -115,7 +115,7 @@ class RookCluster(object): ROOK_SYSTEM_NS, label_selector=label_selector) except ApiException as e: - log.warn("Failed to fetch device metadata: {0}".format(e)) + log.warning("Failed to fetch device metadata: {0}".format(e)) raise nodename_to_devices = {} @@ -356,7 +356,7 @@ class RookCluster(object): "clusters/{0}".format(self.cluster_name), body=patch) except ApiException as e: - log.exception("API exception: {0}".format(e.message)) + log.exception("API exception: {0}".format(e)) raise ApplyException( "Failed to create OSD entries in Cluster CRD: {0}".format( - e.message)) + e)) diff --git a/src/script/kubejacker/Dockerfile b/src/script/kubejacker/Dockerfile index ed2113a8325..60c7578d8d6 100644 --- a/src/script/kubejacker/Dockerfile +++ b/src/script/kubejacker/Dockerfile @@ -12,10 +12,11 @@ ENV TERM linux RUN (grep -q rhel /etc/os-release && ( \ yum install -y python-pip && \ yum install -y liboath && \ - yum install -y python-bcrypt librdmacm \ + yum install -y python-bcrypt librdmacm && \ + pip install kubernetes==6.0.0 \ )) || (grep -q suse /etc/os-release && ( \ zypper --non-interactive --gpg-auto-import-keys install --no-recommends --auto-agree-with-licenses --replacefiles --details \ - python-pip \ + python3-kubernetes \ liboauth-devel \ python-bcrypt \ lz4 \ @@ -23,9 +24,6 @@ RUN (grep -q rhel /etc/os-release && ( \ libopenssl1_1 \ )) - -RUN pip install kubernetes==6.0.0 - ADD bin.tar.gz /usr/bin/ ADD lib.tar.gz /usr/lib64/