X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Freboot.py;h=46d667b0a61c5dc58b7e7bb265036994811d07bd;hb=fbe2fbd7f5d866205f878e68968dcef14a3812ab;hp=15d5c522d649a42190a9541f5b307555fbe187f7;hpb=c9d06f3b274ecbc092a0b3eb1f5ceb6c0f734aad;p=monitor.git diff --git a/monitor/reboot.py b/monitor/reboot.py index 15d5c52..46d667b 100755 --- a/monitor/reboot.py +++ b/monitor/reboot.py @@ -9,7 +9,7 @@ import xml, xmlrpclib import errno, time, traceback import urllib2 import urllib -import threading, popen2 +import threading import array, struct import base64 from subprocess import PIPE, Popen @@ -108,37 +108,6 @@ def reboot_policy(nodename, continue_probe, dryrun): print "return true" return True -def main(): - logger.setLevel(logging.DEBUG) - ch = logging.StreamHandler() - ch.setLevel(logging.DEBUG) - formatter = logging.Formatter('LOGGER - %(message)s') - ch.setFormatter(formatter) - logger.addHandler(ch) +if __name__ == "__main__": + print "ERROR: Can not execute module as a command! Please use commands/%s.py" % os.path.splitext(__file__)[0] - try: - if "test" in sys.argv: - dryrun = True - else: - dryrun = False - - for node in sys.argv[1:]: - if node == "test": continue - - print "Rebooting %s" % node - if reboot_policy(node, True, dryrun): - print "success" - else: - print "failed" - except Exception, err: - import traceback; traceback.print_exc() - from monitor.common import email_exception - email_exception(node) - print err - -if __name__ == '__main__': - logger = logging.getLogger("monitor") - main() - f = open("/tmp/rebootlog", 'a') - f.write("reboot %s\n" % sys.argv) - f.close()