X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=pcubad.py;h=59dfe7ae38ed991c78ddf2b5b36b5e76391988f6;hb=cd00bfb50bf22f4a06b1a12dcf43839698f390eb;hp=16a8f4ffe95b188724c3ea5003a42ca99675669f;hpb=918528c7c4bf21956b8eaba4d599fed998d8c345;p=monitor.git diff --git a/pcubad.py b/pcubad.py index 16a8f4f..59dfe7a 100755 --- a/pcubad.py +++ b/pcubad.py @@ -31,8 +31,8 @@ def main2(config): l_pcus = None if config.site is not None: - site = api.GetSites(config.site) - l_nodes = api.GetNodes(site[0]['node_ids'], ['pcu_ids']) + site = plccache.GetSitesByName([config.site]) + l_nodes = plccache.GetNodesByIds(site[0]['node_ids']) pcus = [] for node in l_nodes: pcus += node['pcu_ids'] @@ -40,10 +40,8 @@ def main2(config): l_pcus = [pcu for pcu in sets.Set(pcus)] elif config.node: - l_nodes = api.GetNodes(config.node, ['pcu_ids']) - 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)] @@ -72,7 +70,7 @@ def check_pcu_state(rec, pcu): pcu.status = 'offline' pcu.last_changed = datetime.now() - if ( pcu_state == 0 or pcu_state == "0" ) and changed_lessthan(pcu.last_changed, 0.5) and pcu.status != 'online': + if ( pcu_state == 0 or pcu_state == "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() @@ -117,6 +115,7 @@ def checkAndRecordState(l_pcus, l_plcpcus): 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