From f18523fa219ef6e39902625ed2ae0da47695625a Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 8 May 2020 13:00:36 +0200 Subject: [PATCH] mgr/cephadm: add extra function for the auth entity Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/module.py | 5 +---- src/pybind/mgr/cephadm/services/cephadmservice.py | 2 +- src/pybind/mgr/cephadm/utils.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index a28c2baee6c91..0ce9da421c9a8 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1798,10 +1798,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 591ebcdf8bbd8..c230be389b909 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 3cc6d6e1a74ab..290011843e08d 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") -- 2.39.5