X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=pcubad.py;h=085389faa8a794b520c8c7818e5dda1937a2f8a0;hb=7d52901a1fa58072b9b55aca27ad9f67fa9e5647;hp=59dfe7ae38ed991c78ddf2b5b36b5e76391988f6;hpb=6a452e8ece2ca8a47105c128eaebc38507bc76c5;p=monitor.git diff --git a/pcubad.py b/pcubad.py index 59dfe7a..085389f 100755 --- a/pcubad.py +++ b/pcubad.py @@ -17,7 +17,7 @@ from monitor.wrapper import plc,plccache from monitor.const import MINUP from monitor.common import * -from nodequery import verify,query_to_dict,node_select +from monitor.query import verify,query_to_dict,node_select from monitor.model import * api = plc.getAuthAPI() @@ -64,17 +64,20 @@ def check_pcu_state(rec, pcu): pcu_state = rec.reboot_trial_status - if ( pcu_state == 'NetDown' or pcu_state == 'Not_Run' or not ( pcu_state == 0 or pcu_state == "0" ) ) and \ - ( pcu.status == 'online' or pcu.status == 'good' ): - print "changed status from %s to offline" % pcu.status - pcu.status = 'offline' - pcu.last_changed = datetime.now() + # DOWN + if pcu_state not in [0, "0"] and pcu.status not in ['offline', 'down']: + print "changed status from %s to offline" % pcu.status + pcu.status = 'offline' + pcu.last_changed = datetime.now() - if ( pcu_state == 0 or pcu_state == "0" ) and pcu.status not in [ 'online', 'good' ]: + # ONLINE + if pcu_state in [0, "0"] and pcu.status not in [ 'online', 'good' ]: print "changed status from %s to online" % pcu.status pcu.status = 'online' pcu.last_changed = datetime.now() + + # STATE TRANSITIONS if pcu.status == 'online' and changed_greaterthan(pcu.last_changed, 0.5): #send thank you notice, or on-line notice. print "changed status from %s to good" % pcu.status @@ -85,12 +88,11 @@ def check_pcu_state(rec, pcu): # send down pcu notice print "changed status from %s to down" % pcu.status pcu.status = 'down' - pcu.last_changed = datetime.now() - if ( pcu.status == 'offline' or pcu.status == 'down' ) and changed_greaterthan(pcu.last_changed, 2*30): - print "changed status from %s to down" % pcu.status - pcu.status = 'down' - pcu.last_changed = datetime.now() +# if pcu.status in [ 'offline', 'down' ] and changed_greaterthan(pcu.last_changed, 2*30): +# print "changed status from %s to down" % pcu.status +# pcu.status = 'down' +# pcu.last_changed = datetime.now() def checkAndRecordState(l_pcus, l_plcpcus): count = 0