summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/controllers/orchestrator.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/dashboard/controllers/orchestrator.py
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
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.py48
1 files changed, 48 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..fe0794da5
--- /dev/null
+++ b/src/pybind/mgr/dashboard/controllers/orchestrator.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+from functools import wraps
+
+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()