]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add option to install systemd unit only 53987/head
authorCyril Duval <cyril.duval@diabolocom.com>
Thu, 12 Oct 2023 11:11:15 +0000 (13:11 +0200)
committerCyril Duval <cyril.duval@diabolocom.com>
Thu, 19 Oct 2023 08:45:03 +0000 (10:45 +0200)
Cephadm is responsible for installing systemd units on the system. If
for some reasons the units are missing, this newly added option cephadm
    unit-install will install them (and do nothing else).

This is useful in some cases where going through the others means of
creating such unit are not possible, or do extra unwanted things.

Signed-off-by: Cyril Duval <cyril.duval@diabolocom.com>
src/cephadm/cephadm.py

index 4901abf42cd37692049d6ddf6b6bad4eda5ffef7..e58f523c0fc9205d918622f856434f0616b12669 100755 (executable)
@@ -5493,6 +5493,24 @@ def command_ceph_volume(ctx):
 ##################################
 
 
+def command_unit_install(ctx):
+    # type: (CephadmContext) -> int
+    if not ctx.fsid:
+        raise Error('must pass --fsid to specify cluster')
+
+    fsid = ctx.fsid
+    install_base_units(ctx, fsid)
+    unit = get_unit_file(ctx, fsid)
+    unit_file = 'ceph-%s@.service' % (fsid)
+    with open(ctx.unit_dir + '/' + unit_file + '.new', 'w') as f:
+        f.write(unit)
+        os.rename(ctx.unit_dir + '/' + unit_file + '.new',
+                  ctx.unit_dir + '/' + unit_file)
+    call_throws(ctx, ['systemctl', 'daemon-reload'])
+
+    return 0
+
+
 @infer_fsid
 def command_unit(ctx):
     # type: (CephadmContext) -> int
@@ -7223,6 +7241,10 @@ def _get_parser():
         required=True,
         help='daemon name (type.id)')
 
+    parser_unit_install = subparsers.add_parser(
+        'unit-install', help="Install the daemon's systemd unit")
+    parser_unit_install.set_defaults(func=command_unit_install)
+
     parser_logs = subparsers.add_parser(
         'logs', help='print journald logs for a daemon container')
     parser_logs.set_defaults(func=command_logs)