|
6 | 6 |
|
7 | 7 | from DIRAC import S_OK, S_ERROR, gLogger, gConfig
|
8 | 8 | from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getQueue
|
9 |
| -from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getGroupOption, getUsernameForDN, getVOForGroup |
| 9 | +from DIRAC.ConfigurationSystem.Client.Helpers.Registry import ( |
| 10 | + getDNForUsername, |
| 11 | + getGroupOption, |
| 12 | + getVOForGroup, |
| 13 | +) |
10 | 14 | from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
|
11 | 15 | from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
|
12 | 16 | from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager
|
@@ -56,13 +60,20 @@ def getPilotProxy(pilotDict):
|
56 | 60 | :param dict pilotDict: pilot parameters
|
57 | 61 | :return: S_OK/S_ERROR with proxy as Value
|
58 | 62 | """
|
59 |
| - ownerDN = pilotDict["OwnerDN"] |
60 |
| - group = pilotDict["OwnerGroup"] |
61 |
| - |
62 |
| - groupVOMS = getGroupOption(group, "VOMSRole", group) |
63 |
| - result = gProxyManager.getPilotProxyFromVOMSGroup(ownerDN, groupVOMS) |
| 63 | + pilotGroup = pilotDict["OwnerGroup"] |
| 64 | + |
| 65 | + pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN") |
| 66 | + if not pilotDN: |
| 67 | + owner = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotUser") |
| 68 | + res = getDNForUsername(owner) |
| 69 | + if not res["OK"]: |
| 70 | + return S_ERROR(f"Cannot get the generic pilot DN: {res['Message']}") |
| 71 | + pilotDN = res["Value"][0] |
| 72 | + |
| 73 | + groupVOMS = getGroupOption(pilotGroup, "VOMSRole", pilotGroup) |
| 74 | + result = gProxyManager.getPilotProxyFromVOMSGroup(pilotDN, groupVOMS) |
64 | 75 | if not result["OK"]:
|
65 |
| - gLogger.error("Could not get proxy:", f"User \"{ownerDN}\" Group \"{groupVOMS}\" : {result['Message']}") |
| 76 | + gLogger.error("Could not get proxy:", f"User \"{pilotDN}\" Group \"{groupVOMS}\" : {result['Message']}") |
66 | 77 | return S_ERROR("Failed to get the pilot's owner proxy")
|
67 | 78 | return result
|
68 | 79 |
|
@@ -124,19 +135,20 @@ def killPilotsInQueues(pilotRefDict):
|
124 | 135 | ce = result["Value"]
|
125 | 136 |
|
126 | 137 | pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN")
|
127 |
| - |
128 |
| - if pilotGroup and pilotDN: |
129 |
| - res = getUsernameForDN(pilotDN) |
| 138 | + if not pilotDN: |
| 139 | + owner = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotUser") |
| 140 | + res = getDNForUsername(owner) |
130 | 141 | if not res["OK"]:
|
131 |
| - return res |
132 |
| - owner = res["Value"] |
133 |
| - group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup) |
134 |
| - ret = gProxyManager.getPilotProxyFromVOMSGroup(owner, group) |
135 |
| - if not ret["OK"]: |
136 |
| - gLogger.error("Could not get proxy:", f"User '{owner}' Group '{group}' : {ret['Message']}") |
137 |
| - return S_ERROR("Failed to get the pilot's owner proxy") |
138 |
| - proxy = ret["Value"] |
139 |
| - ce.setProxy(proxy) |
| 142 | + return S_ERROR(f"Cannot get the generic pilot DN: {res['Message']}") |
| 143 | + pilotDN = res["Value"][0] |
| 144 | + |
| 145 | + group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup) |
| 146 | + ret = gProxyManager.getPilotProxyFromVOMSGroup(pilotDN, group) |
| 147 | + if not ret["OK"]: |
| 148 | + gLogger.error("Could not get proxy:", f"User '{pilotDN}' Group '{group}' : {ret['Message']}") |
| 149 | + return S_ERROR("Failed to get the pilot's owner proxy") |
| 150 | + proxy = ret["Value"] |
| 151 | + ce.setProxy(proxy) |
140 | 152 |
|
141 | 153 | pilotList = pilotDict["PilotList"]
|
142 | 154 | result = ce.killJob(pilotList)
|
|
0 commit comments