Skip to content
Snippets Groups Projects
Commit 87cf5f50 authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

Renamed castor2fs to castor for the URL parameters and added a pfn2 parameter...

Renamed castor2fs to castor for the URL parameters and added a pfn2 parameter to URLs for disk-to-disk copies
parent cc74fa5d
No related branches found
No related tags found
No related merge requests found
......@@ -42,13 +42,15 @@ def signBase64(content, RSAKey):
signature = signer.sign(contentHash)
return base64.b64encode(signature)
def buildXrootURL(self, diskserver, path, transferType):
def buildXrootURL(self, diskserver, path, transferId, transferType):
'''Builds a xroot valid url for the given path on the given diskserver'''
# base url and key parameter
url = 'root://'+diskserver+':1095//' + path + '?'
opaque_dict = {'castor2fs.pfn1' : path,
opaque_dict = {'castor.pfn1' : path,
'castor.pfn2' : '0:' + self.config.getValue('DiskManager', 'MoverHandlerPort', 15511) \
+ ':' + transferId,
'castor.txtype' : transferType,
'castor2fs.exptime' : str(int(time.time()) + 3600)}
'castor.exptime' : str(int(time.time()) + 3600)}
# signature part
try:
......@@ -57,10 +59,11 @@ def buildXrootURL(self, diskserver, path, transferType):
'/opt/xrootd/keys/key.pem')
key = RSA.importKey(open(keyFile, 'r').read())
# sign opaque part obtained by concatenating the values
opaque_token = ''.join([opaque_dict['castor2fs.pfn1'],
opaque_token = ''.join([opaque_dict['castor.pfn1'],
opaque_dict['castor.pfn2'],
opaque_dict['castor.txtype'],
"0", # accessop
opaque_dict['castor2fs.exptime']])
opaque_dict['castor.exptime']])
signature = signBase64(opaque_token, key)
opaque = ""
......@@ -118,8 +121,8 @@ class ActivityControlThread(threading.Thread):
# build command line
transferType = 'd2d' + D2DTransferType.toStr(transfer.replicationType)
srcDS, srcPath = srcDcPath.split(':', 1)
cmdLine = ['xrdcp', buildXrootURL(self, srcDS, srcPath, transferType), \
buildXrootURL(self, 'localhost', destDcPath, transferType)]
cmdLine = ['xrdcp', buildXrootURL(self, srcDS, srcPath, transfer.transferId, transferType), \
buildXrootURL(self, 'localhost', destDcPath, transfer.transferId, transferType)]
# "Transfer starting" message
dlf.write(msgs.TRANSFERSTARTING, subreqid=transfer.transferId,
reqid=transfer.reqId, fileId=transfer.fileId,
......
......@@ -388,11 +388,11 @@ XrootC2FSReadFile::XrootC2FSReadFile(const std::string &url,
using XrdCl::OpenFlags;
m_signedURL = m_URL;
// Turn the bare URL into a Castor URL, by adding opaque tags:
// ?castor2fs.pfn1=/srv/castor/... (duplication of the path in practice)
// ?castor.pfn1=/srv/castor/... (duplication of the path in practice)
// ?castor.txtype=tape
// ?castor2fs.pool=xxx optional ceph pool
// ?castor2fs.exptime=(unix time)
// ?castor2fs.signature=
// ?castor.pool=xxx optional ceph pool
// ?castor.exptime=(unix time)
// ?castor.signature=
//Find the path part of the url. It is the first occurence of "//"
// after the inital [x]root://
const std::string scheme = "root://";
......@@ -416,12 +416,12 @@ XrootC2FSReadFile::XrootC2FSReadFile(const std::string &url,
std::string signature = CryptoPPSigner::sign(signatureBlock.str(), xrootPrivateKey);
std::stringstream opaqueBloc;
opaqueBloc << "?castor2fs.pfn1=" << path;
opaqueBloc << "?castor.pfn1=" << path;
if (pool.size())
opaqueBloc << "&castor2fs.pool=" << pool;
opaqueBloc << "&castor.pool=" << pool;
opaqueBloc << "&castor.txtype=tape";
opaqueBloc << "&castor2fs.exptime=" << expTime;
opaqueBloc << "&castor2fs.signature=" << signature;
opaqueBloc << "&castor.exptime=" << expTime;
opaqueBloc << "&castor.signature=" << signature;
m_signedURL = m_URL + opaqueBloc.str();
// ... and finally open the file
......@@ -479,10 +479,10 @@ XrootC2FSWriteFile::XrootC2FSWriteFile(const std::string &url,
m_URL=url;
m_signedURL = m_URL;
// Turn the bare URL into a Castor URL, by adding opaque tags:
// ?castor2fs.pfn1=/srv/castor/... (duplication of the path in practice)
// ?castor2fs.pool=xxx optional ceph pool
// ?castor2fs.exptime=(unix time)
// ?castor2fs.signature=
// ?castor.pfn1=/srv/castor/... (duplication of the path in practice)
// ?castor.pool=xxx optional ceph pool
// ?castor.exptime=(unix time)
// ?castor.signature=
//Find the path part of the url. It is the first occurence of "//"
// after the inital [x]root://
const std::string scheme = "root://";
......@@ -506,12 +506,12 @@ XrootC2FSWriteFile::XrootC2FSWriteFile(const std::string &url,
std::string signature = CryptoPPSigner::sign(signatureBlock.str(), xrootPrivateKey);
std::stringstream opaqueBloc;
opaqueBloc << "?castor2fs.pfn1=" << path;
opaqueBloc << "?castor.pfn1=" << path;
if (pool.size())
opaqueBloc << "&castor2fs.pool=" << pool;
opaqueBloc << "&castor.pool=" << pool;
opaqueBloc << "&castor.txtype=tape";
opaqueBloc << "&castor2fs.exptime=" << expTime;
opaqueBloc << "&castor2fs.signature=" << signature;
opaqueBloc << "&castor.exptime=" << expTime;
opaqueBloc << "&castor.signature=" << signature;
m_signedURL = m_URL + opaqueBloc.str();
XrootClEx::throwOnError(m_xrootFile.Open(m_signedURL, OpenFlags::Delete),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment