]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/services/cephx.py
import ceph 15.2.13
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / cephx.py
CommitLineData
11fdf7f2
TL
1# -*- coding: utf-8 -*-
2from __future__ import absolute_import
3
4from .ceph_service import CephService
5
6
7class 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):
7f7e6c64 25 return list(cls._clients_map())
11fdf7f2
TL
26
27 @classmethod
28 def get_client_key(cls, client_id):
29 return cls._clients_map()[client_id]['key']