summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/services/cephx.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/mgr/dashboard/services/cephx.py')
-rw-r--r--src/pybind/mgr/dashboard/services/cephx.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/services/cephx.py b/src/pybind/mgr/dashboard/services/cephx.py
new file mode 100644
index 00000000..ccda3879
--- /dev/null
+++ b/src/pybind/mgr/dashboard/services/cephx.py
@@ -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']