]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: cephx: added CephX service class
authorRicardo Dias <rdias@suse.com>
Thu, 20 Dec 2018 09:26:13 +0000 (09:26 +0000)
committerRicardo Dias <rdias@suse.com>
Thu, 31 Jan 2019 09:42:27 +0000 (09:42 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/dashboard/services/cephx.py [new file with mode: 0644]

diff --git a/src/pybind/mgr/dashboard/services/cephx.py b/src/pybind/mgr/dashboard/services/cephx.py
new file mode 100644 (file)
index 0000000..ccda387
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+from .ceph_service import CephService
+
+
+class CephX(object):
+    @classmethod
+    def _entities_map(cls, entity_type=None):
+        auth_dump = CephService.send_command("mon", "auth list")
+        result = {}
+        for auth_entry in auth_dump['auth_dump']:
+            entity = auth_entry['entity']
+            if not entity_type or entity.startswith('{}.'.format(entity_type)):
+                entity_id = entity[entity.find('.')+1:]
+                result[entity_id] = auth_entry
+        return result
+
+    @classmethod
+    def _clients_map(cls):
+        return cls._entities_map("client")
+
+    @classmethod
+    def list_clients(cls):
+        return [client for client in cls._clients_map()]
+
+    @classmethod
+    def get_client_key(cls, client_id):
+        return cls._clients_map()[client_id]['key']