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 committed 2024-09-21 09:22:31 -04:00
1 parent 4a34feefb0
commit 711c19b511
1 file changed
+6
+6
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],