diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/pybind/mgr/dashboard/controllers/orchestrator.py | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/dashboard/controllers/orchestrator.py')
-rw-r--r-- | src/pybind/mgr/dashboard/controllers/orchestrator.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/controllers/orchestrator.py b/src/pybind/mgr/dashboard/controllers/orchestrator.py new file mode 100644 index 000000000..3864820ea --- /dev/null +++ b/src/pybind/mgr/dashboard/controllers/orchestrator.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +from functools import wraps + +from .. import mgr +from ..exceptions import DashboardException +from ..services.orchestrator import OrchClient +from . import APIDoc, Endpoint, EndpointDoc, ReadPermission, RESTController, UIRouter + +STATUS_SCHEMA = { + "available": (bool, "Orchestrator status"), + "message": (str, "Error message") +} + + +def raise_if_no_orchestrator(features=None): + def inner(method): + @wraps(method) + def _inner(self, *args, **kwargs): + orch = OrchClient.instance() + if not orch.available(): + raise DashboardException(code='orchestrator_status_unavailable', # pragma: no cover + msg='Orchestrator is unavailable', + component='orchestrator', + http_status_code=503) + if features is not None: + missing = orch.get_missing_features(features) + if missing: + msg = 'Orchestrator feature(s) are unavailable: {}'.format(', '.join(missing)) + raise DashboardException(code='orchestrator_features_unavailable', + msg=msg, + component='orchestrator', + http_status_code=503) + return method(self, *args, **kwargs) + return _inner + return inner + + +@UIRouter('/orchestrator') +@APIDoc("Orchestrator Management API", "Orchestrator") +class Orchestrator(RESTController): + + @Endpoint() + @ReadPermission + @EndpointDoc("Display Orchestrator Status", + responses={200: STATUS_SCHEMA}) + def status(self): + return OrchClient.instance().status() + + @Endpoint() + def get_name(self): + return mgr.get_module_option_ex('orchestrator', 'orchestrator') |