X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tools.py;h=02e2ab9b7193b17f8f9aef7e9e6ccd3f9f65215a;hb=385b6b2088b9e9413e3b85f46adb18d4a38eebbb;hp=f08182632d657c3b2493a66f0b77b21d9eaa0b1e;hpb=cbe129e67722d4c042fd48d045ef43d8796381e8;p=nodemanager.git diff --git a/tools.py b/tools.py index f081826..02e2ab9 100644 --- a/tools.py +++ b/tools.py @@ -310,6 +310,15 @@ def get_node_virt (): f.write(virt) return virt +### this return True or False to indicate that systemctl is present on that box +# cache result in memory as _has_systemctl +_has_systemctl=None +def has_systemctl (): + global _has_systemctl + if _has_systemctl is None: + _has_systemctl = (subprocess.call([ 'systemctl', '--help' ]) == 0) + return _has_systemctl + # how to run a command in a slice # now this is a painful matter # the problem is with capsh that forces a bash command to be injected in its exec'ed command @@ -333,7 +342,7 @@ def command_in_slice (slicename, argv): def init_signals (): def handler (signum, frame): logger.log("Received signal %d - exiting"%signum) - exit(1) + os._exit(1) signal.signal(signal.SIGHUP,handler) signal.signal(signal.SIGQUIT,handler) signal.signal(signal.SIGINT,handler)