Add conditional restart (try-restart) capability to services

This will conditionally restart a service if it is active.

https://pagure.io/freeipa/issue/8105

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Ade Lee <alee@redhat.com>
This commit is contained in:
Rob Crittenden
2019-10-25 10:07:33 -04:00
parent 3cb9444c4c
commit 1e3de17269

View File

@@ -173,6 +173,9 @@ class PlatformService:
def restart(self, instance_name="", capture_output=True, wait=True):
pass
def try_restart(self, instance_name="", capture_output=True, wait=True):
pass
def is_running(self, instance_name="", wait=True):
return False
@@ -338,6 +341,10 @@ class SystemdService(PlatformService):
self._restart_base(instance_name, "restart",
capture_output, wait)
def try_restart(self, instance_name="", capture_output=True, wait=True):
self._restart_base(instance_name, "try-restart",
capture_output, wait)
def is_running(self, instance_name="", wait=True):
instance = self.service_instance(instance_name, 'is-active')