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",'') |
32 |
> |
self.user_port = cfg_params.get("USER.storage_port",'8443') |
33 |
|
self.user_se_path = cfg_params.get("USER.storage_path",'') |
34 |
< |
|
34 |
> |
if self.user_se_path: |
35 |
> |
if ( self.user_se_path[-1] != '/' ) : self.user_se_path = self.user_se_path + '/' |
36 |
> |
|
37 |
|
#check if using "private" Storage |
38 |
|
self.usePhedex = True |
39 |
< |
if (self.node.find('T1_') + self.node.find('T2_')) == -2: self.usePhedex = False |
40 |
< |
if not self.usePhedex and ( self.user_lfn == '' or self.user_se_path == '' ): |
39 |
> |
stage_out_faq='https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#How_to_store_output_with_CRAB_2' |
40 |
> |
if not self.node : |
41 |
> |
msg = 'Please specify the storage_element name in your crab.cfg section [USER].\n' |
42 |
> |
msg +=' For further information please visit : %s'%stage_out_faq |
43 |
> |
raise CrabException(msg) |
44 |
> |
if (self.node.find('T1_') + self.node.find('T2_')+self.node.find('T3_')) == -3: self.usePhedex = False |
45 |
> |
if not self.usePhedex : |
46 |
> |
self.user_lfn = cfg_params.get("USER.lfn",'') |
47 |
> |
if self.user_lfn: |
48 |
> |
if self.user_remote_dir: |
49 |
> |
msg = 'ERROR: In your crab.cfg you are specifying both lfn and user_remote_dir parameters giving different values. \n' |
50 |
> |
msg += '\t lfn is now deprecated. Please use only user_remote_dir removing lfn from your crab.cfg' |
51 |
> |
raise CrabException(msg) |
52 |
> |
|
53 |
> |
if not self.usePhedex and ( self.user_remote_dir == '' or self.user_se_path == '' ): |
54 |
|
msg = 'You are asking to stage out without using CMS Storage Name convention. In this case you \n' |
55 |
< |
msg += ' must specify both lfn and storage_path in the crab.cfg section [USER].\n ' |
56 |
< |
msg += ' For further information please visit: ADD_TWIKI_LINK' |
55 |
> |
msg += '\t must specify both user_remote_dir and storage_path in the crab.cfg section [USER].\n ' |
56 |
> |
msg += '\t For further information please visit : %s'%stage_out_faq |
57 |
|
raise CrabException(msg) |
58 |
|
self.sched = common.scheduler.name().upper() |
40 |
– |
|
59 |
|
self.protocol = self.srm_version |
60 |
|
if self.sched in ['CAF','LSF']:self.protocol = 'direct' |
61 |
|
|
62 |
+ |
self.forced_path = '/store/user/' |
63 |
+ |
if not self.usePhedex: |
64 |
+ |
self.forced_path = self.user_remote_dir |
65 |
|
return |
66 |
|
|
67 |
|
def getEndpoint(self): |
89 |
|
if self.protocol == 'direct': |
90 |
|
query=endpoint |
91 |
|
SE_PATH = endpoint |
92 |
+ |
SE = self.sched |
93 |
|
else: |
94 |
|
url = 'http://'+endpoint.split('://')[1] |
95 |
|
# python > 2.4 |
100 |
|
USER = (query.split('user')[1]).split('/')[1] |
101 |
|
else: |
102 |
|
SE = self.node |
103 |
< |
SE_PATH = self.user_se_path + self.user_lfn |
103 |
> |
SE_PATH = self.user_se_path + self.user_remote_dir |
104 |
|
try: |
105 |
|
USER = (self.lfn.split('user')[1]).split('/')[1] |
106 |
|
except: |
120 |
|
## check if storage_name is a T2 (siteDB query) |
121 |
|
## if yes :match self.user_lfn with LFNBaseName... |
122 |
|
## if NOT : raise (you are using a T2. It's not allowed stage out into self.user_path+self.user_lfn) |
123 |
< |
lfn = self.user_lfn |
123 |
> |
lfn = self.user_remote_dir |
124 |
|
return lfn |
125 |
|
if self.publish_data_name == '' and int(self.publish_data) == 1: |
126 |
|
msg = "Eeror. The [USER] section does not have 'publish_data_name'" |
130 |
|
if int(self.publish_data) == 1 or int(self.usenamespace) == 1: |
131 |
|
if self.sched in ['CAF']: l_User=True |
132 |
|
primaryDataset = self.computePrimaryDataset() |
133 |
< |
lfn = LFNBase(primaryDataset,self.publish_data_name,LocalUser=l_User) + '/${PSETHASH}/' |
133 |
> |
lfn = LFNBase(self.forced_path, primaryDataset, self.publish_data_name, LocalUser=l_User) + '/${PSETHASH}/' |
134 |
|
else: |
135 |
< |
if self.sched in ['LSF']: l_User=True |
136 |
< |
lfn = LFNBase(self.user_remote_dir,LocalUser=l_User) |
135 |
> |
if self.sched in ['CAF','LSF']: l_User=True |
136 |
> |
lfn = LFNBase(self.forced_path,self.user_remote_dir,LocalUser=l_User) |
137 |
|
return lfn |
138 |
|
|
139 |
|
def computePrimaryDataset(self): |
214 |
|
|
215 |
|
stageoutpfn = self.parse_lfn2pfn(domlfn2pfn) |
216 |
|
if not stageoutpfn: |
217 |
< |
msg ='Unable to get stageout path for Site %s. Maybe it does not correctly export its TFC. \n'%self.node |
218 |
< |
msg+=' Please alert the FacOps group through their savannah %s'%self.FacOps_savannah |
217 |
> |
msg ='Unable to get stageout path from TFC at Site %s \n'%self.node |
218 |
> |
msg+=' Please alert the CompInfraSup group through their savannah %s \n'%self.FacOps_savannah |
219 |
> |
msg+=' reporting: \n' |
220 |
> |
msg+=' Summary: Unable to get user stageout from TFC at Site %s \n'%self.node |
221 |
> |
msg+=' OriginalSubmission: stageout path is not retrieved from %s \n'%fullurl |
222 |
|
raise CrabException(msg) |
223 |
|
else: |
224 |
< |
stageoutpfn = 'srm://'+self.node+':8443'+self.user_se_path+self.lfn |
224 |
> |
if self.sched in ['CAF','LSF'] : |
225 |
> |
stageoutpfn = self.user_se_path+self.lfn |
226 |
> |
else: |
227 |
> |
stageoutpfn = 'srm://'+self.node+':'+self.user_port+self.user_se_path+self.lfn |
228 |
|
|
229 |
|
return stageoutpfn |
230 |
+ |
|
231 |
+ |
|
232 |
+ |
|
233 |
+ |
if __name__ == '__main__': |
234 |
+ |
""" |
235 |
+ |
Sort of unit testing to check Phedex API for whatever site and/or lfn. |
236 |
+ |
Usage: |
237 |
+ |
python PhEDExDatasvcInfo.py --node T2_IT_Bari --lfn /store/maremma |
238 |
+ |
|
239 |
+ |
""" |
240 |
+ |
import getopt,sys |
241 |
+ |
from crab_util import * |
242 |
+ |
import common |
243 |
+ |
klass_name = 'SchedulerGlite' |
244 |
+ |
klass = importName(klass_name, klass_name) |
245 |
+ |
common.scheduler = klass() |
246 |
+ |
|
247 |
+ |
lfn="/store/user/" |
248 |
+ |
node='T2_IT_Bari' |
249 |
+ |
valid = ['node=','lfn='] |
250 |
+ |
try: |
251 |
+ |
opts, args = getopt.getopt(sys.argv[1:], "", valid) |
252 |
+ |
except getopt.GetoptError, ex: |
253 |
+ |
print str(ex) |
254 |
+ |
sys.exit(1) |
255 |
+ |
for o, a in opts: |
256 |
+ |
if o == "--node": |
257 |
+ |
node = a |
258 |
+ |
if o == "--lfn": |
259 |
+ |
lfn = a |
260 |
+ |
|
261 |
+ |
mycfg_params = { 'USER.storage_element': node } |
262 |
+ |
dsvc = PhEDExDatasvcInfo(mycfg_params) |
263 |
+ |
dsvc.lfn = lfn |
264 |
+ |
print dsvc.getStageoutPFN() |
265 |
+ |
|