exporttapepool.sh 2.57 KB
Newer Older
1
#!/bin/bash
2
#/******************************************************************************
3
# *                      exporttapepool.sh
4
5
# *
# * This file is part of the Castor/CTA project.
Giuseppe Lo Presti's avatar
Giuseppe Lo Presti committed
6
7
# * See http://cern.ch/castor and http://cern.ch/eoscta
# * Copyright (C) 2019  CERN
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# *
# * 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 2
# * 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, write to the Free Software
# * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# *
# * command line tool to prepare the export of a tapepool metadata
# * to CTA, the CASTOR successor
#
# * @author Castor Dev team, castor-dev@cern.ch
# *****************************************************************************/

# check arguments
28
if [[ $# != 3 && $# != 4 ]]; then
Giuseppe Lo Presti's avatar
Giuseppe Lo Presti committed
29
  echo Usage: $0 tapepool vo eosctaInstance [-d]
30
  echo        -d  enables dry-run mode
31
32
33
  exit 1
fi

34
# if NOT dry-run, execute all pre-checks and drop the migration routes
35
if [[ "$4" != "-d" ]]; then
36

37
38
39
  # 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
40

41
42
  # check that no migrations are pending/ongoing for this tapepool
  printmigrationstatus | grep $1 && echo 'Migrations still ongoing, aborting' && exit 1
43

44
45
46
  # 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
47

48
  # on the stager, make the tapepool unusable (the tapepool metadata can stay)
49
  [[ ! -x migrationroute_$1 ]] && printmigrationroute | grep -w $1 > ~/ctaexport/migrationroutes_$1
50
51
  printmigrationroute | grep -w $1 | awk '{print $1}' | xargs -i deletemigrationroute {}
fi
52

53
# from now on, exit for any error from any command
54
55
set -e

56
# execute the DB extraction from the CTA DB
57
tapepool_castor_to_cta.py -t $1 -v $2 -i $3 $4
58
59

# execute the EOS metadata import
60
eos-import-dirs --delta     # should there be any
61
eos-import-files
62

63
# terminate the export
64
complete_tapepool_export.py -t $1 $4
65