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.3 by spiga, Sun Sep 21 10:53:10 2008 UTC vs.
Revision 1.24 by slacapra, Thu May 7 08:04:55 2009 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/SWGuideCrabHowTo#Stageout_and_publication'
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 (self.node.find('T1_') + self.node.find('T2_')) == -2: self.usePhedex = False
49 <        if not self.usePhedex and ( self.user_lfn == '' or self.user_se_path == '' ):
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 >
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
42        if self.sched in ['CAF','LSF']:self.protocol = 'direct'
61  
62 +        self.forced_path = '/store/user/'
63 +        if self.sched in ['CAF','LSF']:
64 +            self.protocol = 'direct'
65 +            self.SE = {'CAF':'caf.cern.ch', 'LSF':''}
66 +            if self.sched == 'CAF': self.forced_path = '/store/caf/user/'
67 +            
68 +        if not self.usePhedex:
69 +            self.forced_path = self.user_remote_dir
70          return
71  
72      def getEndpoint(self):  
# Line 68 | Line 94 | class PhEDExDatasvcInfo:
94              if self.protocol == 'direct':
95                  query=endpoint
96                  SE_PATH = endpoint
97 +                SE = self.SE[self.sched]
98              else:
99                  url = 'http://'+endpoint.split('://')[1]
100                  # python > 2.4
# Line 77 | Line 104 | class PhEDExDatasvcInfo:
104                  SE_PATH = endpoint.split(host)[1]
105              USER = (query.split('user')[1]).split('/')[1]
106          else:
107 +            #### to test #####
108 +           # url = 'http://'+endpoint.split('://')[1]
109 +           # scheme, host, path, params, query, fragment = urlparse(url)
110 +           # SE = host.split(':')[0]
111 +           # SE_PATH = endpoint.split(host)[1]
112              SE = self.node
113 <            SE_PATH = self.user_se_path + self.user_lfn
113 >            SE_PATH = self.user_se_path + self.user_remote_dir
114              try:
115                  USER = (self.lfn.split('user')[1]).split('/')[1]
116              except:
# Line 98 | Line 130 | class PhEDExDatasvcInfo:
130              ## check if storage_name is a T2 (siteDB query)
131              ## if yes :match self.user_lfn with LFNBaseName...
132              ##     if NOT : raise (you are using a T2. It's not allowed stage out into self.user_path+self.user_lfn)  
133 <            lfn = self.user_lfn
133 >            lfn = self.user_remote_dir
134              return lfn
135          if self.publish_data_name == '' and int(self.publish_data) == 1:
136 <            msg = "Eeror. The [USER] section does not have 'publish_data_name'"
136 >            msg = "Error. The [USER] section does not have 'publish_data_name'\n"
137 >            msg += '\tFor further information please visit : \n\t%s'%self.dataPub_faq
138              raise CrabException(msg)
139          if self.publish_data_name == '' and int(self.usenamespace) == 1:
140             self.publish_data_name = "DefaultDataset"
141          if int(self.publish_data) == 1 or int(self.usenamespace) == 1:
142              if self.sched in ['CAF']: l_User=True
143              primaryDataset = self.computePrimaryDataset()
144 <            lfn = LFNBase(primaryDataset,self.publish_data_name,LocalUser=l_User)  + '/${PSETHASH}/'    
144 >            lfn = LFNBase(self.forced_path, primaryDataset, self.publish_data_name)  + '/${PSETHASH}/'    
145          else:
146 <            if self.sched in ['LSF']: l_User=True
147 <            lfn = LFNBase(self.user_remote_dir,LocalUser=l_User)
146 >            if self.sched in ['CAF','LSF']: l_User=True
147 >            lfn = LFNBase(self.forced_path,self.user_remote_dir)
148          return lfn
149  
150      def computePrimaryDataset(self):
# Line 134 | Line 167 | class PhEDExDatasvcInfo:
167          params = {'node' : self.node , 'lfn': self.lfn , 'protocol': self.protocol}
168          params = urllib.urlencode(params)
169          datasvc_lfn2pfn="%s/lfn2pfn"%self.datasvc_url
137        urlresults = urllib.urlopen(datasvc_lfn2pfn, params)
170          try:
171 +            urlresults = urllib.urlopen(datasvc_lfn2pfn, params)
172              urlresults = parse(urlresults)
173 +        except IOError:
174 +            msg="Unable to access PhEDEx Data Service at %s"%datasvc_lfn2pfn
175 +            raise CrabException(msg)
176          except:
177              urlresults = None
178  
# Line 192 | Line 228 | class PhEDExDatasvcInfo:
228    
229              stageoutpfn = self.parse_lfn2pfn(domlfn2pfn)
230              if not stageoutpfn:
231 <                msg ='Unable to get stageout path for Site %s. Maybe it does not correctly export its TFC. \n'%self.node
232 <                msg+='      Please alert the FacOps group through their savannah %s'%self.FacOps_savannah
231 >                msg ='Unable to get stageout path from TFC at Site %s \n'%self.node
232 >                msg+='      Please alert the CompInfraSup group through their savannah %s \n'%self.FacOps_savannah
233 >                msg+='      reporting: \n'
234 >                msg+='       Summary: Unable to get user stageout from TFC at Site %s \n'%self.node
235 >                msg+='       OriginalSubmission: stageout path is not retrieved from %s \n'%fullurl
236                  raise CrabException(msg)
237          else:
238 <            stageoutpfn = 'srm://'+self.node+':8443'+self.user_se_path+self.lfn
238 >            if self.sched in ['CAF','LSF'] :
239 >                stageoutpfn = self.user_se_path+self.lfn
240 >            else:
241 >                stageoutpfn = 'srm://'+self.node+':'+self.user_port+self.user_se_path+self.lfn
242  
243          return stageoutpfn
244 +
245 +
246 +
247 + if __name__ == '__main__':
248 +  """
249 +  Sort of unit testing to check Phedex API for whatever site and/or lfn.
250 +  Usage:
251 +     python PhEDExDatasvcInfo.py --node T2_IT_Bari --lfn /store/maremma
252 +
253 +  """
254 +  import getopt,sys
255 +  from crab_util import *
256 +  import common
257 +  klass_name = 'SchedulerGlite'
258 +  klass = importName(klass_name, klass_name)
259 +  common.scheduler = klass()
260 +
261 +  lfn="/store/user/"
262 +  node='T2_IT_Bari'
263 +  valid = ['node=','lfn=']
264 +  try:
265 +       opts, args = getopt.getopt(sys.argv[1:], "", valid)
266 +  except getopt.GetoptError, ex:
267 +       print str(ex)
268 +       sys.exit(1)
269 +  for o, a in opts:
270 +        if o == "--node":
271 +            node = a
272 +        if o == "--lfn":
273 +            lfn = a
274 +  
275 +  mycfg_params = { 'USER.storage_element': node }
276 +  dsvc = PhEDExDatasvcInfo(mycfg_params)
277 +  dsvc.lfn = lfn
278 +  print dsvc.getStageoutPFN()
279 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines