Add function to check status of a given systemd service.

Returns 'active', 'failed' or 'inactive' strings, depending of
the systemd service status
Signed-off-by: Simental Magana, Marcos <marcos.simental.magana@intel.com>
This commit is contained in:
Simental Magana, Marcos
2016-02-02 16:47:02 -06:00
parent 7f5f6019b2
commit 750ebed4c0
+6
View File
@@ -59,6 +59,12 @@ def port_open(port):
return (sck.connect_ex(('127.0.0.1', port)) == 0)
def service_status(service):
"""Return status of a given systemd service."""
stdout, stderr = run_command("systemctl is-active " + str(service))
return (stdout.strip().decode("utf-8"))
def setup_debugging(debug, is_remote_host=True):
if not os.path.isdir(LOG_DIR):
os.makedirs(LOG_DIR)