From: John Mulligan Date: Sun, 19 Nov 2023 00:00:38 +0000 (-0500) Subject: cephadm: add a terminate_service systemd function X-Git-Tag: v19.3.0~284^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=87e6dc6c5fac5f3ad2641015ffebd4206bc9a0b0;p=ceph.git cephadm: add a terminate_service systemd function 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 --- diff --git a/src/cephadm/cephadmlib/systemd.py b/src/cephadm/cephadmlib/systemd.py index 69fc8b740868..a07757eccadc 100644 --- a/src/cephadm/cephadmlib/systemd.py +++ b/src/cephadm/cephadmlib/systemd.py @@ -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, + )