Skip to content

Commit

Permalink
feat: add VO to credential dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Jan 25, 2024
1 parent 17b504b commit 2629899
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/DIRAC/Core/Security/m2crypto/X509Chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ def getCredentials(self, ignoreDefault=False, withRegistryInfo=True):
* username: DIRAC username associated to the DN (needs withRegistryInfo)
(see :py:func:`DIRAC.ConfigurationSystem.Client.Helpers.Registry.getUsernameForDN`)
* group: DIRAC group, depending on ignoreDefault param(see :py:meth:`.getDIRACGroup`)
* VO: virtual organization
* validGroup: True if the group found is in the list of groups the user belongs to
* groupProperty: (only if validGroup) get the properties of the group
Expand Down Expand Up @@ -1003,6 +1004,7 @@ def getCredentials(self, ignoreDefault=False, withRegistryInfo=True):
if retVal["OK"] and diracGroup in retVal["Value"]:
credDict["validGroup"] = True
credDict["groupProperties"] = Registry.getPropertiesForGroup(diracGroup)
credDict["VO"] = Registry.getVOForGroup(diracGroup)
elif withRegistryInfo:
retVal = Registry.getHostnameForDN(credDict["subject"])
if retVal["OK"]:
Expand Down
6 changes: 2 additions & 4 deletions src/DIRAC/WorkloadManagementSystem/DB/SandboxMetadataDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def __registerAndGetOwnerId(self, owner, ownerGroup, VO):
if data:
return S_OK(data[0][0])
# Its not there, insert it
sqlCmd = (
f"INSERT INTO `sb_Owners` ( OwnerId, Owner, OwnerGroup, VO ) VALUES ( 0, {ownerEscaped}, {ownerGroupEscaped}, {VOEscaped} )"
)
sqlCmd = f"INSERT INTO `sb_Owners` ( OwnerId, Owner, OwnerGroup, VO ) VALUES ( 0, {ownerEscaped}, {ownerGroupEscaped}, {VOEscaped} )"
result = self._update(sqlCmd)
if not result["OK"]:
return result
Expand All @@ -100,7 +98,7 @@ def __registerAndGetOwnerId(self, owner, ownerGroup, VO):
return S_ERROR("Can't determine owner id after insertion")
return S_OK(result["Value"][0][0])

def registerAndGetSandbox(self, owner, ownerGroup, sbSE, sbPFN, size=0):
def registerAndGetSandbox(self, owner, ownerGroup, VO, sbSE, sbPFN, size=0):
"""
Register a new sandbox in the metadata catalog
Returns ( sbid, newSandbox )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _getFromClient(self, fileId, token, fileSize, fileHelper=None, data=""):
result = self.sandboxDB.registerAndGetSandbox(
credDict["username"],
credDict["group"],
credDict["VO"]
credDict["VO"],
self.__seNameToUse,
sbPath,
fSize,
Expand Down Expand Up @@ -442,7 +442,9 @@ def export_getSandboxesAssignedToEntity(self, entityId):
Get the sandboxes associated to a job and the association type
"""
credDict = self.getRemoteCredentials()
result = self.sandboxDB.getSandboxesAssignedToEntity(entityId, credDict["username"], credDict["group"], credDict["VO"])
result = self.sandboxDB.getSandboxesAssignedToEntity(
entityId, credDict["username"], credDict["group"], credDict["VO"]
)
if not result["OK"]:
return result
sbDict = {}
Expand Down

0 comments on commit 2629899

Please sign in to comment.