]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add extra function for the auth entity 34961/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Fri, 8 May 2020 11:00:36 +0000 (13:00 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 8 May 2020 11:00:36 +0000 (13:00 +0200)
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/services/cephadmservice.py
src/pybind/mgr/cephadm/utils.py

index a28c2baee6c9103cb6ba83f447fa799f4530cbdd..0ce9da421c9a8e9d3981fee534f30e613cf647b1 100644 (file)
@@ -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,
index 591ebcdf8bbd89e69e8b70dbbe4533e107350927..c230be389b9095db6c3ddf2d4d79756577446bb2 100644 (file)
@@ -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/"',
index 3cc6d6e1a74ab17fe5e422f7fec6a61dc3c52514..290011843e08da793ef6f1780e8b231c921e602d 100644 (file)
@@ -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")