Skip to content

Commit 25d6120

Browse files
committed
feat: store in TransformationDB the Author alongside the AuthorDN
1 parent 506eadc commit 25d6120

14 files changed

+81
-174
lines changed

src/DIRAC/TransformationSystem/Agent/TaskManagerAgentBase.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, *args, **kwargs):
5050
# credentials
5151
self.shifterProxy = None
5252
self.credentials = None
53-
self.credTuple = (None, None, None)
53+
self.credTuple = (None, None)
5454

5555
self.pluginLocation = ""
5656
self.bulkSubmissionFlag = False
@@ -101,17 +101,16 @@ def execute(self):
101101
"""The execution method is transformations that need to be processed"""
102102

103103
# 1. determining which credentials will be used for the submission
104-
owner, ownerGroup, ownerDN = None, None, None
104+
owner, ownerGroup = None, None
105105
# getting the credentials for submission
106106
resProxy = getProxyInfo(proxy=False, disableVOMS=False)
107107
if resProxy["OK"]: # there is a shifterProxy
108108
proxyInfo = resProxy["Value"]
109109
owner = proxyInfo["username"]
110110
ownerGroup = proxyInfo["group"]
111-
ownerDN = proxyInfo["identity"]
112111
self.log.info(f"ShifterProxy: Tasks will be submitted with the credentials {owner}:{ownerGroup}")
113112
elif self.credentials:
114-
owner, ownerGroup, ownerDN = self.credTuple
113+
owner, ownerGroup = self.credTuple
115114
else:
116115
self.log.info("Using per Transformation Credentials!")
117116

@@ -137,7 +136,6 @@ def execute(self):
137136
transformations,
138137
owner=owner,
139138
ownerGroup=ownerGroup,
140-
ownerDN=ownerDN,
141139
)
142140

143141
# 2.2. Determine whether the task files status is to be monitored and updated
@@ -159,7 +157,6 @@ def execute(self):
159157
transformations,
160158
owner=owner,
161159
ownerGroup=ownerGroup,
162-
ownerDN=ownerDN,
163160
)
164161

165162
# Determine whether the checking of reserved tasks is to be performed
@@ -181,7 +178,6 @@ def execute(self):
181178
transformations,
182179
owner=owner,
183180
ownerGroup=ownerGroup,
184-
ownerDN=ownerDN,
185181
)
186182

187183
# Determine whether the submission of tasks is to be performed
@@ -210,7 +206,6 @@ def execute(self):
210206
transformations,
211207
owner=owner,
212208
ownerGroup=ownerGroup,
213-
ownerDN=ownerDN,
214209
)
215210

216211
# now call _execute...

src/DIRAC/TransformationSystem/Agent/TransformationCleaningAgent.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ def execute(self):
148148
self._executeClean(transDict)
149149
else:
150150
self.log.info(
151-
f"Cleaning transformation {transDict['TransformationID']} with {transDict['AuthorDN']}, {transDict['AuthorGroup']}"
151+
f"Cleaning transformation {transDict['TransformationID']} with {transDict['Author']}, {transDict['AuthorGroup']}"
152152
)
153153
executeWithUserProxy(self._executeClean)(
154-
transDict, proxyUserDN=transDict["AuthorDN"], proxyUserGroup=transDict["AuthorGroup"]
154+
transDict, proxyUserName=transDict["Author"], proxyUserGroup=transDict["AuthorGroup"]
155155
)
156156
else:
157157
self.log.error("Failed to get transformations", res["Message"])
@@ -164,11 +164,11 @@ def execute(self):
164164
self._executeRemoval(transDict)
165165
else:
166166
self.log.info(
167-
"Removing files for transformation %(TransformationID)s with %(AuthorDN)s, %(AuthorGroup)s"
167+
"Removing files for transformation %(TransformationID)s with %(Author)s, %(AuthorGroup)s"
168168
% transDict
169169
)
170170
executeWithUserProxy(self._executeRemoval)(
171-
transDict, proxyUserDN=transDict["AuthorDN"], proxyUserGroup=transDict["AuthorGroup"]
171+
transDict, proxyUserName=transDict["Author"], proxyUserGroup=transDict["AuthorGroup"]
172172
)
173173
else:
174174
self.log.error("Could not get the transformations", res["Message"])
@@ -186,11 +186,11 @@ def execute(self):
186186
self._executeArchive(transDict)
187187
else:
188188
self.log.info(
189-
"Archiving files for transformation %(TransformationID)s with %(AuthorDN)s, %(AuthorGroup)s"
189+
"Archiving files for transformation %(TransformationID)s with %(Author)s, %(AuthorGroup)s"
190190
% transDict
191191
)
192192
executeWithUserProxy(self._executeArchive)(
193-
transDict, proxyUserDN=transDict["AuthorDN"], proxyUserGroup=transDict["AuthorGroup"]
193+
transDict, proxyUserName=transDict["Author"], proxyUserGroup=transDict["AuthorGroup"]
194194
)
195195
else:
196196
self.log.error("Could not get the transformations", res["Message"])
@@ -244,22 +244,22 @@ def finalize(self):
244244
self._executeClean(transDict)
245245
else:
246246
self.log.info(
247-
f"Cleaning transformation {transDict['TransformationID']} with {transDict['AuthorDN']}, {transDict['AuthorGroup']}"
247+
f"Cleaning transformation {transDict['TransformationID']} with {transDict['Author']}, {transDict['AuthorGroup']}"
248248
)
249249
executeWithUserProxy(self._executeClean)(
250-
transDict, proxyUserDN=transDict["AuthorDN"], proxyUserGroup=transDict["AuthorGroup"]
250+
transDict, proxyUserName=transDict["Author"], proxyUserGroup=transDict["AuthorGroup"]
251251
)
252252

