]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add a terminate_service systemd function
authorJohn Mulligan <jmulligan@redhat.com>
Sun, 19 Nov 2023 00:00:38 +0000 (19:00 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 2 Jan 2024 14:30:21 +0000 (09:30 -0500)
Add a function that encapsulates the common 3-step process found in
cephadm of stopping, resetting errors, and disabling a service.
This will be used to handle new services to stop as well as cleaning
up some places where the three steps are performed inline.

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

index 69fc8b740868b81b0443604db178f4b9ec28010f..a07757eccadc9dbc3f6126dcaacae4a3f70e093f 100644 (file)
@@ -68,3 +68,21 @@ def check_units(ctx, units, enabler=None):
                 logger.info('Enabling unit %s' % u)
                 enabler.enable_service(u)
     return False
+
+
+def terminate_service(ctx: CephadmContext, service_name: str) -> None:
+    call(
+        ctx,
+        ['systemctl', 'stop', service_name],
+        verbosity=CallVerbosity.DEBUG,
+    )
+    call(
+        ctx,
+        ['systemctl', 'reset-failed', service_name],
+        verbosity=CallVerbosity.DEBUG,
+    )
+    call(
+        ctx,
+        ['systemctl', 'disable', service_name],
+        verbosity=CallVerbosity.DEBUG,
+    )