From c3d536f77d62da7c37406dd831dae8d22cb9bd1a Mon Sep 17 00:00:00 2001 From: DmitriyEshenko Date: Mon, 9 Aug 2021 09:55:11 +0000 Subject: openconnect: T3695: Add systemd service checker on commit --- python/vyos/util.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python') diff --git a/python/vyos/util.py b/python/vyos/util.py index be7c53438..28f0c9bd1 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -702,3 +702,9 @@ def get_interface_config(interface): from json import loads tmp = loads(cmd(f'ip -d -j link show {interface}'))[0] return tmp + +def is_systemd_service_running(service): + """ Test is a specified systemd service is actually running. + Returns True if service is running, false otherwise. """ + tmp = run(f'systemctl is-active --quiet {service}') + return bool((tmp == 0)) -- cgit v1.2.3