remove old blacklist
[monitor.git] / grouprins.py
index c30e85d..5529418 100755 (executable)
@@ -17,7 +17,8 @@ from monitor import util
 from monitor import const
 from monitor import database
 from monitor import parser as parsermodule
-from pcucontrol  import reboot
+from monitor import reboot
+from monitor.database.info.model import *
 from monitor.wrapper import plc
 api = plc.getAuthAPI()
 
@@ -33,7 +34,7 @@ import time
 
 import bootman                 # debug nodes
 import mailmonitor     # down nodes without pcu
-from emailTxt import mailtxt
+from monitor.wrapper.emailTxt import mailtxt
 import sys
 
 class Reboot(object):
@@ -73,6 +74,7 @@ class Reboot(object):
                                        return ret
 
                                except Exception,e:
+                                       email_exception()
                                        print traceback.print_exc(); print e
 
                                        # NOTE: this failure could be an implementation issue on
@@ -95,6 +97,7 @@ class Reboot(object):
                                        return ret
 
                                except Exception,e:
+                                       email_exception()
                                        print traceback.print_exc(); print e
 
                                        # NOTE: this failure could be an implementation issue on
@@ -138,6 +141,7 @@ class Reboot(object):
                try:
                        return mailmonitor.reboot(host)
                except Exception, e:
+                       email_exception(host)
                        print traceback.print_exc(); print e
                        return False
 
@@ -248,7 +252,8 @@ if config.findbad:
        os.system("./findbad.py --cachenodes --increment --nodelist %s" % file)
        # TODO: shouldn't we reload the node list now?
 
-l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : [])
+q_blacklist = BlacklistRecord.query.all()
+l_blacklist = [ n.hostname for n in q_blacklist ]
 # commands:
 i = 1
 count = 1
@@ -261,6 +266,7 @@ for host in hostnames:
                try:
                        node = api.GetNodes(host)[0]
                except:
+                       email_exception()
                        print traceback.print_exc(); 
                        print "FAILED GETNODES for host: %s" % host
                        continue
@@ -285,6 +291,7 @@ for host in hostnames:
                                        # todo: send thank you, etc.
                                        mailmonitor.reboot(host)
                                except Exception, e:
+                                       email_exception()
                                        print traceback.print_exc(); print e
 
                                continue
@@ -355,6 +362,7 @@ for host in hostnames:
                print "Killed by interrupt"
                sys.exit(0)
        except:
+               email_exception()
                print traceback.print_exc();
                print "Continuing..."