28 |
|
|
29 |
|
dCacheDoor = 't2srv0012.cmsaf.mit.edu' |
30 |
|
|
31 |
+ |
def Domain(): |
32 |
+ |
domain = os.uname()[1] |
33 |
+ |
f = domain.split('.') |
34 |
+ |
return '.'.join(f[1:]) |
35 |
+ |
|
36 |
|
def Seconds(): |
37 |
|
for secs in os.popen('date +%s').readlines(): |
38 |
|
secs = int(secs[:-1]) |
271 |
|
skip = '' |
272 |
|
skipList = [] |
273 |
|
mitCfg = 'filefi' |
274 |
< |
version = '014' |
274 |
> |
version = '023' |
275 |
|
cmssw = '' |
276 |
|
blockLocal = 0 |
277 |
|
localStorageUrl = '' |
278 |
< |
localPath = '/server/02b/mitprod' |
278 |
> |
localPath = '/mnt/hadoop/cmsprod' |
279 |
|
pattern = '' |
280 |
|
noCache = 0 |
281 |
|
backward = '' |
333 |
|
cmd = '--cmsDataset option not provided. This is required.' |
334 |
|
raise RuntimeError, cmd |
335 |
|
|
336 |
< |
crabFile = os.environ['MIT_PROD_DIR'] + '/' + mitCfg + '/' + version + '/' + 'crab.cfg' |
337 |
< |
if not os.path.exists(crabFile): |
338 |
< |
cmd = 'Crab file not found: %s' % crabFile |
336 |
> |
seFile = os.environ['MIT_PROD_DIR'] + '/' + mitCfg + '/' + version + '/' + 'seTable' |
337 |
> |
if not os.path.exists(seFile): |
338 |
> |
cmd = 'Storage element file not found: %s' % seFile |
339 |
|
raise RuntimeError, cmd |
340 |
|
cmsswFile = os.environ['MIT_PROD_DIR'] + '/' + mitCfg + '/' + version + '/' + cmsswCfg |
341 |
|
if not os.path.exists(cmsswFile): |
348 |
|
raise RuntimeError, cmd |
349 |
|
|
350 |
|
# Resolve the other mitCfg parameters from the configuration file |
351 |
< |
cmd = 'cat ' + os.environ['MIT_PROD_DIR'] + '/' + mitCfg + '/' + version + '/' + 'Productions' |
351 |
> |
#cmd = 'cat ' + os.environ['MIT_PROD_DIR'] + '/' + mitCfg + '/' + version + '/' + 'Productions' |
352 |
> |
cmd = 'cat ' + './' + mitCfg + '/' + version + '/' + 'Productions' |
353 |
|
if cmssw != '': |
354 |
|
cmd = cmd + '.' + cmssw |
355 |
|
|
420 |
|
pMitDset = re.compile('XX-MITDATASET-XX') |
421 |
|
pMitCfg = re.compile('XX-MITCFG-XX') |
422 |
|
pMitVers = re.compile('XX-MITVERSION-XX') |
423 |
< |
# find the forseen storage place |
424 |
< |
crabFile = os.environ['MIT_PROD_DIR'] + '/' + mitCfg + '/' + version + '/' + 'crab.cfg' |
425 |
< |
cmd = 'grep ^storage_element ' + crabFile |
426 |
< |
for file in os.popen(cmd).readlines(): # run command |
427 |
< |
line = file[:-1] # strip '\n' |
428 |
< |
# decode the storage element name |
429 |
< |
names = line.split("=") # splitting every '=' |
430 |
< |
storageEle = names.pop() |
431 |
< |
storageEle = re.sub("\s", "",storageEle) |
432 |
< |
# Compile search and replacement sequences just for the path |
433 |
< |
cmd = 'grep ^storage_path ' + crabFile |
434 |
< |
for file in os.popen(cmd).readlines(): # run command |
435 |
< |
line = file[:-1] # strip '\n' |
436 |
< |
line = pMitDset.sub(mitDataset,line); |
437 |
< |
line = pMitCfg .sub(mitCfg, line); |
438 |
< |
line = pMitVers.sub(version, line); |
439 |
< |
# decode the storage directory name |
440 |
< |
names = line.split("=") # splitting every '=' |
441 |
< |
names = names[1:] |
436 |
< |
storagePath = "=".join(names) |
437 |
< |
storagePath = re.sub("\s", "",storagePath) |
438 |
< |
|
439 |
< |
##storage_element = srm-cms.cern.ch |
440 |
< |
##storage_path = /srm/managerv2?SFN=/castor/cern.ch |
441 |
< |
|
442 |
< |
## Hardwire |
443 |
< |
if fromCern: |
444 |
< |
storageEle = 'srm-cms.cern.ch' |
445 |
< |
storagePath = '/srm/managerv2?SFN=/castor/cern.ch' |
423 |
> |
# decide on the forseen default storage place (where are we running) |
424 |
> |
storageTag = 'T2_US_MIT' |
425 |
> |
domain = Domain() |
426 |
> |
if re.search('mit.edu',domain): |
427 |
> |
storageTag = 'T2_US_MIT' |
428 |
> |
elif re.search('cern.ch',domain): |
429 |
> |
storageTag = 'T0_CH_CERN' |
430 |
> |
|
431 |
> |
cmd = 'grep ^' + storageTag + ' ' + seFile |
432 |
> |
for line in os.popen(cmd).readlines(): # run command |
433 |
> |
print ' LINE: ' + line |
434 |
> |
line = line[:-1] # strip '\n' |
435 |
> |
line = line.replace(' ','') |
436 |
> |
f = line.split(':') |
437 |
> |
storageEle = f[1] |
438 |
> |
storagePath = f[2] |
439 |
> |
userRemoteDir = f[3] |
440 |
> |
print ' Storage -- Ele: ' + storageEle \ |
441 |
> |
+ ' Path: ' + storagePath + ' UserDir: ' + userRemoteDir |
442 |
|
|
443 |
< |
storageUrl = 'srm://' + storageEle + ':8443' + storagePath |
448 |
< |
|
449 |
< |
cmd = 'grep ^user_remote_dir ' + crabFile |
450 |
< |
for file in os.popen(cmd).readlines(): # run command |
451 |
< |
line = file[:-1] # strip '\n' |
452 |
< |
line = pMitDset.sub(mitDataset,line); |
453 |
< |
line = pMitCfg .sub(mitCfg, line); |
454 |
< |
line = pMitVers.sub(version, line); |
455 |
< |
# decode the storage directory name |
456 |
< |
names = line.split("=") # splitting every '=' |
457 |
< |
names = names[1:] |
458 |
< |
userRemoteDir = "=".join(names) |
459 |
< |
userRemoteDir = re.sub("\s","",userRemoteDir) |
460 |
< |
userRemoteDir = re.sub("/XX-CRABID-XX","",userRemoteDir) |
461 |
< |
|
462 |
< |
## Hardwire |
443 |
> |
# Hardwire |
444 |
|
if fromCern: |
445 |
+ |
storageEle = 'srm-cms.cern.ch' |
446 |
+ |
storagePath = '/srm/managerv2?SFN=/castor/cern.ch' |
447 |
|
userRemoteDir = "/user/p/paus/" + mitCfg + "/" + version + "/" + mitDataset |
448 |
|
|
449 |
+ |
# determine the storage URL |
450 |
+ |
storageUrl = 'srm://' + storageEle + ':8443' + storagePath |
451 |
|
if userRemoteDir != '': |
452 |
|
storagePath += userRemoteDir |
453 |
|
storageUrl += userRemoteDir |