5 |
|
# Author: C.Paus (May 06, 2010) |
6 |
|
#--------------------------------------------------------------------------------------------------- |
7 |
|
import os,sys,getopt,re |
8 |
+ |
import srm |
9 |
+ |
user = os.environ['TICKET_HOLDER'] |
10 |
+ |
t2user = os.environ['TIER2_USER'] |
11 |
|
|
12 |
|
def debugPrint(text): |
13 |
|
if debug ==1: |
17 |
|
if re.search('dcap:',file): |
18 |
|
g = file.split('/') |
19 |
|
file = '/'.join(g[3:]) |
20 |
+ |
if re.search('root:',file): |
21 |
+ |
g = file.split('/') |
22 |
+ |
file = '/'.join(g[3:]) |
23 |
+ |
file = '/mnt/hadoop/cms' + file |
24 |
|
debugPrint(' Cleaned: ' + file) |
25 |
|
|
26 |
|
return file |
29 |
|
def exists(target): |
30 |
|
if re.search('/castor/cern.ch/',target): |
31 |
|
debugPrint(' Identified a castor directory: ' + target) |
32 |
< |
cmd = 'rfdir ' + target + '\>\& /dev/null' |
33 |
< |
elif re.search('/pnfs/cmsaf.mit.edu/',target): |
32 |
> |
cmd = 'ssh ' + t2user + '@lxplus.cern.ch rfdir ' + target + '>& /dev/null' |
33 |
> |
elif re.search('/mnt/hadoop/cms/store',target): |
34 |
|
debugPrint(' Identified a tier-2 directory: ' + target) |
35 |
< |
cmd = 'ssh paus@cgate.mit.edu ls -1 ' + target + '\>\& /dev/null' |
35 |
> |
cmd = 'ssh ' + t2user + '@se01.cmsaf.mit.edu ls -1 ' + target + ' \>\& /dev/null' |
36 |
|
else: |
37 |
|
debugPrint(' Identified a normal directory: ' + target) |
38 |
< |
cmd = 'ls -1 ' + target + '\>\& /dev/null' |
38 |
> |
cmd = 'ls -1 ' + target + '>\& /dev/null' |
39 |
|
|
40 |
|
status = os.system(cmd) |
41 |
|
debugPrint(' Status: %d' % status) |
45 |
|
def move(source,target): |
46 |
|
if re.search('/castor/cern.ch/',source) and re.search('/castor/cern.ch/',target): |
47 |
|
debugPrint(' Identified two castor directories') |
48 |
< |
cmd = 'rfrename ' + source + ' ' + target |
49 |
< |
elif re.search('/pnfs/cmsaf.mit.edu/',source) and re.search('/pnfs/cmsaf.mit.edu/',target): |
50 |
< |
debugPrint(' Identified two tier-2 directories') |
51 |
< |
cmd = 'ssh paus@cgate.mit.edu mv ' + source + ' ' + target |
48 |
> |
cmd = 'ssh ' + user + '@lxplus.cern.ch nsrename ' + source + ' ' + target |
49 |
> |
elif re.search('/mnt/hadoop/cms/store',target): |
50 |
> |
urlSource = srm.convertToUrl(source,False) |
51 |
> |
urlTarget = srm.convertToUrl(target,False) |
52 |
> |
cmd = 'srmmv ' + urlSource + ' ' + urlTarget + ' >& /dev/null' |
53 |
> |
cmd = 'glexec mv ' + source + ' ' + target ## + ' >& /dev/null' |
54 |
> |
#debugPrint(' Identified a tier-2 directory: ' + target) |
55 |
> |
#cmd = 'ssh ' + t2user + '@se01.cmsaf.mit.edu ls -1 ' + target + ' \>\& /dev/null' |
56 |
|
else: |
57 |
|
debugPrint(' Identified a normal directory') |
58 |
|
cmd = 'mv ' + source + ' ' + target |