]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: convert deploy_daemon_units to to use a DaemonIdentity argument
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 26 Jul 2023 17:44:58 +0000 (13:44 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 11 Sep 2023 19:23:04 +0000 (15:23 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_cephadm.py

index 962f40c5dbac43afcefcd973e4489ca62d997fb7..1371e02acb202380e8f7c46aea7a049c5e4755b1 100755 (executable)
@@ -2920,9 +2920,16 @@ def deploy_daemon(
             cephadm_agent.deploy_daemon_unit(config_js)
         else:
             if c:
-                deploy_daemon_units(ctx, fsid, uid, gid, daemon_type, daemon_id,
-                                    c, osd_fsid=osd_fsid, endpoints=endpoints,
-                                    init_containers=init_containers)
+                deploy_daemon_units(
+                    ctx,
+                    ident,
+                    uid,
+                    gid,
+                    c,
+                    osd_fsid=osd_fsid,
+                    endpoints=endpoints,
+                    init_containers=init_containers,
+                )
             else:
                 raise RuntimeError('attempting to deploy a daemon without a container image')
 
@@ -3070,11 +3077,9 @@ def clean_cgroup(ctx: CephadmContext, fsid: str, unit_name: str) -> None:
 
 def deploy_daemon_units(
     ctx: CephadmContext,
-    fsid: str,
+    ident: 'DaemonIdentity',
     uid: int,
     gid: int,
-    daemon_type: str,
-    daemon_id: Union[int, str],
     container: 'CephContainer',
     enable: bool = True,
     start: bool = True,
@@ -3084,7 +3089,11 @@ def deploy_daemon_units(
 ) -> None:
     # cmd
 
-    ident = DaemonIdentity(fsid, daemon_type, daemon_id)
+    # unpack values from ident because they're used very frequently
+    fsid = ident.fsid
+    daemon_type = ident.daemon_type
+    daemon_id = ident.daemon_id
+
     data_dir = get_data_dir(ident, ctx.data_dir)
     run_file_path = data_dir + '/unit.run'
     meta_file_path = data_dir + '/unit.meta'
@@ -6997,10 +7006,17 @@ def command_adopt_ceph(ctx, daemon_type, daemon_id, fsid):
     logger.info('Creating new units...')
     make_var_run(ctx, fsid, uid, gid)
     c = get_container(ctx, fsid, daemon_type, daemon_id)
-    deploy_daemon_units(ctx, fsid, uid, gid, daemon_type, daemon_id, c,
-                        enable=True,  # unconditionally enable the new unit
-                        start=(state == 'running' or ctx.force_start),
-                        osd_fsid=osd_fsid)
+    ident = DaemonIdentity(fsid, daemon_type, daemon_id)
+    deploy_daemon_units(
+        ctx,
+        ident,
+        uid,
+        gid,
+        c,
+        enable=True,  # unconditionally enable the new unit
+        start=(state == 'running' or ctx.force_start),
+        osd_fsid=osd_fsid,
+    )
     update_firewalld(ctx, daemon_type)
 
 
index 1fcf1558b5b819d3e25020d84429eb7ebbd0de5c..1a90876202faf0ff1dc91edf63106776306b905d 100644 (file)
@@ -1741,15 +1741,12 @@ class TestIscsi:
             _cephadm.get_parm.return_value = config_json
             c = _cephadm.get_container(ctx, fsid, 'iscsi', 'daemon_id')
 
-            _cephadm.make_data_dir(
-                ctx, _cephadm.DaemonIdentity(fsid, 'iscsi', 'daemon_id')
-            )
+            ident = _cephadm.DaemonIdentity(fsid, 'iscsi', 'daemon_id')
+            _cephadm.make_data_dir(ctx, ident)
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'iscsi',
-                'daemon_id',
                 c,
                 True, True
             )
@@ -2293,10 +2290,8 @@ class TestSNMPGateway:
 
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'snmp-gateway',
-                'daemon_id',
                 c,
                 True, True
             )
@@ -2324,10 +2319,8 @@ class TestSNMPGateway:
 
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'snmp-gateway',
-                'daemon_id',
                 c,
                 True, True
             )
@@ -2355,10 +2348,8 @@ class TestSNMPGateway:
 
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'snmp-gateway',
-                'daemon_id',
                 c,
                 True, True
             )
@@ -2562,10 +2553,8 @@ class TestJaeger:
             _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'jaeger-collector',
-                'daemon_id',
                 c,
                 True, True
             )
@@ -2584,10 +2573,8 @@ class TestJaeger:
             _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'jaeger-collector',
-                'daemon_id',
                 c,
                 True, True
             )
@@ -2606,10 +2593,8 @@ class TestJaeger:
             _cephadm.create_daemon_dirs(ctx, ident, 0, 0)
             _cephadm.deploy_daemon_units(
                 ctx,
-                fsid,
+                ident,
                 0, 0,
-                'jaeger-agent',
-                'daemon_id',
                 c,
                 True, True
             )