From: John Mulligan Date: Tue, 25 Jul 2023 20:36:31 +0000 (-0400) Subject: cephadm: add unit_name property to DaemonIdentity X-Git-Tag: v19.0.0~479^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc22f7f47d6931ec4494313b9c754aeb3ffe7858;p=ceph.git cephadm: add unit_name property to DaemonIdentity Replace some uses of get_unit_name with the new method. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index c096b091baba..2721a6333d6c 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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, diff --git a/src/cephadm/cephadmlib/daemon_identity.py b/src/cephadm/cephadmlib/daemon_identity.py index fad0c96561a4..3a84ee425222 100644 --- a/src/cephadm/cephadmlib/daemon_identity.py +++ b/src/cephadm/cephadmlib/daemon_identity.py @@ -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)