X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nodeinfo.py;h=3c8e4e5adfb5507ebe194bf7a19a292ace71a751;hb=da913fbd1629fc4669b186915df8ff3a340482d3;hp=30838f1a494eef81643da8fcaae307ad49fdcc2f;hpb=944d143a6528c4157b71f51ed480aec806cbaa06;p=monitor.git diff --git a/nodeinfo.py b/nodeinfo.py index 30838f1..3c8e4e5 100755 --- a/nodeinfo.py +++ b/nodeinfo.py @@ -1,20 +1,19 @@ #!/usr/bin/python -import plc +from monitor.wrapper import plc api = plc.getAuthAPI() from monitor import * -#import database -import reboot +from monitor import util +from monitor import parser as parsermodule + +from monitor import database +from monitor.pcu import reboot import time -from model import * +from monitor.model import * from nodecommon import * -from unified_model import node_end_record, PersistFlags - -import util.file - -import parser as parsermodule +#from monitor.model import node_end_record, PersistFlags parser = parsermodule.getParser() parser.set_defaults(node=None, @@ -46,7 +45,10 @@ def plc_print_nodeinfo(plcnode): def fb_print_nodeinfo(fbnode): pf = PersistFlags(fbnode['hostname'], 1, db='node_persistflags') - fbnode['last_change'] = diff_time(pf.last_changed) + try: + fbnode['last_change'] = diff_time(pf.last_changed) + except: + fbnode['last_change'] = diff_time(time.time()) print " Checked: ", if 'checked' in fbnode: print "%11.11s " % diff_time(fbnode['checked']) @@ -76,8 +78,7 @@ def act_print_nodeinfo(actnode, header): if 'rt' in actnode and 'Status' in actnode['rt']: print "\t %5.5s %5.5s | %8.8s | %15.15s | %s" % \ (actnode['rt']['Status'], actnode['rt']['id'][7:], - actnode['category'], actnode['action'][0], - actnode['msg_format'][:-1]) + actnode['category'], actnode['action'][0], actnode['info'][1:]) else: if type(actnode['action']) == type([]): action = actnode['action'][0] @@ -139,11 +140,11 @@ if config.findbad: for node in config.args: config.node = node - fb = database.dbLoad("findbad") plc_nodeinfo = api.GetNodes({'hostname': config.node}, None)[0] - fb_nodeinfo = fb['nodes'][config.node]['values'] - + fb_noderec = FindbadNodeRecord.get_latest_by(hostname=node) + fb_nodeinfo = fb_noderec.to_dict() plc_print_nodeinfo(plc_nodeinfo) + fb_nodeinfo['hostname'] = node fb_print_nodeinfo(fb_nodeinfo)