def main(): """reads in the options and deletes the matching pilots""" options = Params() options.registerCLISwitches() Script.parseCommandLine(ignoreErrors=True) # make sure *something* is set if not options.site and not options.ce and not options.vo and not options.status: print( "You must chose at least one of the following options: --vo, --ce --site" ) # occasionally the same job might appear twice, but that shouldn't matter conditions = {} if options.status: conditions["Status"] = options.status[0] else: conditions["Status"] = ["Submitted", "Scheduled", "Waiting", "Unknown"] if options.site: conditions["GridSite"] = options.site if options.ce: conditions["DestinationSite"] = options.ce if options.vo: pilotstring = options.vo + "_pilot" conditions["OwnerGroup"] = pilotstring # conditions = {"Status":"Submitted", "GridSite":"LCG.UKI-LT2-IC-HEP.uk", # "OwnerGroup":["lz_pilot", "gridpp_pilot"], "DestinationSite":"ceprod00.grid.hep.ph.ic.ac.uk"} print("Selecting pilots fulfulling the following conditions: %s" % conditions) pilotmanager = PilotManagerClient() result = pilotmanager.selectPilots(conditions) if not result['Value']: print("No pilots matching these criteria were found.") sys.exit(0) print("Found the following matching pilots:") for pilotRef in result['Value']: print(pilotRef) if options.dryrun: print("Dry run only. No pilots will be deleted") sys.exit(0) # now get the pilot references and delete them from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin diracAdmin = DiracAdmin() for pilotRef in result['Value']: result = diracAdmin.killPilot(pilotRef) if not result['OK']: print("Error encountered when deleting pilot %s" % pilotRef) print(result)
def test_PilotsDB(): pilots = PilotManagerClient() res = pilots.addPilotTQReference(['aPilot'], 1, '/a/ownerDN', 'a/owner/Group') assert res['OK'] is True, res['Message'] res = pilots.getCurrentPilotCounters({}) assert res['OK'] is True, res['Message'] assert res['Value'] == {'Submitted': 1}, res['Value'] res = pilots.deletePilots('aPilot') assert res['OK'] is True, res['Message'] res = pilots.getCurrentPilotCounters({}) assert res['OK'] is True, res['Message'] assert res['Value'] == {}, res['Value'] res = pilots.addPilotTQReference(['anotherPilot'], 1, '/a/ownerDN', 'a/owner/Group') assert res['OK'] is True, res['Message'] res = pilots.storePilotOutput('anotherPilot', 'This is an output', 'this is an error') assert res['OK'] is True, res['Message'] res = pilots.getPilotOutput('anotherPilot') assert res['OK'] is True, res['Message'] assert res['Value'] == {'OwnerDN': '/a/ownerDN', 'OwnerGroup': 'a/owner/Group', 'StdErr': 'this is an error', 'FileList': [], 'StdOut': 'This is an output'} res = pilots.getPilotInfo('anotherPilot') assert res['OK'] is True, res['Message'] assert res['Value']['anotherPilot']['AccountingSent'] == 'False', res['Value'] assert res['Value']['anotherPilot']['PilotJobReference'] == 'anotherPilot', res['Value'] res = pilots.selectPilots({}) assert res['OK'] is True, res['Message'] res = pilots.getPilotSummary('', '') assert res['OK'] is True, res['Message'] assert res['Value']['Total']['Submitted'] == 1 res = pilots.getPilotMonitorWeb({}, [], 0, 100) assert res['OK'] is True, res['Message'] assert res['Value']['TotalRecords'] == 1 res = pilots.getPilotMonitorSelectors() assert res['OK'] is True, res['Message'] assert res['Value'] == {'GridType': ['DIRAC'], 'OwnerGroup': ['a/owner/Group'], 'DestinationSite': ['NotAssigned'], 'Broker': ['Unknown'], 'Status': ['Submitted'], 'OwnerDN': ['/a/ownerDN'], 'GridSite': ['Unknown'], 'Owner': []}, res['Value'] res = pilots.getPilotSummaryWeb({}, [], 0, 100) assert res['OK'] is True, res['Message'] assert res['Value']['TotalRecords'] == 1, res['Value'] res = pilots.setAccountingFlag('anotherPilot', 'True') assert res['OK'] is True, res['Message'] res = pilots.setPilotStatus('anotherPilot', 'Running') assert res['OK'] is True, res['Message'] res = pilots.getPilotInfo('anotherPilot') assert res['OK'] is True, res['Message'] assert res['Value']['anotherPilot']['AccountingSent'] == 'True', res['Value'] assert res['Value']['anotherPilot']['Status'] == 'Running', res['Value'] res = pilots.setJobForPilot(123, 'anotherPilot') assert res['OK'] is True, res['Message'] res = pilots.setPilotBenchmark('anotherPilot', 12.3) assert res['OK'] is True, res['Message'] res = pilots.countPilots({}) assert res['OK'] is True, res['Message'] # res = pilots.getCounters() # # getPilotStatistics res = pilots.deletePilots('anotherPilot') assert res['OK'] is True, res['Message'] res = pilots.getCurrentPilotCounters({}) assert res['OK'] is True, res['Message'] assert res['Value'] == {}, res['Value']
def test_PilotsDB(): pilots = PilotManagerClient() # This will allow you to run the test again if necessary for jobID in ["aPilot", "anotherPilot"]: pilots.deletePilots(jobID) res = pilots.addPilotTQReference(["aPilot"], 1, "/a/ownerDN", "a/owner/Group") assert res["OK"], res["Message"] res = pilots.getCurrentPilotCounters({}) assert res["OK"], res["Message"] assert res["Value"] == {"Submitted": 1} res = pilots.deletePilots("aPilot") assert res["OK"], res["Message"] res = pilots.getCurrentPilotCounters({}) assert res["OK"], res["Message"] assert res["Value"] == {} res = pilots.addPilotTQReference(["anotherPilot"], 1, "/a/ownerDN", "a/owner/Group") assert res["OK"], res["Message"] res = pilots.storePilotOutput("anotherPilot", "This is an output", "this is an error") assert res["OK"], res["Message"] res = pilots.getPilotOutput("anotherPilot") assert res["OK"], res["Message"] assert res["Value"] == { "OwnerDN": "/a/ownerDN", "OwnerGroup": "a/owner/Group", "StdErr": "this is an error", "FileList": [], "StdOut": "This is an output", } res = pilots.getPilotInfo("anotherPilot") assert res["OK"], res["Message"] assert res["Value"]["anotherPilot"]["AccountingSent"] == "False" assert res["Value"]["anotherPilot"]["PilotJobReference"] == "anotherPilot" res = pilots.selectPilots({}) assert res["OK"], res["Message"] res = pilots.getPilotSummary("", "") assert res["OK"], res["Message"] assert res["Value"]["Total"]["Submitted"] == 1 res = pilots.getPilotMonitorWeb({}, [], 0, 100) assert res["OK"], res["Message"] assert res["Value"]["TotalRecords"] == 1 res = pilots.getPilotMonitorSelectors() assert res["OK"], res["Message"] assert res["Value"] == { "GridType": ["DIRAC"], "OwnerGroup": ["a/owner/Group"], "DestinationSite": ["NotAssigned"], "Broker": ["Unknown"], "Status": ["Submitted"], "OwnerDN": ["/a/ownerDN"], "GridSite": ["Unknown"], "Owner": [], } res = pilots.getPilotSummaryWeb({}, [], 0, 100) assert res["OK"], res["Message"] assert res["Value"]["TotalRecords"] == 1 res = pilots.setAccountingFlag("anotherPilot", "True") assert res["OK"], res["Message"] res = pilots.setPilotStatus("anotherPilot", "Running") assert res["OK"], res["Message"] res = pilots.getPilotInfo("anotherPilot") assert res["OK"], res["Message"] assert res["Value"]["anotherPilot"]["AccountingSent"] == "True" assert res["Value"]["anotherPilot"]["Status"] == "Running" res = pilots.setJobForPilot(123, "anotherPilot") assert res["OK"], res["Message"] res = pilots.setPilotBenchmark("anotherPilot", 12.3) assert res["OK"], res["Message"] res = pilots.countPilots({}) assert res["OK"], res["Message"] # res = pilots.getCounters() # # getPilotStatistics res = pilots.deletePilots("anotherPilot") assert res["OK"], res["Message"] res = pilots.getCurrentPilotCounters({}) assert res["OK"], res["Message"] assert res["Value"] == {}