]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Eject media takes Location as Autochanger Name
authorEric Bollengier <eric@eb.homelinux.org>
Sat, 9 Sep 2006 10:39:39 +0000 (10:39 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Sat, 9 Sep 2006 10:39:39 +0000 (10:39 +0000)
ebl  Email is now sent when request to move media

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3444 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bweb/ReleaseNotes
gui/bweb/cgi/bweb.pl
gui/bweb/lib/Bweb.pm
gui/bweb/tpl/change_location.tpl
gui/bweb/tpl/location_add.tpl

index 51c66fa8edca097e0f6ef0345813176799bdecc7..8d070a70c2324c5c4ffa4a57792a64bdc4fc30c2 100644 (file)
@@ -1,4 +1,8 @@
-          Release Notes for bweb 1.39.20
+          Release Notes for bweb 1.39.23
+
+2006/09/08:
+ - Eject media takes Location as Autochanger Name
+ - Email is now sent when request to move media
 
 2006/09/06:
  - Can delete empty location
index 1d832dd048a1cc2225c84ac761623aad6f864e5b..bee4e76cc3d5c2f310f9274331d8c65b9c01e7fe 100755 (executable)
@@ -208,9 +208,12 @@ if ($action eq 'begin') {          # main display
     $bweb->help_extern_compute();
 
 } elsif ($action eq 'extern') {
-    print "TODO : Eject ", join(",", CGI::param('media'));
+    $bweb->eject_media();
     $bweb->move_media();
 
+} elsif ($action eq 'move_email') {
+    $bweb->move_email();
+
 } elsif ($action eq 'change_location') {
     $bweb->change_location();
 
index 8fd86361e9ae2531211dee8825d81f21ed616d1e..7891371ad4480baefd0df4cf5cc8576af9395f0b 100644 (file)
@@ -853,7 +853,7 @@ sub transfer
     
     if ($? == 0) {
        my $content = $self->get_slot($src);
-       print "content = $content<br/> $src => $dst<br/>";
+       print "$content ($src) => $dst<br/>";
        $self->{slot}->[$src] = 'empty';
        $self->set_slot($dst, $content);
        return 1;
@@ -2395,7 +2395,9 @@ sub save_location
 
     my $nb = $self->dbh_do($query);
 
-    print "$nb media updated";
+    print "$nb media updated, you may have to update your autochanger.";
+
+    $self->display_media();
 }
 
 sub change_location
@@ -2599,17 +2601,12 @@ WHERE JobStatus IN ('C','R','B','e','D','F','S','m','M','s','j','c','d','t','p')
 sub eject_media
 {
     my ($self) = @_;
-    my $arg = $self->get_form('jmedias', 'slots', 'ach');
+    my $arg = $self->get_form('jmedias');
 
     unless ($arg->{jmedias}) {
        return $self->error("Can't get media selection");
     }
 
-    my $a = $self->ach_get($arg->{ach});
-    unless ($a) {
-       return 0;
-    }
-    
     my $query = "
 SELECT Media.VolumeName  AS volumename,
        Storage.Name      AS storage,
@@ -2623,9 +2620,18 @@ WHERE Media.VolumeName IN ($arg->{jmedias})
 
     my $all = $self->dbh_selectall_hashref($query, 'volumename');
 
-    $a->status();
-
     foreach my $vol (values %$all) {
+       my $a = $self->ach_get($vol->{location});
+       unless ($a) {
+           $self->error("Can't find autochanger $vol->{location}");
+           next;
+       }
+
+       unless ($a->{have_status}) {
+           $a->status();
+           $a->{have_status} = 1;
+       }
+
        print "eject $vol->{volumename} from $vol->{storage} : ";
        if ($a->send_to_io($vol->{slot})) {
            print "ok</br>";
@@ -2635,6 +2641,23 @@ WHERE Media.VolumeName IN ($arg->{jmedias})
     }
 }
 
+sub move_email
+{
+    my ($self) = @_;
+
+    my ($to, $subject, $content) = (CGI::param('email'),
+                                   CGI::param('subject'),
+                                   CGI::param('content'));
+    $to =~ s/[^\w\d\.\@<>,]//;
+    $subject =~ s/[^\w\d\.\[\]]/ /;    
+
+    open(MAIL, "|mail -s '$subject' '$to'") ;
+    print MAIL $content;
+    close(MAIL);
+
+    print "Mail sent";
+}
+
 sub restore
 {
     my ($self) = @_;
index 273e414bf8bc4d987a29da3a86c27767f46d8338..d7f96519cefdc55c1fb119317e79e169be46e1aa 100644 (file)
@@ -24,14 +24,13 @@ Media :
  - <TMPL_VAR VolumeName>  (<TMPL_VAR location>)
 </TMPL_LOOP>
 
-When it's finish, could you update media location ? (you can use <a
-href="<TMPL_VAR url>">
-this link</a>).
+When it's finish, could you update media location ? 
+(you can use this link : <TMPL_VAR url>).
 
 Thanks
 </textarea>
 </td></tr></table>
-<input class='formulaire' type='submit' name='action' value='email_move'>
+<input class='formulaire' type='submit' name='action' value='move_email'>
 </form>
 <br>
 <a href="<TMPL_VAR url>"><img alt='update now' src='/bweb/update.png'>Update now</a>
index 50a868189e7033fe58ea90a43548e7c8c5a18748..8dd702600effdde3dbde0142497703c18fe3b45c 100644 (file)
@@ -22,4 +22,7 @@
     <input type="image" name='action' value='location_add' title="save"
       src='/bweb/save.png'>
    </form>
+
+Tips: It's a good idea to have a location per autochanger. 
+
 </div>