]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/controllers/daemon.py
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / daemon.py
index eeea5a326255541fc08d071b51d15834265d836f..d5c288131b92e5263f92f49607341ee5d4684ec7 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from typing import Optional
+from typing import List, Optional
 
 from ..exceptions import DashboardException
 from ..security import Scope
@@ -31,3 +31,19 @@ class Daemon(RESTController):
         orch = OrchClient.instance()
         res = orch.daemons.action(action=action, daemon_name=daemon_name, image=container_image)
         return res
+
+    @raise_if_no_orchestrator([OrchFeature.DAEMON_LIST])
+    @handle_orchestrator_error('daemon')
+    @RESTController.MethodMap(version=APIVersion.DEFAULT)
+    def list(self, daemon_types: Optional[List[str]] = None):
+        """List all daemons in the cluster. Also filter by the daemon types specified
+
+        :param daemon_types: List of daemon types to filter by.
+        :return: Returns list of daemons.
+        :rtype: list
+        """
+        orch = OrchClient.instance()
+        daemons = [d.to_dict() for d in orch.services.list_daemons()]
+        if daemon_types:
+            daemons = [d for d in daemons if d['daemon_type'] in daemon_types]
+        return daemons