]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/__init__.py
update ceph source to reef 18.1.2
[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"""
7c673cae 6
11fdf7f2 7import os
f67539c2 8
f6b5b4d7
TL
9import cherrypy
10
11if 'COVERAGE_ENABLED' in os.environ:
12 import coverage # pylint: disable=import-error
13 __cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)),
14 data_suffix=True)
15 __cov.start()
16 cherrypy.engine.subscribe('after_request', __cov.save)
17 cherrypy.engine.subscribe('stop', __cov.stop)
11fdf7f2
TL
18
19if 'UNITTEST' not in os.environ:
11fdf7f2
TL
20 class _ModuleProxy(object):
21 def __init__(self):
22 self._mgr = None
23
24 def init(self, module_inst):
11fdf7f2 25 self._mgr = module_inst
11fdf7f2
TL
26
27 def __getattr__(self, item):
28 if self._mgr is None:
29 raise AttributeError("global manager module instance not initialized")
30 return getattr(self._mgr, item)
31
32 mgr = _ModuleProxy()
11fdf7f2 33
11fdf7f2
TL
34else:
35 import logging
36 logging.basicConfig(level=logging.DEBUG)
11fdf7f2 37 logging.root.handlers[0].setLevel(logging.DEBUG)
f67539c2 38 import sys
11fdf7f2 39
f67539c2
TL
40 # Used to allow the running of a tox-based yml doc generator from the dashboard directory
41 if os.path.abspath(sys.path[0]) == os.getcwd():
42 sys.path.pop(0)
43
44 from tests import mock # type: ignore
11fdf7f2
TL
45
46 mgr = mock.Mock()
20effc67
TL
47 mgr.get_frontend_path.return_value = os.path.abspath(os.path.join(
48 os.path.dirname(__file__),
49 'frontend/dist'))
e306af50 50
2a845540
TL
51 import rbd
52
53 # Api tests do not mock rbd as opposed to dashboard unit tests. Both
54 # use UNITTEST env variable.
55 if isinstance(rbd, mock.Mock):
56 rbd.RBD_MIRROR_IMAGE_MODE_JOURNAL = 0
57 rbd.RBD_MIRROR_IMAGE_MODE_SNAPSHOT = 1
58
e306af50
TL
59# DO NOT REMOVE: required for ceph-mgr to load a module
60from .module import Module, StandbyModule # noqa: F401