Commit 9eabbcc4 authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

[CASTOR migration] added main script to the cta-migration package

parent 7bdcea7f
......@@ -311,6 +311,8 @@ directory metadata into the EOS namespace.
%attr(0755,root,root) %{_bindir}/eos-test-file-inject
%attr(0755,root,root) %{_bindir}/eos-test-inject.sh
%attr(0755,root,root) %{_bindir}/json-pretty-print.sh
%attr(0755,root,root) %{_bindir}/exportapepool.sh
%attr(0755,root,root) %{_bindir}/undoexportapepool.sh
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/castor-migration.conf.example
%package -n cta-rmcd
......
......@@ -17,3 +17,4 @@
cmake_minimum_required (VERSION 2.6)
add_subdirectory(gRPC)
add_subdirectory(castor)
# The CERN Tape Archive (CTA) project
# Copyright 2019 CERN
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
install(FILES ${CMAKE_SOURCE_DIR}/migration/castor/exporttapepool.sh
${CMAKE_SOURCE_DIR}/migration/castor/undoexporttapepool.sh
DESTINATION usr/bin)
......@@ -31,31 +31,43 @@ if [[ $# != 3 && $# != 4 ]]; then
exit 1
fi
# check that the tapepool exists for this stager
printtapepool $1 > /dev/null
[[ $? -gt 0 ]] && echo 'Tape pool' $1 'not found or not configured on this stager' && exit 1
# if NOT dry-run, execute all pre-checks
if [[ "$4" != "-d" ]]; then
# check that no migrations are pending/ongoing for this tapepool
printmigrationstatus | grep $1 && echo 'Migrations still ongoing, aborting' && exit 1
# check that the tapepool exists for this stager
printtapepool $1 > /dev/null
[[ $? -gt 0 ]] && echo 'Tape pool' $1 'not found or not configured on this stager' && exit 1
# check that all tapes are good for export, that is no BUSY tape; RDONLY is OK
busytapes=`vmgrlisttape -P $1 | grep -c BUSY`
[[ $busytapes -gt 0 ]] && echo 'Found' $busytapes 'tape(s) in BUSY state, aborting' && exit 1
# check that no migrations are pending/ongoing for this tapepool
printmigrationstatus | grep $1 && echo 'Migrations still ongoing, aborting' && exit 1
# backup relevant metadata
mkdir -p ~/ctaexport
cd ~/ctaexport
[[ ! -x stager_listprivileges_output ]] && \
stager_listprivileges > stager_listprivileges_output && \
# pause the stager altogether (this destroys the B&W lists!)
stager_removeprivilege -U:
# check that all tapes are good for export, that is no BUSY tape; RDONLY is OK
busytapes=`vmgrlisttape -P $1 | grep -c BUSY`
[[ $busytapes -gt 0 ]] && echo 'Found' $busytapes 'tape(s) in BUSY state, aborting' && exit 1
# on the stager, make the tapepool unusable (the tapepool metadata can stay)
[[ ! -x migrationroute_$1 ]] && printmigrationroute | grep -w $1 > migrationroutes_$1
printmigrationroute | grep -w $1 | awk '{print $1}' | xargs -i deletemigrationroute {}
# backup relevant metadata
mkdir -p ~/ctaexport
cd ~/ctaexport
[[ ! -x stager_listprivileges_output ]] && \
stager_listprivileges > stager_listprivileges_output && \
# pause the stager altogether (this destroys the B&W lists!)
stager_removeprivilege -U:
# on the stager, make the tapepool unusable (the tapepool metadata can stay)
[[ ! -x migrationroute_$1 ]] && printmigrationroute | grep -w $1 > migrationroutes_$1
printmigrationroute | grep -w $1 | awk '{print $1}' | xargs -i deletemigrationroute {}
fi
# execute the DB extraction from the CTA DB
python tapepool_castor_to_cta.py -t $1 -v $2 -i $3 $4
python tapepool_castor_to_cta.py -t $1 -v $2 -i $3 $4 || exit 1
# execute the EOS metadata import
eos-import-dirs || exit 1
eos-import-files || exit 1
# terminate the import
python complete_tapepool_import.py $1 || exit 1
# empty the CASTOR disk cache (not necessary)
#for h in `printdiskserver | grep cern.ch | awk '{print $1}'`; do
......@@ -66,3 +78,4 @@ python tapepool_castor_to_cta.py -t $1 -v $2 -i $3 $4
# to resume the stager once everything is completed:
#stager_addprivilege -U:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment