X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=findbad.py;h=47459ad3e5b1ba422dae16d78641921ff377eb07;hb=6d46ab9b534b60675a3dcb11fcb664589a3691f8;hp=7efa52cd0507810842851895979295b51e456334;hpb=6496f5b4a0220e4055fee76c97f92293f9559117;p=monitor.git diff --git a/findbad.py b/findbad.py index 7efa52c..47459ad 100755 --- a/findbad.py +++ b/findbad.py @@ -4,6 +4,8 @@ import os import sys import string import time +import config +import util.file # QUERY all nodes. @@ -29,8 +31,7 @@ import syncplcdb from nodequery import verify,query_to_dict,node_select import traceback import plc -import auth -api = plc.PLC(auth.auth, auth.plc) +api = plc.getAuthAPI() def collectPingAndSSH(nodename, cohash): ### RUN PING ###################### @@ -341,8 +342,8 @@ def main(): #cohash = {} cohash = cotop.coget(cotop_url) l_nodes = syncplcdb.create_plcdb() - if config.filename: - f_nodes = config.getListFromFile(config.filename) + if config.nodelist: + f_nodes = util.file.getListFromFile(config.nodelist) l_nodes = filter(lambda x: x['hostname'] in f_nodes, l_nodes) elif config.node: f_nodes = [config.node] @@ -359,7 +360,8 @@ def main(): # perform this query after the above options, so that the filter above # does not break. if config.nodeselect: - l_nodes = node_select(config.nodeselect) + fb = database.dbLoad("findbad") + l_nodes = node_select(config.nodeselect, fb['nodes'].keys(), fb) print "fetching %s hosts" % len(l_nodes) @@ -369,30 +371,21 @@ def main(): if __name__ == '__main__': - from config import config - from optparse import OptionParser - parser = OptionParser() - parser.set_defaults(filename=None, node=None, site=None, nodeselect=False, nodegroup=None, - increment=False, dbname="findbadnodes", cachenodes=False) - parser.add_option("", "--node", dest="node", metavar="hostname", - help="Provide a single node to operate on") - parser.add_option("-f", "--nodelist", dest="filename", metavar="FILE", - help="Provide the input file for the node list") - parser.add_option("", "--nodeselect", dest="nodeselect", metavar="query string", - help="Provide a selection string to return a node list.") - parser.add_option("", "--nodegroup", dest="nodegroup", metavar="FILE", - help="Provide the nodegroup for the list of nodes.") - parser.add_option("", "--site", dest="site", metavar="site name", - help="Specify a site to view node status") + import parser as parsermodule + parser = parsermodule.getParser(['nodesets']) + + parser.set_defaults( increment=False, dbname="findbad", cachenodes=False) parser.add_option("", "--cachenodes", action="store_true", help="Cache node lookup from PLC") parser.add_option("", "--dbname", dest="dbname", metavar="FILE", help="Specify the name of the database to which the information is saved") 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) + + cfg = parsermodule.parse_args(parser) try: main()