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') {
87 $bweb->can_do('r_configure');
90 } elsif ($action eq 'edit_conf') {
91 $bweb->can_do('r_configure');
94 } elsif ($action eq 'apply_conf') {
95 $bweb->can_do('r_configure');
98 } elsif ($action eq 'user_del') {
101 } elsif ($action eq 'user_add') {
104 } elsif ($action eq 'user_edit') {
105 $bweb->display_user();
107 } elsif ($action eq 'user_save') {
110 } elsif ($action eq 'users') {
111 $bweb->display_users();
113 } elsif ($action eq 'client') {
114 $bweb->display_clients();
116 } elsif ($action eq 'pool') {
117 $bweb->display_pool();
119 } elsif ($action eq 'location_edit') {
120 $bweb->location_edit();
122 } elsif ($action eq 'location_save') {
123 $bweb->location_save();
125 } elsif ($action eq 'location_add') {
126 $bweb->location_add();
128 } elsif ($action eq 'location_del') {
129 $bweb->location_del();
131 } elsif ($action eq 'media') {
132 print "<div><table border='0'><tr><td valign='top'>\n";
133 my $fields = $bweb->get_form(qw/db_locations db_pools expired
134 qlocations qpools volstatus qre_media
135 limit qmediatypes db_mediatypes/);
136 $bweb->display($fields, "display_form_media.tpl");
138 print "</td><td valign='top'>";
139 $bweb->display_media(offset => $arg->{offset},
140 limit => $arg->{limit});
141 print "</td></tr></table></div>";
143 } elsif ($action eq 'allmedia') {
144 $bweb->display_allmedia();
146 } elsif ($action eq 'eject') {
147 $bweb->can_do('r_autochanger_mgnt');
149 my $arg = $bweb->get_form("ach");
150 my $a = $bweb->ach_get($arg->{ach});
154 foreach my $slot (CGI::param('slot')) {
155 print $a->{error} unless $a->send_to_io($slot);
158 foreach my $media (CGI::param('media')) {
159 my $slot = $a->get_media_slot($media);
160 print $a->{error} unless $a->send_to_io($slot);
163 $a->display_content();
166 } elsif ($action eq 'eject_media') {
167 $bweb->eject_media();
169 } elsif ($action eq 'clear_io') {
170 $bweb->can_do('r_autochanger_mgnt');
172 my $arg = $bweb->get_form('ach');
174 my $a = $bweb->ach_get($arg->{ach});
178 $a->display_content();
181 } elsif ($action eq 'ach_edit') {
184 } elsif ($action eq 'ach_del') {
187 } elsif ($action eq 'ach_view') {
188 $bweb->can_do('r_autochanger_mgnt');
190 # TODO : get autochanger name and create it
192 my $arg = $bweb->get_form('ach');
194 my $a = $bweb->ach_get($arg->{ach});
197 $a->display_content();
200 } elsif ($action eq 'ach_add') {
203 } elsif ($action eq 'ach_load') {
204 $bweb->can_do('r_autochanger_mgnt');
206 my $arg = $bweb->get_form('ach', 'drive', 'slot');
208 my $a = $bweb->ach_get($arg->{ach});
210 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
212 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
213 # TODO : use template here
215 $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
218 $bweb->error("Can't get drive, slot or ach");
221 } elsif ($action eq 'ach_unload') {
222 $bweb->can_do('r_autochanger_mgnt');
224 my $arg = $bweb->get_form('drive', 'slot', 'ach');
226 my $a = $bweb->ach_get($arg->{ach});
228 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
230 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
231 # TODO : use template here
233 $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
237 $bweb->error("Can't get drive, slot or ach");
239 } elsif ($action eq 'intern_media') {
240 $bweb->help_intern();
242 } elsif ($action eq 'compute_intern_media') {
243 $bweb->help_intern_compute();
245 } elsif ($action eq 'extern_media') {
246 $bweb->help_extern();
248 } elsif ($action eq 'compute_extern_media') {
249 $bweb->help_extern_compute();
251 } elsif ($action eq 'extern') {
252 $bweb->can_do('r_media_mgnt');
253 $bweb->can_do('r_autochanger_mgnt');
255 print "<div style='float: left;'>";
256 my @achs = $bweb->eject_media();
257 for my $ach (@achs) {
258 CGI::param('ach', $ach);
259 $bweb->update_slots();
261 print "</div><div style='float: left;margin-left: 20px;'>";
262 $bweb->move_media('no'); # enabled = no
265 } elsif ($action eq 'move_email') {
268 } elsif ($action eq 'change_location') {
269 $bweb->location_change();
271 } elsif ($action eq 'location') {
272 $bweb->location_display();
274 } elsif ($action eq 'about') {
275 $bweb->display($bweb, 'about.tpl');
277 } elsif ($action eq 'intern') {
278 $bweb->move_media('yes'); # TODO : remove that
280 } elsif ($action eq 'move_media') {
281 my $a = $bweb->get_form('enabled');
282 $bweb->move_media($a->{enabled});
284 } elsif ($action eq 'save_location') {
285 $bweb->save_location();
287 } elsif ($action eq 'update_location') {
288 $bweb->update_location();
290 } elsif ($action eq 'update_media') {
291 $bweb->update_media();
293 } elsif ($action eq 'do_update_media') {
294 $bweb->do_update_media();
296 } elsif ($action eq 'update_slots') {
297 $bweb->update_slots();
299 } elsif ($action eq 'graph') {
300 $bweb->display_graph();
302 } elsif ($action eq 'next_job') {
303 $bweb->director_show_sched();
305 } elsif ($action eq 'enable_job') {
306 $bweb->enable_disable_job(1);
308 } elsif ($action eq 'disable_job') {
309 $bweb->enable_disable_job(0);
311 } elsif ($action eq 'groups') {
312 $bweb->display_groups();
314 } elsif ($action eq 'groups_edit') {
315 $bweb->groups_edit();
317 } elsif ($action eq 'groups_save') {
318 $bweb->groups_save();
320 } elsif ($action eq 'groups_del') {
323 } elsif ($action eq 'job') {
324 $bweb->can_do('r_view_job');
325 print "<div><table border='0'><tr><td valign='top'>\n";
326 my $fields = $bweb->get_form(qw/status level filter db_clients
328 limit age offset qclients qfilesets
329 jobtype qpools db_pools
330 db_client_groups qclient_groups/); # drop this to hide
332 $bweb->display($fields, "display_form_job.tpl");
334 print "</td><td valign='top'>";
335 $bweb->display_job(age => $arg->{age}, # last 7 days
336 offset => $arg->{offset},
337 limit => $arg->{limit});
338 print "</td></tr></table></div>";
339 } elsif ($action eq 'job_group') {
340 $bweb->can_do('r_view_job');
341 print "<div><table border='0'><tr><td valign='top'>\n";
342 my $fields = $bweb->get_form(qw/limit level age filter
343 db_client_groups qclient_groups/); # drop this to hide
345 $fields->{hide_status} = 1;
346 $fields->{hide_type} = 1;
347 $fields->{action} = 'job_group';
349 $bweb->display($fields, "display_form_job.tpl");
351 print "</td><td valign='top'>";
352 $bweb->display_job_group(age => $arg->{age}, # last 7 days
353 limit => $arg->{limit});
354 print "</td></tr></table></div>";
355 } elsif ($action eq 'client_stats') {
357 foreach my $client (CGI::param('client')) {
358 if ($client =~ m/$client_re/) {
359 $bweb->display_client_stats(clientname => $1,
364 } elsif ($action eq 'group_stats') {
365 $bweb->display_group_stats(age => $arg->{age});
367 } elsif ($action eq 'running') {
368 $bweb->display_running_jobs(1);
370 } elsif ($action eq 'dsp_cur_job') {
371 $bweb->display_running_job();
373 } elsif ($action eq 'update_from_pool') {
374 $bweb->can_do('r_media_mgnt');
375 my $elt = $bweb->get_form(qw/media pool/);
376 unless ($elt->{media} || $elt->{pool}) {
377 $bweb->error("Can't get media or pool param");
379 my $b = new Bconsole(pref => $conf) ;
382 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
383 title => "Update pool",
384 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
388 $bweb->update_media();
390 } elsif ($action eq 'client_status') {
391 $bweb->can_do('r_client_status');
393 foreach my $client (CGI::param('client')) {
394 if ($client =~ m/$client_re/) {
396 $b = new Bconsole(pref => $conf)
400 content => $b->send_cmd("st client=$client"),
401 title => "Client status",
406 $bweb->error("Can't get client selection");
410 } elsif ($action eq 'cancel_job') {
413 } elsif ($action eq 'media_zoom') {
414 $bweb->display_media_zoom();
416 } elsif ($action eq 'job_zoom') {
418 $bweb->display_job_zoom($arg->{jobid});
419 $bweb->get_job_log();
421 } elsif ($action eq 'job_log') {
422 $bweb->get_job_log();
424 } elsif ($action eq 'prune') {
427 } elsif ($action eq 'purge') {
430 } elsif ($action eq 'run_job') {
433 } elsif ($action eq 'run_job_mod') {
434 $bweb->run_job_mod();
436 } elsif ($action eq 'run_job_now') {
437 $bweb->run_job_now();
439 } elsif ($action eq 'label_barcodes') {
440 $bweb->label_barcodes();
442 } elsif ($action eq 'delete') {
445 } elsif ($action eq 'fileset_view') {
446 $bweb->fileset_view();
449 $bweb->error("Sorry, this action doesn't exist");
452 $bweb->display_end();
454 $bweb->dbh_disconnect();
460 o Affichage des job en cours, termines
461 o Affichage du detail d'un job (status client)
462 o Acces aux log d'une sauvegarde
466 o Affichage des medias (pool, cf bacweb)
467 o Affichage de la liste des cartouches
468 o Affichage d'un autochangeur
469 o Mise a jour des slots
471 o Affichage des medias qui ont besoin d'etre change
473 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
474 o Affichage des stats sur un type de job
475 o Affichage des infos de query.sql
477 - Affichage des du TapeAlert sur le site
478 - Recuperation des erreurs SCSI de /var/log/kern.log
483 o Configuration des autochanger a la main dans un hash dumper