From: John Mulligan Date: Wed, 26 Jul 2023 14:35:09 +0000 (-0400) Subject: cephadm: convert _write_custom_conf_files to use a DaemonIdentity arg X-Git-Tag: v19.0.0~479^2~16 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b72d13af6f44a46475ac430003ea9dc372db28df;p=ceph-ci.git cephadm: convert _write_custom_conf_files to use a DaemonIdentity arg Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index d0adaa542fc..57b6e8c36e3 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -2247,15 +2247,22 @@ def create_daemon_dirs( sg = SNMPGateway.init(ctx, fsid, ident.daemon_id) sg.create_daemon_conf() - _write_custom_conf_files(ctx, daemon_type, ident.daemon_id, fsid, uid, gid) + _write_custom_conf_files(ctx, ident, uid, gid) -def _write_custom_conf_files(ctx: CephadmContext, daemon_type: str, daemon_id: str, fsid: str, uid: int, gid: int) -> None: +def _write_custom_conf_files( + ctx: CephadmContext, ident: 'DaemonIdentity', uid: int, gid: int +) -> None: # mostly making this its own function to make unit testing easier ccfiles = fetch_custom_config_files(ctx) if not ccfiles: return - custom_config_dir = os.path.join(ctx.data_dir, fsid, 'custom_config_files', f'{daemon_type}.{daemon_id}') + custom_config_dir = os.path.join( + ctx.data_dir, + ident.fsid, + 'custom_config_files', + f'{ident.daemon_type}.{ident.daemon_id}', + ) if not os.path.exists(custom_config_dir): makedirs(custom_config_dir, uid, gid, 0o755) mandatory_keys = ['mount_path', 'content'] @@ -2266,7 +2273,7 @@ def _write_custom_conf_files(ctx: CephadmContext, daemon_type: str, daemon_id: s f.write(ccf['content']) # temporary workaround to make custom config files work for tcmu-runner # container we deploy with iscsi until iscsi is refactored - if daemon_type == 'iscsi': + if ident.daemon_type == 'iscsi': tcmu_config_dir = custom_config_dir + '.tcmu' if not os.path.exists(tcmu_config_dir): makedirs(tcmu_config_dir, uid, gid, 0o755) diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index ebf7d42c339..b43f7fa1217 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -446,7 +446,9 @@ class TestCephAdm(object): 'mount_path': '/etc/no-content.conf', }, ] - _cephadm._write_custom_conf_files(ctx, 'mon', 'host1', 'fsid', 0, 0) + _cephadm._write_custom_conf_files( + ctx, _cephadm.DaemonIdentity('fsid', 'mon', 'host1'), 0, 0 + ) with open(os.path.join(_cephadm.DATA_DIR, 'fsid', 'custom_config_files', 'mon.host1', 'testing.str'), 'r') as f: assert 'this\nis\na\nstring' == f.read() with open(os.path.join(_cephadm.DATA_DIR, 'fsid', 'custom_config_files', 'mon.host1', 'testing.conf'), 'r') as f: