forked from DIRACGrid/DIRAC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
from DIRAC.Resources.Storage.StorageElement import StorageElement | ||
|
||
from DIRAC.FrameworkSystem.Client.Logger import gLogger | ||
from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager | ||
|
||
from DIRAC.Core.Utilities.ReturnValues import S_OK, S_ERROR | ||
from DIRAC.Core.Utilities.DErrno import cmpError | ||
|
@@ -422,6 +423,8 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N | |
log.debug(f"Not preparing transfer for file {ftsFile.lfn}") | ||
continue | ||
|
||
srcToken, dstToken = None | ||
|
||
sourceSURL, targetSURL = allSrcDstSURLs[ftsFile.lfn] | ||
stageURL = allStageURLs.get(ftsFile.lfn) | ||
|
||
|
@@ -478,26 +481,33 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N | |
if self.activity: | ||
trans_metadata["activity"] = self.activity | ||
|
||
# will need https://gitlab.cern.ch/fts/fts-rest-flask/-/merge_requests/116 | ||
# If both supports tokens | ||
# get an access token | ||
# In [26]: pfnparse(url) | ||
# Out[26]: | ||
# {'OK': True, | ||
# 'Value': {'Protocol': 'root', | ||
# 'Host': '[email protected]', | ||
# 'Port': '', | ||
# 'WSUrl': '', | ||
# 'Path': '//eos/lhcb/grid/user/lhcb/tata', | ||
# 'FileName': 'yoyo.txt'}} | ||
# In [24]: fullPath | ||
# Out[24]: PosixPath('//eos/lhcb/grid/user/lhcb/tata') | ||
|
||
# In [25]: fullPath.resolve() | ||
# Out[25]: PosixPath('/eos/lhcb/grid/user/lhcb/tata') | ||
|
||
# In [19]: fullPath.relative_to('//eos/lhcb') | ||
# Out[19]: PosixPath('grid/user/lhcb/tata') | ||
# Add tokens if both storages support it | ||
if self.__seTokenSupport(hopSrcSEName) and self.__seTokenSupport(hopDstSEName): | ||
res = srcSE.getWLCGTokenPath(ftsFile.lfn) | ||
if not res["OK"]: | ||
return res | ||
srcTokenPath = res["Value"] | ||
res = gTokenManager.getToken( | ||
userGroup="lhcb_data", | ||
requiredTimeLeft=3600, | ||
scope=[f"storage.read:/{srcTokenPath}", "offline_access"], | ||
) | ||
if not res["OK"]: | ||
return res | ||
srcToken = res["Value"] | ||
|
||
res = dstSE.getWLCGTokenPath(ftsFile.lfn) | ||
if not res["OK"]: | ||
return res | ||
dstTokenPath = res["Value"] | ||
res = gTokenManager.getToken( | ||
userGroup="lhcb_data", | ||
requiredTimeLeft=3600, | ||
scope=[f"storage.create:/{dstTokenPath}", "offline_access"], | ||
) | ||
if not res["OK"]: | ||
return res | ||
dstToken = res["Value"] | ||
|
||
# because of an xroot bug (https://github.com/xrootd/xrootd/issues/1433) | ||
# the checksum needs to be lowercase. It does not impact the other | ||
|
@@ -511,6 +521,8 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N | |
filesize=ftsFile.size, | ||
metadata=trans_metadata, | ||
activity=self.activity, | ||
source_token=srcToken, | ||
destination_token=dstToken, | ||
) | ||
|
||
transfers.append(trans) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters