Skip to content

Commit 087b14f

Browse files
authored
Merge pull request #8 from rlcee/sll_221213
updates
2 parents 95fe159 + 189b4f4 commit 087b14f

File tree

3 files changed

+145
-26
lines changed

3 files changed

+145
-26
lines changed

bin/dcacheFileInfo

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mcs.mu2e.DS-cosmic-mix-cat.MDC2018i.001002_00000001.art
2323
-l print locality
2424
NEARLINE - only on tape, ONLINE- on disk
2525
ONLINE_AND_NEARLINE means both
26+
-d print create date in epoch seconds
2627
-v verbose
2728
-t interpret argument as file name only, and lookup the tape location
2829
-p interpret argument as file name only, and lookup the persis. location
@@ -39,18 +40,22 @@ mcs.mu2e.DS-cosmic-mix-cat.MDC2018i.001002_00000001.art
3940

4041
DOCRC=""
4142
DOLOC=""
43+
DODATE=""
4244
VERBOSE=""
4345
LTAPE=""
4446
LDISK=""
4547

46-
while getopts cltpvh OPT; do
48+
while getopts cldtpvh OPT; do
4749
case $OPT in
4850
c)
4951
DOCRC=yes
5052
;;
5153
l)
5254
DOLOC=yes
5355
;;
56+
d)
57+
DODATE=yes
58+
;;
5459
t)
5560
LTAPE=yes
5661
;;
@@ -94,24 +99,16 @@ if [[ -n "$LTAPE" || -n "$LDISK" ]]; then
9499
source /cvmfs/mu2e.opensciencegrid.org/setupmu2e-art.sh
95100
setup mu2efilename
96101
fi
97-
if [ $LTAPE ]; then
98-
FFS=$(echo -n $FFS | mu2eabsname_tape )
102+
if [ "$LTAPE" ]; then
103+
FFS=$(echo $FFS | mu2eabsname_tape )
99104
else
100-
FFS=$(echo -n $FFS | mu2eabsname_disk )
105+
FFS=$(echo $FFS | mu2eabsname_disk )
101106
fi
102107
fi
103-
#if [ "$STUB" != "/pnfs" ]; then
104-
# echo "ERROR - one pnfs filespec argument is required"
105-
# exit 1
106-
#fi
107108

108109
# canonical dCache filespec
109110
CFFS=$(echo $FFS | sed 's|/pnfs|/pnfs/fnal.gov/usr|' )
110111

111-
112-
113-
#curl -L --capath /etc/grid-security/certificates --cert $FINV --cacert $FINV --key $FINV -X GET "https://fndca1.fnal.gov:3880/api/v1/namespace${CFFS}?checksum=true&locality=true"
114-
115112
VS=" -s "
116113
[ $VERBOSE ] && VS=""
117114

@@ -124,7 +121,7 @@ if [ $RC -ne 0 ]; then
124121
exit 1
125122
fi
126123

127-
[ $VERBOSE ] && echo -n "$ANS"
124+
[ $VERBOSE ] && echo "$ANS"
128125

129126
CRC=""
130127
if [ $DOCRC ]; then
@@ -133,9 +130,15 @@ fi
133130

134131
LOC=""
135132
if [ $DOLOC ]; then
136-
LOC=$( echo -n "$ANS" | grep fileLocality | tr -d '":,' | awk '{print$2}' )
133+
LOC=$( echo -n "$ANS" | grep fileLocality | tr -d '":,' | awk '{print $2}' )
134+
fi
135+
136+
DATE=""
137+
if [ $DODATE ]; then
138+
DATEMS=$( echo -n "$ANS" | grep creationTime | tr -d '":,' | awk '{print $2}' )
139+
DATE=$(($DATEMS/1000))
137140
fi
138141

139-
[ ${CRC}${LOC} ] && echo $CRC $LOC
142+
[ ${CRC}${LOC} ] && echo $CRC $LOC $DATE
140143

141144
exit 0

bin/samListLocations

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,38 @@ elif [ "$1" == "-f" ]; then
5555
TMPF=$(mktemp)
5656
fi
5757

58+
[ -z "$MU2E" ] && setup mu2e
59+
[ -z "$SETUP_SAM_WEB_CLIENT" ] && setup sam_web_client
60+
[ -z "$SETUP_DHTOOLS" ] && setup dhtools
61+
if ! voms-proxy-info > /dev/null 2>&1 ; then
62+
vomsCert > /dev/null 2>&1
63+
fi
64+
65+
TMPL=$(mktemp)
5866

67+
samweb list-file-locations "${@}" | tr ":" " " > $TMPL
5968

