1 # Copyright (c) 2005-2008 Zmanda, Inc. All Rights Reserved.
3 # This library is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU Lesser General Public License version 2.1 as
5 # published by the Free Software Foundation.
7 # This library is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 # License for more details.
12 # You should have received a copy of the GNU Lesser General Public License
13 # along with this library; if not, write to the Free Software Foundation,
14 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16 # Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 package Amanda::Changer::single;
24 @ISA = qw( Amanda::Changer );
26 use File::Glob qw( :glob );
28 use Amanda::Config qw( :getconf );
35 Amanda::Changer::single
39 This changer represents a single drive as a changer. It may eventually morph
40 into something similar to the old C<chg-manual>.
42 Whatever you load, you get the volume in the drive. The volume's either
43 reserved or not. All pretty straightforward.
47 Support notifying the user that a tape is required, and some kind of "OK,
48 loaded" feedback mechanism -- perhaps a utility script of some sort, or an
55 my ($cc, $tpchanger) = @_;
56 my ($device_name) = ($tpchanger =~ /chg-single:(.*)/);
59 device_name => $device_name,
63 bless ($self, $class);
71 die "no res_cb supplied" unless (exists $params{'res_cb'});
73 if ($self->{'reserved'}) {
74 Amanda::MainLoop::call_later($params{'res_cb'},
75 "'{$self->{device_name}}' is already reserved", undef);
77 Amanda::MainLoop::call_later($params{'res_cb'},
78 undef, Amanda::Changer::single::Reservation->new($self));
87 die "no info_cb supplied" unless (exists $params{'info_cb'});
88 die "no info supplied" unless (exists $params{'info'});
90 for my $inf (@{$params{'info'}}) {
91 if ($inf eq 'num_slots') {
94 warn "Ignoring request for info key '$inf'";
98 Amanda::MainLoop::call_later($params{'info_cb'}, undef, %results);
101 package Amanda::Changer::single::Reservation;
103 @ISA = qw( Amanda::Changer::Reservation );
107 my ($chg, $drive, $next_slot) = @_;
108 my $self = Amanda::Changer::Reservation::new($class);
110 $self->{'chg'} = $chg;
112 $self->{'device_name'} = $chg->{'device_name'};
113 $self->{'this_slot'} = '1';
114 $self->{'next_slot'} = '1';
115 $chg->{'reserved'} = 1;
124 $self->{'chg'}->{'reserved'} = 0;
126 if (exists $params{'finished_cb'}) {
127 Amanda::MainLoop::call_later($params{'finished_cb'}, undef);