retrieve_archive_file 2.55 KB
Newer Older
1
2
3
4
#!/bin/bash

EINVAL=22
ECANCELED=125
5

6
export XrdSecPROTOCOL=sss
7
export XrdSecSSSKT=/etc/cta/cta-cli.sss.keytab   # This location is used on EOSCTATAPE
8
export XrdSecSSSKT=/etc/ctafrontend_SSS_c.keytab # This location is used for CI
9

10
11
12
export XRD_STREAMTIMEOUT=600     # increased from 60s
export XRD_TIMEOUTRESOLUTION=600 # increased from 15s

13
14
15
16
17
18
if test $# -ne 9; then
  echo "Wrong number of command-line arguments"
  echo "Usage: retrieve_archive_file wf_tag rusername rgroupname archive_file_id turl disk_username disk_groupname metadata_base64 file_path"
  exit ${EINVAL}
fi

19
CTA_BIN=/usr/bin/cta
20

21
22
23
24
25
26
27
28
29
30
WF_TAG="$1"
RUSERNAME="$2"
RGROUPNAME="$3"
ARCHIVE_FILE_ID="$4"
TURL="$5"
DISK_USERNAME="$6"
DISK_GROUPNAME="$7"
METADATA_BASE64="$8"
FILE_PATH="$9"

31
DST_URL=${TURL}'\&eos.ruid=0\&eos.rgid=0\&eos.injection=1\&eos.workflow=CTA_retrieve'
32

33
LOG_DATE=`/usr/bin/date +%s | /usr/bin/tr '\n' ' ' ; /usr/bin/date`
34
LOG_SCRIPT_NAME=`/usr/bin/basename $0`
35
36
37
LOG_FILE="/var/log/eos/wfe/${WF_TAG}.log"

if test UNDEF = ${ARCHIVE_FILE_ID}; then
38
  echo "$LOG_DATE $LOG_SCRIPT_NAME cannot retrieve an archive file without the sys.archiveFileId attribute being set: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} dsturl=${DST_URL} disk_username=${DISK_USERNAME} disk_groupname=${DISK_GROUPNAME} path=${FILE_PATH}" >> ${LOG_FILE}
39
40
41
  exit ${ECANCELED}
fi

42
43
44
45
if ! RESULT=`unset XrdSecPROTOCOL XrdSecSSSKT ; /usr/bin/eos ls -y ${FILE_PATH} | /usr/bin/grep -s ^d0`; then
  echo "$LOG_DATE $LOG_SCRIPT_NAME file already has at least one online replica on disk: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} dsturl=${DST_URL} disk_username=${DISK_USERNAME} disk_groupname=${DISK_GROUPNAME} path=${FILE_PATH}" >> ${LOG_FILE}
  exit 0
fi
46

47
if RESULT=`2>&1 ${CTA_BIN} retrieve --user ${RUSERNAME} --group ${RGROUPNAME} --id ${ARCHIVE_FILE_ID} --dsturl ${DST_URL} --diskfilepath ${FILE_PATH} --diskfileowner ${DISK_USERNAME} --diskfilegroup ${DISK_GROUPNAME} --recoveryblob:base64 ${METADATA_BASE64}`; then
48
  echo "$LOG_DATE $LOG_SCRIPT_NAME queued retrieve request: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} dsturl=${DST_URL} disk_username=${DISK_USERNAME} disk_groupname=${DISK_GROUPNAME} path=${FILE_PATH}" >> ${LOG_FILE}
49
50
  exit 0
else
51
  echo "$LOG_DATE $LOG_SCRIPT_NAME failed to queue retrieve request: error=${RESULT} rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} dsturl=${DST_URL} disk_username=${DISK_USERNAME} disk_groupname=${DISK_GROUPNAME} path=${FILE_PATH}" >> ${LOG_FILE}
52
53
  exit ${ECANCELED}
fi