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 'cmd_storage') {
132 $bweb->cmd_storage();
134 } elsif ($action eq 'media') {
135 $bweb->can_do('r_view_media');
137 print "<div><table border='0'><tr><td valign='top'>\n";
138 my $fields = $bweb->get_form(qw/db_locations db_pools expired
139 qlocations qpools volstatus qre_media
140 limit qmediatypes db_mediatypes/);
141 $bweb->display($fields, "display_form_media.tpl");
143 print "</td><td valign='top'>";
144 $bweb->display_media(offset => $arg->{offset},
145 limit => $arg->{limit});
146 print "</td></tr></table></div>";
148 } elsif ($action eq 'allmedia') {
149 $bweb->display_allmedia();
151 } elsif ($action eq 'eject') {
152 $bweb->can_do('r_autochanger_mgnt');
154 my $arg = $bweb->get_form("ach");
155 my $a = $bweb->ach_get($arg->{ach});
159 foreach my $slot (CGI::param('slot')) {
160 print $a->{error} unless $a->send_to_io($slot);
163 foreach my $media (CGI::param('media')) {
164 my $slot = $a->get_media_slot($media);
165 print $a->{error} unless $a->send_to_io($slot);
168 $a->display_content();
170 } elsif ($action eq 'add_media') {
173 } elsif ($action eq 'eject_media') {
174 $bweb->eject_media();
176 } elsif ($action eq 'clear_io') {
177 $bweb->can_do('r_autochanger_mgnt');
179 my $arg = $bweb->get_form('ach');
181 my $a = $bweb->ach_get($arg->{ach});
185 $a->display_content();
188 } elsif ($action eq 'ach_edit') {
191 } elsif ($action eq 'ach_del') {
194 } elsif ($action eq 'ach_view') {
195 $bweb->can_do('r_autochanger_mgnt');
197 # TODO : get autochanger name and create it
199 my $arg = $bweb->get_form('ach');
201 my $a = $bweb->ach_get($arg->{ach});
204 $a->display_content();
207 } elsif ($action eq 'ach_add') {
210 } elsif ($action eq 'ach_load') {
211 $bweb->can_do('r_autochanger_mgnt');
213 my $arg = $bweb->get_form('ach', 'drive', 'slot');
215 my $a = $bweb->ach_get($arg->{ach});
217 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
219 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
220 # TODO : use template here
222 $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
225 $bweb->error("Can't get drive, slot or ach");
228 } elsif ($action eq 'ach_unload') {
229 $bweb->can_do('r_autochanger_mgnt');
231 my $arg = $bweb->get_form('drive', 'slot', 'ach');
233 my $a = $bweb->ach_get($arg->{ach});
235 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
237 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
238 # TODO : use template here
240 $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
244 $bweb->error("Can't get drive, slot or ach");
246 } elsif ($action eq 'intern_media') {
247 $bweb->help_intern();
249 } elsif ($action eq 'compute_intern_media') {
250 $bweb->help_intern_compute();
252 } elsif ($action eq 'extern_media') {
253 $bweb->help_extern();
255 } elsif ($action eq 'compute_extern_media') {
256 $bweb->help_extern_compute();
258 } elsif ($action eq 'extern') {
259 $bweb->can_do('r_media_mgnt');
260 $bweb->can_do('r_autochanger_mgnt');
262 print "<div style='float: left;'>";
263 my @achs = $bweb->eject_media();
264 for my $ach (@achs) {
265 CGI::param('ach', $ach);
266 $bweb->update_slots();
268 print "</div><div style='float: left;margin-left: 20px;'>";
269 $bweb->move_media('no'); # enabled = no
272 } elsif ($action eq 'move_email') {
275 } elsif ($action eq 'change_location') {
276 $bweb->location_change();
278 } elsif ($action eq 'location') {
279 $bweb->location_display();
281 } elsif ($action eq 'about') {
282 $bweb->display($bweb, 'about.tpl');
284 } elsif ($action eq 'intern') {
285 $bweb->move_media('yes'); # TODO : remove that
287 } elsif ($action eq 'move_media') {
288 my $a = $bweb->get_form('enabled');
289 $bweb->move_media($a->{enabled});
291 } elsif ($action eq 'save_location') {
292 $bweb->save_location();
294 } elsif ($action eq 'update_location') {
295 $bweb->update_location();
297 } elsif ($action eq 'update_media') {
298 $bweb->update_media();
300 } elsif ($action eq 'do_update_media') {
301 $bweb->do_update_media();
303 } elsif ($action eq 'update_slots') {
304 $bweb->update_slots();
306 } elsif ($action eq 'graph') {
307 $bweb->display_graph();
309 } elsif ($action eq 'next_job') {
310 $bweb->director_show_sched();
312 } elsif ($action eq 'enable_job') {
313 $bweb->enable_disable_job(1);
315 } elsif ($action eq 'disable_job') {
316 $bweb->enable_disable_job(0);
318 } elsif ($action eq 'groups') {
319 $bweb->display_groups();
321 } elsif ($action eq 'groups_edit') {
322 $bweb->groups_edit();
324 } elsif ($action eq 'groups_save') {
325 $bweb->groups_save();
327 } elsif ($action eq 'groups_del') {
330 } elsif ($action eq 'job') {
331 $bweb->can_do('r_view_job');
332 print "<div><table border='0'><tr><td valign='top'>\n";
333 my $fields = $bweb->get_form(qw/status level filter db_clients
335 limit age offset qclients qfilesets
336 jobtype qpools db_pools
337 db_client_groups qclient_groups/); # drop this to hide
338 if (!CGI::param('since')) {
339 $fields->{hide_since}=1 ;
340 delete $fields->{since};
342 $bweb->display($fields, "display_form_job.tpl");
344 print "</td><td valign='top'>";
345 $bweb->display_job(age => $fields->{age}, # last 7 days
346 since => $fields->{since},
347 offset => $fields->{offset},
348 limit => $fields->{limit});
349 print "</td></tr></table></div>";
350 } elsif ($action eq 'job_group') {
351 $bweb->can_do('r_view_job');
352 print "<div><table border='0'><tr><td valign='top'>\n";
353 my $fields = $bweb->get_form(qw/limit level age filter
354 db_client_groups qclient_groups/); # drop this to hide
356 $fields->{hide_status} = 1;
357 $fields->{hide_type} = 1;
358 $fields->{hide_since}=1;
359 $fields->{action} = 'job_group';
361 $bweb->display($fields, "display_form_job.tpl");
363 print "</td><td valign='top'>";
364 $bweb->display_job_group(age => $arg->{age}, # last 7 days
365 limit => $arg->{limit});
366 print "</td></tr></table></div>";
367 } elsif ($action eq 'client_stats') {
369 foreach my $client (CGI::param('client')) {
370 if ($client =~ m/$client_re/) {
371 $bweb->display_client_stats(clientname => $1,
376 } elsif ($action eq 'group_stats') {
377 $bweb->display_group_stats(age => $arg->{age});
379 } elsif ($action eq 'running') {
380 $bweb->display_running_jobs(1);
382 } elsif ($action eq 'dsp_cur_job') {
383 $bweb->display_running_job();
385 } elsif ($action eq 'update_from_pool') {
386 $bweb->can_do('r_media_mgnt');
387 my $elt = $bweb->get_form(qw/media pool/);
388 unless ($elt->{media} || $elt->{pool}) {
389 $bweb->error("Can't get media or pool param");
391 my $b = new Bconsole(pref => $conf) ;
394 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
395 title => "Update pool",
396 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
400 $bweb->update_media();
402 } elsif ($action eq 'client_status') {
403 $bweb->can_do('r_client_status');
405 foreach my $client (CGI::param('client')) {
406 if ($client =~ m/$client_re/) {
408 $b = new Bconsole(pref => $conf)
412 content => $b->send_cmd("st client=$client"),
413 title => "Client status",
418 $bweb->error("Can't get client selection");
422 } elsif ($action eq 'cancel_job') {
425 } elsif ($action eq 'media_zoom') {
426 $bweb->display_media_zoom();
428 } elsif ($action eq 'job_zoom') {
430 $bweb->display_job_zoom($arg->{jobid});
431 $bweb->get_job_log();
433 } elsif ($action eq 'job_log') {
434 $bweb->get_job_log();
436 } elsif ($action eq 'prune') {
439 } elsif ($action eq 'purge') {
442 } elsif ($action eq 'run_job') {
445 } elsif ($action eq 'run_job_mod') {
446 $bweb->run_job_mod();
448 } elsif ($action eq 'run_job_now') {
449 $bweb->run_job_now();
451 } elsif ($action eq 'label_barcodes') {
452 $bweb->label_barcodes();
454 } elsif ($action eq 'delete') {
457 } elsif ($action eq 'fileset_view') {
458 $bweb->fileset_view();
460 } elsif ($action eq 'next_job2') {
461 $bweb->display_next_job();
463 } elsif ($action eq 'missing') {
464 $bweb->display_missing_job();
466 } elsif ($action eq 'overview') {
467 $bweb->can_do('r_view_job');
468 print "<div><table border='0'><tr><td valign='top'>\n";
469 my $fields = $bweb->get_form(qw/level filter age jobtype since type
470 db_client_groups qclient_groups/); # drop this to hide
471 $fields->{hide_status}=1;
472 $fields->{view_time_slice}=1;
473 $fields->{action}='overview';
474 $bweb->display($fields, "display_form_job.tpl");
476 print "</td><td valign='top'>";
477 $bweb->display_overview();
478 print "</td></tr></table></div>";
480 } elsif ($action eq 'overview_zoom') {
481 $bweb->can_do('r_view_job');
482 print "<div><table border='0'><tr><td valign='top'>\n";
483 my $fields = $bweb->get_form(qw/level filter age jobtype since type
484 db_client_groups qclient_groups/); # drop this to hide
485 $fields->{hide_status}=1;
486 $fields->{view_time_slice}=1;
487 $fields->{action}='overview_zoom';
488 $bweb->display($fields, "display_form_job.tpl");
489 print "</td><td valign='top'>";
490 $bweb->display_overview_zoom();
491 print "</td></tr></table></div>";
494 $bweb->error("Sorry, this action doesn't exist");
497 $bweb->display_end();
499 $bweb->dbh_disconnect();
505 o Affichage des medias qui ont besoin d'etre change
506 o Affichage des infos de query.sql
508 - Affichage des du TapeAlert sur le site
509 - Recuperation des erreurs SCSI de /var/log/kern.log