diff --git a/src/DIRAC/Interfaces/API/DiracAdmin.py b/src/DIRAC/Interfaces/API/DiracAdmin.py index 48119e8e52e..acf94947b4a 100755 --- a/src/DIRAC/Interfaces/API/DiracAdmin.py +++ b/src/DIRAC/Interfaces/API/DiracAdmin.py @@ -19,6 +19,9 @@ from DIRAC.WorkloadManagementSystem.Client.JobManagerClient import JobManagerClient from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient from DIRAC.WorkloadManagementSystem.Client.WMSAdministratorClient import WMSAdministratorClient +from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import ( + killPilotsInQueues, +) voName = "" ret = getProxyInfo(disableVOMS=True) @@ -452,8 +455,28 @@ def killPilot(self, gridReference): if not isinstance(gridReference, (str, list)): return self._errorReport("Expected string or list of strings for pilot reference") - result = PilotManagerClient().killPilot(gridReference) - return result + # Make a list if it is not yet + if isinstance(gridReference, str): + gridReference = [gridReference] + + # Regroup pilots per site + pilotRefDict = {} + for pilotReference in gridReference: + result = PilotManagerClient().getPilotInfo(pilotReference) + if not result["OK"] or not result["Value"]: + return S_ERROR(f"Failed to get info for pilot {pilotReference}") + + pilotDict = result["Value"][pilotReference] + queue = "@@@".join( + [pilotDict["VO"], pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]] + ) + gridType = pilotDict["GridType"] + pilotRefDict.setdefault(queue, {}) + pilotRefDict[queue].setdefault("PilotList", []) + pilotRefDict[queue]["PilotList"].append(pilotReference) + pilotRefDict[queue]["GridType"] = gridType + + return killPilotsInQueues(pilotRefDict) ############################################################################# def getPilotLoggingInfo(self, gridReference): diff --git a/src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py b/src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py index 74123b81b11..5826f00f1a2 100644 --- a/src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py +++ b/src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py @@ -13,7 +13,6 @@ from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import ( getPilotCE, getPilotRef, - killPilotsInQueues, setPilotCredentials, ) @@ -301,35 +300,6 @@ def export_getPilots(cls, jobID): return cls.pilotAgentsDB.getPilotInfo(pilotID=result["Value"]) - ############################################################################## - types_killPilot = [[str, list]] - - @classmethod - def export_killPilot(cls, pilotRefList): - """Kill the specified pilots""" - # Make a list if it is not yet - if isinstance(pilotRefList, str): - pilotRefList = [pilotRefList] - - # Regroup pilots per site - pilotRefDict = {} - for pilotReference in pilotRefList: - result = cls.pilotAgentsDB.getPilotInfo(pilotReference) - if not result["OK"] or not result["Value"]: - return S_ERROR(f"Failed to get info for pilot {pilotReference}") - - pilotDict = result["Value"][pilotReference] - queue = "@@@".join( - [pilotDict["VO"], pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]] - ) - gridType = pilotDict["GridType"] - pilotRefDict.setdefault(queue, {}) - pilotRefDict[queue].setdefault("PilotList", []) - pilotRefDict[queue]["PilotList"].append(pilotReference) - pilotRefDict[queue]["GridType"] = gridType - - return killPilotsInQueues(pilotRefDict) - ############################################################################## types_setJobForPilot = [[str, int], str]