]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: convert _write_custom_conf_files to use a DaemonIdentity arg
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 26 Jul 2023 14:35:09 +0000 (10:35 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 11 Sep 2023 19:08:53 +0000 (15:08 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_cephadm.py

index d0adaa542fc0f98326bbbb4dfc2dcb41274e7291..57b6e8c36e34e1ded7723837585e694085ed33f5 100755 (executable)
@@ -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)
index ebf7d42c3398c09d78d1bcd3745929205d310767..b43f7fa121783b1cf9fa466f4b03349caf14f81b 100644 (file)
@@ -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: