From b09f754ecb1ba35586adf43e902c1847ba353340 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 8 Feb 2018 18:55:37 +0800 Subject: [PATCH] pybind/mgr: use relative import * in python3, we cannot assume default relative import. instead, we should be explicit. also, only import the `Module` and `StandbyModule` classes from plugins, as they are what we are interested. * and import urllib.parse in python3. Fixes: http://tracker.ceph.com/issues/22880 Signed-off-by: Kefu Chai --- src/pybind/mgr/balancer/__init__.py | 3 +-- src/pybind/mgr/dashboard/__init__.py | 2 +- src/pybind/mgr/dashboard/cephfs_clients.py | 2 +- src/pybind/mgr/dashboard/module.py | 17 ++++++++++------- src/pybind/mgr/dashboard/rbd_iscsi.py | 2 +- src/pybind/mgr/dashboard/rbd_ls.py | 4 ++-- src/pybind/mgr/dashboard/rbd_mirroring.py | 2 +- src/pybind/mgr/dashboard/rgw.py | 2 +- src/pybind/mgr/influx/__init__.py | 2 +- src/pybind/mgr/localpool/__init__.py | 3 +-- src/pybind/mgr/prometheus/__init__.py | 2 +- src/pybind/mgr/restful/__init__.py | 2 +- src/pybind/mgr/restful/api/__init__.py | 16 ++++++++-------- src/pybind/mgr/restful/hooks.py | 2 +- src/pybind/mgr/restful/module.py | 4 ++-- src/pybind/mgr/selftest/__init__.py | 2 +- src/pybind/mgr/status/__init__.py | 3 +-- src/pybind/mgr/zabbix/__init__.py | 2 +- 18 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/pybind/mgr/balancer/__init__.py b/src/pybind/mgr/balancer/__init__.py index 79f5b86fd5045..8f210ac9247ea 100644 --- a/src/pybind/mgr/balancer/__init__.py +++ b/src/pybind/mgr/balancer/__init__.py @@ -1,2 +1 @@ - -from module import * # NOQA +from .module import Module diff --git a/src/pybind/mgr/dashboard/__init__.py b/src/pybind/mgr/dashboard/__init__.py index 79f5b86fd5045..5d6e417e4d852 100644 --- a/src/pybind/mgr/dashboard/__init__.py +++ b/src/pybind/mgr/dashboard/__init__.py @@ -1,2 +1,2 @@ -from module import * # NOQA +from .module import Module, StandbyModule diff --git a/src/pybind/mgr/dashboard/cephfs_clients.py b/src/pybind/mgr/dashboard/cephfs_clients.py index 40d79713f3b55..ebbb556abcfb9 100644 --- a/src/pybind/mgr/dashboard/cephfs_clients.py +++ b/src/pybind/mgr/dashboard/cephfs_clients.py @@ -2,7 +2,7 @@ import json from mgr_module import CommandResult -from remote_view_cache import RemoteViewCache +from .remote_view_cache import RemoteViewCache class CephFSClients(RemoteViewCache): diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 67f079500db8c..213f05f0319e7 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -26,18 +26,21 @@ import socket import cherrypy import jinja2 -import urlparse +try: + import urlparse +except ImportError: + import urllib.parse as urlparse from mgr_module import MgrModule, MgrStandbyModule, CommandResult -from types import OsdMap, NotFound, Config, FsMap, MonMap, \ +from .types import OsdMap, NotFound, Config, FsMap, MonMap, \ PgSummary, Health, MonStatus -import rbd_iscsi -import rbd_mirroring -from rbd_ls import RbdLs, RbdPoolLs -from cephfs_clients import CephFSClients -from rgw import RGWDaemons +from . import rbd_iscsi +from . import rbd_mirroring +from .rbd_ls import RbdLs, RbdPoolLs +from .cephfs_clients import CephFSClients +from .rgw import RGWDaemons log = logging.getLogger("dashboard") diff --git a/src/pybind/mgr/dashboard/rbd_iscsi.py b/src/pybind/mgr/dashboard/rbd_iscsi.py index 6f5e75ed1804a..c7882738ae26e 100644 --- a/src/pybind/mgr/dashboard/rbd_iscsi.py +++ b/src/pybind/mgr/dashboard/rbd_iscsi.py @@ -1,7 +1,7 @@ import rados import rbd -from remote_view_cache import RemoteViewCache +from .remote_view_cache import RemoteViewCache SERVICE_TYPE = 'tcmu-runner' diff --git a/src/pybind/mgr/dashboard/rbd_ls.py b/src/pybind/mgr/dashboard/rbd_ls.py index 96d362e3467c1..d6d88c30717f1 100644 --- a/src/pybind/mgr/dashboard/rbd_ls.py +++ b/src/pybind/mgr/dashboard/rbd_ls.py @@ -1,8 +1,8 @@ import rbd import rados -from types import OsdMap -from remote_view_cache import RemoteViewCache +from .types import OsdMap +from .remote_view_cache import RemoteViewCache class RbdPoolLs(RemoteViewCache): def _get(self): diff --git a/src/pybind/mgr/dashboard/rbd_mirroring.py b/src/pybind/mgr/dashboard/rbd_mirroring.py index e549ed5172787..edc3a9815f200 100644 --- a/src/pybind/mgr/dashboard/rbd_mirroring.py +++ b/src/pybind/mgr/dashboard/rbd_mirroring.py @@ -3,7 +3,7 @@ import json import re import rados import rbd -from remote_view_cache import RemoteViewCache +from .remote_view_cache import RemoteViewCache class DaemonsAndPools(RemoteViewCache): def _get(self): diff --git a/src/pybind/mgr/dashboard/rgw.py b/src/pybind/mgr/dashboard/rgw.py index 383233440cc9b..257e22ef2f1b5 100644 --- a/src/pybind/mgr/dashboard/rgw.py +++ b/src/pybind/mgr/dashboard/rgw.py @@ -1,7 +1,7 @@ # -*- code: utf-8 -*- import json -from remote_view_cache import RemoteViewCache +from .remote_view_cache import RemoteViewCache import logging diff --git a/src/pybind/mgr/influx/__init__.py b/src/pybind/mgr/influx/__init__.py index 0440e0705fb0c..8f210ac9247ea 100644 --- a/src/pybind/mgr/influx/__init__.py +++ b/src/pybind/mgr/influx/__init__.py @@ -1 +1 @@ -from module import * # NOQA +from .module import Module diff --git a/src/pybind/mgr/localpool/__init__.py b/src/pybind/mgr/localpool/__init__.py index 79f5b86fd5045..8f210ac9247ea 100644 --- a/src/pybind/mgr/localpool/__init__.py +++ b/src/pybind/mgr/localpool/__init__.py @@ -1,2 +1 @@ - -from module import * # NOQA +from .module import Module diff --git a/src/pybind/mgr/prometheus/__init__.py b/src/pybind/mgr/prometheus/__init__.py index 6441bb420334a..763a84261e6e9 100644 --- a/src/pybind/mgr/prometheus/__init__.py +++ b/src/pybind/mgr/prometheus/__init__.py @@ -1,2 +1,2 @@ -from module import * # NOQA +from .module import Module, StandbyModule diff --git a/src/pybind/mgr/restful/__init__.py b/src/pybind/mgr/restful/__init__.py index 0440e0705fb0c..8f210ac9247ea 100644 --- a/src/pybind/mgr/restful/__init__.py +++ b/src/pybind/mgr/restful/__init__.py @@ -1 +1 @@ -from module import * # NOQA +from .module import Module diff --git a/src/pybind/mgr/restful/api/__init__.py b/src/pybind/mgr/restful/api/__init__.py index 07d73dd827409..ebf2bd1dfcde9 100644 --- a/src/pybind/mgr/restful/api/__init__.py +++ b/src/pybind/mgr/restful/api/__init__.py @@ -1,14 +1,14 @@ from pecan import expose from pecan.rest import RestController -from config import Config -from crush import Crush -from doc import Doc -from mon import Mon -from osd import Osd -from pool import Pool -from request import Request -from server import Server +from .config import Config +from .crush import Crush +from .doc import Doc +from .mon import Mon +from .osd import Osd +from .pool import Pool +from .request import Request +from .server import Server class Root(RestController): diff --git a/src/pybind/mgr/restful/hooks.py b/src/pybind/mgr/restful/hooks.py index 3fd244aa85e26..8a62c84fc3a53 100644 --- a/src/pybind/mgr/restful/hooks.py +++ b/src/pybind/mgr/restful/hooks.py @@ -2,7 +2,7 @@ from pecan.hooks import PecanHook import traceback -import module +from . import module class ErrorHook(PecanHook): def on_error(self, stat, exc): diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index 5125253e4667b..0d94674cf5555 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -12,7 +12,7 @@ import threading import traceback import socket -import common +from . import common from uuid import uuid4 from pecan import jsonify, make_app @@ -20,7 +20,7 @@ from OpenSSL import crypto from pecan.rest import RestController from werkzeug.serving import make_server, make_ssl_devcert -from hooks import ErrorHook +from .hooks import ErrorHook from mgr_module import MgrModule, CommandResult # Global instance to share diff --git a/src/pybind/mgr/selftest/__init__.py b/src/pybind/mgr/selftest/__init__.py index 622a611b6099c..554aacbf946c9 100644 --- a/src/pybind/mgr/selftest/__init__.py +++ b/src/pybind/mgr/selftest/__init__.py @@ -1,3 +1,3 @@ -from module import * +from .module import Module diff --git a/src/pybind/mgr/status/__init__.py b/src/pybind/mgr/status/__init__.py index 79f5b86fd5045..8f210ac9247ea 100644 --- a/src/pybind/mgr/status/__init__.py +++ b/src/pybind/mgr/status/__init__.py @@ -1,2 +1 @@ - -from module import * # NOQA +from .module import Module diff --git a/src/pybind/mgr/zabbix/__init__.py b/src/pybind/mgr/zabbix/__init__.py index 0440e0705fb0c..8f210ac9247ea 100644 --- a/src/pybind/mgr/zabbix/__init__.py +++ b/src/pybind/mgr/zabbix/__init__.py @@ -1 +1 @@ -from module import * # NOQA +from .module import Module -- 2.39.5