X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=findbadpcu.py;h=ca653442ebc50fb329a9be4afd945ddc23303f47;hb=ae32cae5caa3b752d8fb3acaaed73c11662d1189;hp=55422a30231f5cd71e3772517524aecacec177c3;hpb=944d143a6528c4157b71f51ed480aec806cbaa06;p=monitor.git diff --git a/findbadpcu.py b/findbadpcu.py index 55422a3..ca65344 100755 --- a/findbadpcu.py +++ b/findbadpcu.py @@ -5,10 +5,14 @@ import sys import string import time import socket +import util.file +import plc +import sets import signal import traceback +from nodequery import pcu_select #old_handler = signal.getsignal(signal.SIGCHLD) @@ -326,7 +330,7 @@ def checkAndRecordState(l_pcus, cohash): global count global_round = externalState['round'] - tp = threadpool.ThreadPool(20) + tp = threadpool.ThreadPool(10) # CREATE all the work requests for pcuname in l_pcus: @@ -380,11 +384,25 @@ def main(): # update global round number to force refreshes across all nodes externalState['round'] += 1 - if config.nodelist == None and config.pcuid == None: + if config.site is not None: + api = plc.getAuthAPI() + site = api.GetSites(config.site) + l_nodes = api.GetNodes(site[0]['node_ids'], ['pcu_ids']) + pcus = [] + for node in l_nodes: + pcus += node['pcu_ids'] + # clear out dups. + l_pcus = [pcu for pcu in sets.Set(pcus)] + elif config.pcuselect is not None: + n, pcus = pcu_select(config.pcuselect) + # clear out dups. + l_pcus = [pcu for pcu in sets.Set(pcus)] + + elif 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.nodelist is not None: - l_pcus = config.getListFromFile(config.nodelist) + l_pcus = util.file.getListFromFile(config.nodelist) l_pcus = [int(pcu) for pcu in l_pcus] elif config.pcuid is not None: l_pcus = [ config.pcuid ] @@ -409,14 +427,21 @@ if __name__ == '__main__': parser.set_defaults(nodelist=None, increment=False, pcuid=None, + pcuselect=None, + site=None, dbname="findbadpcus", cachenodes=False, refresh=False, ) parser.add_option("-f", "--nodelist", dest="nodelist", metavar="FILE", help="Provide the input file for the node list") + parser.add_option("", "--site", dest="site", metavar="FILE", + help="Get all pcus associated with the given site's nodes") + parser.add_option("", "--pcuselect", dest="pcuselect", metavar="FILE", + help="Query string to apply to the findbad pcus") parser.add_option("", "--pcuid", dest="pcuid", metavar="id", help="Provide the id for a single pcu") + parser.add_option("", "--cachenodes", action="store_true", help="Cache node lookup from PLC") parser.add_option("", "--dbname", dest="dbname", metavar="FILE",