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()
l_pcus = [pcu for pcu in sets.Set(pcus)]
elif config.node:
- l_nodes = plccache.GetNodeByName(config.node)
- pcus = []
- for node in l_nodes:
- pcus += node['pcu_ids']
+ node = plccache.GetNodeByName(config.node)
+ pcus = node['pcu_ids']
# clear out dups.
l_pcus = [pcu for pcu in sets.Set(pcus)]
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
# 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
except:
print "COULD NOT FIND FB record for %s" % reboot.pcu_name(d_pcu)
import traceback
+ email_exception()
print traceback.print_exc()
# don't have the info to create a new entry right now, so continue.
continue