ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PhEDExDatasvcInfo.py
(Generate patch)

Comparing COMP/CRAB/python/PhEDExDatasvcInfo.py (file contents):
Revision 1.4 by spiga, Sun Sep 21 12:41:57 2008 UTC vs.
Revision 1.18 by fanzago, Mon Dec 8 16:37:46 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines