# 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,
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/"',
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")