mirror of
https://github.com/ceph/ceph
synced 2025-02-21 01:47:25 +00:00
Merge pull request #31969 from sebastian-philipp/mgr-fix-mocking
pybind/mgr: Make it easier to create a Module instance without the mgr Reviewed-by: Ricardo Dias <rdias@suse.com> Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
88636f8bf0
@ -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)
|
||||
|
||||
|
@ -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': '',
|
||||
|
Loading…
Reference in New Issue
Block a user