]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add unit_name property to DaemonIdentity
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 25 Jul 2023 20:36:31 +0000 (16:36 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 11 Sep 2023 17:34:11 +0000 (13:34 -0400)
Replace some uses of get_unit_name with the new method.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/cephadmlib/daemon_identity.py

index c096b091baba440f8e2f15e5775247a71f5927ba..2721a6333d6cc820e907854c3701f32d2179cc4f 100755 (executable)
@@ -1887,7 +1887,7 @@ def get_unit_name(fsid, daemon_type, daemon_id=None):
     # type: (str, str, Optional[Union[int, str]]) -> str
     # accept either name or type + id
     if daemon_id is not None:
-        return 'ceph-%s@%s.%s' % (fsid, daemon_type, daemon_id)
+        return DaemonIdentity(fsid, daemon_type, daemon_id).unit_name
     else:
         return 'ceph-%s@%s' % (fsid, daemon_type)
 
@@ -5803,9 +5803,8 @@ def get_deployment_type(ctx: CephadmContext, daemon_type: str, daemon_id: str) -
     deployment_type: DeploymentType = DeploymentType.DEFAULT
     if ctx.reconfig:
         deployment_type = DeploymentType.RECONFIG
-    unit_name = get_unit_name(ctx.fsid, daemon_type, daemon_id)
-    (_, state, _) = check_unit(ctx, unit_name)
     ident = DaemonIdentity(ctx.fsid, daemon_type, daemon_id)
+    (_, state, _) = check_unit(ctx, ident.unit_name)
     if state == 'running' or is_container_running(ctx, CephContainer.for_daemon(ctx, ident, 'bash')):
         # if reconfig was set, that takes priority over redeploy. If
         # this is considered a fresh deployment at this stage,
index fad0c96561a4a9b09f3b55949f7e3d6aa2ca10a3..3a84ee425222f8df40240ef7f0afc792aa96a377 100644 (file)
@@ -39,6 +39,10 @@ class DaemonIdentity:
         name = f'ceph-{self.fsid}-{self.daemon_type}-{self.daemon_id}'
         return name.replace('.', '-')
 
+    @property
+    def unit_name(self) -> str:
+        return f'ceph-{self.fsid}@{self.daemon_type}.{self.daemon_id}'
+
     @classmethod
     def from_name(cls, fsid: str, name: str) -> 'DaemonIdentity':
         daemon_type, daemon_id = name.split('.', 1)