Hi all,
After the transition to the new farm at NIKHEF, the old storage
element front-end host is going to be decommissioned soon. The data
will just continue to be there, since it's hosted by a set of backend
servers, just the hostname will change.
For some (odd) reason, I can do that myself for all catalogues :-) No
security whatsoever, so sometime today I propose we here run through
the catalogues and do the updates.
The script we will use for that is included below for everyones scrutiny
(it's in turn generated by a perl script that runs though all catalogues
for all VOs looking for specific mappingsByPfn).
Any problems to be expetced with this operation?
Cheers,
DavidG.
--- example of perl-script output, to be run by /bin/sh ---
update_lrc() {
# syntax: update_lrc $vo $guido $oldsfn $newsfn
lcg-rf --vo $1 -g $2 $4
if [ $? -ne 0 ]; then
echo "Failed to register new PFN for $2: error $?" >&2
exit 1
fi
match=`lcg-lr --vo $1 $2 | grep -c "$4"`
if [ $match -eq 0 ]; then
echo "Catalogue failure for $2: lost entry after insert" >&2
exit 1
else
lcg-uf --vo $1 $2 $3
if [ $? -ne 0 ]; then
echo "Failed to UNregister old PFN for $2: error $?" >&2
exit 1
fi
fi;
}
update_lrc esr guid:2aaf6635-0ca7-11d9-8789-8254ae2c0f36 \
sfn://tbn17.nikhef.nl/datastore2/esr/generated/2004-09-22/file20209c24-0ca7-11d9-8789-8254ae2c0f36
\
sfn://tbn15.nikhef.nl/datastore2/esr/generated/2004-09-22/file20209c24-0ca7-11d9-8789-8254ae2c0f36
update_lrc esr ...
...
The generator script for this script is attached :-)
--
David Groep
** National Institute for Nuclear and High Energy Physics, PDP/Grid group **
** Room: H1.56 Phone: +31 20 5922179, PObox 41882, NL-1009DB Amsterdam NL **
#! /usr/bin/perl
#
# @(#)$Id$
#
# lcg-lrc-fixse: a quick hack to update the PFNs in all LRC catalogues
# whenever a hostname changes
#
use Net::LDAP qw(:all);
# change these setting to match your local BDII
$bdii="boswachter.nikhef.nl:2170";
@vos = qw( atlas alice lhcb cms pvier astron astrop esr
eo biome magic asci dzero );
# what has to be changed? From $oldpath to $newpath!
$oldpath="sfn://tbn17.nikhef.nl";
$newpath="sfn://tbn15.nikhef.nl";
##############################################################################
# retrieve all RLS endpoints, assuming that the VO name for the ACL
# is the same as the VO name for the RLS instances
#
$serverbase="Mds-Vo-name=local,o=Grid";
my $hldap = Net::LDAP->new($bdii);
my $result = $hldap->search(
base=>"$serverbase",
scope=>"sub",
filter=>'(GlueServiceType=edg-local-replica-catalog)',
attrs=>["GlueServiceAccessPointURL","GlueServiceAccessControlRule"]
);
my @entries = $result->entries;
@entries or die "Did not find LRC endpoints in $serverbase on $ldapserver\n";
# this hash needed to find duplicate guids in broken catalogue setups
%guid=();
##############################################################################
# output the shell function first, to be used lated by the
# generated update_lrc commands
#
print <<EOF;
update_lrc() {
# syntax: update_lrc \$vo \$guido \$oldsfn \$newsfn
lcg-rf --vo \$1 -g \$2 \$4
if [ \$? -ne 0 ]; then
echo "Failed to register new PFN for \$2: error \$?" >&2
exit 1
fi
match=`lcg-lr --vo \$1 \$2 | grep -c "\$4"`
if [ \$match -eq 0 ]; then
echo "Catalogue failure for \$2: lost entry after insert" >&2
exit 1
else
lcg-uf --vo \$1 \$2 \$3
if [ \$? -ne 0 ]; then
echo "Failed to UNregister old PFN for \$2: error \$?" >&2
exit 1
fi
fi;
}
EOF
##############################################################################
# iterate over all VOs found there
#
foreach $entr ( @entries ) {
my $dn = $entr->dn();
my $ep = $entr->get_value("GlueServiceAccessPointURL");
my $vo = $entr->get_value("GlueServiceAccessControlRule");
$maxres = 10;
my $dothis=0;
my $v;
foreach $v ( @vos ) { ($vo =~ /^$v$/) and $dothis++; };
$dothis or next;
print "# DN: $dn\n";
print "# endpoint = $ep\n";
print "# vo = $vo\n";
#####################################################################
# find maximum number of entries to query
#
$cmd="edg-lrc metadata --endpoint $ep";
open LRC,"$cmd 2>&1|" or die "Cannot execute LRC command for VO $vo: $!\n";
while (<LRC>) {
chomp($_); split;
/Total number of GUIDs/ and $maxres=($maxres<$_[$#_]?$_[$#_]:$maxres+1);
/Total number of PFNs/ and $maxres=($maxres<$_[$#_]?$_[$#_]:$maxres+1);
}
close LRC;
print "# VO $vo: maximum PFNs/GUIDs is $maxres\n";
#####################################################################
# for every VO, find the list of guids that have an SFN entry on
# the $oldpath and generate the lcg-rf/uf commands to move that
#
$cmd="edg-lrc mappingsByPfn --endpoint $ep --length $maxres ";
$cmd.="$oldpath\*";
open LRC,"$cmd 2>&1|" or die "Cannot execute LRC command for VO $vo: $!\n";
while (<LRC>) {
chomp($_);
/^There might be more mappings/ and
warn "# VO $vo: too many mappings\n";
my ($guid,$sfn) = split(/,\s+/,$_,2);
# remove duplicate guids in case of broken RLS setup
if ($guid{$guid}) {
print "# Duplicate GUID $vo (from ".$guid{$guid}."): $guid\n";
next;
}
$guid{$guid}=$vo;
(my $nsfn=$sfn) =~ s $oldpath $newpath m;
print "update_lrc $vo $guid $sfn $nsfn\n";
}
close LRC;
}
|