action_utils: Add a method to reset services in 'failed' state

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
James Valleroy 2024-09-21 08:47:21 -04:00
parent 4a34feefb0
commit 711c19b511
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -143,6 +143,12 @@ def service_try_reload_or_restart(service_name):
service_action(service_name, 'try-reload-or-restart')
def service_reset_failed(service_name):
"""Reset the 'failed' state of units."""
service_action(service_name, 'reset-failed')
def service_action(service_name, action):
"""Perform the given action on the service_name."""
subprocess.run(['systemctl', action, service_name],