$bweb->location_add();
} elsif ($action eq 'location_del') {
- $bweb->del_location();
+ $bweb->location_del();
} elsif ($action eq 'media') {
$bweb->display_media();
my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
# TODO : use template here
print "<pre>\n";
- $b->send_cmd_with_drive("mount slot=$arg->{slot} storage=\"" . $a->get_drive_name($arg->{drive}) . '"',
- $arg->{drive});
+ $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
print "</pre>\n";
} else {
$bweb->error("Can't get drive, slot or ach");
my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
# TODO : use template here
print "<pre>\n";
- $b->send_cmd_with_drive("umount storage=\"" . $a->get_drive_name($arg->{drive}) . '"',
- $arg->{drive});
-
+ $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
print "</pre>\n";
} else {
my ($self, $how) = @_;
if ($self->{bconsole}) {
- $self->{bconsole}->log_stdout($how);
+ $self->{bconsole}->log_stdout($how);
}
-
+
$self->{log_stdout} = $how;
}
return $self->before();
}
-sub send_cmd_with_drive
-{
- my ($self, $cmd, $drive) = @_;
- $drive = $drive || '0';
-
- unless ($self->connect()) {
- return '';
- }
- $self->send("$cmd\n");
- $self->expect_it('-re', qr/:/); # wait for drive input
-
- $self->send("$drive\n");
- $self->expect_it('-re', '[0-9]');
- $self->{bconsole}->clear_accum();
- $self->expect_it('-re',qr/^[*]/);
- return $self->before();
-}
-
sub label_barcodes
{
my ($self, %arg) = @_;
}
$self->send("$cmd\n");
- $self->expect_it('-re', ':'); # wait for drive input
+ $self->expect_it('-re', '\[0\]\s*:');
$self->send("$arg{drive}\n");
$self->expect_it('-re', '[?].+\)\s*:');
my $res = $self->before();
sub update_slots
{
my ($self, $storage, $drive) = @_;
-
- return $self->send_cmd_with_drive("update slots storage=$storage", $drive);
+ $drive = $drive || 0;
+
+ return $self->send_cmd("update slots storage=$storage drive=$drive");
}
sub get_fileset
print "job : ", join(',', $c->list_job()), "\n";
print "storage : ", join(',', $c->list_storage()), "\n";
#print "prune : " . $c->prune_volume('000001'), "\n";
-#print "update : " . $c->send_cmd_with_drive('update slots storage=SDLT-1-2'), "\n";
+#print "update : " . $c->send_cmd('update slots storage=SDLT-1-2, drive=0'), "\n";
#print "label : ", join(',', $c->label_barcodes(storage => 'SDLT-1-2',
# slots => 6,
# drive => 0)), "\n";
$self->display_location();
}
+sub location_del
+{
+ my ($self) = @_ ;
+ my $arg = $self->get_form(qw/qlocation/) ;
+
+ unless ($arg->{qlocation}) {
+ return $self->error("Can't get location");
+ }
+
+ my $query = "
+SELECT count(Media.MediaId) AS nb
+ FROM Media INNER JOIN Location USING (LocationID)
+WHERE Location = $arg->{qlocation}
+";
+
+ my $res = $self->dbh_selectrow_hashref($query);
+
+ if ($res->{nb}) {
+ return $self->error("Sorry, the location must be empty");
+ }
+
+ $query = "
+DELETE FROM Location WHERE Location = $arg->{qlocation} LIMIT 1
+";
+
+ $self->dbh_do($query);
+
+ $self->display_location();
+}
+
+
sub location_add
{
my ($self) = @_ ;
) AS media_avg_size ON (Media.MediaType = media_avg_size.MediaType)
GROUP BY Media.MediaType, Media.PoolId
) AS subq
-INNER JOIN Pool ON (Pool.PoolId = subq.PoolId)
+LEFT JOIN Pool ON (Pool.PoolId = subq.PoolId)
GROUP BY subq.PoolId
";