14 |
|
url="https://cmsweb.cern.ch/phedex/datasvc/xml/prod" |
15 |
|
self.datasvc_url = cfg_params.get("USER.datasvc_url",url) |
16 |
|
|
17 |
< |
self.FacOps_savannah = 'https://savannah.cern.ch/projects/cmscompinfrasup/' |
17 |
> |
self.FacOps_savannah = 'https://savannah.cern.ch/support/?func=additem&group=cmscompinfrasup' |
18 |
> |
|
19 |
|
|
20 |
|
self.srm_version = cfg_params.get("USER.srm_version",'srmv2') |
21 |
|
self.node = cfg_params.get('USER.storage_element',None) |
22 |
|
|
23 |
|
self.publish_data = cfg_params.get("USER.publish_data",0) |
24 |
|
self.usenamespace = cfg_params.get("USER.usenamespace",0) |
25 |
< |
self.user_remote_dir = cfg_params.get("USER.remote_dir",'') |
25 |
> |
self.user_remote_dir = cfg_params.get("USER.user_remote_dir",'') |
26 |
> |
if self.user_remote_dir: |
27 |
> |
if ( self.user_remote_dir[-1] != '/' ) : self.user_remote_dir = self.user_remote_dir + '/' |
28 |
> |
|
29 |
|
self.datasetpath = cfg_params.get("CMSSW.datasetpath") |
30 |
|
self.publish_data_name = cfg_params.get('USER.publish_data_name','') |
31 |
|
|
32 |
|
self.user_lfn = cfg_params.get("USER.lfn",'') |
33 |
+ |
if self.user_lfn: |
34 |
+ |
if ( self.user_lfn[-1] != '/' ) : self.user_lfn = self.user_lfn + '/' |
35 |
+ |
|
36 |
+ |
self.user_port = cfg_params.get("USER.storage_port",'8443') |
37 |
|
self.user_se_path = cfg_params.get("USER.storage_path",'') |
38 |
+ |
if self.user_se_path: |
39 |
+ |
if ( self.user_se_path[-1] != '/' ) : self.user_se_path = self.user_se_path + '/' |
40 |
+ |
|
41 |
|
|
42 |
|
#check if using "private" Storage |
43 |
|
self.usePhedex = True |
44 |
< |
if (self.node.find('T1_') + self.node.find('T2_')) == -2: self.usePhedex = False |
44 |
> |
stage_out_faq='https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#How_to_store_output_with_CRAB_2' |
45 |
> |
if not self.node : |
46 |
> |
msg = 'Please specify the storage_element name in your crab.cfg section [USER].\n' |
47 |
> |
msg +=' For further information please visit : %s'%stage_out_faq |
48 |
> |
raise CrabException(msg) |
49 |
> |
if (self.node.find('T1_') + self.node.find('T2_')+self.node.find('T3_')) == -3: self.usePhedex = False |
50 |
|
if not self.usePhedex and ( self.user_lfn == '' or self.user_se_path == '' ): |
51 |
|
msg = 'You are asking to stage out without using CMS Storage Name convention. In this case you \n' |
52 |
|
msg += ' must specify both lfn and storage_path in the crab.cfg section [USER].\n ' |
53 |
< |
msg += ' For further information please visit: ADD_TWIKI_LINK' |
53 |
> |
msg += ' For further information please visit : %s'%stage_out_faq |
54 |
|
raise CrabException(msg) |
55 |
|
self.sched = common.scheduler.name().upper() |
40 |
– |
|
56 |
|
self.protocol = self.srm_version |
57 |
|
if self.sched in ['CAF','LSF']:self.protocol = 'direct' |
58 |
|
|
59 |
+ |
self.forced_path = '/store/user/' |
60 |
+ |
if not self.usePhedex: |
61 |
+ |
self.forced_path = self.user_lfn |
62 |
|
return |
63 |
|
|
64 |
|
def getEndpoint(self): |
86 |
|
if self.protocol == 'direct': |
87 |
|
query=endpoint |
88 |
|
SE_PATH = endpoint |
89 |
+ |
SE = self.sched |
90 |
|
else: |
91 |
|
url = 'http://'+endpoint.split('://')[1] |
92 |
|
# python > 2.4 |
127 |
|
if int(self.publish_data) == 1 or int(self.usenamespace) == 1: |
128 |
|
if self.sched in ['CAF']: l_User=True |
129 |
|
primaryDataset = self.computePrimaryDataset() |
130 |
< |
lfn = LFNBase(primaryDataset,self.publish_data_name,LocalUser=l_User) + '/${PSETHASH}/' |
130 |
> |
lfn = LFNBase(self.forced_path, primaryDataset, self.publish_data_name, LocalUser=l_User) + '/${PSETHASH}/' |
131 |
|
else: |
132 |
< |
if self.sched in ['LSF']: l_User=True |
133 |
< |
lfn = LFNBase(self.user_remote_dir,LocalUser=l_User) |
132 |
> |
if self.sched in ['CAF','LSF']: l_User=True |
133 |
> |
lfn = LFNBase(self.forced_path,self.user_remote_dir,LocalUser=l_User) |
134 |
|
return lfn |
135 |
|
|
136 |
|
def computePrimaryDataset(self): |
211 |
|
|
212 |
|
stageoutpfn = self.parse_lfn2pfn(domlfn2pfn) |
213 |
|
if not stageoutpfn: |
214 |
< |
msg ='Unable to get stageout path for Site %s. Maybe it does not correctly export its TFC. \n'%self.node |
215 |
< |
msg+=' Please alert the FacOps group through their savannah %s'%self.FacOps_savannah |
214 |
> |
msg ='Unable to get stageout path from TFC at Site %s \n'%self.node |
215 |
> |
msg+=' Please alert the CompInfraSup group through their savannah %s \n'%self.FacOps_savannah |
216 |
> |
msg+=' reporting: \n' |
217 |
> |
msg+=' Summary: Unable to get user stageout from TFC at Site %s \n'%self.node |
218 |
> |
msg+=' OriginalSubmission: stageout path is not retrieved from %s \n'%fullurl |
219 |
|
raise CrabException(msg) |
220 |
|
else: |
221 |
< |
stageoutpfn = 'srm://'+self.node+':8443'+self.user_se_path+self.lfn |
221 |
> |
if self.sched in ['CAF','LSF'] : |
222 |
> |
stageoutpfn = self.user_se_path+self.lfn |
223 |
> |
else: |
224 |
> |
stageoutpfn = 'srm://'+self.node+':'+self.user_port+self.user_se_path+self.lfn |
225 |
|
|
226 |
|
return stageoutpfn |
227 |
+ |
|
228 |
+ |
|
229 |
+ |
|
230 |
+ |
if __name__ == '__main__': |
231 |
+ |
""" |
232 |
+ |
Sort of unit testing to check Phedex API for whatever site and/or lfn. |
233 |
+ |
Usage: |
234 |
+ |
python PhEDExDatasvcInfo.py --node T2_IT_Bari --lfn /store/maremma |
235 |
+ |
|
236 |
+ |
""" |
237 |
+ |
import getopt,sys |
238 |
+ |
from crab_util import * |
239 |
+ |
import common |
240 |
+ |
klass_name = 'SchedulerGlite' |
241 |
+ |
klass = importName(klass_name, klass_name) |
242 |
+ |
common.scheduler = klass() |
243 |
+ |
|
244 |
+ |
lfn="/store/user/" |
245 |
+ |
node='T2_IT_Bari' |
246 |
+ |
valid = ['node=','lfn='] |
247 |
+ |
try: |
248 |
+ |
opts, args = getopt.getopt(sys.argv[1:], "", valid) |
249 |
+ |
except getopt.GetoptError, ex: |
250 |
+ |
print str(ex) |
251 |
+ |
sys.exit(1) |
252 |
+ |
for o, a in opts: |
253 |
+ |
if o == "--node": |
254 |
+ |
node = a |
255 |
+ |
if o == "--lfn": |
256 |
+ |
lfn = a |
257 |
+ |
|
258 |
+ |
mycfg_params = { 'USER.storage_element': node } |
259 |
+ |
dsvc = PhEDExDatasvcInfo(mycfg_params) |
260 |
+ |
dsvc.lfn = lfn |
261 |
+ |
print dsvc.getStageoutPFN() |
262 |
+ |
|