X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nodebad.py;h=767a4fe634e0c3aa569b89f04625bf2780e99b10;hb=4d56ef5473c6486c321dd2797be45b45b0606dae;hp=5543f903d5fa15c2795ee6826be0d90e6ce55d41;hpb=da913fbd1629fc4669b186915df8ff3a340482d3;p=monitor.git diff --git a/nodebad.py b/nodebad.py index 5543f90..767a4fe 100755 --- a/nodebad.py +++ b/nodebad.py @@ -8,12 +8,13 @@ from datetime import datetime,timedelta from nodequery import verify,query_to_dict,node_select -from nodecommon import * +from monitor.common import * from monitor import config from monitor.wrapper import plc,plccache from monitor.const import MINUP -from monitor.database import FindbadNodeRecord, HistoryNodeRecord +from monitor.database.info.model import FindbadNodeRecord, HistoryNodeRecord +from monitor.database.dborm import mon_session as session from monitor.model import * @@ -54,6 +55,10 @@ def checkAndRecordState(l_nodes, l_plcnodes): print traceback.print_exc() continue + if not noderec: + print "none object for %s"% nodename + continue + node_state = noderec.observed_status if noderec.plc_node_stats: boot_state = noderec.plc_node_stats['boot_state'] @@ -80,6 +85,7 @@ def checkAndRecordState(l_nodes, l_plcnodes): # replace with another operations that also commits all pending ops, such # as session.commit() or flush() or something print HistoryNodeRecord.query.count() + session.flush() return True