SRMv2-user 6.04 KB
Newer Older
Nicolo Magini's avatar
Nicolo Magini committed
1
2
3
#!/bin/bash

echo "<h2>Checking if TFC is available for SRMv2 endpoint and using it to perform lfn to pfn matching</h2>"
4
echo "<h4>version 2010 03 25 15:45</h4>"
Nicolo Magini's avatar
Nicolo Magini committed
5
6
7
8
9
10
11
12
13
14
echo "<h3>Checking PYTHONPATH</h3>"
echo "<pre>"
echo "PYTHONPATH=$PYTHONPATH"
echo "</pre>"
echo "<h3>Invoking site test</h3>"
echo "<pre>"

echo "<h5>"
echo "USER/WHOAMI?:" $USER/`whoami`
echo "USER ID:" $uid
Stefano Belforte's avatar
Stefano Belforte committed
15
16
17
18
19
echo "X509_USER_PROXY:" $X509_USER_PROXY 
voms-proxy-info -debug -all
env|grep -i proxy
env|grep /tmp

Nicolo Magini's avatar
Nicolo Magini committed
20
21
echo "</h5>"

22
23
24
25
26
27
28
29
30
echo
echo " temporarly remove lcgadim role"
tproxy=`mktemp`
ls -l $tproxy

echo X509_USER_PROXY=$X509_USER_PROXY 

savedProxy=$X509_USER_PROXY
echo savedProxy=$savedProxy
31
which voms-proxy-init
32
33
34
echo "seem I cannot do: voms-proxy-init -voms cms -cert $X509_USER_PROXY -out $tproxy"

cp -v $$X509_USER_PROXY $tproxy
35
36
37
38
39
40
41
42
43
44

ls -l $tproxy
voms-proxy-info -all -path $tproxy

export X509_USER_PROXY=$tproxy
voms-proxy-info -all -path

exit $SAME_INFO
echo "==========================================================="

Nicolo Magini's avatar
Nicolo Magini committed
45
nodeName=$1
46
testLFN="/store/temp/user/test"
Nicolo Magini's avatar
Nicolo Magini committed
47
48
pfnFilename="userpfn.txt"

49
cd $SAME_SENSOR_HOME/tests
Nicolo Magini's avatar
Nicolo Magini committed
50
51
52
53
54
55
56
57
if [ $? -ne 0 ]; then
   echo "ERROR: Could not access the tests directory"
   exit $SAME_ERROR
else
  chmod u+x LfnToPfnFromTfc.py 
  ./LfnToPfnFromTfc.py $nodeName $testLFN $pfnFilename | tee $SAME_SENSOR_WORK/nodes/$nodeName/LfnToPfnFromTfc.out
  EXIT_STATUS=$?
fi
58

Nicolo Magini's avatar
Nicolo Magini committed
59
60
61
62
echo "</pre>"

if [ $EXIT_STATUS -ne 0 ]; then
   echo "ERROR: LfnToPfnFromTfc.py script failed: $EXIT_STATUS"
63
   export X509_USER_PROXY=$savedProxy
Nicolo Magini's avatar
Nicolo Magini committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
   exit $SAME_ERROR
else
   
   if [ -f $SAME_SENSOR_WORK/nodes/$nodeName/$pfnFilename ]; then

       if [ ! -f $SAME_SENSOR_WORK/nodes/$nodeName/list_$pfnFilename ]; then

	   echo "<pre>"
	   echo "WARNING: Retrieval of PFN from TFC webservice failed; cached PFN will be used"
	   echo "</pre>"

       fi

      echo "<pre>"
      echo "TFC Test successful"
      echo "</pre>" 
      grep -w $nodeName $SAME_SENSOR_WORK/nodes/$nodeName/$pfnFilename > /dev/null
      MATCH_RESULT=$?
   
      if [ $MATCH_RESULT -ne 0 ]; then
         echo "<pre>"
         echo "SRM endpoint in TFC does not match $nodeName"
         echo "</pre>"
      fi
	
89
      cat $SAME_SENSOR_WORK/nodes/$nodeName/$pfnFilename | cut -d "?" -f1 > $SAME_SENSOR_WORK/nodes/$nodeName/endpoint.txt
90
91
      storagepath=`cat $SAME_SENSOR_WORK/nodes/$nodeName/$pfnFilename | cut -d= -f2- | cut -d " " -f1`
      token=`cat $SAME_SENSOR_WORK/nodes/$nodeName/$pfnFilename | cut -d " " -f3`
Nicolo Magini's avatar
Nicolo Magini committed
92
      echo $storagepath > $SAME_SENSOR_WORK/nodes/$nodeName/userpath.txt
93
      echo "GlueVOInfoPath: "$storagepath" GlueVOInfoTag: "$token" GlueChunkKey: usertokenfromtfc"  > $SAME_SENSOR_WORK/nodes/$nodeName/usertoken.txt
Nicolo Magini's avatar
Nicolo Magini committed
94
95
96
97
98
99
100
 

      
   else
       echo "<p>"
       echo "TFC not found or rule for SRM non found in TFC"
       echo "</p>"
101
       export X509_USER_PROXY=$savedProxy
Nicolo Magini's avatar
Nicolo Magini committed
102
103
104
105
106
107
108
       exit $SAME_ERROR
   fi
   
fi