253253
for transDict in toArchive:
254254
if self.shifterProxy:
255255
self._executeArchive(transDict)
256256
else:
257257
self.log.info(
258-
"Archiving files for transformation %(TransformationID)s with %(AuthorDN)s, %(AuthorGroup)s"
258+
"Archiving files for transformation %(TransformationID)s with %(Author)s, %(AuthorGroup)s"
259259
% transDict
260260
)
261261
executeWithUserProxy(self._executeArchive)(
262-
transDict, proxyUserDN=transDict["AuthorDN"], proxyUserGroup=transDict["AuthorGroup"]
262+
transDict, proxyUserName=transDict["Author"], proxyUserGroup=transDict["AuthorGroup"]
263263
)
264264

265265
# Remove JobIDs that were unknown to the TransformationSystem

src/DIRAC/TransformationSystem/Agent/test/Test_Agent_TransformationSystem.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ def test_checkReservedTasks(
148148
"TransformationID": 1,
149149
"Operations": ["op1", "op2"],
150150
"Body": "veryBigBody",
151-
"Owner": "prodMan",
152-
"OwnerDN": "/ca=man/user=prodMan",
153-
"OwnerGroup": "prodMans",
151+
"Owner": "prod",
152+
"OwnerGroup": "prods",
154153
}
155154
sOkJobDict = {"OK": True, "Value": {"JobDictionary": {123: "foo", 456: "bar"}}}
156155
sOkJobs = {"OK": True, "Value": {123: "foo", 456: "bar"}}

src/DIRAC/TransformationSystem/Client/RequestTasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from DIRAC import S_OK, S_ERROR, gLogger
44

5-
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername
65
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
76
from DIRAC.Core.Utilities.JEncode import decode
87

src/DIRAC/TransformationSystem/Client/Transformation.py

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from DIRAC.TransformationSystem.Client.BodyPlugin.BaseBody import BaseBody
1212
from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient
1313
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
14-
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1514
from DIRAC.RequestManagementSystem.Client.Operation import Operation
1615

1716
COMPONENT_NAME = "Transformation"
@@ -269,7 +268,7 @@ def getTransformationLogging(self, printOutput=False):
269268
loggingList = res["Value"]
270269
if printOutput:
271270
self._printFormattedDictList(
272-
loggingList, ["Message", "MessageDate", "AuthorDN"], "MessageDate", "MessageDate"
271+
loggingList, ["Message", "MessageDate", "Author"], "MessageDate", "MessageDate"
273272
)
274273
return S_OK(loggingList)
275274

