executable flag
[monitor.git] / commands / reboot.py
1 from monitor.reboot import *
2
3 def main():
4         logger.setLevel(logging.DEBUG)
5         ch = logging.StreamHandler()
6         ch.setLevel(logging.DEBUG)
7         formatter = logging.Formatter('LOGGER - %(message)s')
8         ch.setFormatter(formatter)
9         logger.addHandler(ch)
10
11         try:
12                 if "test" in sys.argv:
13                         dryrun = True
14                 else:
15                         dryrun = False
16
17                 for node in sys.argv[1:]:
18                         if node == "test": continue
19
20                         print "Rebooting %s" % node
21                         if reboot_policy(node, True, dryrun):
22                                 print "success"
23                         else:
24                                 print "failed"
25         except Exception, err:
26                 import traceback; traceback.print_exc()
27                 from monitor.common import email_exception
28                 email_exception(node)
29                 print err
30
31 if __name__ == '__main__':
32         main()
33         f = open("/tmp/rebootlog", 'a')
34         f.write("reboot %s\n" % sys.argv)
35         f.close()