X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nodebad.py;h=767a4fe634e0c3aa569b89f04625bf2780e99b10;hb=2ecb77e4a1817ecc7ce62dd59fefbb701eac6a83;hp=baa016ced4e779320850d77e1627db3307c92acc;hpb=21f8190281cfb38c3e24dfba6c89420830435f1f;p=monitor.git diff --git a/nodebad.py b/nodebad.py index baa016c..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.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