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