@@ -425,63 +424,19 @@ def getTransformations(
425424
self._printFormattedDictList(res["Value"], outputFields, "TransformationID", orderBy)
426425
return res
427426

428-
#############################################################################
429-
def getAuthorDNfromProxy(self):
430-
"""gets the AuthorDN and username of the transformation from the uploaded proxy"""
431-
username = ""
432-
author = ""
433-
res = getProxyInfo()
434-
if res["OK"]:
435-
author = res["Value"]["identity"]
436-
username = res["Value"]["username"]
437-
else:
438-
gLogger.error(f"Unable to get uploaded proxy Info {res['Message']} ")
439-
return S_ERROR(res["Message"])
440-
441-
res = {"username": username, "authorDN": author}
442-
return S_OK(res)
443-
444427
#############################################################################
445428
def getTransformationsByUser(
446429
self,
447-
authorDN="",
448430
userName="",
449431
transID=[],
450432
transStatus=[],
451-
outputFields=["TransformationID", "Status", "AgentType", "TransformationName", "CreationDate", "AuthorDN"],
433+
outputFields=["TransformationID", "Status", "AgentType", "TransformationName", "CreationDate", "Author"],
452434
orderBy="TransformationID",
453435
printOutput=False,
454436
):
455437
condDict = {}
456-
if authorDN == "":
457-
res = self.getAuthorDNfromProxy()
458-
if not res["OK"]:
459-
gLogger.error(res["Message"])
460-
return S_ERROR(res["Message"])
461-
else:
462-
foundUserName = res["Value"]["username"]
463-
foundAuthor = res["Value"]["authorDN"]
464-
# If the username whom created the uploaded proxy is different than the provided username report error and exit
465-
if not (userName == "" or userName == foundUserName):
466-
gLogger.error(
467-
"Couldn't resolve the authorDN for user '%s' from the uploaded proxy (proxy created by '%s')"
468-
% (userName, foundUserName)
469-
)
470-
return S_ERROR(
471-
"Couldn't resolve the authorDN for user '%s' from the uploaded proxy (proxy created by '%s')"
472-
% (userName, foundUserName)
473-
)
474-
475-
userName = foundUserName
476-
authorDN = foundAuthor
477-
gLogger.info(
478-
"Will list transformations created by user '%s' with status '%s'"
479-
% (userName, ", ".join(transStatus))
480-
)
481-
else:
482-
gLogger.info(f"Will list transformations created by '{authorDN}' with status '{', '.join(transStatus)}'")
483-
484-
condDict["AuthorDN"] = authorDN
438+
gLogger.info(f"Will list transformations created by user '{userName}' with status '{transStatus}'")
439+
condDict["Author"] = userName
485440
if transID:
486441
condDict["TransformationID"] = transID
487442
if transStatus:

src/DIRAC/TransformationSystem/Client/TransformationCLI.py

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -112,53 +112,22 @@ def do_getall(self, args):
112112
def do_getAllByUser(self, args):
113113
"""Get all transformations created by a given user
114114
115-
The first argument is the authorDN or username. The authorDN
116-
is preferred: it need to be inside quotes because contains
117-
white spaces. Only authorDN should be quoted.
115+
The first argument is the username.
118116
119-
When the username is provided instead,
120-
the authorDN is retrieved from the uploaded proxy,
121-
so that the retrieved transformations are those created by
122-
the user who uploaded that proxy: that user could be different
123-
that the username provided to the function.
124-
125-
usage: getAllByUser authorDN or username [Status] [Status]
117+
usage: getAllByUser username [Status] [Status]
126118
"""
127119
oTrans = Transformation()
128120
argss = args.split()
129121
username = ""
130-
author = ""
131122
status = []
132123
if not len(argss) > 0:
133124
print(self.do_getAllByUser.__doc__)
134125
return
135126

136-
# if the user didnt quoted the authorDN ends
137-
if "=" in argss[0] and argss[0][0] not in ["'", '"']:
138-
print("AuthorDN need to be quoted (just quote that argument)")
139-
return
127+
username = argss[0]
128+
status = argss[1:]
140129

141-
if argss[0][0] in ["'", '"']: # authorDN given
142-
author = argss[0]
143-
status_idx = 1
144-
for arg in argss[1:]:
145-
author += " " + arg
146-
status_idx += 1
147-
if arg[-1] in ["'", '"']:
148-
break
149-
# At this point we should have something like 'author'
150-
if not author[0] in ["'", '"'] or not author[-1] in ["'", '"']:
151-
print("AuthorDN need to be quoted (just quote that argument)")
152-
return
153-
else:
154-
author = author[1:-1] # throw away the quotes
155-
# the rest are the requested status
156-
status = argss[status_idx:]
157-
else: # username given
158-
username = argss[0]
159-
status = argss[1:]
160-
161-
oTrans.getTransformationsByUser(authorDN=author, userName=username, transStatus=status, printOutput=True)
130+
oTrans.getTransformationsByUser(userName=username, transStatus=status, printOutput=True)
162131

163132
def do_summaryTransformations(self, args):
164133
"""Show the summary for a list of Transformations

src/DIRAC/TransformationSystem/DB/TransformationDB.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, dbname=None, dbconfig=None, dbIn=None, parentLogger=None):
5555
"LongDescription",
5656
"CreationDate",
5757
"LastUpdate",
58-
"AuthorDN",
58+
"Author",
5959
"AuthorGroup",
6060
"Type",
6161
"Plugin",
@@ -129,7 +129,7 @@ def addTransformation(
129129
transName,
130130
description,
131131
longDescription,
132-
authorDN,
132+
author,
133133
authorGroup,
134134
transType,
135135
plugin,
@@ -162,7 +162,7 @@ def addTransformation(
162162
body = res["Value"]
163163
req = (
164164
"INSERT INTO Transformations (TransformationName,Description,LongDescription, \
165-
CreationDate,LastUpdate,AuthorDN,AuthorGroup,Type,Plugin,AgentType,\
165+
CreationDate,LastUpdate,Author,AuthorGroup,Type,Plugin,AgentType,\
166166
FileMask,Status,TransformationGroup,GroupSize,\
167167
InheritedFrom,Body,MaxNumberOfTasks,EventsPerTask)\
168168
VALUES ('%s','%s','%s',\
@@ -173,7 +173,7 @@ def addTransformation(
173173
transName,
174174
description,
175175
longDescription,
176-
authorDN,
176+
author,
177177
authorGroup,
178178
transType,
179179
plugin,
@@ -218,19 +218,19 @@ def addTransformation(
218218
originalID = res["Value"]
219219
# FIXME: this is not the right place to change status information, and in general the whole should not be here
220220
res = self.setTransformationParameter(
221-
originalID, "Status", "Completing", author=authorDN, connection=connection
221+
originalID, "Status", "Completing", author=author, connection=connection
222222
)
223223
if not res["OK"]:
224224
gLogger.error("Failed to update parent transformation status: now deleting", res["Message"])
225225
return self.deleteTransformation(transID, connection=connection)
226226
res = self.setTransformationParameter(
227-
originalID, "AgentType", "Automatic", author=authorDN, connection=connection
227+
originalID, "AgentType", "Automatic", author=author, connection=connection
228228
)
229229
if not res["OK"]:
230230
gLogger.error("Failed to update parent transformation agent type, now deleting", res["Message"])
231231
return self.deleteTransformation(transID, connection=connection)
232232
message = "Creation of the derived transformation (%d)" % transID
233-
self.__updateTransformationLogging(originalID, message, authorDN, connection=connection)
233+
self.__updateTransformationLogging(originalID, message, author, connection=connection)
234234
res = self.getTransformationFiles(condDict={"TransformationID": originalID}, connection=connection)
235235
if not res["OK"]:
236236
gLogger.error("Could not get transformation files, now deleting", res["Message"])
@@ -266,7 +266,7 @@ def addTransformation(
266266
gLogger.error("Failed to add files to transformation", f"{transID} {res['Message']}")
267267
message = "Created transformation %d" % transID
268268

269-
self.__updateTransformationLogging(transID, message, authorDN, connection=connection)
269+
self.__updateTransformationLogging(transID, message, author, connection=connection)
270270
return S_OK(transID)
271271

272272
def getTransformations(
@@ -1268,19 +1268,19 @@ def __deleteTransformationTaskInputs(self, transID, taskID=0, connection=False):
12681268
# These methods manipulate the TransformationLog table
12691269
#
12701270

1271-
def __updateTransformationLogging(self, transName, message, authorDN, connection=False):
1271+
def __updateTransformationLogging(self, transName, message, author, connection=False):
12721272
"""Update the Transformation log table with any modifications"""
1273-
if not authorDN:
1273+
if not author:
12741274
res = getProxyInfo(False, False)
12751275
if res["OK"]:
1276-
authorDN = res["Value"]["subject"]
1276+
author = res["Value"]["username"]
12771277
res = self._getConnectionTransID(connection, transName)
12781278
if not res["OK"]:
12791279
return res
12801280
connection = res["Value"]["Connection"]
12811281
transID = res["Value"]["TransformationID"]
12821282
req = "INSERT INTO TransformationLog (TransformationID,Message,Author,MessageDate)"
1283-
req = req + f" VALUES ({transID},'{message}','{authorDN}',UTC_TIMESTAMP());"
1283+
req = req + f" VALUES ({transID},'{message}','{author}',UTC_TIMESTAMP());"
12841284
return self._update(req, conn=connection)
12851285

12861286
def getTransformationLogging(self, transName, connection=False):
@@ -1296,11 +1296,11 @@ def getTransformationLogging(self, transName, connection=False):
12961296
if not res["OK"]:
12971297
return res
12981298
transList = []
1299-
for transID, message, authorDN, messageDate in res["Value"]:
1299+
for transID, message, author, messageDate in res["Value"]:
13001300
transDict = {}
13011301
transDict["TransformationID"] = transID
13021302
transDict["Message"] = message
1303-
transDict["AuthorDN"] = authorDN
1303+
transDict["Author"] = author
13041304
transDict["MessageDate"] = messageDate
13051305
transList.append(transDict)
13061306
return S_OK(transList)

0 commit comments

Comments
 (0)