return r
-def create_daemon_dirs(ctx, fsid, daemon_type, daemon_id, uid, gid,
- config=None, keyring=None):
- # type: (CephadmContext, str, str, Union[int, str], int, int, Optional[str], Optional[str]) -> None
- ident = DaemonIdentity(fsid, daemon_type, daemon_id)
+def create_daemon_dirs(
+ ctx: CephadmContext,
+ ident: 'DaemonIdentity',
+ uid: int,
+ gid: int,
+ config: Optional[str] = None,
+ keyring: Optional[str] = None,
+) -> None:
+ # unpack fsid and daemon_type from ident because they're used very frequently
+ fsid, daemon_type = ident.fsid, ident.daemon_type
data_dir = make_data_dir(ctx, ident, uid=uid, gid=gid)
if daemon_type in Ceph.daemons:
f.write(content)
elif daemon_type == NFSGanesha.daemon_type:
- nfs_ganesha = NFSGanesha.init(ctx, fsid, daemon_id)
+ nfs_ganesha = NFSGanesha.init(ctx, fsid, ident.daemon_id)
nfs_ganesha.create_daemon_dirs(data_dir, uid, gid)
elif daemon_type == CephIscsi.daemon_type:
- ceph_iscsi = CephIscsi.init(ctx, fsid, daemon_id)
+ ceph_iscsi = CephIscsi.init(ctx, fsid, ident.daemon_id)
ceph_iscsi.create_daemon_dirs(data_dir, uid, gid)
elif daemon_type == CephNvmeof.daemon_type:
- ceph_nvmeof = CephNvmeof.init(ctx, fsid, daemon_id)
+ ceph_nvmeof = CephNvmeof.init(ctx, fsid, ident.daemon_id)
ceph_nvmeof.create_daemon_dirs(data_dir, uid, gid)
elif daemon_type == HAproxy.daemon_type:
- haproxy = HAproxy.init(ctx, fsid, daemon_id)
+ haproxy = HAproxy.init(ctx, fsid, ident.daemon_id)
haproxy.create_daemon_dirs(data_dir, uid, gid)
elif daemon_type == Keepalived.daemon_type:
- keepalived = Keepalived.init(ctx, fsid, daemon_id)
+ keepalived = Keepalived.init(ctx, fsid, ident.daemon_id)
keepalived.create_daemon_dirs(data_dir, uid, gid)
elif daemon_type == CustomContainer.daemon_type:
- cc = CustomContainer.init(ctx, fsid, daemon_id)
+ cc = CustomContainer.init(ctx, fsid, ident.daemon_id)
cc.create_daemon_dirs(data_dir, uid, gid)
elif daemon_type == SNMPGateway.daemon_type:
- sg = SNMPGateway.init(ctx, fsid, daemon_id)
+ sg = SNMPGateway.init(ctx, fsid, ident.daemon_id)
sg.create_daemon_conf()
- _write_custom_conf_files(ctx, daemon_type, str(daemon_id), fsid, uid, gid)
+ _write_custom_conf_files(ctx, daemon_type, ident.daemon_id, fsid, uid, gid)
def _write_custom_conf_files(ctx: CephadmContext, daemon_type: str, daemon_id: str, fsid: str, uid: int, gid: int) -> None:
tmp_config = write_tmp(config, uid, gid)
# --mkfs
- create_daemon_dirs(ctx, fsid, daemon_type, daemon_id, uid, gid)
+ create_daemon_dirs(ctx, ident, uid, gid)
assert ident.daemon_type == 'mon'
mon_dir = get_data_dir(ident, ctx.data_dir)
log_dir = get_log_dir(fsid, ctx.log_dir)
f.write(config)
else:
# dirs, conf, keyring
- create_daemon_dirs(
- ctx,
- fsid, daemon_type, daemon_id,
- uid, gid,
- config, keyring)
+ create_daemon_dirs(ctx, ident, uid, gid, config, keyring)
# only write out unit files and start daemon
# with systemd if this is not a reconfig
) -> Tuple[str, str]:
logger.info('Creating mon...')
ident = DaemonIdentity(fsid, 'mon', mon_id)
- create_daemon_dirs(ctx, fsid, 'mon', mon_id, uid, gid)
+ create_daemon_dirs(ctx, ident, uid, gid)
mon_dir = get_data_dir(ident, ctx.data_dir)
log_dir = get_log_dir(fsid, ctx.log_dir)
out = CephContainer(
}
})
- _cephadm.create_daemon_dirs(ctx,
- fsid,
- daemon_type,
- daemon_id,
- uid,
- gid,
- config=None,
- keyring=None)
+ _cephadm.create_daemon_dirs(
+ ctx,
+ _cephadm.DaemonIdentity(fsid, daemon_type, daemon_id),
+ uid,
+ gid,
+ config=None,
+ keyring=None,
+ )
prefix = '{data_dir}/{fsid}/{daemon_type}.{daemon_id}'.format(
data_dir=ctx.data_dir,
# assert uid/gid after redeploy
new_uid = uid+1
new_gid = gid+1
- _cephadm.create_daemon_dirs(ctx,
- fsid,
- daemon_type,
- daemon_id,
- new_uid,
- new_gid,
- config=None,
- keyring=None)
+ _cephadm.create_daemon_dirs(
+ ctx,
+ _cephadm.DaemonIdentity(fsid, daemon_type, daemon_id),
+ new_uid,
+ new_gid,
+ config=None,
+ keyring=None,
+ )
for file,content in expected.items():
file = os.path.join(prefix, file)
assert os.stat(file).st_uid == new_uid
_cephadm.get_parm.return_value = self.V2c_config
c = _cephadm.get_container(ctx, fsid, 'snmp-gateway', 'daemon_id')
- _cephadm.make_data_dir(
- ctx, _cephadm.DaemonIdentity(fsid, 'snmp-gateway', 'daemon_id')
- )
+ ident = _cephadm.DaemonIdentity(fsid, 'snmp-gateway', 'daemon_id')
+ _cephadm.make_data_dir(ctx, ident)
- _cephadm.create_daemon_dirs(ctx, fsid, 'snmp-gateway', 'daemon_id', 0, 0)
+ _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
with open(f'/var/lib/ceph/{fsid}/snmp-gateway.daemon_id/snmp-gateway.conf', 'r') as f:
conf = f.read().rstrip()
assert conf == 'SNMP_NOTIFIER_COMMUNITY=public'
_cephadm.get_parm.return_value = self.V3_no_priv_config
c = _cephadm.get_container(ctx, fsid, 'snmp-gateway', 'daemon_id')
- _cephadm.make_data_dir(
- ctx, _cephadm.DaemonIdentity(fsid, 'snmp-gateway', 'daemon_id')
- )
+ ident = _cephadm.DaemonIdentity(fsid, 'snmp-gateway', 'daemon_id')
+ _cephadm.make_data_dir(ctx, ident)
- _cephadm.create_daemon_dirs(ctx, fsid, 'snmp-gateway', 'daemon_id', 0, 0)
+ _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
with open(f'/var/lib/ceph/{fsid}/snmp-gateway.daemon_id/snmp-gateway.conf', 'r') as f:
conf = f.read()
assert conf == 'SNMP_NOTIFIER_AUTH_USERNAME=myuser\nSNMP_NOTIFIER_AUTH_PASSWORD=mypassword\n'
_cephadm.get_parm.return_value = self.V3_priv_config
c = _cephadm.get_container(ctx, fsid, 'snmp-gateway', 'daemon_id')
- _cephadm.make_data_dir(
- ctx, _cephadm.DaemonIdentity(fsid, 'snmp-gateway', 'daemon_id')
- )
+ ident = _cephadm.DaemonIdentity(fsid, 'snmp-gateway', 'daemon_id')
+ _cephadm.make_data_dir(ctx, ident)
- _cephadm.create_daemon_dirs(ctx, fsid, 'snmp-gateway', 'daemon_id', 0, 0)
+ _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
with open(f'/var/lib/ceph/{fsid}/snmp-gateway.daemon_id/snmp-gateway.conf', 'r') as f:
conf = f.read()
assert conf == 'SNMP_NOTIFIER_AUTH_USERNAME=myuser\nSNMP_NOTIFIER_AUTH_PASSWORD=mypassword\nSNMP_NOTIFIER_PRIV_PASSWORD=mysecret\n'
ctx.config_json = json.dumps(self.single_es_node_conf)
ctx.fsid = fsid
c = _cephadm.get_container(ctx, fsid, 'jaeger-collector', 'daemon_id')
- _cephadm.create_daemon_dirs(ctx, fsid, 'jaeger-collector', 'daemon_id', 0, 0)
+ ident = _cephadm.DaemonIdentity(fsid, 'jaeger-collector', 'daemon_id')
+ _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
_cephadm.deploy_daemon_units(
ctx,
fsid,
ctx.config_json = json.dumps(self.multiple_es_nodes_conf)
ctx.fsid = fsid
c = _cephadm.get_container(ctx, fsid, 'jaeger-collector', 'daemon_id')
- _cephadm.create_daemon_dirs(ctx, fsid, 'jaeger-collector', 'daemon_id', 0, 0)
+ ident = _cephadm.DaemonIdentity(fsid, 'jaeger-collector', 'daemon_id')
+ _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
_cephadm.deploy_daemon_units(
ctx,
fsid,
ctx.config_json = json.dumps(self.agent_conf)
ctx.fsid = fsid
c = _cephadm.get_container(ctx, fsid, 'jaeger-agent', 'daemon_id')
- _cephadm.create_daemon_dirs(ctx, fsid, 'jaeger-agent', 'daemon_id', 0, 0)
+ ident = _cephadm.DaemonIdentity(fsid, 'jaeger-agent', 'daemon_id')
+ _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
_cephadm.deploy_daemon_units(
ctx,
fsid,