#! @PERL@
# Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
+# 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
return;
} elsif ($err->volinuse and defined $err->{'slot'}) {
$last_slot = $err->{'slot'};
+ print STDERR sprintf("slot %3s: in use\n", $last_slot);
+ } elsif ($err->empty and defined $err->{'slot'}) {
+ $last_slot = $err->{'slot'};
+ print STDERR sprintf("slot %3s: empty\n", $last_slot);
} else {
return failure($err, $finished_cb) if $err;
}
} else {
print STDERR sprintf("slot %3s: %s\n", $last_slot, $dev->error_or_status());
}
- } else {
- print STDERR sprintf("slot %3s: in use\n", $last_slot);
}
if ($res) {
for my $sl (@$inv) {
my $line = "slot $sl->{slot}:";
+ my $tle;
if (!defined($sl->{device_status}) && !defined($sl->{label})) {
$line .= " unknown state";
} elsif ($sl->{'state'} == Amanda::Changer::SLOT_EMPTY) {
} else {
if (defined $sl->{label}) {
$line .= " label $sl->{label}";
- my $tle = $tl->lookup_tapelabel($sl->{label});
- if ($tle->{'meta'}) {
- $line .= " ($tle->{'meta'})";
+ $tle = $tl->lookup_tapelabel($sl->{label});
+ if (defined $tle) {
+ if ($tle->{'meta'}) {
+ $line .= " ($tle->{'meta'})";
+ }
}
} elsif ($sl->{'device_status'} == $DEVICE_STATUS_VOLUME_UNLABELED) {
$line .= " blank";
if ($sl->{'current'}) {
$line .= " (current)";
}
+ if (defined $tle) {
+ if (defined $sl->{'barcode'} and
+ defined $tle->{'barcode'} and
+ $sl->{'barcode'} ne $tle->{'barcode'}) {
+ $line .= " MISTMATCH barcode in tapelist: $tle->{'barcode'}";
+ }
+ }
# note that inventory goes to stdout
print "$line\n";
sub failure {
my ($msg, $finished_cb) = @_;
- print STDERR "ERROR: $msg\n";
+ if ($msg->isa("Amanda::Changer::Error") and defined $msg->{'slot'}) {
+ print STDERR "ERROR: Slot: $msg->{'slot'}: $msg\n";
+ } else {
+ print STDERR "ERROR: $msg\n";
+ }
$exit_status = 1;
$finished_cb->();
}