1 |
|
#!/usr/bin/env python |
2 |
|
import sys, os, commands,string, re |
3 |
+ |
import exceptions |
4 |
+ |
from crab_exceptions import * |
5 |
|
from crab_util import * |
6 |
|
import common |
7 |
|
|
10 |
|
print '\nERROR accessing DLS for fileblock '+fileblocks+'\n' |
11 |
|
pass |
12 |
|
|
13 |
+ |
|
14 |
+ |
class DLSNoReplicas(exceptions.Exception): |
15 |
+ |
def __init__(self, FileBlock): |
16 |
+ |
args ="No replicas exists for fileblock: "+FileBlock+"\n" |
17 |
+ |
exceptions.Exception.__init__(self, args) |
18 |
+ |
pass |
19 |
+ |
|
20 |
+ |
def getClassName(self): |
21 |
+ |
""" Return class name. """ |
22 |
+ |
return "%s" % (self.__class__.__name__) |
23 |
+ |
|
24 |
+ |
def getErrorMessage(self): |
25 |
+ |
""" Return exception error. """ |
26 |
+ |
return "%s" % (self.args) |
27 |
+ |
|
28 |
|
############################################################################## |
29 |
|
# Class to extract info from DLS |
30 |
|
############################################################################## |
32 |
|
class DLSInfo: |
33 |
|
def __init__(self, fileblocks): |
34 |
|
self.fileblocks = fileblocks |
35 |
< |
self.DLSclient_ = 'DLSAPI/dls-get-se ' |
35 |
> |
self.DLSclient_ = 'dls-get-se ' |
36 |
|
self.DLSServer_ = 'lxgate10.cern.ch' |
37 |
|
self.DLSServerPort_ = '18081' |
38 |
|
#self.DLSServerPort_ = '18080' |
39 |
+ |
|
40 |
+ |
out=commands.getstatusoutput('which '+self.DLSclient_) |
41 |
+ |
if out[0]>0: |
42 |
+ |
msg="ERROR no DLS CLI available in $PATH : %s"%self.DLSclient_ |
43 |
+ |
raise CrabException(msg) |
44 |
|
|
45 |
|
# #################################### |
46 |
|
def getReplicas(self): |
49 |
|
""" |
50 |
|
## |
51 |
|
cmd = self.DLSclient_+" --port "+self.DLSServerPort_+" --host "+self.DLSServer_+" --datablock "+self.fileblocks |
52 |
+ |
#print cmd |
53 |
|
sites = runCommand(cmd) |
54 |
+ |
sites=string.strip(sites) |
55 |
+ |
if len(sites)<=0: |
56 |
+ |
raise DLSNoReplicas(self.fileblocks) |
57 |
+ |
|
58 |
|
ListSites=string.split(string.strip(sites),'\n') |
59 |
|
return ListSites |