Skip to content

Commit 1bd1c7f

Browse files
committed
feat: using owner instead of ownerDN
1 parent 87fc17d commit 1bd1c7f

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

src/DIRAC/TransformationSystem/Agent/RequestTaskAgent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def initialize(self):
6565

6666
return S_OK()
6767

68-
def _getClients(self, ownerDN=None, ownerGroup=None):
68+
def _getClients(self, owner=None, ownerGroup=None):
6969
"""Set the clients for task submission.
7070
7171
Here the taskManager becomes a RequestTasks object.
7272
7373
See :func:`DIRAC.TransformationSystem.TaskManagerAgentBase._getClients`.
7474
"""
75-
res = super()._getClients(ownerDN=ownerDN, ownerGroup=ownerGroup)
76-
threadTaskManager = self.requestTasksCls(ownerDN=ownerDN, ownerGroup=ownerGroup)
75+
res = super()._getClients(owner=owner, ownerGroup=ownerGroup)
76+
threadTaskManager = self.requestTasksCls(owner=owner, ownerGroup=ownerGroup)
7777
res.update({"TaskManager": threadTaskManager})
7878
return res

src/DIRAC/TransformationSystem/Agent/TaskManagerAgentBase.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from DIRAC.Core.Utilities.List import breakListIntoChunks
1919
from DIRAC.Core.Utilities.Dictionaries import breakDictionaryIntoChunks
2020
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
21-
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername, getUsernameForDN
2221
from DIRAC.TransformationSystem.Client.FileReport import FileReport
2322
from DIRAC.TransformationSystem.Client.WorkflowTasks import WorkflowTasks
2423
from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient
@@ -249,21 +248,21 @@ def _selectTransformations(self, transType=None, status=None, agentType=None):
249248

250249
#############################################################################
251250

252-
def _getClients(self, ownerDN=None, ownerGroup=None):
251+
def _getClients(self, owner=None, ownerGroup=None):
253252
"""Returns the clients used in the threads
254253
255254
This is another function that should be extended.
256255
257256
The clients provided here are defaults, and should be adapted
258257
259-
If ownerDN and ownerGroup are not None the clients will delegate to these credentials
258+
If owner and ownerGroup are not None the clients will delegate to these credentials
260259
261-
:param str ownerDN: DN of the owner of the submitted jobs
260+
:param str owner: owner of the submitted jobs
262261
:param str ownerGroup: group of the owner of the submitted jobs
263262
:returns: dict of Clients
264263
"""
265264
threadTransformationClient = TransformationClient()
266-
threadTaskManager = WorkflowTasks(ownerDN=ownerDN, ownerGroup=ownerGroup)
265+
threadTaskManager = WorkflowTasks(owner=owner, ownerGroup=ownerGroup)
267266
threadTaskManager.pluginLocation = self.pluginLocation
268267

269268
return {"TransformationClient": threadTransformationClient, "TaskManager": threadTaskManager}
@@ -274,7 +273,7 @@ def _execute(self, transDict):
274273
clients = (
275274
self._getClients()
276275
if self.shifterProxy
277-
else self._getClients(ownerGroup=self.credTuple[1], ownerDN=self.credTuple[2])
276+
else self._getClients(owner=self.credTuple[0], ownerGroup=self.credTuple[1])
278277
if self.credentials
279278
else None
280279
)
@@ -288,8 +287,8 @@ def _execute(self, transDict):
288287
transID = transDict["TransformationID"]
289288
operations = transDict["Operations"]
290289
if not (self.credentials or self.shifterProxy):
291-
ownerDN, group = transDict["OwnerDN"], transDict["OwnerGroup"]
292-
clients = self._getClients(ownerDN=ownerDN, ownerGroup=group)
290+
owner, group = transDict["Owner"], transDict["OwnerGroup"]
291+
clients = self._getClients(owner=owner, ownerGroup=group)
293292
self._logInfo("Start processing transformation", method=method, transID=transID)
294293
for operation in operations:
295294
self._logInfo(f"Executing {operation}", method=method, transID=transID)
@@ -651,30 +650,28 @@ def _addOperationForTransformations(
651650
transformations,
652651
owner=None,
653652
ownerGroup=None,
654-
ownerDN=None,
655653
):
656654
"""Fill the operationsOnTransformationDict"""
657655

