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 =~ m/$client_re/) {
377 $bweb->display_client_stats(clientname => $1,
381 } elsif ($action eq 'group_stats') {
382 $bweb->display_group_stats();
384 } elsif ($action eq 'group_stats') {
385 $bweb->display_group_stats(age => $arg->{age});
387 } elsif ($action eq 'running') {
388 $bweb->display_running_jobs(1);
390 } elsif ($action eq 'dsp_cur_job') {
391 $bweb->display_running_job();
393 } elsif ($action eq 'update_from_pool') {
394 $bweb->can_do('r_media_mgnt');
395 my $elt = $bweb->get_form(qw/media pool/);
396 unless ($elt->{media} || $elt->{pool}) {
397 $bweb->error("Can't get media or pool param");
399 my $b = new Bconsole(pref => $conf) ;
402 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
403 title => "Update pool",
404 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
408 $bweb->update_media();
410 } elsif ($action eq 'client_status') {
411 $bweb->can_do('r_client_status');
413 foreach my $client (CGI::param('client')) {
414 if ($client =~ m/$client_re/) {
416 $b = new Bconsole(pref => $conf)
420 content => $b->send_cmd("st client=$client"),
421 title => "Client status",
426 $bweb->error("Can't get client selection");
430 } elsif ($action eq 'cancel_job') {
433 } elsif ($action eq 'media_zoom') {
434 $bweb->display_media_zoom();
436 } elsif ($action eq 'job_zoom') {
438 $bweb->display_job_zoom($arg->{jobid});
439 $bweb->get_job_log();
441 } elsif ($action eq 'job_log') {
442 $bweb->get_job_log();
444 } elsif ($action eq 'prune') {
447 } elsif ($action eq 'purge') {
450 } elsif ($action eq 'run_job') {
453 } elsif ($action eq 'run_job_mod') {
454 $bweb->run_job_mod();
456 } elsif ($action eq 'run_job_now') {
457 $bweb->run_job_now();
459 } elsif ($action eq 'label_barcodes') {
460 $bweb->label_barcodes();
462 } elsif ($action eq 'delete') {
465 } elsif ($action eq 'fileset_view') {
466 $bweb->fileset_view();
468 } elsif ($action eq 'next_job2') {
469 $bweb->display_next_job();
471 } elsif ($action eq 'missing') {
472 $bweb->display_missing_job();
474 } elsif ($action eq 'overview') {
475 $bweb->can_do('r_view_job');
476 print "<div><table border='0'><tr><td valign='top'>\n";
477 my $fields = $bweb->get_form(qw/level filter age jobtype since type
478 db_client_groups qclient_groups/); # drop this to hide
479 $fields->{hide_status}=1;
480 $fields->{view_time_slice}=1;
481 $fields->{action}='overview';
482 $bweb->display($fields, "display_form_job.tpl");
484 print "</td><td valign='top'>";
485 $bweb->display_overview();
486 print "</td></tr></table></div>";
488 } elsif ($action eq 'overview_zoom') {
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_zoom';
496 $bweb->display($fields, "display_form_job.tpl");
497 print "</td><td valign='top'>";
498 $bweb->display_overview_zoom();
499 print "</td></tr></table></div>";
502 $bweb->error("Sorry, this action doesn't exist");
505 $bweb->display_end();
507 $bweb->dbh_disconnect();
513 o Affichage des medias qui ont besoin d'etre change
514 o Affichage des infos de query.sql
516 - Affichage des du TapeAlert sur le site
517 - Recuperation des erreurs SCSI de /var/log/kern.log