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 'client_edit') {
117 $bweb->client_edit();
119 } elsif ($action eq 'client_save') {
120 $bweb->client_save();
122 } elsif ($action eq 'pool') {
123 $bweb->display_pool();
125 } elsif ($action eq 'location_edit') {
126 $bweb->location_edit();
128 } elsif ($action eq 'location_save') {
129 $bweb->location_save();
131 } elsif ($action eq 'location_add') {
132 $bweb->location_add();
134 } elsif ($action eq 'location_del') {
135 $bweb->location_del();
137 } elsif ($action eq 'cmd_storage') {
138 $bweb->cmd_storage();
140 } elsif ($action eq 'media') {
141 $bweb->can_do('r_view_media');
143 print "<div><table border='0'><tr><td valign='top'>\n";
144 my $fields = $bweb->get_form(qw/db_locations db_pools expired
145 qlocations qpools volstatus qre_media
146 limit qmediatypes db_mediatypes/);
147 $bweb->display($fields, "display_form_media.tpl");
149 print "</td><td valign='top'>";
150 $bweb->display_media(offset => $arg->{offset},
151 limit => $arg->{limit});
152 print "</td></tr></table></div>";
154 } elsif ($action eq 'allmedia') {
155 $bweb->display_allmedia();
157 } elsif ($action eq 'eject') {
158 $bweb->can_do('r_autochanger_mgnt');
160 my $arg = $bweb->get_form("ach");
161 my $a = $bweb->ach_get($arg->{ach});
165 foreach my $slot (CGI::param('slot')) {
166 print $a->{error} unless $a->send_to_io($slot);
169 foreach my $media (CGI::param('media')) {
170 my $slot = $a->get_media_slot($media);
171 print $a->{error} unless $a->send_to_io($slot);
174 $a->display_content();
176 } elsif ($action eq 'add_media') {
179 } elsif ($action eq 'eject_media') {
180 $bweb->eject_media();
182 } elsif ($action eq 'clear_io') {
183 $bweb->can_do('r_autochanger_mgnt');
185 my $arg = $bweb->get_form('ach');
187 my $a = $bweb->ach_get($arg->{ach});
191 $a->display_content();
194 } elsif ($action eq 'ach_edit') {
197 } elsif ($action eq 'ach_del') {
200 } elsif ($action eq 'ach_view') {
201 $bweb->can_do('r_autochanger_mgnt');
203 # TODO : get autochanger name and create it
205 my $arg = $bweb->get_form('ach');
207 my $a = $bweb->ach_get($arg->{ach});
210 $a->display_content();
213 } elsif ($action eq 'ach_add') {
216 } elsif ($action eq 'ach_load') {
217 $bweb->can_do('r_autochanger_mgnt');
219 my $arg = $bweb->get_form('ach', 'drive', 'slot');
221 my $a = $bweb->ach_get($arg->{ach});
223 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
225 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
226 # TODO : use template here
228 $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
231 $bweb->error("Can't get drive, slot or ach");
234 } elsif ($action eq 'ach_unload') {
235 $bweb->can_do('r_autochanger_mgnt');
237 my $arg = $bweb->get_form('drive', 'slot', 'ach');
239 my $a = $bweb->ach_get($arg->{ach});
241 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
243 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
244 # TODO : use template here
246 $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
250 $bweb->error("Can't get drive, slot or ach");
252 } elsif ($action eq 'intern_media') {
253 $bweb->help_intern();
255 } elsif ($action eq 'compute_intern_media') {
256 $bweb->help_intern_compute();
258 } elsif ($action eq 'extern_media') {
259 $bweb->help_extern();
261 } elsif ($action eq 'compute_extern_media') {
262 $bweb->help_extern_compute();
264 } elsif ($action eq 'extern') {
265 $bweb->can_do('r_media_mgnt');
266 $bweb->can_do('r_autochanger_mgnt');
268 print "<div style='float: left;'>";
269 my @achs = $bweb->eject_media();
270 for my $ach (@achs) {
271 CGI::param('ach', $ach);
272 $bweb->update_slots();
274 print "</div><div style='float: left;margin-left: 20px;'>";
275 $bweb->move_media('yes'); # pb with enabled = no for restore
278 } elsif ($action eq 'move_email') {
281 } elsif ($action eq 'change_location') {
282 $bweb->location_change();
284 } elsif ($action eq 'location') {
285 $bweb->location_display();
287 } elsif ($action eq 'about') {
288 $bweb->display($bweb, 'about.tpl');
290 } elsif ($action eq 'intern') {
291 $bweb->move_media('yes'); # TODO : remove that
293 } elsif ($action eq 'move_media') {
294 my $a = $bweb->get_form('enabled');
295 $bweb->move_media($a->{enabled});
297 } elsif ($action eq 'save_location') {
298 $bweb->save_location();
300 } elsif ($action eq 'update_location') {
301 $bweb->update_location();
303 } elsif ($action eq 'update_media') {
304 $bweb->update_media();
306 } elsif ($action eq 'do_update_media') {
307 $bweb->do_update_media();
309 } elsif ($action eq 'update_slots') {
310 $bweb->update_slots();
312 } elsif ($action eq 'graph') {
313 $bweb->display_graph();
315 } elsif ($action eq 'next_job') {
316 $bweb->director_show_sched();
318 } elsif ($action eq 'enable_job') {
319 $bweb->enable_disable_job(1);
321 } elsif ($action eq 'disable_job') {
322 $bweb->enable_disable_job(0);
324 } elsif ($action eq 'groups') {
325 $bweb->display_groups();
327 } elsif ($action eq 'groups_edit') {
328 $bweb->groups_edit();
330 } elsif ($action eq 'groups_save') {
331 $bweb->groups_save();
333 } elsif ($action eq 'groups_del') {
336 } elsif ($action eq 'job') {
337 $bweb->can_do('r_view_job');
338 print "<div><table border='0'><tr><td valign='top'>\n";
339 my $fields = $bweb->get_form(qw/status level filter db_clients
341 limit age offset qclients qfilesets
342 jobtype qpools db_pools
343 db_client_groups qclient_groups/); # drop this to hide
344 if (!CGI::param('since')) {
345 $fields->{hide_since}=1 ;
346 delete $fields->{since};
348 $bweb->display($fields, "display_form_job.tpl");
350 print "</td><td valign='top'>";
351 $bweb->display_job(age => $fields->{age}, # last 7 days
352 since => $fields->{since},
353 offset => $fields->{offset},
354 limit => $fields->{limit});
355 print "</td></tr></table></div>";
356 } elsif ($action eq 'job_group') {
357 $bweb->can_do('r_view_job');
358 print "<div><table border='0'><tr><td valign='top'>\n";
359 my $fields = $bweb->get_form(qw/limit level age filter
360 db_client_groups qclient_groups/); # drop this to hide
362 $fields->{hide_status} = 1;
363 $fields->{hide_type} = 1;
364 $fields->{hide_since}=1;
365 $fields->{action} = 'job_group';
367 $bweb->display($fields, "display_form_job.tpl");
369 print "</td><td valign='top'>";
370 $bweb->display_job_group(age => $arg->{age}, # last 7 days
371 limit => $arg->{limit});
372 print "</td></tr></table></div>";
373 } elsif ($action eq 'client_stats') {
375 foreach my $client (CGI::param('client')) {
376 if ($client =~ $client_re) {
377 $bweb->display_client_stats(clientname => $1,
381 } elsif ($action eq 'group_stats') {
382 $bweb->can_do('r_view_stat');
383 print "<div><table border='0'><tr><td valign='top'>\n";
384 my $fields = $bweb->get_form(qw/since age
385 db_client_groups qclient_groups/);
386 $fields->{action}='group_stats';
387 $fields->{hide_level}=1;
388 $fields->{hide_type}=1;
389 $fields->{hide_status}=1;
391 $bweb->display($fields, "display_form_job.tpl");
393 print "</td><td valign='top'>";
394 $bweb->display_group_stats();
396 print "</td></tr></table></div>"
398 } elsif ($action eq 'running') {
399 $bweb->display_running_jobs(1);
401 } elsif ($action eq 'dsp_cur_job') {
402 $bweb->display_running_job();
404 } elsif ($action eq 'update_from_pool') {
405 $bweb->can_do('r_media_mgnt');
406 my $elt = $bweb->get_form(qw/media pool/);
407 unless ($elt->{media} || $elt->{pool}) {
408 $bweb->error("Can't get media or pool param");
410 my $b = new Bconsole(pref => $conf) ;
413 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
414 title => "Update pool",
415 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
419 $bweb->update_media();
421 } elsif ($action eq 'client_status') {
422 $bweb->can_do('r_client_status');
424 foreach my $client (CGI::param('client')) {
425 if ($client =~ $client_re) {
427 $b = new Bconsole(pref => $conf)
431 content => $b->send_cmd("st client=$client"),
432 title => "Client status",
437 $bweb->error("Can't get client selection");
441 } elsif ($action eq 'cancel_job') {
444 } elsif ($action eq 'cancel_future_job') {
445 $bweb->cancel_future_job();
447 } elsif ($action eq 'media_zoom') {
448 $bweb->display_media_zoom();
450 } elsif ($action eq 'job_zoom') {
452 $bweb->display_job_zoom($arg->{jobid});
453 $bweb->get_job_log();
455 } elsif ($action eq 'job_log') {
456 $bweb->get_job_log();
458 } elsif ($action eq 'prune') {
461 } elsif ($action eq 'purge') {
464 } elsif ($action eq 'run_job') {
467 } elsif ($action eq 'run_job_mod') {
468 $bweb->run_job_mod();
470 } elsif ($action eq 'run_job_now') {
471 $bweb->run_job_now();
473 } elsif ($action eq 'label_barcodes') {
474 $bweb->label_barcodes();
476 } elsif ($action eq 'delete') {
479 } elsif ($action eq 'fileset_view') {
480 $bweb->fileset_view();
482 } elsif ($action eq 'next_job2') {
483 $bweb->display_next_job();
485 } elsif ($action eq 'missing') {
486 $bweb->display_missing_job();
488 } elsif ($action eq 'overview') {
489 $bweb->can_do('r_view_job');
490 print "<div><table border='0'><tr><td valign='top'>\n";
491 my $fields = $bweb->get_form(qw/level filter age jobtype since type
492 db_client_groups qclient_groups/); # drop this to hide
493 $fields->{hide_status}=1;
494 $fields->{view_time_slice}=1;
495 $fields->{action}='overview';
496 $bweb->display($fields, "display_form_job.tpl");
498 print "</td><td valign='top'>";
499 $bweb->display_overview();
500 print "</td></tr></table></div>";
502 } elsif ($action eq 'overview_zoom') {
503 $bweb->can_do('r_view_job');
504 print "<div><table border='0'><tr><td valign='top'>\n";
505 my $fields = $bweb->get_form(qw/level filter age jobtype since type
506 db_client_groups qclient_groups/); # drop this to hide
507 $fields->{hide_status}=1;
508 $fields->{view_time_slice}=1;
509 $fields->{action}='overview_zoom';
510 $bweb->display($fields, "display_form_job.tpl");
511 print "</td><td valign='top'>";
512 $bweb->display_overview_zoom();
513 print "</td></tr></table></div>";
516 $bweb->error("Sorry, this action doesn't exist");
519 $bweb->display_end();
521 $bweb->dbh_disconnect();
527 o Affichage des medias qui ont besoin d'etre change
528 o Affichage des infos de query.sql
530 - Affichage des du TapeAlert sur le site
531 - Recuperation des erreurs SCSI de /var/log/kern.log