]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/__init__.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / __init__.py
CommitLineData
11fdf7f2
TL
1# -*- coding: utf-8 -*-
2# pylint: disable=wrong-import-position,global-statement,protected-access
3"""
4ceph dashboard module
5"""
6from __future__ import absolute_import
7c673cae 7
11fdf7f2
TL
8import os
9
10
11if 'UNITTEST' not in os.environ:
12 class _LoggerProxy(object):
13 def __init__(self):
14 self._logger = None
15
16 def __getattr__(self, item):
17 if self._logger is None:
18 raise AttributeError("logger not initialized")
19 return getattr(self._logger, item)
20
21 class _ModuleProxy(object):
22 def __init__(self):
23 self._mgr = None
24
25 def init(self, module_inst):
26 global logger
27 self._mgr = module_inst
28 logger._logger = self._mgr._logger
29
30 def __getattr__(self, item):
31 if self._mgr is None:
32 raise AttributeError("global manager module instance not initialized")
33 return getattr(self._mgr, item)
34
35 mgr = _ModuleProxy()
36 logger = _LoggerProxy()
37
38 from .module import Module, StandbyModule
39else:
40 import logging
41 logging.basicConfig(level=logging.DEBUG)
42 logger = logging.getLogger(__name__)
43 logging.root.handlers[0].setLevel(logging.DEBUG)
44 os.environ['PATH'] = '{}:{}'.format(os.path.abspath('../../../../build/bin'),
45 os.environ['PATH'])
46
47 # Mock ceph module otherwise every module that is involved in a testcase and imports it will
48 # raise an ImportError
49 import sys
50 import mock
51 sys.modules['ceph_module'] = mock.Mock()
52
53 mgr = mock.Mock()