blob: 5156403e34e101560348e9b283dabf88d9997f4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# -*- coding: utf-8 -*-
# pylint: disable=wrong-import-position,global-statement,protected-access
"""
ceph dashboard module
"""
from __future__ import absolute_import
import os
import cherrypy
if 'COVERAGE_ENABLED' in os.environ:
import coverage # pylint: disable=import-error
__cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)),
data_suffix=True)
__cov.start()
cherrypy.engine.subscribe('after_request', __cov.save)
cherrypy.engine.subscribe('stop', __cov.stop)
if 'UNITTEST' not in os.environ:
class _ModuleProxy(object):
def __init__(self):
self._mgr = None
def init(self, module_inst):
self._mgr = module_inst
def __getattr__(self, item):
if self._mgr is None:
raise AttributeError("global manager module instance not initialized")
return getattr(self._mgr, item)
mgr = _ModuleProxy()
else:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.root.handlers[0].setLevel(logging.DEBUG)
os.environ['PATH'] = '{}:{}'.format(os.path.abspath('../../../../build/bin'),
os.environ['PATH'])
import sys
# Used to allow the running of a tox-based yml doc generator from the dashboard directory
if os.path.abspath(sys.path[0]) == os.getcwd():
sys.path.pop(0)
from tests import mock # type: ignore
mgr = mock.Mock()
mgr.get_frontend_path.side_effect = lambda: os.path.abspath("./frontend/dist")
import rbd
# Api tests do not mock rbd as opposed to dashboard unit tests. Both
# use UNITTEST env variable.
if isinstance(rbd, mock.Mock):
rbd.RBD_MIRROR_IMAGE_MODE_JOURNAL = 0
rbd.RBD_MIRROR_IMAGE_MODE_SNAPSHOT = 1
# DO NOT REMOVE: required for ceph-mgr to load a module
from .module import Module, StandbyModule # noqa: F401
|