]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Orchestrator client service
authorRicardo Dias <rdias@suse.com>
Mon, 17 Dec 2018 09:30:33 +0000 (09:30 +0000)
committerRicardo Marques <rimarques@suse.com>
Tue, 22 Jan 2019 22:19:37 +0000 (22:19 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/dashboard/services/orchestrator.py [new file with mode: 0644]
src/pybind/mgr/dashboard/settings.py

diff --git a/src/pybind/mgr/dashboard/services/orchestrator.py b/src/pybind/mgr/dashboard/services/orchestrator.py
new file mode 100644 (file)
index 0000000..bfcec2b
--- /dev/null
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+import time
+
+from .. import mgr, logger
+from ..settings import Settings
+
+
+class NoOrchesrtatorConfiguredException(Exception):
+    pass
+
+
+class OrchClient(object):
+    _instance = None
+
+    @classmethod
+    def instance(cls):
+        if cls._instance is None:
+            cls._instance = OrchClient()
+        return cls._instance
+
+    def _call(self, method, *args, **kwargs):
+        if not Settings.ORCHESTRATOR_BACKEND:
+            raise NoOrchesrtatorConfiguredException()
+        return mgr.remote(Settings.ORCHESTRATOR_BACKEND, method, *args,
+                          **kwargs)
+
+    def _wait(self, completions):
+        while not self._call("wait", completions):
+            if any(c.should_wait for c in completions):
+                time.sleep(5)
+            else:
+                break
+
+    def list_service_info(self, service_type):
+        completion = self._call("describe_service", service_type, None, None)
+        self._wait([completion])
+        return completion.result
+
+    def available(self):
+        if not Settings.ORCHESTRATOR_BACKEND:
+            return False
+        status, desc = self._call("available")
+        logger.info("[ORCH] is orchestrator available: %s, %s", status, desc)
+        return status
+
+    def reload_service(self, service_type, service_ids):
+        if not isinstance(service_ids, list):
+            service_ids = [service_ids]
+
+        completion_list = [self._call("update_stateless_service", service_type,
+                                      service_id, None)
+                           for service_id in service_ids]
+        self._wait(completion_list)
index 7c0ea15411af096effa986eb1f8c72647ce8583b..73c490297e72276ba8b2e1deb5160f6d857bd324 100644 (file)
@@ -40,6 +40,9 @@ class Options(object):
     GRAFANA_API_USERNAME = ('admin', str)
     GRAFANA_API_PASSWORD = ('admin', str)
 
+    # Orchestrator settings
+    ORCHESTRATOR_BACKEND = ('', str)
+
     @staticmethod
     def has_default_value(name):
         return getattr(Settings, name, None) is None or \