X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=perl%2FAmanda%2FChanger%2Frobot.pm;fp=perl%2FAmanda%2FChanger%2Frobot.pm;h=dae6af016477daa0bf36643be5388c065a4d4eb4;hb=949b8910a5e23c4285d0b1aedacfc82a14dc97a5;hp=d13e342fd76df26710591a383dd4feea89fc0670;hpb=c6f0a88c567f8536c498f554285aed1f8150da18;p=debian%2Famanda diff --git a/perl/Amanda/Changer/robot.pm b/perl/Amanda/Changer/robot.pm index d13e342..dae6af0 100644 --- a/perl/Amanda/Changer/robot.pm +++ b/perl/Amanda/Changer/robot.pm @@ -1,4 +1,4 @@ -# 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 @@ -471,7 +471,7 @@ sub load_unlocked { @check_order = (@{$self->{'driveorder'}}); } else { # the constructor should detect this circumstance - die "invalid drive_choice"; + confess "invalid drive_choice"; } my %checked; @@ -587,7 +587,7 @@ sub load_unlocked { 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"); @@ -644,7 +644,13 @@ sub load_unlocked { } $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'}, @@ -689,11 +695,17 @@ sub load_unlocked { $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; } @@ -845,6 +857,11 @@ sub _set_label_unlocked { $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; } @@ -1914,6 +1931,7 @@ sub status { } else { my %status; for my $line (split '\n', $output) { + debug("mtx: $line"); my ($slot, $ie, $slinfo); # drives (data transfer elements) @@ -2025,12 +2043,12 @@ sub _run_system_command { 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) {