SRMv2-user 5.96 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
31
32
33
34
35
36
37
38
39
40
41
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
voms-proxy-init -voms cms -cert $X509_USER_PROXY -out $tproxy

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
42
nodeName=$1
43
testLFN="/store/temp/user/test"
Nicolo Magini's avatar
Nicolo Magini committed
44
45
pfnFilename="userpfn.txt"

46
cd $SAME_SENSOR_HOME/tests
Nicolo Magini's avatar
Nicolo Magini committed
47
48
49
50
51
52
53
54
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
55

Nicolo Magini's avatar
Nicolo Magini committed
56
57
58
59
echo "</pre>"

if [ $EXIT_STATUS -ne 0 ]; then
   echo "ERROR: LfnToPfnFromTfc.py script failed: $EXIT_STATUS"
60
   export X509_USER_PROXY=$savedProxy
Nicolo Magini's avatar
Nicolo Magini committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
   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
	
86
      cat $SAME_SENSOR_WORK/nodes/$nodeName/$pfnFilename | cut -d "?" -f1 > $SAME_SENSOR_WORK/nodes/$nodeName/endpoint.txt
87
88
      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
89
      echo $storagepath > $SAME_SENSOR_WORK/nodes/$nodeName/userpath.txt
90
      echo "GlueVOInfoPath: "$storagepath" GlueVOInfoTag: "$token" GlueChunkKey: usertokenfromtfc"  > $SAME_SENSOR_WORK/nodes/$nodeName/usertoken.txt
Nicolo Magini's avatar
Nicolo Magini committed
91
92
93
94
95
96
97
 

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


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


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>"
115
    export X509_USER_PROXY=$savedProxy
Nicolo Magini's avatar
Nicolo Magini committed
116
117
118
    exit $SAME_WARNING
else
    echo "Testing SRMv2 endpoint " 
119
    srmv2=`cat $SAME_SENSOR_WORK/nodes/$nodeName/endpoint.txt`
Nicolo Magini's avatar
Nicolo Magini committed
120
121
122
    echo $srmv2
fi

123
124
125
126
127
128
echo "<p>"
echo "Using lcg-utils version:"
echo "<p>"

echo "<pre>"
set -x
129
130
which lcg-cp
lcg-cp --version
131
132
set +x
echo "</pre>"
Nicolo Magini's avatar
Nicolo Magini committed
133
134
135
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

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
161
162
163
164
165
166
      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'
167
      #lcg-cp -b --vo ${VO} -D srmv2 -U srmv2 -v file:/afs/cern.ch/user/b/belforte/scratch0/oneEvt.root ${SURL}
168
      result=$copyresult
Nicolo Magini's avatar
Nicolo Magini committed
169
170
171
172
173
174
175
176
177
178
179
180
181
182
      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
183
	  lcg-del -v -b -l -D srmv2 -T srmv2 --vo ${VO} ${SURL}
Nicolo Magini's avatar
Nicolo Magini committed
184
185
186
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
	  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

219
220
export X509_USER_PROXY=$savedProxy

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