]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/services/cephx.py
Import ceph 15.2.8
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / cephx.py
1 # -*- coding: utf-8 -*-
2 from __future__ import absolute_import
3
4 from .ceph_service import CephService
5
6
7 class CephX(object):
8 @classmethod
9 def _entities_map(cls, entity_type=None):
10 auth_dump = CephService.send_command("mon", "auth list")
11 result = {}
12 for auth_entry in auth_dump['auth_dump']:
13 entity = auth_entry['entity']
14 if not entity_type or entity.startswith('{}.'.format(entity_type)):
15 entity_id = entity[entity.find('.')+1:]
16 result[entity_id] = auth_entry
17 return result
18
19 @classmethod
20 def _clients_map(cls):
21 return cls._entities_map("client")
22
23 @classmethod
24 def list_clients(cls):
25 return [client for client in cls._clients_map()]
26
27 @classmethod
28 def get_client_key(cls, client_id):
29 return cls._clients_map()[client_id]['key']