Skip to content

Commit

Permalink
Merge pull request #7510 from fstagni/fixVO_2
Browse files Browse the repository at this point in the history
[9.0] SandboxStore: add VO if needed
  • Loading branch information
fstagni authored Apr 17, 2024
2 parents 56cb16d + 7822f23 commit 01e939c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/DIRAC/Core/Security/ProxyInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def getProxyInfo(proxy=False, disableVOMS=False):
* values that can be there
* 'path' : path to the file,
* 'group' : DIRAC group
* 'VO' : DIRAC VO
* 'groupProperties' : Properties that apply to the DIRAC Group
* 'username' : DIRAC username
* 'identity' : DN that generated the proxy
Expand Down Expand Up @@ -69,6 +70,9 @@ def getProxyInfo(proxy=False, disableVOMS=False):
else:
infoDict["VOMSError"] = retVal["Message"].strip()

if "group" in infoDict:
infoDict["VO"] = Registry.getVOForGroup(infoDict["group"])

infoDict["hasDiracxToken"] = False
if proxyLocation:
infoDict["hasDiracxToken"] = bool(diracxTokenFromPEM(proxyLocation))
Expand Down
6 changes: 0 additions & 6 deletions src/DIRAC/ResourceStatusSystem/Service/PublisherHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ def feedTree(elementsList):
def export_setToken(self, element, name, statusType, token, elementType, username, lastCheckTime):
lastCheckTime = datetime.strptime(lastCheckTime, "%Y-%m-%d %H:%M:%S")

credentials = self.getRemoteCredentials()
self.log.info(credentials)

elementInDB = self.rsClient.selectStatusElement(
element, "Status", name=name, statusType=statusType, elementType=elementType, lastCheckTime=lastCheckTime
)
Expand Down Expand Up @@ -346,9 +343,6 @@ def export_setStatus(self, element, name, statusType, status, elementType, usern
else:
lastCheckTime = datetime.strptime(lastCheckTime, "%Y-%m-%d %H:%M:%S")

credentials = self.getRemoteCredentials()
self.log.info(credentials)

elementInDB = self.rsClient.selectStatusElement(
element,
"Status",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _getFromClient(self, fileId, token, fileSize, fileHelper=None, data=""):
gLogger.info("Upload requested", f"for {aHash} [{extension}]")

credDict = self.getRemoteCredentials()
vo = Registry.getVOForGroup(credDict["group"])
vo = credDict.get("VO", Registry.getVOForGroup(credDict["group"]))

disabledVOs = gConfig.getValue("/DiracX/DisabledVOs", [])
if self._useDiracXBackend and vo not in disabledVOs:
Expand Down Expand Up @@ -199,7 +199,7 @@ def _getFromClient(self, fileId, token, fileSize, fileHelper=None, data=""):
result = self.sandboxDB.registerAndGetSandbox(
credDict["username"],
credDict["group"],
credDict["VO"],
vo,
self.__localSEName,
sbPath,
fSize,
Expand Down Expand Up @@ -236,14 +236,15 @@ def transfer_bulkFromClient(self, fileId, token, _fileSize, fileHelper):
gLogger.info("Sandbox path will be", sbPath)
# Register in DB
credDict = self.getRemoteCredentials()
vo = credDict.get("VO", Registry.getVOForGroup(credDict["group"]))
result = self.sandboxDB.getSandboxId(self.__localSEName, sbPath, credDict["username"], credDict["group"])
if result["OK"]:
return S_OK(f"SB:{self.__localSEName}|{sbPath}")

result = self.sandboxDB.registerAndGetSandbox(
credDict["username"],
credDict["group"],
credDict["VO"],
vo,
self.__localSEName,
sbPath,
fileHelper.getTransferedBytes(),
Expand Down Expand Up @@ -364,9 +365,8 @@ 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"]
)
vo = credDict.get("VO", Registry.getVOForGroup(credDict["group"]))
result = self.sandboxDB.getSandboxesAssignedToEntity(entityId, credDict["username"], credDict["group"], vo)
if not result["OK"]:
return result
sbDict = {}
Expand Down

0 comments on commit 01e939c

Please sign in to comment.