6 Bweb - A Bacula web interface
7 Bacula® - The Network Backup Solution
9 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
11 The main author of Bweb is Eric Bollengier.
12 The main author of Bacula is Kern Sibbald, with contributions from
13 many others, a complete list can be found in the file AUTHORS.
15 This program is Free Software; you can redistribute it and/or
16 modify it under the terms of version two of the GNU General Public
17 License as published by the Free Software Foundation plus additions
18 that are listed in the file LICENSE.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 Bacula® is a registered trademark of John Walker.
31 The licensor of Bacula is the Free Software Foundation Europe
32 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
33 Switzerland, email:ftf@fsfeurope.org.
45 my $client_re = qr/^([\w\d\.-]+)$/;
47 my $action = CGI::param('action') || 'begin';
49 if ($action eq 'restore') {
50 print CGI::header('text/brestore'); # specialy to run brestore.pl
53 print CGI::header('text/html');
57 my $conf = new Bweb::Config(config_file => $Bweb::config_file);
60 my $bweb = new Bweb(info => $conf);
62 # just send data with text/brestore content
63 if ($action eq 'restore') {
68 my $arg = $bweb->get_form('jobid', 'limit', 'offset', 'age');
70 $bweb->display_begin();
72 # if no configuration, we send edit_conf
73 if ($action ne 'apply_conf' and !$bweb->{info}->{dbi}) {
74 $action = 'edit_conf';
77 if ($action eq 'begin') { # main display
78 print "<div style='left=0;'><table border='0'><tr><td valign='top' width='100%'>\n";
79 $bweb->display_general(age => $arg->{age});
80 $bweb->display_running_jobs(0);
81 print "</td><td valign='top'>";
82 $bweb->display({}, "stats.tpl");
83 print "</td></tr></table></div>";
84 $bweb->display_job(limit => 10);
86 } elsif ($action eq 'view_conf') {
89 } elsif ($action eq 'edit_conf') {
92 } elsif ($action eq 'apply_conf') {
95 } elsif ($action eq 'client') {
96 $bweb->display_clients();
98 } elsif ($action eq 'pool') {
99 $bweb->display_pool();
101 } elsif ($action eq 'location_edit') {
102 $bweb->location_edit();
104 } elsif ($action eq 'location_save') {
105 $bweb->location_save();
107 } elsif ($action eq 'location_add') {
108 $bweb->location_add();
110 } elsif ($action eq 'location_del') {
111 $bweb->location_del();
113 } elsif ($action eq 'media') {
114 print "<div><table border='0'><tr><td valign='top'>\n";
115 my $fields = $bweb->get_form(qw/db_locations db_pools expired
116 qlocations qpools volstatus qre_media
117 limit qmediatypes db_mediatypes/);
118 $bweb->display($fields, "display_form_media.tpl");
120 print "</td><td valign='top'>";
121 $bweb->display_media(offset => $arg->{offset},
122 limit => $arg->{limit});
123 print "</td></tr></table></div>";
125 } elsif ($action eq 'allmedia') {
126 $bweb->display_allmedia();
128 } elsif ($action eq 'eject') {
129 my $arg = $bweb->get_form("ach");
130 my $a = $bweb->ach_get($arg->{ach});
134 foreach my $slot (CGI::param('slot')) {
135 print $a->{error} unless $a->send_to_io($slot);
138 foreach my $media (CGI::param('media')) {
139 my $slot = $a->get_media_slot($media);
140 print $a->{error} unless $a->send_to_io($slot);
143 $a->display_content();
146 } elsif ($action eq 'eject_media') {
147 $bweb->eject_media();
149 } elsif ($action eq 'clear_io') {
150 my $arg = $bweb->get_form('ach');
152 my $a = $bweb->ach_get($arg->{ach});
156 $a->display_content();
159 } elsif ($action eq 'ach_edit') {
162 } elsif ($action eq 'ach_del') {
165 } elsif ($action eq 'ach_view') {
166 # TODO : get autochanger name and create it
168 my $arg = $bweb->get_form('ach');
170 my $a = $bweb->ach_get($arg->{ach});
173 $a->display_content();
176 } elsif ($action eq 'ach_add') {
179 } elsif ($action eq 'ach_load') {
180 my $arg = $bweb->get_form('ach', 'drive', 'slot');
182 my $a = $bweb->ach_get($arg->{ach});
184 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
186 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
187 # TODO : use template here
189 $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
192 $bweb->error("Can't get drive, slot or ach");
195 } elsif ($action eq 'ach_unload') {
196 my $arg = $bweb->get_form('drive', 'slot', 'ach');
198 my $a = $bweb->ach_get($arg->{ach});
200 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
202 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
203 # TODO : use template here
205 $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
209 $bweb->error("Can't get drive, slot or ach");
211 } elsif ($action eq 'intern_media') {
212 $bweb->help_intern();
214 } elsif ($action eq 'compute_intern_media') {
215 $bweb->help_intern_compute();
217 } elsif ($action eq 'extern_media') {
218 $bweb->help_extern();
220 } elsif ($action eq 'compute_extern_media') {
221 $bweb->help_extern_compute();
223 } elsif ($action eq 'extern') {
224 print "<div style='float: left;'>";
225 my @achs = $bweb->eject_media();
226 for my $ach (@achs) {
227 CGI::param('ach', $ach);
228 $bweb->update_slots();
230 print "</div><div style='float: left;margin-left: 20px;'>";
231 $bweb->move_media('no'); # enabled = no
234 } elsif ($action eq 'move_email') {
237 } elsif ($action eq 'change_location') {
238 $bweb->location_change();
240 } elsif ($action eq 'location') {
241 $bweb->location_display();
243 } elsif ($action eq 'about') {
244 $bweb->display($bweb, 'about.tpl');
246 } elsif ($action eq 'intern') {
247 $bweb->move_media('yes'); # TODO : remove that
249 } elsif ($action eq 'move_media') {
250 my $a = $bweb->get_form('enabled');
251 $bweb->move_media($a->{enabled});
253 } elsif ($action eq 'save_location') {
254 $bweb->save_location();
256 } elsif ($action eq 'update_location') {
257 $bweb->update_location();
259 } elsif ($action eq 'update_media') {
260 $bweb->update_media();
262 } elsif ($action eq 'do_update_media') {
263 $bweb->do_update_media();
265 } elsif ($action eq 'update_slots') {
266 $bweb->update_slots();
268 } elsif ($action eq 'graph') {
269 $bweb->display_graph();
271 } elsif ($action eq 'next_job') {
272 $bweb->director_show_sched();
274 } elsif ($action eq 'enable_job') {
275 $bweb->enable_disable_job(1);
277 } elsif ($action eq 'disable_job') {
278 $bweb->enable_disable_job(0);
280 } elsif ($action eq 'groups') {
281 $bweb->display_groups();
283 } elsif ($action eq 'groups_edit') {
284 $bweb->groups_edit();
286 } elsif ($action eq 'groups_save') {
287 $bweb->groups_save();
289 } elsif ($action eq 'groups_add') {
292 } elsif ($action eq 'groups_del') {
295 } elsif ($action eq 'job') {
297 print "<div><table border='0'><tr><td valign='top'>\n";
298 my $fields = $bweb->get_form(qw/status level db_clients db_filesets
299 limit age offset qclients qfilesets
300 jobtype qpools db_pools
301 db_client_groups qclient_groups/); # drop this to hide
303 $bweb->display($fields, "display_form_job.tpl");
305 print "</td><td valign='top'>";
306 $bweb->display_job(age => $arg->{age}, # last 7 days
307 offset => $arg->{offset},
308 limit => $arg->{limit});
309 print "</td></tr></table></div>";
310 } elsif ($action eq 'job_group') {
312 print "<div><table border='0'><tr><td valign='top'>\n";
313 my $fields = $bweb->get_form(qw/limit level age
314 db_client_groups qclient_groups/); # drop this to hide
316 $fields->{hide_status} = 1;
317 $fields->{hide_type} = 1;
318 $fields->{action} = 'job_group';
320 $bweb->display($fields, "display_form_job.tpl");
322 print "</td><td valign='top'>";
323 $bweb->display_job_group(age => $arg->{age}, # last 7 days
324 limit => $arg->{limit});
325 print "</td></tr></table></div>";
326 } elsif ($action eq 'client_stats') {
328 foreach my $client (CGI::param('client')) {
329 if ($client =~ m/$client_re/) {
330 $bweb->display_client_stats(clientname => $1,
335 } elsif ($action eq 'group_stats') {
337 $bweb->display_group_stats(age => $arg->{age});
339 } elsif ($action eq 'running') {
340 $bweb->display_running_jobs(1);
342 } elsif ($action eq 'dsp_cur_job') {
343 $bweb->display_running_job();
345 } elsif ($action eq 'update_from_pool') {
346 my $elt = $bweb->get_form(qw/media pool/);
347 unless ($elt->{media} || $elt->{pool}) {
348 $bweb->error("Can't get media or pool param");
350 my $b = new Bconsole(pref => $conf) ;
353 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
354 title => "Update pool",
355 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
359 $bweb->update_media();
361 } elsif ($action eq 'client_status') {
363 foreach my $client (CGI::param('client')) {
364 if ($client =~ m/$client_re/) {
366 $b = new Bconsole(pref => $conf)
370 content => $b->send_cmd("st client=$client"),
371 title => "Client status",
376 $bweb->error("Can't get client selection");
380 } elsif ($action eq 'cancel_job') {
383 } elsif ($action eq 'media_zoom') {
384 $bweb->display_media_zoom();
386 } elsif ($action eq 'job_zoom') {
388 $bweb->display_job_zoom($arg->{jobid});
389 $bweb->get_job_log();
391 } elsif ($action eq 'job_log') {
392 $bweb->get_job_log();
394 } elsif ($action eq 'prune') {
397 } elsif ($action eq 'purge') {
400 } elsif ($action eq 'run_job') {
403 } elsif ($action eq 'run_job_mod') {
404 $bweb->run_job_mod();
406 } elsif ($action eq 'run_job_now') {
407 $bweb->run_job_now();
409 } elsif ($action eq 'label_barcodes') {
410 $bweb->label_barcodes();
412 } elsif ($action eq 'delete') {
415 } elsif ($action eq 'fileset_view') {
416 $bweb->fileset_view();
419 $bweb->error("Sorry, this action don't exist");
422 $bweb->display_end();
424 $bweb->dbh_disconnect();
430 o Affichage des job en cours, termines
431 o Affichage du detail d'un job (status client)
432 o Acces aux log d'une sauvegarde
436 o Affichage des medias (pool, cf bacweb)
437 o Affichage de la liste des cartouches
438 o Affichage d'un autochangeur
439 o Mise a jour des slots
441 o Affichage des medias qui ont besoin d'etre change
443 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
444 o Affichage des stats sur un type de job
445 o Affichage des infos de query.sql
447 - Affichage des du TapeAlert sur le site
448 - Recuperation des erreurs SCSI de /var/log/kern.log
453 o Configuration des autochanger a la main dans un hash dumper