From 32e47491837a321e684ea167ab6aa430145562f1 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Wed, 31 Aug 2011 20:11:21 +0000 Subject: [PATCH] Minor updates: pcuinfo is a simple db query enable reboot command add an fprobe repair to bootman.py account for new pcu type in monitorweb/controllers --- commands/pcuinfo.py | 49 +++++++----------------- commands/reboot.py | 2 +- monitor/bootman.py | 22 ++++++++++- monitor/reboot.py | 2 +- web/MonitorWeb/monitorweb/controllers.py | 10 ++++- 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/commands/pcuinfo.py b/commands/pcuinfo.py index c9d1e90..108f86c 100755 --- a/commands/pcuinfo.py +++ b/commands/pcuinfo.py @@ -1,8 +1,8 @@ #!/usr/bin/python -import database -import plc -import parser as parsermodule +#import database +from monitor.wrapper import plccache +import monitor.parser as parsermodule import sys from reboot import pcu_name, get_pcu_values @@ -12,43 +12,20 @@ def print_dict(dict): for key in dict.keys(): print "%30s : %s" % (key, dict[key]) -parser = parsermodule.getParser() -parser.set_defaults(withpcu=False, - refresh=False) -parser.add_option("-f", "--nodelist",dest="filename",default="", metavar="FILE", - help="Provide the input file for the downnode list") -parser.add_option("", "--refresh", action="store_true", dest="refresh", - help="Refresh the cached values") - -config = parsermodule.parse_args(parser) - -if not config.run: - k = config.__dict__.keys() - k.sort() - for o in k: - print o, "=", config.__dict__[o] - print "Add --run to actually perform the command" - sys.exit(1) - -pculist = plccache.l_pcus # database.if_cached_else_refresh(1, - # config.refresh, - # "pculist", - # lambda : plc.GetPCUs()) +pculist = plccache.l_pcus for pcu in pculist: - #print pcu - #sys.exit(1) - if pcu['model'] == None: + if 'model' in pcu and pcu['model'] == None: continue - if True: # pcu['model'].find("APC AP79xx/Masterswitch") >= 0: + if True: host = pcu_name(pcu) values = get_pcu_values(pcu['pcu_id']) - if 'portstatus' not in values: - portstatus = "" - else: - if values['reboot'] == 0 or (not isinstance(values['reboot'],int) and values['reboot'].find("error") >= 0): - portstatus = "22:%(22)s 23:%(23)s" % values['portstatus'] - if values['reboot'] == 0: - print "%6d %20s %50s %s" % (pcu['pcu_id'], pcu['password'], "%s@%s" % (pcu['username'], host), portstatus) + #if 'port_status' not in values: + # portstatus = "" + #else: + # if values['reboot_trial_status'] == 0 or (not isinstance(values['reboot_trial_status'],int) and values['reboot_trial_status'].find("error") >= 0): + # portstatus = "22:%(22)s 23:%(23)s" % values['port_status'] + #if 'reboot_trial_status' in values and (values['reboot_trial_status'] == 0 or values['reboot_trial_status'] == "0"): + print "%6d: %10s %20s %50s reboot:%s" % (pcu['pcu_id'], pcu['model'], pcu['password'], "%s@%s" % (pcu['username'], host), values['reboot_trial_status']) #database.dbDump("pculist", pculist, 'php') diff --git a/commands/reboot.py b/commands/reboot.py index 4963900..d5ce318 100755 --- a/commands/reboot.py +++ b/commands/reboot.py @@ -32,7 +32,7 @@ def main(): print err if __name__ == '__main__': - #main() + main() f = open("/tmp/rebootlog", 'a') f.write("reboot %s %s\n" % (time.time(), " ".join(sys.argv[1:]))) f.close() diff --git a/monitor/bootman.py b/monitor/bootman.py index 2070e00..9754218 100755 --- a/monitor/bootman.py +++ b/monitor/bootman.py @@ -129,6 +129,21 @@ class NodeConnection: print key, " == ", bm.VARS[key] else: print " Unable to read Node Configuration" + + def fprobe_repair_node(self): + # When fprobe data gets too much, it fills the root partition and + # fails to boot + c = self.c + self.c.modules.sys.path.append("/tmp/source/") + + # NOTE: assume that the root fs is already mounted... + if self.c.modules.os.path.exists('/tmp/mnt/sysimg/var/local/fprobe'): + print "CLEARING FPROBE DATA on %s" % self.node + self.c.modules.os.chdir('/tmp/mnt/sysimg/var/local/fprobe') + cmd = """ ls -lrt . | awk '{if (i