X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=perl%2FAmanda%2FTapelist.pm;h=6a746ba623e6df860027e927dcf3f6f0f716cda0;hb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;hp=40991d0f43dc647e427b5520269aa93382aa184e;hpb=96f35b20267e8b1a1c846d476f27fcd330e0b018;p=debian%2Famanda diff --git a/perl/Amanda/Tapelist.pm b/perl/Amanda/Tapelist.pm index 40991d0..6a746ba 100644 --- a/perl/Amanda/Tapelist.pm +++ b/perl/Amanda/Tapelist.pm @@ -49,6 +49,8 @@ sub this { package Amanda::Tapelist; +*get_last_reusable_tape_label = *Amanda::Tapelistc::get_last_reusable_tape_label; +*list_new_tapes = *Amanda::Tapelistc::list_new_tapes; *C_read_tapelist = *Amanda::Tapelistc::C_read_tapelist; *C_clear_tapelist = *Amanda::Tapelistc::C_clear_tapelist; @@ -60,7 +62,6 @@ package Amanda::Tapelist; @EXPORT_OK = (); %EXPORT_TAGS = (); -use Amanda::Debug qw(:logging); =head1 NAME @@ -70,121 +71,204 @@ Amanda::Tapelist - manipulate the Amanda tapelist use Amanda::Tapelist; - my $tl = Amanda::Tapelist::read_tapelist("/path/to/tapefile"); + # to get a read only copy of the tapelist file: + my $tl = Amanda::Tapelist->new("/path/to/tapefile"); + + # to read/update/write the tapelist file + # read and take lock + my $tl = Amanda::Tapelist->new("/path/to/tapefile", 1); + # modify the memory copy $tl->add_tapelabel($datestamp, $label); - $tl->add_tapelabel($datestamp2, $label2, $comment); - $tl->write("/path/to/tapefile"); + $tl->add_tapelabel($datestamp2, $label2, $comment, 1); + # write it and unlock + $tl->write(); + + # If you already have a read only copy and want to modify it + # take a read only copy + my $tl = Amanda::Tapelist->new("/path/to/tapefile"); + # reload and take lock + $tl->reload(1); + # modify the memory copy + tl->add_tapelabel($datestamp, $label); + $tl->add_tapelabel($datestamp2, $label2, $comment, 1); + # write it and unlock + $tl->write(); -=head1 API STATUS +=head1 OBJECT-ORIENTED INTERFACE -Stable +C returns a hash with no C set if the tapelist does +not exist. C is an empty array if the tapelist is empty. +Invalid entries are silently ignored. -=head1 OBJECT-ORIENTED INTERFACE +=head2 tapelist object + +A tapelist object is a hash with the following keys: + +=over -The package-level functions C and C -both return a new tapelist object. C returns C if the -tapelist does not exist. Invalid entries are silently ignored. +=item C -A tapelist object is a sequence of tapelist -elements (referred to as TLEs in this document). Each TLE is a hash with the -following keys: + The filename of the tapelist file. + +=item C + + The filename of the lock file. + +=item C + + A Amanda::Util::file_lock is the file is locked. + +=item C + +A sequence of tapelist elements (referred to as TLEs in this document), +sorted by datestamp from newest to oldest. + +=back + +=head2 tapelist element + +A tapelist elementas a hash with the following keys: =over -=item C -- the one-based position of the TLE in the tapelist +=item C + +the one-based position of the TLE in the tapelist + +=item C + +the datestamp on which this was written, or "0" for an unused tape + +=item C -=item C -- the datestamp on which this was written, or "0" for an -unused tape +true if this tape can be reused when it is no longer active -=item C -- true if this tape can be reused when it is no longer active +=item C