update to db model. now uses automatic history on updates: acts_as_versioned()
[monitor.git] / bootman.py
index 67ce675..0cd88ec 100755 (executable)
@@ -14,7 +14,7 @@ from getsshkeys import SSHKnownHosts
 
 import subprocess
 import time
-from monitor.util import command as moncommands
+from pcucontrol.util import command as moncommands
 from sets import Set
 
 from pcucontrol.transports.ssh import pxssh as pxssh
@@ -82,11 +82,11 @@ class NodeConnection:
                        print "   ERROR:", x
                        print "   Possibly, unable to find valid configuration file"
 
-               if bm_continue and self.config and not self.config.quiet:
+               if bm_continue:
                        for key in bm.VARS.keys():
                                print key, " == ", bm.VARS[key]
                else:
-                       if self.config and not self.config.quiet: print "   Unable to read Node Configuration"
+                       print "   Unable to read Node Configuration"
                
 
        def compare_and_repair_nodekeys(self):
@@ -308,7 +308,8 @@ def reboot(hostname, config=None, forced_action=None):
        # NOTE: Nothing works if the bootcd is REALLY old.
        #       So, this is the first step.
        fbnode = FindbadNodeRecord.get_latest_by(hostname=hostname).to_dict()
-       if fbnode['category'] == "OLDBOOTCD":
+       print fbnode.keys()
+       if fbnode['observed_category'] == "OLDBOOTCD":
                print "...NOTIFY OWNER TO UPDATE BOOTCD!!!"
                args = {}
                args['hostname_list'] = "    %s" % hostname
@@ -331,6 +332,8 @@ def reboot(hostname, config=None, forced_action=None):
        try:
                k = SSHKnownHosts(); k.update(node); k.write(); del k
        except:
+               from monitor.common import email_exception
+               email_exception()
                print traceback.print_exc()
                return False
 
@@ -340,8 +343,11 @@ def reboot(hostname, config=None, forced_action=None):
                else:
                        session = PlanetLabSession(node, config.nosetup, config.verbose)
        except Exception, e:
-               print "ERROR setting up session for %s" % hostname
+               msg = "ERROR setting up session for %s" % hostname
+               print msg
                print traceback.print_exc()
+               from monitor.common import email_exception
+               email_exception(msg)
                print e
                return False
 
@@ -355,6 +361,8 @@ def reboot(hostname, config=None, forced_action=None):
                        conn = session.get_connection(config)
                except:
                        print traceback.print_exc()
+                       from monitor.common import email_exception
+                       email_exception()
                        return False
 
        if forced_action == "reboot":
@@ -587,6 +595,7 @@ def reboot(hostname, config=None, forced_action=None):
                        # actual solution appears to involve removing the bad files, and
                        # continually trying to boot the node.
                        "bminit-cfg-auth-getplc-update-installinit-validate-rebuildinitrd-netcfg-disk-update4-update3-update3-implementerror-update-debug-done",
+                       "bminit-cfg-auth-getplc-installinit-validate-exception-bmexceptmount-exception-noinstall-update-debug-done",
                        ]:
                sequences.update({n : "restart_bootmanager_rins"})
 
@@ -793,6 +802,8 @@ def reboot(hostname, config=None, forced_action=None):
                                node = api.GetNodes(hostname)[0]
                                net = api.GetNodeNetworks(node['nodenetwork_ids'])[0]
                        except:
+                               from monitor.common import email_exception
+                               email_exception()
                                print traceback.print_exc()
                                # TODO: api error. skip email, b/c all info is not available,
                                # flag_set will not be recorded.