# loading lcg_util164 libraries
109
#LD_LIBRARY_PATH=$HOME/bin/external/usr/lib:$HOME/bin/lcg_utils164+gfal1105/lib:$LD_LIBRARY_PATH
Nicolo Magini's avatar
Nicolo Magini committed
110
111
112
113
114
115
116
117


cdate=`date '+%Y%m%d-%H%M%S'`

if [ ! -f $SAME_SENSOR_WORK/nodes/$nodeName/endpoint.txt ] ; then
    echo "<p>"
    echo "Full SRMv2 endpoint not provided"
    echo "</p>"
118
    export X509_USER_PROXY=$savedProxy
Nicolo Magini's avatar
Nicolo Magini committed
119
120
121
    exit $SAME_WARNING
else
    echo "Testing SRMv2 endpoint " 
122
    srmv2=`cat $SAME_SENSOR_WORK/nodes/$nodeName/endpoint.txt`
Nicolo Magini's avatar
Nicolo Magini committed
123
124
125
    echo $srmv2
fi

126
127
128
129
130
131
echo "<p>"
echo "Using lcg-utils version:"
echo "<p>"

echo "<pre>"
set -x
132
133
which lcg-cp
lcg-cp --version
134
135
set +x
echo "</pre>"
Nicolo Magini's avatar
Nicolo Magini committed
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

VO=$SAME_VO

echo "<h2>"
echo "Testing storage area without specifying space tokens"
echo "</h2>"

if [ -f $SAME_SENSOR_WORK/nodes/$nodeName/userpath.txt ] ; then
    
    cat $SAME_SENSOR_WORK/nodes/$nodeName/userpath.txt | while read line
      do
      echo "<p>"
      echo "Testing storage space in path:"
      echo "</p>"
      echo "<pre>"
      echo $line
      echo "</pre>"
      SURL=$srmv2?SFN=$line/lcg-util/testfile-user-${cdate}.txt
      #SURL=$srmv2?SFN=$line/oneEvt.root
      echo "<p>"
      echo "The SURL used for testing will be:"
      echo "</p>"
      echo "<pre>"
      echo $SURL
      echo "</pre>"
      echo "<p>"
      echo "<pre>"
      set -x
164
165
166
167
168
169
      lcg-cp -b --vo ${VO} -D srmv2 -U srmv2 -v file:$SAME_SENSOR_WORK/testFile.txt ${SURL} 1>$SAME_SENSOR_WORK/nodes/$nodeName/SRMv2-lcg-user-put-output 2>$SAME_SENSOR_WORK/nodes/$nodeName/SRMv2-lcg-user-put-stderr
      #copyresult=${PIPESTATUS[0]}
      copyresult=$?
      set +x
      cat $SAME_SENSOR_WORK/nodes/$nodeName/SRMv2-lcg-user-put-output | sed 's/\&/\&amp;/g' | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
      cat $SAME_SENSOR_WORK/nodes/$nodeName/SRMv2-lcg-user-put-stderr | sed 's/\&/\&amp;/g' | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'
170
      #lcg-cp -b --vo ${VO} -D srmv2 -U srmv2 -v file:/afs/cern.ch/user/b/belforte/scratch0/oneEvt.root ${SURL}
171
      result=$copyresult
Nicolo Magini's avatar
Nicolo Magini committed
172
173
174
175
176
177
178
179
180
181
182
183
184
185
      set +x
      echo "</pre>"  
      if [ $result -ne 0 ] ; then
	  echo "<p>"
	  echo "ERROR: File ${SURL} not copied"
	  echo "</p>"
      else
	  echo "<p>"
	  echo "File ${SURL} copied successfully"
	  echo "</p>"
	     
      
	  echo "<pre>"
	  set -x
186
	  lcg-del -v -b -l -D srmv2 -T srmv2 --vo ${VO} ${SURL}
Nicolo Magini's avatar
Nicolo Magini committed
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
	  dresult=$?
	  set +x
	  echo "</pre>"
	  if [ $dresult != 0 ] ; then
	      echo "<p>"
	      echo "ERROR: File ${SURL} not deleted"
	      echo "</p>"
	      echo "<p>"
	      echo "Exit status: $dresult"
	      echo "</p>"
	  else
	      echo "<p>"
	      echo "File ${SURL} deleted successfully"
	      echo "</p>"
	  fi
      fi

      if [ $result != 0 ] || [ $dresult != 0 ] ; then
	  echo 1 > $SAME_SENSOR_WORK/nodes/$nodeName/SRM-user.error
      else
	  echo "<p>"
	  echo "Default path "
	  echo $line
	  echo " tested successfully"
	  echo "</p>"
      fi
      
    done
else
     echo "<p>"
     echo "WARNING: Default path not defined"
     echo "</p>"
     echo 1 > $SAME_SENSOR_WORK/nodes/$nodeName/SRM-user.error 
fi

222
223
export X509_USER_PROXY=$savedProxy

Nicolo Magini's avatar
Nicolo Magini committed
224
if [ -f $SAME_SENSOR_WORK/nodes/$nodeName/SRM-user.error ] ; then
225
226
#    exit $SAME_ERROR
    exit $SAME_WARNING
Nicolo Magini's avatar
Nicolo Magini committed
227
228
229
230
elif  [ -f $SAME_SENSOR_WORK/nodes/$nodeName/SRM-user.error ] ; then
    exit $SAME_OK
else
    exit $SAME_OK
231
fi