From fa4650c4834c670d06b6a0aaaa40c2651c9e0794 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 3 Dec 2019 12:49:07 +0100 Subject: [PATCH] pybind/mgr: Make it easier to create a Module instance without the mgr Caused by conflict between #30961 and #30262 Signed-off-by: Sebastian Wagner --- src/pybind/mgr/mgr_module.py | 8 ++++---- src/pybind/mgr/ssh/tests/fixtures.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index d776fe6a23e..c17d98219ed 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -414,7 +414,7 @@ class CPlusPlusHandler(logging.Handler): class FileHandler(logging.FileHandler): def __init__(self, module_inst): - path = module_inst._ceph_get_option("log_file") + path = module_inst.get_ceph_option("log_file") idx = path.rfind(".log") if idx != -1: self.path = "{}.{}.log".format(path[:idx], module_inst.module_name) @@ -535,7 +535,7 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule, MgrModuleLoggingMixin): super(MgrStandbyModule, self).__init__(capsule) self.module_name = module_name - mgr_level = self._ceph_get_option("debug_mgr") + mgr_level = self.get_ceph_option("debug_mgr") log_level = self.get_module_option("log_level") self._configure_logging(mgr_level, log_level, False) @@ -641,7 +641,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin): self.module_name = module_name super(MgrModule, self).__init__(py_modules_ptr, this_ptr) - mgr_level = self._ceph_get_option("debug_mgr") + mgr_level = self.get_ceph_option("debug_mgr") log_level = self.get_module_option("log_level") self._configure_logging(mgr_level, log_level, self.get_module_option("log_to_file", False)) @@ -733,7 +733,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin): def _config_notify(self): # check logging options for changes - mgr_level = self._ceph_get_option("debug_mgr") + mgr_level = self.get_ceph_option("debug_mgr") module_level = self.get_module_option("log_level") log_to_file = self.get_module_option("log_to_file", False) diff --git a/src/pybind/mgr/ssh/tests/fixtures.py b/src/pybind/mgr/ssh/tests/fixtures.py index eddfbe55e03..273aae244b4 100644 --- a/src/pybind/mgr/ssh/tests/fixtures.py +++ b/src/pybind/mgr/ssh/tests/fixtures.py @@ -23,13 +23,17 @@ def get_store_prefix(self, prefix): if k.startswith(prefix) } +def get_ceph_option(_, key): + return __file__ @pytest.yield_fixture() def ssh_module(): - with mock.patch("ssh.module.SSHOrchestrator.get_ceph_option", lambda _, key: __file__),\ + with mock.patch("ssh.module.SSHOrchestrator.get_ceph_option", get_ceph_option),\ + mock.patch("ssh.module.SSHOrchestrator._configure_logging", lambda *args: None),\ mock.patch("ssh.module.SSHOrchestrator.set_store", set_store),\ mock.patch("ssh.module.SSHOrchestrator.get_store", get_store),\ mock.patch("ssh.module.SSHOrchestrator.get_store_prefix", get_store_prefix): + SSHOrchestrator._register_commands('') m = SSHOrchestrator.__new__ (SSHOrchestrator) m._store = { 'ssh_config': '', -- 2.39.5