60-
OLDIFS=${IFS}
61-
samweb list-file-locations "${@}" | while read line
69+
# loop over unique file names
70+
cat $TMPL | awk '{print $3}' | sort | uniq \
71+
| while read FILENAME
6272
do
63-
IFS=$'\t'
64-
read -a strarr <<< "$line"
65-
FILEPATH=`echo ${strarr[0]} | cut -d':' -f2`
66-
FILESPEC=${FILEPATH}/${strarr[1]}
67-
68-
LOC=""
69-
if [ $DOLOC ]; then
70-
LOC=$( dcacheFileInfo -l $FILESPEC )
73+
74+
# list of locations, dcache first
75+
FSS=$(cat $TMPL | awk '{if($3=="'$FILENAME'") print $1" "$2}' | sort )
76+
77+
TAPESPEC=$(echo "$FSS" | awk '{if($1=="enstore") print $2"/'$FILENAME'"}')
78+
DISKSPEC=$(echo "$FSS" | awk '{if($1=="dcache") print $2"/'$FILENAME'"}')
79+
80+
if [ "$DISKSPEC" ]; then
81+
FILESPEC="$DISKSPEC"
82+
LOC="ONLINE"
83+
else
84+
FILESPEC="$TAPESPEC"
85+
LOC=""
86+
if [ $DOLOC ]; then
87+
# have to see if tape-backed is on disk
88+
LOC=$( dcacheFileInfo -l $FILESPEC )
89+
fi
7190
fi
7291

7392
if [ $DODISK ]; then
@@ -83,11 +102,12 @@ do
83102
fi
84103

85104
done
86-
IFS=${OLDIFS}
87105

88106
if [ $DOFIRST ]; then
89107
cat $TMPF
90108
rm -f $TMPF
91109
fi
110+
rm -f $TMPL
111+
rm -f $TMPF
92112

93113
exit 0

build/tarball.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
#
3+
# script to make a ups tarball
4+
# args: $1=version
5+
# tarball will be created in the cwd
6+
#
7+
VERSION="$1"
8+
if [ ! "$VERSION" ]; then
9+
echo "ERROR - no required version argument"
10+
exit 1
11+
fi
12+
13+
OWD=$PWD
14+
SDIR=$(dirname $(readlink -f $BASH_SOURCE) | sed 's|/build||' )
15+
16+
PDIR=$(mktemp -d)
17+
cd $PDIR
18+
mkdir -p dhtools
19+
cd dhtools
20+
mkdir -p $VERSION
21+
cd $VERSION
22+
23+
rsync --exclude "*~" --exclude "*__*" \
24+
-r $SDIR/bin $SDIR/python .
25+
mkdir -p ups
26+
cd ups
27+
28+
cat > dhtools.table <<EOL
29+
File = table
30+
Product = dhtools
31+
32+
#*************************************************
33+
# Starting Group definition
34+
35+
Group:
36+
37+
Flavor = ANY
38+
Qualifiers = ""
39+
40+
Action = flavorSetup
41+
42+
Flavor = ANY
43+
Qualifiers = "grid"
44+
45+
Action = flavorSetup
46+
sourceRequired(\${UPS_PROD_DIR}/bin/mgf_functions.sh,UPS_ENV)
47+
48+
Common:
49+
Action = setup
50+
setupRequired( ifdhc )
51+
setupRequired( sam_web_client )
52+
prodDir()
53+
setupEnv()
54+
envSet(\${UPS_PROD_NAME_UC}_VERSION, $VERSION)
55+
sourceRequired(\${UPS_PROD_DIR}/bin/dh_functions.sh,UPS_ENV)
56+
pathPrepend(PATH,\${UPS_PROD_DIR}/bin)
57+
pathPrepend(PYTHONPATH,\${UPS_PROD_DIR}/python)
58+
exeActionRequired(flavorSetup)
59+
60+
End:
61+
# End Group definition
62+
#*************************************************
63+
EOL
64+
65+
# up to dhtools dir
66+
cd ../..
67+
68+
mkdir -p ${VERSION}.version
69+
cd ${VERSION}.version
70+
71+
cat > NULL <<EOL
72+
FILE = version
73+
PRODUCT = dhtools
74+
VERSION = $VERSION
75+
76+
FLAVOR = NULL
77+
QUALIFIERS = ""
78+
PROD_DIR = dhtools/$VERSION
79+
UPS_DIR = ups
80+
TABLE_FILE = dhtools.table
81+
82+
FLAVOR = NULL
83+
QUALIFIERS = "grid"
84+
PROD_DIR = dhtools/$VERSION
85+
UPS_DIR = ups
86+
TABLE_FILE = dhtools.table
87+
EOL
88+
89+
cd ../..
90+
91+
tar -cjf $OWD/dhtools-${VERSION}.bz2 dhtools/${VERSION} dhtools/${VERSION}.version
92+
rm -rf $PDIR/dhtools
93+
rmdir $PDIR
94+
95+
cd $OWD
96+
exit 0

0 commit comments

Comments
 (0)