6 Copyright (C) 2006 Eric Bollengier
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 my $client_re = qr/^([\w\d\.-]+)$/;
35 my $action = CGI::param('action') || 'begin';
37 if ($action eq 'restore') {
38 print CGI::header('text/brestore'); # specialy to run brestore.pl
41 print CGI::header('text/html');
45 my $conf = new Bweb::Config(config_file => '/etc/bweb/config');
48 my $bweb = new Bweb(info => $conf);
50 # just send data with text/brestore content
51 if ($action eq 'restore') {
56 my $arg = $bweb->get_form('jobid', 'limit', 'offset', 'age');
58 $bweb->display_begin();
60 # if no configuration, we send edit_conf
61 if ($action ne 'apply_conf' and !$bweb->{info}->{dbi}) {
62 $action = 'edit_conf';
65 if ($action eq 'begin') { # main display
66 print "<div style='left=0;'><table border='0'><tr><td valign='top' width='100%'>\n";
67 $bweb->display_general(age => $arg->{age});
68 $bweb->display_running_jobs(0);
69 print "</td><td valign='top'>";
70 $bweb->display({}, "stats.tpl");
71 print "</td></tr></table></div>";
72 $bweb->display_job(limit => 10);
74 } elsif ($action eq 'view_conf') {
77 } elsif ($action eq 'edit_conf') {
80 } elsif ($action eq 'apply_conf') {
83 } elsif ($action eq 'client') {
84 $bweb->display_clients();
86 } elsif ($action eq 'pool') {
87 $bweb->display_pool();
89 } elsif ($action eq 'location_edit') {
90 $bweb->location_edit();
92 } elsif ($action eq 'location_save') {
93 $bweb->location_save();
95 } elsif ($action eq 'location_add') {
96 $bweb->location_add();
98 } elsif ($action eq 'location_del') {
99 $bweb->location_del();
101 } elsif ($action eq 'media') {
102 $bweb->display_media();
104 } elsif ($action eq 'medias') {
105 $bweb->display_medias();
107 } elsif ($action eq 'eject') {
108 my $arg = $bweb->get_form("ach");
109 my $a = $bweb->ach_get($arg->{ach});
113 foreach my $slot (CGI::param('slot')) {
114 print $a->{error} unless $a->send_to_io($slot);
117 foreach my $media (CGI::param('media')) {
118 my $slot = $a->get_media_slot($media);
119 print $a->{error} unless $a->send_to_io($slot);
122 $a->display_content();
125 } elsif ($action eq 'eject_media') {
126 $bweb->eject_media();
128 } elsif ($action eq 'clear_io') {
129 my $arg = $bweb->get_form('ach');
131 my $a = $bweb->ach_get($arg->{ach});
135 $a->display_content();
138 } elsif ($action eq 'ach_edit') {
141 } elsif ($action eq 'ach_del') {
144 } elsif ($action eq 'ach_view') {
145 # TODO : get autochanger name and create it
147 my $arg = $bweb->get_form('ach');
149 my $a = $bweb->ach_get($arg->{ach});
152 $a->display_content();
155 } elsif ($action eq 'ach_add') {
158 } elsif ($action eq 'ach_load') {
159 my $arg = $bweb->get_form('ach', 'drive', 'slot');
161 my $a = $bweb->ach_get($arg->{ach});
163 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
165 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
166 # TODO : use template here
168 $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
171 $bweb->error("Can't get drive, slot or ach");
174 } elsif ($action eq 'ach_unload') {
175 my $arg = $bweb->get_form('drive', 'slot', 'ach');
177 my $a = $bweb->ach_get($arg->{ach});
179 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
181 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
182 # TODO : use template here
184 $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
188 $bweb->error("Can't get drive, slot or ach");
190 } elsif ($action eq 'intern_media') {
191 $bweb->help_intern();
193 } elsif ($action eq 'compute_intern_media') {
194 $bweb->help_intern_compute();
196 } elsif ($action eq 'extern_media') {
197 $bweb->help_extern();
199 } elsif ($action eq 'compute_extern_media') {
200 $bweb->help_extern_compute();
202 } elsif ($action eq 'extern') {
203 $bweb->eject_media();
206 } elsif ($action eq 'move_email') {
209 } elsif ($action eq 'change_location') {
210 $bweb->change_location();
212 } elsif ($action eq 'location') {
213 $bweb->display_location();
215 } elsif ($action eq 'about') {
216 $bweb->display($bweb, 'about.tpl');
218 } elsif ($action eq 'intern') {
219 $bweb->move_media(); # TODO : remove that
221 } elsif ($action eq 'move_media') {
224 } elsif ($action eq 'save_location') {
225 $bweb->save_location();
227 } elsif ($action eq 'update_location') {
228 $bweb->update_location();
230 } elsif ($action eq 'update_media') {
231 $bweb->update_media();
233 } elsif ($action eq 'do_update_media') {
234 $bweb->do_update_media();
236 } elsif ($action eq 'update_slots') {
237 $bweb->update_slots();
239 } elsif ($action eq 'graph') {
240 $bweb->display_graph();
242 } elsif ($action eq 'next_job') {
243 $bweb->director_show_sched();
245 } elsif ($action eq 'enable_job') {
246 $bweb->enable_disable_job(1);
248 } elsif ($action eq 'disable_job') {
249 $bweb->enable_disable_job(0);
251 } elsif ($action eq 'job') {
253 print "<div><table border='0'><tr><td valign='top'>\n";
254 my $fields = $bweb->get_form(qw/status level db_clients db_filesets
255 limit age offset qclients qfilesets
257 $bweb->display($fields, "display_form_job.tpl");
259 print "</td><td valign='top'>";
260 $bweb->display_job(age => $arg->{age}, # last 7 days
261 offset => $arg->{offset},
262 limit => $arg->{limit});
263 print "</td></tr></table></div>";
264 } elsif ($action eq 'client_stats') {
266 foreach my $client (CGI::param('client')) {
267 if ($client =~ m/$client_re/) {
268 $bweb->display_client_stats(clientname => $1,
273 } elsif ($action eq 'running') {
274 $bweb->display_running_jobs(1);
276 } elsif ($action eq 'dsp_cur_job') {
277 $bweb->display_running_job();
279 } elsif ($action eq 'update_from_pool') {
280 my $elt = $bweb->get_form(qw/media pool/);
281 unless ($elt->{media} || $elt->{pool}) {
282 $bweb->error("Can't get media or pool param");
284 my $b = new Bconsole(pref => $conf) ;
287 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
288 title => "Update pool",
289 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
293 $bweb->update_media();
295 } elsif ($action eq 'client_status') {
297 foreach my $client (CGI::param('client')) {
298 if ($client =~ m/$client_re/) {
300 $b = new Bconsole(pref => $conf)
304 content => $b->send_cmd("st client=$client"),
305 title => "Client status",
310 $bweb->error("Can't get client selection");
314 } elsif ($action eq 'cancel_job') {
317 } elsif ($action eq 'media_zoom') {
318 $bweb->display_media_zoom();
320 } elsif ($action eq 'job_zoom') {
322 $bweb->display_job_zoom($arg->{jobid});
323 $bweb->get_job_log();
325 } elsif ($action eq 'job_log') {
326 $bweb->get_job_log();
328 } elsif ($action eq 'prune') {
331 } elsif ($action eq 'purge') {
334 } elsif ($action eq 'run_job') {
337 } elsif ($action eq 'run_job_mod') {
338 $bweb->run_job_mod();
340 } elsif ($action eq 'run_job_now') {
341 $bweb->run_job_now();
343 } elsif ($action eq 'label_barcodes') {
344 $bweb->label_barcodes();
346 } elsif ($action eq 'delete') {
349 } elsif ($action eq 'fileset_view') {
350 $bweb->fileset_view();
353 $bweb->error("Sorry, this action don't exist");
356 $bweb->display_end();
363 o Affichage des job en cours, termines
364 o Affichage du detail d'un job (status client)
365 o Acces aux log d'une sauvegarde
369 o Affichage des medias (pool, cf bacweb)
370 o Affichage de la liste des cartouches
371 o Affichage d'un autochangeur
372 o Mise a jour des slots
374 o Affichage des medias qui ont besoin d'etre change
376 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
377 o Affichage des stats sur un type de job
378 o Affichage des infos de query.sql
380 - Affichage des du TapeAlert sur le site
381 - Recuperation des erreurs SCSI de /var/log/kern.log
386 o Configuration des autochanger a la main dans un hash dumper