From 7f5157b47721fd9a945baaca85b005a207e2ec2c Mon Sep 17 00:00:00 2001 From: Vladimir Bahyl <Vladimir.Bahyl@cern.ch> Date: Fri, 14 Jul 2017 11:37:06 +0200 Subject: [PATCH] Optimization + shortening the script name --- eos_wfe_scripts/create_tape_drop_disk_replicas | 10 ++++++---- eos_wfe_scripts/delete_archive_file | 8 +++++--- eos_wfe_scripts/retrieve_archive_file | 8 +++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/eos_wfe_scripts/create_tape_drop_disk_replicas b/eos_wfe_scripts/create_tape_drop_disk_replicas index 6463df1641..639f143f5e 100755 --- a/eos_wfe_scripts/create_tape_drop_disk_replicas +++ b/eos_wfe_scripts/create_tape_drop_disk_replicas @@ -9,18 +9,20 @@ WF_TAG="$1" FILE_PATH="$2" TAPE_FS_ID="$3" +LOG_DATE=`/usr/bin/date +%s | /usr/bin/tr '\n' ' ' ; /usr/bin/date` +LOG_SCRIPT_NAME=`basename $0` LOG_FILE="/var/log/eos/wfe/${WF_TAG}.log" -echo `date +%s` `date`" $0: creating tape replica with fsid ${TAPE_FS_ID} for ${FILE_PATH}" >> ${LOG_FILE} +echo "$LOG_DATE $LOG_SCRIPT_NAME creating tape replica with fsid ${TAPE_FS_ID} for ${FILE_PATH}" >> ${LOG_FILE} if ! eos -r 0 0 file tag "${FILE_PATH}" +${TAPE_FS_ID}; then - echo `date +%s` `date`" $0: failed to create tape replica with fsid ${TAPE_FS_ID} for ${FILE_PATH}" >> ${LOG_FILE} + echo "$LOG_DATE $LOG_SCRIPT_NAME failed to create tape replica with fsid ${TAPE_FS_ID} for ${FILE_PATH}" >> ${LOG_FILE} exit 1 fi for DISK_FSID in `eos file info "${FILE_PATH}" -m | sed s/\ /'\n'/g | grep fsid | sed s/fsid=// | grep -v ${TAPE_FS_ID}`; do - echo `date +%s` `date`" $0: deleting disk replica with fsid ${DISK_FSID} for ${FILE_PATH}" >> ${LOG_FILE} + echo "$LOG_DATE $LOG_SCRIPT_NAME deleting disk replica with fsid ${DISK_FSID} for ${FILE_PATH}" >> ${LOG_FILE} if ! eos -r 0 0 file drop "${FILE_PATH}" ${DISK_FSID}; then - echo `date +%s` `date`" $0: failed to delete disk replica with fsid ${DISK_FSID} for ${FILE_PATH}" >> ${LOG_FILE} + echo "$LOG_DATE $LOG_SCRIPT_NAME failed to delete disk replica with fsid ${DISK_FSID} for ${FILE_PATH}" >> ${LOG_FILE} exit 1 fi done diff --git a/eos_wfe_scripts/delete_archive_file b/eos_wfe_scripts/delete_archive_file index 1f1441743d..201de3e8a6 100755 --- a/eos_wfe_scripts/delete_archive_file +++ b/eos_wfe_scripts/delete_archive_file @@ -17,17 +17,19 @@ RGROUPNAME="$3" ARCHIVE_FILE_ID="$4" FILE_PATH="$5" +LOG_DATE=`/usr/bin/date +%s | /usr/bin/tr '\n' ' ' ; /usr/bin/date` +LOG_SCRIPT_NAME=`basename $0` LOG_FILE="/var/log/eos/wfe/${WF_TAG}.log" if test UNDEF = ${ARCHIVE_FILE_ID}; then - echo `date +%s` `date`" $0: ignoring deletion of non-existent tape archive file: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} path=${FILE_PATH}" >> ${LOG_FILE} + echo "$LOG_DATE $LOG_SCRIPT_NAME ignoring deletion of non-existent tape archive file: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} path=${FILE_PATH}" >> ${LOG_FILE} exit 0 fi if RESULT=`2>&1 /usr/bin/cta deletearchive --user ${RUSERNAME} --group ${RGROUPNAME} --id ${ARCHIVE_FILE_ID}`; then - echo `date +%s` `date`" $0: deleted tape archive file: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} path=${FILE_PATH}" >> ${LOG_FILE} + echo "$LOG_DATE $LOG_SCRIPT_NAME deleted tape archive file: rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} path=${FILE_PATH}" >> ${LOG_FILE} exit 0 else - echo `date +%s` `date`" $0: failed to delete tape archive file: error=${RESULT} rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} path=${FILE_PATH}" >> ${LOG_FILE} + echo "$LOG_DATE $LOG_SCRIPT_NAME failed to delete tape archive file: error=${RESULT} rusername=${RUSERNAME} rgroupname=${RGROUPNAME} archiveFileId=${ARCHIVE_FILE_ID} path=${FILE_PATH}" >> ${LOG_FILE} exit ${ECANCELED} fi diff --git a/eos_wfe_scripts/retrieve_archive_file b/eos_wfe_scripts/retrieve_archive_file index 940a368de4..74ac33d9e2 100755 --- a/eos_wfe_scripts/retrieve_archive_file +++ b/eos_wfe_scripts/retrieve_archive_file @@ -23,17 +23,19 @@ FILE_PATH="$9" DST_URL=${TURL}'\&eos.ruid=0&eos.rgid=0\&eos.injection=1\&eos.workflow=CTA_retrieve' +LOG_DATE=`/usr/bin/date +%s | /usr/bin/tr '\n' ' ' ; /usr/bin/date` +LOG_SCRIPT_NAME=`basename $0` LOG_FILE="/var/log/eos/wfe/${WF_TAG}.log" if test UNDEF = ${ARCHIVE_FILE_ID}; then - echo `date +%s` `date`" $0: 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} + 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} exit ${ECANCELED} fi if RESULT=`2>&1 /usr/bin/cta 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 - echo `date +%s` `date`" $0: 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} + 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} exit 0 else - echo `date +%s` `date`" $0: 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} + 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} exit ${ECANCELED} fi -- GitLab