-# Copyright (c) 2009,2010 Zmanda, Inc. All Rights Reserved.
+# Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License version 2.1 as
@check_order = (@{$self->{'driveorder'}});
} else {
# the constructor should detect this circumstance
- die "invalid drive_choice";
+ confess "invalid drive_choice";
}
my %checked;
step check_device => sub {
my $device_name = $self->{'drive2device'}->{$drive};
- die "drive $drive not found in drive2device" unless $device_name; # shouldn't happen
+ confess "drive $drive not found in drive2device" unless $device_name; # shouldn't happen
$self->_debug("polling '$device_name' to see if it's ready");
}
$state->{'slots'}->{$slot}->{'label'} = $label;
if ($state->{'slots'}->{$slot}->{'barcode'}) {
- $state->{'bc2lb'}->{$state->{'slots'}->{$slot}->{'barcode'}} = $label;
+ my $barcode = $state->{'slots'}->{$slot}->{'barcode'};
+ my $old_label = $state->{'bc2lb'}->{$barcode};
+ if ($label ne $old_label) {
+ $self->_debug("make_res: slot $slot");
+ $self->_debug("update label '$label' for barcode '$barcode', old label was '$old_label'");
+ }
+ $state->{'bc2lb'}->{$barcode} = $label;
}
return $self->make_error("failed", $params{'res_cb'},
$state->{'drives'}->{$drive}->{'state'} = Amanda::Changer::SLOT_FULL;
$state->{'drives'}->{$drive}->{'barcode'} = $state->{'slots'}->{$slot}->{'barcode'};
$state->{'slots'}->{$slot}->{'device_status'} = $device->status;
- if ($label and $state->{'slots'}->{$slot}->{'barcode'}) {
- $state->{'bc2lb'}->{$state->{'slots'}->{$slot}->{'barcode'}} = $label;
+ my $barcode = $state->{'slots'}->{$slot}->{'barcode'};
+ if ($label and $barcode) {
+ my $old_label = $state->{'bc2lb'}->{$barcode};
+ if (defined $old_label and $old_label ne $label) {
+ $self->_debug("load drive $drive slot $slot");
+ $self->_debug("update label '$label' for barcode '$barcode', old label was '$old_label'");
+ }
+ $state->{'bc2lb'}->{$barcode} = $label;
}
if ($params{'set_current'}) {
- $self->_debug("setting current slot to $slot");
+ $self->_debug("setting current slot to $slot");
$state->{'current_slot'} = $slot;
}
$state->{'slots'}->{$slot}->{'label'} = $label;
}
if (defined $barcode) {
+ if (defined $state->{'bc2lb'}->{$barcode} and
+ $state->{'bc2lb'}->{$barcode} ne $label) {
+ my $old_label = $state->{'bc2lb'}->{$barcode};
+ $self->_debug("update barcode '$barcode' to label '$label', old label was '$old_label'");
+ }
$state->{'bc2lb'}->{$barcode} = $label;
}
} else {
my %status;
for my $line (split '\n', $output) {
+ debug("mtx: $line");
my ($slot, $ie, $slinfo);
# drives (data transfer elements)
my ($readfd, $writefd) = POSIX::pipe();
if (!defined($writefd)) {
- die("Error creating pipe: $!");
+ confess("Error creating pipe: $!");
}
my $pid = fork();
if (!defined($pid) or $pid < 0) {
- die("Can't fork to run changer script: $!");
+ confess("Can't fork to run changer script: $!");
}
if (!$pid) {