AFS
view release on metacpan or search on metacpan
changed (see POD doku AFS::VLDB)
User-visible changes:
* improved several test drivers;
* updated example scripts for the modules AFS:VOS, AFS::VLDB,
AFS::Cell, AFS::CM, AFS::FS, AFS::BOS, and AFS::KTC_EKEY
* improved POD documentation for AFS::FS and AFS
* POD documentation gets installed automatically
* fixed method AFS::VLDB->listaddrs: lists now all servers
* fixed method AFS::VOS->listvol: returns correct name and volid when
volume is busy
* fixed method AFS::VOS->listvldb: returns proper "release" strings
* improved error messages when OpenAFS configuration files are missing
* compiles now with OpenAFS system libraries newer than 1.4.4
* improved Makefile.PL script to avoid interactive queries
Developer-visible changes:
* modified initialization of the "cell" variable for "fs" functions
* cleaned up source code and error handling for "vos" functions, "vldb"
functions, and "bos" functions
examples/v2/vos/listvol view on Meta::CPAN
print "Total number of volumes on server $server partition /vicep$part: $totvol \n";
}
sub print_ext {
my $partlist = shift;
foreach my $part (sort keys %$partlist) {
print "Partition $part:\n";
foreach my $vol (sort keys %{$partlist->{$part}}) {
if ($vol !~ /total/) {
if ($vol =~ /volume_busy/) {
print "\t**** Volume $partlist->{$part}->{$vol}->{volid} is busy **** \n";
}
elsif ($vol =~ /volume_notok/) {
print "\t**** Could not attach volume $partlist->{$part}->{$vol}->{volid} **** \n";
}
else {
print "\t$vol:\n";
}
foreach my $key (sort keys %{$partlist->{$part}->{$vol}}) {
if ($key =~ /(Reads|Writes|>1wk|1day-1wk|1hr-1day|10min-1hr|1-10min|0-60sec)/) {
print "\t\tKey $key:\n";
examples/v2/vos/listvol view on Meta::CPAN
}
}
sub print_long {
my $partlist = shift;
foreach my $part (sort keys %$partlist) {
print "$part:\n";
foreach my $vol (sort keys %{$partlist->{$part}}) {
if ($vol !~ /total/) {
if ($vol =~ /volume_busy/) {
print "\t**** Volume $partlist->{$part}->{$vol}->{'volid'} is busy **** \n";
}
elsif ($vol =~ /volume_notok/) {
print "\t**** Could not attach volume $partlist->{$part}->{$vol}->{'volid'} **** \n";
}
else {
print "\t$vol:\n";
}
foreach my $key (sort keys %{$partlist->{$part}->{$vol}}) {
if ($key =~ /(updateDate|creationDate)/) {
printf "\t\t%-12s: %s\n", $key, ctime($partlist->{$part}->{$vol}->{$key});
examples/v2/vos/listvol view on Meta::CPAN
sub print_default {
my $partlist = shift;
my $totvol = 0;
foreach my $part (sort keys %$partlist) {
print "List of volumes on server $server Partition $part: \n";
foreach my $vol (sort keys %{$partlist->{$part}}) {
if ($vol =~ /totalOK/) { next; }
elsif ($vol =~ /totalBusy/) { next; }
elsif ($vol =~ /totalNotOK/) { next; }
elsif ($vol =~ /volume_busy/) {
print "**** Volume $partlist->{$part}->{$vol}->{'volid'} is busy **** \n";
next;
}
elsif ($vol =~ /volume_notok/) {
print "**** Could not attach volume $partlist->{$part}->{$vol}->{'volid'} **** \n";
next;
}
else { $totvol++; printf "%-30s ", $vol; }
print " $partlist->{$part}->{$vol}->{'volid'}";
print " $partlist->{$part}->{$vol}->{'type'}";
printf " %10s K", $partlist->{$part}->{$vol}->{'size'};
print " $partlist->{$part}->{$vol}->{'inUse'}";
print "\n";
# foreach (keys %{$partlist->{$part}->{$vol}}) {
# print "\t\tKey: $_, Value: $partlist->{$part}->{$vol}->{$_}\n";
# }
}
print "\nTotal volumes onLine $partlist->{$part}->{' totalOK'} ;";
print "\tTotal volumes offLine $partlist->{$part}->{' totalNotOK'} ;";
print "\tTotal busy $partlist->{$part}->{' totalBusy'} \n";
}
}
sub print_debug {
my $partlist = shift;
foreach my $part (sort keys %$partlist) {
print "$part:\n";
foreach my $vol (sort keys %{$partlist->{$part}}) {
if ($vol =~ /total/) {
examples/v2/vos/offline view on Meta::CPAN
#!/usr/local/bin/perl
use v5.10.0;
use blib;
use strict;
use warnings;
use AFS::VOS;
use Scalar::Util qw(looks_like_number);
my ($vos, $server, $part, $volume, $busy, $sleep, $ok);
die "Usage: $0 server partition volume [bussy sleep]\n" if $#ARGV < 2;
$server = shift;
$part = shift;
$volume = shift;
$busy = shift // 0;
$sleep = shift // 0;
if (defined $busy and !looks_like_number($busy)) { warn "$0: BUSY is not an INTEGER ...\n"; }
else { $busy = int($busy); }
if (defined $sleep and !looks_like_number($sleep)) { warn "$0: SLEEP is not an INTEGER ...\n"; }
else { $sleep = int($sleep); }
$vos = AFS::VOS->new;
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n" and die;
$ok = $vos->offline($server, $part, $volume, $busy, $sleep);
if ($AFS::CODE) { print "AFS::CODE = $AFS::CODE\n"; }
else { printf "Task %s \n", $ok ? "done" : "failed"; }
pod/v2/afsperlvos.pod view on Meta::CPAN
Moves the indicated read/write volume from its current site FSERVER,
FPARTITION to the destination site TSERVER, TPARTITION. VOLUME
specifies either the complete name or volume ID number of the volume.
It returns the volume id number of the moved volume. It calls the AFS
system library function I<UV_MoveVolume>.
=item B<$ok = $vos-E<gt>offline(SERVER, PARTITION, VOLUME [, BUSY, SLEEP]);>
Takes the specified volume offline. VOLUME specifies either the
complete name or volume ID number of the volume. If you set BUSY
(default 0) to 1 the volume will be marked as I<busy> for the
specified SLEEP seconds. It calls the AFS system library function
I<UV_SetVolume>.
=item B<$ok = $vos-E<gt>online(SERVER, PARTITION, VOLUME);>
Brings the specified volume online. VOLUME specifies either the
complete name or volume ID number of the volume. It calls the AFS
system library function I<UV_SetVolume>.
=item B<$partinfo = $vos-E<gt>partinfo( SERVER [, PARTITION]);>
case VOLSERVOLMOVED:
sprintf(buffer, "VOLSER: volume has moved\n");
break;
case VOLSERBADOP:
sprintf(buffer, "VOLSER: illegal operation\n");
break;
case VOLSERBADRELEASE:
sprintf(buffer, "VOLSER: release could not be completed\n");
break;
case VOLSERVOLBUSY:
sprintf(buffer, "VOLSER: volume is busy\n");
break;
case VOLSERNO_MEMORY:
sprintf(buffer, "VOLSER: volume server is out of memory\n");
break;
case VOLSERNOVOL:
sprintf(buffer,
"VOLSER: no such volume - location specified incorrectly or volume does not exist\n");
break;
case VOLSERMULTIRWVOL:
sprintf(buffer,
struct tqElem {
afs_int32 volid;
struct tqElem *next;
};
struct tqHead {
afs_int32 count;
struct tqElem *next;
};
static struct tqHead busyHead, notokHead;
static void qInit(ahead)
struct tqHead *ahead;
{
Zero(ahead, 1, struct tqHead);
return;
}
static void qPut(ahead, volid)
struct tqHead *ahead;
if (!pntr->updateDate)
safe_hv_store(vol, "updateDate", 10, newSVpv("Never", 5), 0);
else
safe_hv_store(vol, "updateDate", 10, newSViv(pntr->updateDate), 0);
safe_hv_store(vol, "dayUse", 6, newSViv(pntr->dayUse), 0);
}
else if (pntr->status == VBUSY) {
*totalBusy += 1;
qPut(&busyHead, pntr->volid);
}
else {
*totalNotOK += 1;
qPut(¬okHead, pntr->volid);
}
}
}
static void myXDisplayFormat(stats, a_xInfoP, a_servID, a_partID, a_totalOKP,
a_totalNotOKP, a_totalBusyP)
safe_hv_store(stat8, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stat8, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stat8, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stats, ">1wk", 4, newRV_inc((SV *) (stat8)), 0);
} /*Volume status OK */
else if (a_xInfoP->status == VBUSY) {
(*a_totalBusyP)++;
qPut(&busyHead, a_xInfoP->volid);
} /*Busy volume */
else {
(*a_totalNotOKP)++;
qPut(¬okHead, a_xInfoP->volid);
} /*Screwed volume */
} /*myXDisplayFormat */
static void VolumeStats(volinfo, pntr, entry, server, part, voltype)
HV *volinfo;
volintInfo *pntr;
afs_int32 server, part;
volintInfo *pntr;
afs_int32 count, fast;
{
int totalOK, totalNotOK, totalBusy, i;
char buff[32];
totalOK = 0;
totalNotOK = 0;
totalBusy = 0;
qInit(&busyHead);
qInit(¬okHead);
for (i = 0; i < count; i++) {
HV *vol = (HV *) sv_2mortal((SV *) newHV());
myDisplayFormat(vol, pntr, server, part, &totalOK, &totalNotOK, &totalBusy, fast);
if (pntr->status == VOK) {
safe_hv_store(partition, pntr->name, strlen(pntr->name), newRV_inc((SV *) (vol)), 0);
}
else if (pntr->status == VBUSY) {
sprintf(buff, "volume_busy_%d", i);
safe_hv_store(partition, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
/* fprintf(STDERR, "DEBUG-1: %s %d\n", buff, strlen(buff)); */
}
else {
sprintf(buff, "volume_notok_%d", i);
safe_hv_store(partition, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
/* fprintf(STDERR, "DEBUG-2: %s %d\n", buff, strlen(buff)); */
}
pntr++;
}
HV *part;
afs_int32 a_servID;
afs_int32 a_partID;
volintXInfo *a_xInfoP;
afs_int32 a_count;
{ /*XDisplayVolumes */
int totalOK; /*Total OK volumes */
int totalNotOK; /*Total screwed volumes */
int totalBusy; /*Total busy volumes */
int i; /*Loop variable */
char buff[32];
/* Initialize counters and (global!!) queues.*/
totalOK = 0;
totalNotOK = 0;
totalBusy = 0;
qInit(&busyHead);
qInit(¬okHead);
/* Display each volume in the list.*/
for (i = 0; i < a_count; i++) {
HV *vol = (HV *) sv_2mortal((SV *) newHV());
myXDisplayFormat(vol,
a_xInfoP,
a_servID,
a_partID, &totalOK, &totalNotOK, &totalBusy);
if (a_xInfoP->status == VOK) {
safe_hv_store(part, a_xInfoP->name, strlen(a_xInfoP->name), newRV_inc((SV *) (vol)), 0);
}
else if (a_xInfoP->status == VBUSY) {
sprintf(buff, "volume_busy_%d", i);
safe_hv_store(part, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
/* fprintf(STDERR, "DEBUG-1: %s %d\n", buff, strlen(buff)); */
}
else {
sprintf(buff, "volume_notok_%d", i);
safe_hv_store(part, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
/* fprintf(STDERR, "DEBUG-2: %s %d\n", buff, strlen(buff)); */
}
a_xInfoP++;
}
/* If any volumes were found to be busy or screwed, display them.*/
safe_hv_store(part, " totalOK", 8, newSViv(totalOK), 0);
safe_hv_store(part, " totalBusy", 10, newSViv(totalBusy), 0);
safe_hv_store(part, " totalNotOK", 11, newSViv(totalNotOK), 0);
} /*XDisplayVolumes */
/* end of helper functions for VOS class */
/* helper functions for VLDB class: */
void myEnumerateEntry(stats, entry)
SETCODE(0);
RETVAL = volid;
done:
;
}
OUTPUT:
RETVAL
int32
vos_offline(cstruct, servername, parti, id, busy=Nullsv, sleep=Nullsv)
AFS::VOS cstruct
char* servername
char* parti
char *id
SV * busy
SV * sleep
PREINIT:
int32 server, partition, volid;
int32 code, err=0;
int32 ibusy=0, isleep=0, transflag, transdone;
CODE:
{
if (!busy)
busy = newSViv(0);
if (!sleep)
sleep = newSViv(0);
if ((!SvIOKp(busy))) {
char buffer[256];
sprintf(buffer, "Flag \"busy\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
ibusy = SvIV(busy); /* -busy */
if ((!SvIOKp(sleep))) {
char buffer[256];
sprintf(buffer, "Flag \"sleep\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
isleep = SvIV(sleep); /* -sleep */
RETVAL = 0;
if (!volid) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "Unknown volume ID or name '%s'\n", servername);
VSETCODE(err ? err : -1, buffer);
goto done;
}
transflag = (ibusy ? ITBusy : ITOffline);
transdone = (isleep ? 0 /*online */ : VTOutOfService);
if (ibusy && !isleep) {
char buffer[256];
sprintf(buffer, "SLEEP argument must be used with BUSY flag\n");
VSETCODE(-1, buffer);
goto done;
}
code = UV_SetVolume(server, partition, volid, transflag, transdone, isleep);
if (code) {
char buffer[256];
sprintf(buffer, "Failed to set volume. Code = %d\n", code);
src/VOS/t/VOS.t view on Meta::CPAN
$vos->zap($server, $part, 'root.afs', 'a', 0);
like($AFS::CODE, qr/Flag "force" should be numeric/, 'vos->zap(server part volume no_force backup)');
$vos->zap($server, $part, 'no_volume', 0, 0);
like($AFS::CODE, qr/VLDB: no such entry/, 'vos->zap(server part no_volume 0 0)');
$vos->zap($server, 'no_part', 'root.afs', 0, 0);
like($AFS::CODE, qr/could not interpret partition name/, 'vos->zap(server no_part volume 0 0)');
$vos->zap('no_server', $part, 'root.afs', 0, 0);
like($AFS::CODE, qr/not found in host table/, 'vos->zap(no_server part volume 0 0)');
$vos->offline($server, $part, 'root.afs', 0, 'a');
like($AFS::CODE, qr/Flag "sleep" should be numeric/, 'vos->offline(server part volume busy no_sleep)');
$vos->offline($server, $part, 'root.afs', 'a', 0);
like($AFS::CODE, qr/Flag "busy" should be numeric/, 'vos->offline(server part volume no_busy sleep)');
$vos->offline($server, $part, 'no_volume', 0, 0);
like($AFS::CODE, qr/VLDB: no such entry/, 'vos->offline(server part no_volume 0 0)');
$vos->offline($server, 'no_part', 'root.afs', 0, 0);
like($AFS::CODE, qr/could not interpret partition name/, 'vos->offline(server no_part volume 0 0)');
$vos->offline('no_server', $part, 'root.afs', 0, 0);
like($AFS::CODE, qr/not found in host table/, 'vos->offline(no_server part volume 0 0)');
$vos->listpart('no_server');
like($AFS::CODE, qr/not found in host table/, 'vos->listpart(no_server)');
my @partlist = $vos->listpart($server);
( run in 0.285 second using v1.01-cache-2.11-cpan-87723dcf8b7 )