www/printbadnodes.py
[monitor.git] / findbadpcu.py
index 5f54235..55422a3 100755 (executable)
@@ -380,11 +380,11 @@ def main():
                # update global round number to force refreshes across all nodes
                externalState['round'] += 1
 
-       if config.filename == None and config.pcuid == None:
+       if config.nodelist == None and config.pcuid == None:
                print "Calling API GetPCUs() : refresh(%s)" % config.refresh
                l_pcus  = [pcu['pcu_id'] for pcu in l_pcus]
-       elif config.filename is not None:
-               l_pcus = config.getListFromFile(config.filename)
+       elif config.nodelist is not None:
+               l_pcus = config.getListFromFile(config.nodelist)
                l_pcus = [int(pcu) for pcu in l_pcus]
        elif config.pcuid is not None:
                l_pcus = [ config.pcuid ] 
@@ -404,17 +404,16 @@ if __name__ == '__main__':
        formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
        fh.setFormatter(formatter)
        logger.addHandler(fh)
-       from config import config
-       from optparse import OptionParser
-       parser = OptionParser()
-       parser.set_defaults(filename=None, 
+       import parser as parsermodule
+       parser = parsermodule.getParser()
+       parser.set_defaults(nodelist=None, 
                                                increment=False, 
                                                pcuid=None,
                                                dbname="findbadpcus", 
                                                cachenodes=False,
                                                refresh=False,
                                                )
-       parser.add_option("-f", "--nodelist", dest="filename", metavar="FILE", 
+       parser.add_option("-f", "--nodelist", dest="nodelist", metavar="FILE", 
                                                help="Provide the input file for the node list")
        parser.add_option("", "--pcuid", dest="pcuid", metavar="id", 
                                                help="Provide the id for a single pcu")
@@ -426,8 +425,8 @@ if __name__ == '__main__':
                                                help="Refresh the cached values")
        parser.add_option("-i", "--increment", action="store_true", dest="increment", 
                                                help="Increment round number to force refresh or retry")
-       config = config(parser)
-       config.parse_args()
+       parser = parsermodule.getParser(['defaults'], parser)
+       config = parsermodule.parse_args(parser)
        try:
                # NOTE: evidently, there is a bizarre interaction between iLO and ssh
                # when LANG is set... Do not know why.  Unsetting LANG, fixes the problem.