]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: update agent unit file func to use jinja template
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 17 Jul 2023 13:28:35 +0000 (09:28 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 3 Nov 2023 22:51:49 +0000 (18:51 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 84b4a03175ff5303f892e06c5131197ee4af7b3a..8f189becaa125c7e99f69103c9eb415b7378d597 100755 (executable)
@@ -3619,25 +3619,23 @@ class CephadmAgent(DaemonForm):
         return ('set -e\n' + f'{py3} {binary_path} agent --fsid {self.fsid} --daemon-id {self.daemon_id} &\n')
 
     def unit_file(self) -> str:
-        return """#generated by cephadm
+        ts = """#generated by cephadm
 [Unit]
-Description=cephadm agent for cluster {fsid}
+Description=cephadm agent for cluster {{agent.fsid}}
 
-PartOf=ceph-{fsid}.target
-Before=ceph-{fsid}.target
+PartOf=ceph-{{agent.fsid}}.target
+Before=ceph-{{agent.fsid}}.target
 
 [Service]
 Type=forking
-ExecStart=/bin/bash {data_dir}/unit.run
+ExecStart=/bin/bash {{agent.daemon_dir}}/unit.run
 Restart=on-failure
 RestartSec=10s
 
 [Install]
-WantedBy=ceph-{fsid}.target
-""".format(
-            fsid=self.fsid,
-            data_dir=self.daemon_dir
-        )
+WantedBy=ceph-{{agent.fsid}}.target
+"""
+        return templating.template_str(self.ctx, ts, agent=self)
 
     def shutdown(self) -> None:
         self.stop = True