658656
transformationIDsAndBodies = (
659657
(
660658
transformation["TransformationID"],
661659
transformation["Body"],
662-
transformation["AuthorDN"],
660+
transformation["Author"],
663661
transformation["AuthorGroup"],
664662
)
665663
for transformation in transformations["Value"]
666664
)
667-
for transID, body, t_ownerDN, t_ownerGroup in transformationIDsAndBodies:
665+
for transID, body, t_owner, t_ownerGroup in transformationIDsAndBodies:
668666
if transID in operationsOnTransformationDict:
669667
operationsOnTransformationDict[transID]["Operations"].append(operation)
670668
else:
671669
operationsOnTransformationDict[transID] = {
672670
"TransformationID": transID,
673671
"Body": body,
674672
"Operations": [operation],
675-
"Owner": owner if owner else getUsernameForDN(t_ownerDN)["Value"],
673+
"Owner": owner if owner else t_owner,
676674
"OwnerGroup": ownerGroup if owner else t_ownerGroup,
677-
"OwnerDN": ownerDN if owner else t_ownerDN,
678675
}
679676

680677
def __getCredentials(self):
@@ -691,7 +688,6 @@ def __getCredentials(self):
691688
owner = resCred["Value"]["User"]
692689
ownerGroup = resCred["Value"]["Group"]
693690
# returns a list
694-
ownerDN = getDNForUsername(owner)["Value"][0]
695-
self.credTuple = (owner, ownerGroup, ownerDN)
691+
self.credTuple = (owner, ownerGroup)
696692
self.log.info(f"Cred: Tasks will be submitted with the credentials {owner}:{ownerGroup}")
697693
return S_OK()

src/DIRAC/TransformationSystem/Client/RequestTasks.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from DIRAC import S_OK, S_ERROR, gLogger
44

5+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername
56
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
67
from DIRAC.Core.Utilities.JEncode import decode
7-
88
from DIRAC.RequestManagementSystem.Client.ReqClient import ReqClient
99
from DIRAC.RequestManagementSystem.Client.Request import Request
1010
from DIRAC.RequestManagementSystem.Client.Operation import Operation
@@ -35,7 +35,7 @@ def __init__(
3535
requestClient=None,
3636
requestClass=None,
3737
requestValidator=None,
38-
ownerDN=None,
38+
owner=None,
3939
ownerGroup=None,
4040
):
4141
"""c'tor
@@ -49,11 +49,13 @@ def __init__(
4949
logger = gLogger.getSubLogger(self.__class__.__name__)
5050

5151
super().__init__(transClient, logger)
52-
useCertificates = True if (bool(ownerDN) and bool(ownerGroup)) else False
52+
useCertificates = True if (bool(owner) and bool(ownerGroup)) else False
5353

5454
if not requestClient:
5555
self.requestClient = ReqClient(
56-
useCertificates=useCertificates, delegatedDN=ownerDN, delegatedGroup=ownerGroup
56+
useCertificates=useCertificates,
57+
delegatedDN=getDNForUsername(owner)["Value"][0] if owner else None,
58+
delegatedGroup=ownerGroup,
5759
)
5860
else:
5961
self.requestClient = requestClient

src/DIRAC/TransformationSystem/Client/WorkflowTasks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from DIRAC import S_OK, S_ERROR, gLogger
77
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
8+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername
89
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
910
from DIRAC.Core.Utilities.List import fromChar
1011
from DIRAC.Core.Utilities.DErrno import ETSDATA, ETSUKN
@@ -29,7 +30,7 @@ def __init__(
2930
jobClass=None,
3031
opsH=None,
3132
destinationPlugin=None,
32-
ownerDN=None,
33+
owner=None,
3334
ownerGroup=None,
3435
):
3536
"""Generates some default objects.
@@ -42,10 +43,12 @@ def __init__(
4243

4344
super().__init__(transClient, logger)
4445

45-
useCertificates = bool(bool(ownerDN) and bool(ownerGroup))
46+
useCertificates = bool(bool(owner) and bool(ownerGroup))
4647
if not submissionClient:
4748
self.submissionClient = WMSClient(
48-
useCertificates=useCertificates, delegatedDN=ownerDN, delegatedGroup=ownerGroup
49+
useCertificates=useCertificates,
50+
delegatedDN=getDNForUsername(owner)["Value"][0] if owner else None,
51+
delegatedGroup=ownerGroup,
4952
)
5053
else:
5154
self.submissionClient = submissionClient

src/DIRAC/WorkloadManagementSystem/Agent/StalledJobAgent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ def _sendKillCommand(self, job):
607607
ownerGroup = res["Value"]
608608

609609
wmsClient = WMSClient(
610-
useCertificates=True, delegatedDN=getDNForUsername(owner)["Value"][0], delegatedGroup=ownerGroup
610+
useCertificates=True,
611+
delegatedDN=getDNForUsername(owner)["Value"][0] if owner else None,
612+
delegatedGroup=ownerGroup,
611613
)
612614
return wmsClient.killJob(job)

0 commit comments

Comments
 (0)