From: Sebastian Wagner Date: Fri, 8 May 2020 11:00:36 +0000 (+0200) Subject: mgr/cephadm: add extra function for the auth entity X-Git-Tag: v15.2.4~73^2~43 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dd8255abf3f2bd09f6c3283310004372003af9fc;p=ceph.git mgr/cephadm: add extra function for the auth entity Signed-off-by: Sebastian Wagner (cherry picked from commit f18523fa219ef6e39902625ed2ae0da47695625a) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 6fd1b3b60851..d430e5fdbb16 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1533,10 +1533,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): # type: (str, str, Optional[str], Optional[str]) -> Dict[str, Any] # keyring if not keyring: - if daemon_type == 'mon': - ename = 'mon.' - else: - ename = utils.name_to_config_section(daemon_type + '.' + daemon_id) + ename = utils.name_to_auth_entity(daemon_type + '.' + daemon_id) ret, keyring, err = self.check_mon_command({ 'prefix': 'auth get', 'entity': ename, diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index 591ebcdf8bbd..c230be389b90 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -193,7 +193,7 @@ class IscsiService(CephadmService): def create(self, igw_id, host, spec) -> str: ret, keyring, err = self.mgr.check_mon_command({ 'prefix': 'auth get-or-create', - 'entity': utils.name_to_config_section('iscsi') + '.' + igw_id, + 'entity': utils.name_to_auth_entity('iscsi') + '.' + igw_id, 'caps': ['mon', 'profile rbd, ' 'allow command "osd blacklist", ' 'allow command "config-key get" with "key" prefix "iscsi/"', diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py index 3cc6d6e1a74a..290011843e08 100644 --- a/src/pybind/mgr/cephadm/utils.py +++ b/src/pybind/mgr/cephadm/utils.py @@ -13,3 +13,18 @@ def name_to_config_section(name): return name else: return 'mon' + + +def name_to_auth_entity(name) -> str: + """ + Map from daemon names to ceph entity names (as seen in config) + """ + daemon_type = name.split('.', 1)[0] + if daemon_type in ['rgw', 'rbd-mirror', 'nfs', 'crash', 'iscsi']: + return 'client.' + name + elif daemon_type == 'mon': + return 'mon.' + elif daemon_type in ['osd', 'mds', 'mgr', 'client']: + return name + else: + raise OrchestratorError("unknown auth entity name")