CASPUR Tape Dispatcher
Tape Dispatcher API
The Tape Dispatcher API is a set of perl functions that are used to interact with
the main server process. At the end of this section we also provide a pair of small
practical use cases. And here is a a complete list of API functions:
- $session = TDisp->connect(tdhost,port,service,devtype,device,tape);
This function is used to connect to the server process and reserve one device.
Arguments:
- tdhost
- obligatory, specifies the host name (or IP address) of machine that runs the tape dispatcher process
- port
- obligatory, specifies the port used by the tape dispatcher process
- service
- obligatory, denotes an existing or a new service nickname
- devtype
- optional, possible values are "DLT7000","LTO" etc. or "*"
- device
- optional, local device address, e.g. "/dev/rmt/1" or "*"
- tape
- optional, tape VID
- $ok = $session->connected(); - connection state
- $ok = $session->errmes(); - error message from last request
- ($device,@drivetypes) = $session->device(); - assigned local device, tape types supported
(e.g. "/dev/rmt/1" and an array containing a list of tape types supported by this device)
- ($tapeVID,$tapetype) = $session->tape(); - last tape mounted and its type;
- $session->disconnect(); - drop connection and free the device
- $ok = $session->mount(tapeVID); - request to mount a tape with a certain tapeVID
- $ok = $session->mountscratch(); - request to mount a scratch tape
- $ok = $session->unmount(); - unmount tape but keep the device
Use case 1: Mount a scratch tape and save something onto it:
#!/usr/bin/perl -w
require "TDisp.pm";
$tdhost="server.name";
$port=7800;
$session = TDisp->connect($tdhost,$port,'testnickname','LTO');
die $session->errmes() unless $session->connected();
($dev,@drivetytes) = $session->device();
print "Device $dev will be used\n";
die $session->errmes() unless $session->mountscratch();
$tapeVID = $session->tape();
print "Tape $tapeVID is mounted and will be used\n";
system("tar cvf $dev /home/pincopallino");
# Please note that this example does not end with disconnect() operation.
# In fact, disconnection will occur automatically and the tape resource
# will be freed upon the end of "system" call.
Use case 2: Mount a series of known tapes on different devices and get some data from each of them
#!/usr/bin/perl -w
require "TDisp.pm";
$tdhost="server.name";
$port=7800;
$session = TDisp->connect($tdhost,$port,'testnickname','LTO');
die $session->errmes() unless $session->connected();
($dev,@drivetytes) = $session->device();
print "Device $dev will be used\n";
die $session->errmes() unless $session->mount("VID001");
system("tar xf $dev /home/buratino/file1");
die $session->errmes() unless $session->mount("VID002");
system("tar xf $dev /home/pinocchio/file2");
die $session->errmes() unless $session->mount("VID025");
system("tar xf $dev /home/gatto/file3");
$session->disconnect();
$session = TDisp->connect($tdhost,$port,'testnickname','STK9840');
die $session->errmes() unless $session->connected();
($dev,@drivetytes) = $session->device();
print "Device $dev will be used\n";
die $session->errmes() unless $session->mount("VID599");
system("tar xf $dev /home/volpe/file4");
|