Hello Karsten,
Can you try the attached patch?
Jean-Louis
On 02/18/2013 06:57 AM, Karsten Fuhrmann wrote:
I still can't get tapespan to work, with my single tape drive setup.
I added interactivity and tapescan to amanda.conf. And updated amanda to
version 3.3.3
Now even when i load the right tape into the tapedrive, when i run amcheck, i
got the following message by email:
No acceptable volumes found
Insert volume labeled 'cf-daily-lto8' in chg-single:tape:/dev/nsa0
or write the name of a new changer in '/tmp/email_input'
or write 'abort' in the file to abort the scan.
if i write 'abort' into /tmp/email_input it aborts. but if i just touch
/tmp/email_input to tell amanda that the proper tape is inserted, i get the
above email again. What is going on here?
My shell session looks like this:
% sudo -u amanda amcheck cf-daily-lto
Amanda Tape Server Host Check
-----------------------------
WARNING: holding disk /mnt/amanda-holding: only 4 GB free, using nothing
WARNING: Not enough free space specified in amanda.conf
slot 0: volume 'cf-daily-lto8'
slot 0: volume 'cf-daily-lto8'
The second 'slot 0: volume 'cf-daily-lto8' comes after i touched the
/tmp/email_input file.
Here are the relevant parts of my amanda.conf:
define taperscan le_scan {
comment "bla"
plugin "lexical"
}
define interactivity email {
comment "interactivity email"
plugin "email"
property "mailto" "[email protected]"
property "resend_delay" "0"
property "check-file" "/tmp/email_input"
property "check-file-delay" "10"
}
interactivity "email"
taperscan "le_scan"
tpchanger "chg-single:tape:/dev/nsa0"
Please help me, this thing is killing me.
On 14.02.2013, at 18:13, Karsten Fuhrmann wrote:
Hi, now i added this:
define taperscan oldest {
comment "bla"
plugin "oldest"
}
taperscan "oldest"
into my amanda.conf. Now i got an email to change the tape. But then i am
stuck, amanda does not notice the newly inserted tape, and also does not react
on the file /tmp/email_input i created with touch.
It just waits forever. What am i missing?
On 14.02.2013, at 16:53, Jean-Louis Martineau wrote:
On 02/14/2013 10:00 AM, Karsten Fuhrmann wrote:
Hello,
i tried that but does not work. I dont get an email to change the tape, instead
amanda quits with:
FAILURE DUMP SUMMARY:
datastore /tank/koh/user/./k-o lev 0 partial taper: No acceptable volumes found
i added the following in my amanda.conf:
define interactivity email {
comment "interactivity email"
plugin "email"
property "mailto" "[email protected]"
property "resend_delay" "0"
property "check-file" "/tmp/email_input"
property "check-file-delay" "10"
}
interactivity "email"
The default taperscan do not use the interactivity module, you must use the
'oldest' or 'lexical' taperscan.
see: man amanda-taperscan
Jean-Louis
Greetings,
Karsten Fuhrmann
System Administrator
Rothkirch Cartoon-Film GmbH
Hasenheide. 54
D-10967 Berlin
phone +49 30 698084-109
fax +49 30 698084-29
mobile +49 176 49118462
skype: parceval3000
AIM: [email protected]
Jabber: [email protected]
Greetings,
Karsten Fuhrmann
diff --git a/perl/Amanda/Changer/single.pm b/perl/Amanda/Changer/single.pm
index 8417d02..2e51062 100644
--- a/perl/Amanda/Changer/single.pm
+++ b/perl/Amanda/Changer/single.pm
@@ -66,6 +66,11 @@ sub new {
config => $config,
device_name => $device_name,
reserved => 0,
+ state => undef,
+ device_status => undef,
+ f_type => undef,
+ label => undef,
+ 'scan-require-update' => 1,
};
bless ($self, $class);
@@ -82,9 +87,18 @@ sub load {
confess "no res_cb supplied" unless (exists $params{'res_cb'});
if ($self->{'reserved'}) {
- return $self->make_error("failed", $params{'res_cb'},
- reason => "volinuse",
- message => "'$self->{device_name}' is already reserved");
+ if (($self->{'label'} and $params{'label'} and
+ $self->{'label'} eq $params{'label'}) or
+ ($self->{'slot'} and $params{'slot'} and
+ $self->{'slot'} eq $params{'slot'})) {
+ return $self->make_error("failed", $params{'res_cb'},
+ reason => "volinuse",
+ message => "'$self->{device_name}' is already reserved");
+ } else {
+ return $self->make_error("failed", $params{'res_cb'},
+ reason => "driveinuse",
+ message => "'$self->{device_name}' is already reserved");
+ }
}
if (keys %{$params{'except_slots'}} > 0) {
@@ -94,6 +108,10 @@ sub load {
}
my $device = Amanda::Device->new($self->{'device_name'});
+ $self->{'state'} = Amanda::Changer::SLOT_FULL;
+ $self->{'device_status'} = $device->status();
+ $self->{'f_type'} = undef;
+ $self->{'label'} = undef;
if ($device->status() != $DEVICE_STATUS_SUCCESS) {
return $self->make_error("fatal", $params{'res_cb'},
message => "error opening device '$self->{device_name}': " . $device->error_or_status());
@@ -109,6 +127,14 @@ sub load {
my $res = Amanda::Changer::single::Reservation->new($self, $device);
$device->read_label();
+ $self->{'state'} = Amanda::Changer::SLOT_FULL;
+ $self->{'device_status'} = $device->status;
+ if ($device->status == $DEVICE_STATUS_SUCCESS) {
+ $self->{'label'} = $device->volume_label;
+ }
+ if (defined $device->volume_header) {
+ $self->{'f_type'} = $device->volume_header->{type};
+ }
$params{'res_cb'}->(undef, $res);
}
@@ -117,16 +143,25 @@ sub inventory {
my %params = @_;
my @inventory;
- my $s = { slot => 0,
- state => undef,
- device_status => undef,
- f_type => undef,
- label => undef };
+ my $s = { slot => 1,
+ state => $self->{'state'},
+ device_status => $self->{'device_status'},
+ f_type => $self->{'f_type'},
+ label => $self->{'label'} };
push @inventory, $s;
$params{'inventory_cb'}->(undef, \@inventory);
}
+sub update {
+ my $self = shift;
+
+ $self->{'state'} = undef;
+ $self->{'device_status'} = undef;
+ $self->{'f_type'} = undef;
+ $self->{'label'} = undef;
+}
+
sub info_key {
my $self = shift;
my ($key, %params) = @_;
diff --git a/perl/Amanda/Interactivity/email.pm b/perl/Amanda/Interactivity/email.pm
index 4da094d..e485ea2 100644
--- a/perl/Amanda/Interactivity/email.pm
+++ b/perl/Amanda/Interactivity/email.pm
@@ -53,6 +53,11 @@ sub new {
properties => $properties,
};
+ if (defined $self->{'properties'}->{'check-file'}) {
+ my $check_file = $self->{'properties'}->{'check-file'}->{'values'}->[0];
+ unlink($check_file);
+ }
+
return bless ($self, $class);
}
@@ -129,7 +134,6 @@ sub user_request {
print {$fh} "or write 'abort' in the file to abort the scan.\n";
}
close $fh;
- unlink($check_file);
if ($resend_delay) {
$self->{'send_email_src'} = Amanda::MainLoop::call_after($resend_delay, $send_email_cb);
@@ -141,17 +145,23 @@ sub user_request {
$self->{'check_file_src'} = undef;
if (-f $check_file) {
+ $self->{'send_email_src'}->remove();
+ $self->{'send_email_src'} = undef;
my $fh;
open ($fh, '<' , $check_file);
my $line = <$fh>;
- chomp $line;
- $self->abort();
- if ($line =~ /^abort$/i) {
- return $params{'request_cb'}->(
+ if ($line) {
+ chomp $line;
+ $self->abort();
+ if ($line =~ /^abort$/i) {
+ return $params{'request_cb'}->(
Amanda::Changer::Error->new('fatal',
message => "Aborted by user"));
+ } else {
+ return $params{'request_cb'}->(undef, $line);
+ }
} else {
- return $params{'request_cb'}->(undef, $line);
+ return $params{'request_cb'}->(undef, '');
}
}
$self->{'check_file_src'} = Amanda::MainLoop::call_after($check_file_delay, $check_file_cb);
diff --git a/perl/Amanda/Recovery/Scan.pm b/perl/Amanda/Recovery/Scan.pm
index a568281..54efd34 100644
--- a/perl/Amanda/Recovery/Scan.pm
+++ b/perl/Amanda/Recovery/Scan.pm
@@ -264,6 +264,10 @@ sub find_volume {
};
step get_inventory => sub {
+ if ($remove_undef_state and $self->{'chg'}->{'scan-require-update'}) {
+ Amanda::Debug::debug("update the changer");
+ $self->{'chg'}->update();
+ }
$self->{'chg'}->inventory(inventory_cb => $steps->{'parse_inventory'});
};
diff --git a/perl/Amanda/ScanInventory.pm b/perl/Amanda/ScanInventory.pm
index 6f5eec2..16b5168 100644
--- a/perl/Amanda/ScanInventory.pm
+++ b/perl/Amanda/ScanInventory.pm
@@ -126,6 +126,7 @@ sub _scan {
my $scan_running = 0;
my $interactivity_running = 0;
my $restart_scan = 0;
+ my $restart_scan_changer = undef;
my $abort_scan = undef;
my $last_err = undef; # keep the last meaningful error, the one reported
# to the user, most scan end with the notfound error,
@@ -160,10 +161,19 @@ sub _scan {
step restart_scan => sub {
$restart_scan = 0;
+
+ if ($restart_scan_changer) {
+ $self->{'chg'}->quit() if $self->{'chg'} != $self->{'initial_chg'};
+ $self->{'chg'} = $restart_scan_changer;
+ $restart_scan_changer = undef;
+ }
return $steps->{'get_inventory'}->();
};
step get_inventory => sub {
+ if ($remove_undef_state and $self->{'chg'}->{'scan-require-update'}) {
+ $self->{'chg'}->update();
+ }
$self->{'chg'}->inventory(inventory_cb => $steps->{'parse_inventory'});
};
@@ -405,9 +415,11 @@ sub _scan {
};
step after_poll => sub {
- $poll_src->remove() if defined $poll_src;
- $poll_src = undef;
- return $steps->{'restart_scan'}->();
+ if ($poll_src) {
+ $poll_src->remove();
+ $poll_src = undef;
+ return $steps->{'restart_scan'}->();
+ }
};
step scan_interactivity => sub {
@@ -459,8 +471,7 @@ sub _scan {
if ($new_chg->isa("Amanda::Changer::Error")) {
return $steps->{'scan_interactivity'}->("$new_chg");
}
- $self->{'chg'}->quit() if $self->{'chg'} != $self->{'initial_chg'};
- $self->{'chg'} = $new_chg;
+ $restart_scan_changer = $new_chg;
%seen = ();
} else {
$remove_undef_state = 1;