Revision: | 1.18 |
Committed: | Fri Nov 16 11:09:31 2007 UTC (17 years, 5 months ago) by slacapra |
Content type: | text/x-python |
Branch: | MAIN |
CVS Tags: | CRAB_2_4_0_test, CRAB_2_3_1, CRAB_2_3_1_pre6, CRAB_2_3_1_pre5, CRAB_2_3_1_pre4, CRAB_2_3_1_pre3, CRAB_2_3_1_pre2, CRAB_2_3_1_pre1, CRAB_2_3_0, CRAB_2_3_0_pre6, CRAB_2_3_0_pre1, CRAB_2_2_2_pre5, CRAB_2_2_2_pre4, CRAB_2_2_2_pre3, CRAB_2_2_2_pre2, CRAB_2_2_2_pre1, CRAB_2_2_1, CRAB_2_2_1_pre6, CRAB_2_2_1_pre5, CRAB_2_2_1_pre4, PRODCOMMON_0_10_7_testCS2, CRAB_2_2_1_pre3, CRAB_2_2_1_pre2, CRAB_2_2_1_pre1, CRAB_2_2_0, CRAB_2_2_0_pre21, CRAB_2_2_0_pre19, CRAB_2_2_0_pre18, CRAB_2_2_0_pre17, CRAB_2_2_0_pre16, CRAB_2_2_0_pre15, CRAB_2_2_0_pre13, CRAB_2_2_0_pre12, CRAB_2_2_0_pre11, CRAB_2_2_0_pre10, bp_osg_bdii, CRAB_2_2_0_pre9, CRAB_2_2_0_pre8, CRAB_2_2_0_pre7, CRAB_2_1_2, CRAB_2_2_0_pre5, CRAB_2_1_2_pre2, CRAB_2_1_2_pre1, CRAB_2_2_0_pre4, CRAB_2_2_0_pre2, CRAB_2_1_1, CRAB_2_1_1_pre3, CRAB_2_2_0_pre1, CRAB_2_1_1_pre1, CRAB_2_1_0, CRAB_2_1_0_pre6, CRAB_2_1_0_pre5, CRAB_2_1_0_pre4, CRAB_2_1_0_pre3, CRAB_2_1_0_pre2, CRAB_2_1_0_pre1, CRAB_2_0_4, CRAB_2_0_4_pre2, CRAB_2_0_4_pre1, CRAB_2_0_3, CRAB_2_0_3_pre1, CRAB_2_0_2, CRAB_2_0_2_pre6 |
Branch point for: | CRAB_2_3_0_br, osg_bdii, CRAB_2_1_2_br, CRAB_2_1_1_pre2 |
Changes since 1.17: | +10 -34 lines |
Log Message: | remove support for DBS1, and remove DBS2 string from files/class |
# | User | Rev | Content |
---|---|---|---|
1 | afanfani | 1.1 | #!/usr/bin/env python |
2 | import sys, os, commands,string, re | ||
3 | afanfani | 1.4 | import exceptions |
4 | from crab_exceptions import * | ||
5 | afanfani | 1.1 | from crab_util import * |
6 | import common | ||
7 | |||
8 | slacapra | 1.14 | import dlsApi |
9 | import dlsClient | ||
10 | from dlsDataObjects import DlsLocation, DlsFileBlock, DlsEntry | ||
11 | afanfani | 1.7 | |
12 | slacapra | 1.18 | # ## for python 2.2 add the pyexpat.so to PYTHONPATH |
13 | # pythonV=sys.version.split(' ')[0] | ||
14 | # if pythonV.find('2.2') >= 0 : | ||
15 | # Crabpydir=commands.getoutput('which crab') | ||
16 | # Topdir=string.replace(Crabpydir,'/python/crab','') | ||
17 | # extradir=Topdir+'/DLSAPI/extra' | ||
18 | # if sys.path.count(extradir) <= 0: | ||
19 | # if os.path.exists(extradir): | ||
20 | # sys.path.insert(0, extradir) | ||
21 | afanfani | 1.6 | |
22 | |||
23 | afanfani | 1.1 | class DLSError: |
24 | slacapra | 1.5 | def __init__(self, fileblocks): |
25 | print '\nERROR accessing DLS for fileblock '+fileblocks+'\n' | ||
26 | pass | ||
27 | afanfani | 1.1 | |
28 | afanfani | 1.4 | |
29 | class DLSNoReplicas(exceptions.Exception): | ||
30 | slacapra | 1.5 | def __init__(self, FileBlock): |
31 | spiga | 1.15 | self.args ="No replicas exists for fileblock: "+FileBlock+"\n" |
32 | slacapra | 1.14 | exceptions.Exception.__init__(self, self.args) |
33 | slacapra | 1.5 | pass |
34 | |||
35 | def getClassName(self): | ||
36 | """ Return class name. """ | ||
37 | return "%s" % (self.__class__.__name__) | ||
38 | |||
39 | def getErrorMessage(self): | ||
40 | """ Return exception error. """ | ||
41 | return "%s" % (self.args) | ||
42 | afanfani | 1.4 | |
43 | afanfani | 1.6 | |
44 | afanfani | 1.1 | ############################################################################## |
45 | # Class to extract info from DLS | ||
46 | ############################################################################## | ||
47 | |||
48 | class DLSInfo: | ||
49 | mkirn | 1.11 | def __init__(self, type, cfg_params): |
50 | self.cfg_params = cfg_params | ||
51 | slacapra | 1.18 | if type=="DLS_TYPE_DBS": |
52 | gutsche | 1.17 | # |
53 | # use dbs_url as dls_endpoint if dls_type is dbs | ||
54 | # | ||
55 | gutsche | 1.16 | try: |
56 | gutsche | 1.17 | endpoint=self.cfg_params['CMSSW.dbs_url'] |
57 | gutsche | 1.16 | except KeyError: |
58 | endpoint="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet" | ||
59 | afanfani | 1.6 | else: |
60 | gutsche | 1.10 | msg = "DLS type %s not among the supported DLS ( DLS_TYPE_DLI and DLS_TYPE_MYSQL ) "%type |
61 | raise CrabException(msg) | ||
62 | afanfani | 1.6 | |
63 | afanfani | 1.9 | common.logger.debug(5,"DLS interface: %s Server %s"%(type,endpoint)) |
64 | afanfani | 1.6 | try: |
65 | gutsche | 1.10 | self.api = dlsClient.getDlsApi(dls_type=type,dls_endpoint=endpoint) |
66 | afanfani | 1.6 | except dlsApi.DlsApiError, inst: |
67 | slacapra | 1.14 | msg = "Error when binding the DLS interface: %s Server %s"%(str(inst),endpoint) |
68 | gutsche | 1.10 | #print msg |
69 | raise CrabException(msg) | ||
70 | |||
71 | afanfani | 1.1 | # #################################### |
72 | afanfani | 1.6 | def getReplicas(self,fileblocks): |
73 | slacapra | 1.5 | """ |
74 | query DLS to get replicas | ||
75 | """ | ||
76 | ## | ||
77 | afanfani | 1.6 | try: |
78 | gutsche | 1.10 | entryList=self.api.getLocations([fileblocks]) |
79 | afanfani | 1.6 | except dlsApi.DlsApiError, inst: |
80 | slacapra | 1.14 | #msg = "Error in the DLS query: %s." % str(inst) |
81 | gutsche | 1.10 | #print msg |
82 | raise DLSNoReplicas(fileblocks) | ||
83 | afanfani | 1.6 | |
84 | ListSites=[] | ||
85 | for entry in entryList: | ||
86 | gutsche | 1.10 | for loc in entry.locations: |
87 | ListSites.append(str(loc.host)) | ||
88 | afanfani | 1.6 | if len(ListSites)<=0: |
89 | gutsche | 1.10 | raise DLSNoReplicas(fileblocks) |
90 | afanfani | 1.4 | |
91 | slacapra | 1.5 | return ListSites |