From: Eric Bollengier Date: Fri, 7 Nov 2008 19:18:54 +0000 (+0000) Subject: ebl Add a new function that permit to mark missing X-Git-Tag: Release-3.0.0~608 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d7b04a7b73f285ee9470ad1cae3b3e73f5c2ba26;p=bacula%2Fbacula ebl Add a new function that permit to mark missing jobs as failed in job history table. That gives a more accurate way to do statistics. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8016 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bweb.pl b/gui/bweb/cgi/bweb.pl index 38e1b1eff1..4751b35cb1 100755 --- a/gui/bweb/cgi/bweb.pl +++ b/gui/bweb/cgi/bweb.pl @@ -441,6 +441,9 @@ if ($action eq 'begin') { # main display } elsif ($action eq 'cancel_job') { $bweb->cancel_job(); +} elsif ($action eq 'cancel_future_job') { + $bweb->cancel_future_job(); + } elsif ($action eq 'media_zoom') { $bweb->display_media_zoom(); diff --git a/gui/bweb/lang/en/tpl/scheduled_job.tpl b/gui/bweb/lang/en/tpl/scheduled_job.tpl index 15324c17cc..165c2e42fe 100644 --- a/gui/bweb/lang/en/tpl/scheduled_job.tpl +++ b/gui/bweb/lang/en/tpl/scheduled_job.tpl @@ -10,6 +10,10 @@ + + + View docView doc @@ -17,6 +21,7 @@ + @@ -45,6 +50,7 @@ chkbox.onclick = function() { document.form1.pool.value = ''; document.form1.media.value = ''; document.form1.client.value = ''; + document.form1.when.value = ''; if (wiki_url) { document.getElementById('wiki').href=wiki_url + ''; } diff --git a/gui/bweb/lang/es/tpl/scheduled_job.tpl b/gui/bweb/lang/es/tpl/scheduled_job.tpl index 49a1f9b7e9..ac53e8b7ec 100644 --- a/gui/bweb/lang/es/tpl/scheduled_job.tpl +++ b/gui/bweb/lang/es/tpl/scheduled_job.tpl @@ -10,6 +10,10 @@ + + + View docView doc @@ -17,6 +21,7 @@ + @@ -45,6 +50,7 @@ chkbox.onclick = function() { document.form1.pool.value = ''; document.form1.media.value = ''; document.form1.client.value = ''; + document.form1.when.value = ''; if (wiki_url) { document.getElementById('wiki').href=wiki_url + ''; } diff --git a/gui/bweb/lang/fr/tpl/scheduled_job.tpl b/gui/bweb/lang/fr/tpl/scheduled_job.tpl index 8c9dcba1af..c8f56cc1f7 100644 --- a/gui/bweb/lang/fr/tpl/scheduled_job.tpl +++ b/gui/bweb/lang/fr/tpl/scheduled_job.tpl @@ -10,6 +10,10 @@ + + + DocumentationDocumentation @@ -17,6 +21,7 @@ + @@ -45,6 +50,7 @@ chkbox.onclick = function() { document.form1.pool.value = ''; document.form1.media.value = ''; document.form1.client.value = ''; + document.form1.when.value = ''; if (wiki_url) { document.getElementById('wiki').href=wiki_url + ''; } diff --git a/gui/bweb/lib/Bconsole.pm b/gui/bweb/lib/Bconsole.pm index 96b6e1018b..cd8456c0e5 100644 --- a/gui/bweb/lib/Bconsole.pm +++ b/gui/bweb/lib/Bconsole.pm @@ -445,7 +445,7 @@ package main; print "test sans conio\n"; my $c = new Bconsole(pref => { - bconsole => '/tmp/bacula/sbin/bconsole -n -c /tmp/bacula/etc/bconsole.conf', + bconsole => '/tmp/regress/bin/bconsole -n -c /tmp/regress/bin/bconsole.conf', }, debug => 0); diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 37a1b97293..6c3c30a11a 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -1868,7 +1868,7 @@ sub get_form } } elsif (exists $opt_t{$i}) { # 1: hh:min optionnal, 2: hh:min required my $when = CGI::param($i) || ''; - if ($when =~ /(\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?)/) { + if ($when =~ /(\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?)/) { if ($opt_t{$i} == 1 or defined $2) { $ret{$i} = $1; } @@ -4554,6 +4554,69 @@ SELECT count(1) AS nbline, }, 'display_log.tpl'); } +sub cancel_future_job +{ + my ($self) = @_; + $self->can_do('r_cancel_job'); + + my $arg = $self->get_form(qw/job pool level client when/); + + if ( !$arg->{job} or !$arg->{pool} or !$arg->{level} + or !$arg->{client} or !$arg->{when}) + { + return $self->error("Can't get enough information to mark this job as canceled"); + } + + $arg->{level} =~ s/^(.).+/$1/; # we keep the first letter + my $jobtable = $self->{info}->{stat_job_table} || 'JobHistory'; + + if ($jobtable =~ /^Job$/i) { + return $self->error("Can add records only in history table"); + } + my $jname = "$arg->{job}.$arg->{when}"; + $jname =~ s/\s/_/g; + + my $found = $self->dbh_selectrow_hashref(" +SELECT 1 + FROM $jobtable + WHERE JobId = 0 + AND Job = '$jname' + AND Name = '$arg->{job}' +"); + if ($found) { + return $self->error("$jname is already in history table"); + } + + $self->dbh_do(" +INSERT INTO $jobtable + (JobId, Name, Job, Type, Level, JobStatus, SchedTime, StartTime, EndTime, + RealEndTime, ClientId, PoolId) + VALUES + (0, '$arg->{job}', '$jname', 'B', '$arg->{level}', 'A', + '$arg->{when}', '$arg->{when}', '$arg->{when}', '$arg->{when}', + (SELECT ClientId FROM Client WHERE Name = '$arg->{client}'), + (SELECT PoolId FROM Pool WHERE Name = '$arg->{pool}') + ) +"); + $self->display({ Filter => "Dummy record for $jname", + ID => 1, + Jobs => + [{ jobid => 0, + client => $arg->{client}, + jobname => $arg->{job}, + pool => $arg->{pool}, + level => $arg->{level}, + starttime => $arg->{when}, + duration => '00:00:00', + jobfiles => 0, + jobbytes => 0, + joberrors => 0, + jobstatus => 'A', + }] + }, + "display_job.tpl"); +} + sub add_media { my ($self) = @_ ; @@ -4738,8 +4801,8 @@ sub enable_disable_job my ($self, $what) = @_ ; $self->can_do('r_run_job'); - my $name = CGI::param('job') || ''; - unless ($name =~ /^[\w\d\.\-\s]+$/) { + my $arg = $self->get_form('job'); + if (!$arg->{job}) { return $self->error("Can't find job name"); } @@ -4753,9 +4816,9 @@ sub enable_disable_job } $self->display({ - content => $b->send_cmd("$cmd job=\"$name\""), - title => "$cmd $name", - name => "$cmd job=\"$name\"", + content => $b->send_cmd("$cmd job=\"$arg->{job}\""), + title => "$cmd $arg->{job}", + name => "$cmd job=\"$arg->{job}\"", }, "command.tpl"); } @@ -4830,14 +4893,15 @@ sub run_job_mod $self->can_do('r_run_job'); my $b = $self->get_bconsole(); - - my $job = CGI::param('job') || ''; + my $arg = $self->get_form(qw/pool level client fileset storage media job/); + + if (!$arg->{job}) { + return $self->error("Can't get job name"); + } # we take informations from director, and we overwrite with user wish - my $info = $b->send_cmd("show job=\"$job\""); + my $info = $b->send_cmd("show job=\"$arg->{job}\""); my $attr = $self->run_parse_job($info); - - my $arg = $self->get_form(qw/pool level client fileset storage media/); if (!$arg->{pool} and $arg->{media}) { my $r = $self->dbh_selectrow_hashref(" @@ -4893,15 +4957,17 @@ sub run_job_now # TODO: check input (don't use pool, level) - my $arg = $self->get_form('pool', 'level', 'client', 'priority', 'when', 'fileset'); - my $job = CGI::param('job') || ''; - my $storage = CGI::param('storage') || ''; + my $arg = $self->get_form(qw/pool level client priority when + fileset job storage/); + if (!$arg->{job}) { + return $self->error("Can't get your job name"); + } - my $jobid = $b->run(job => $job, + my $jobid = $b->run(job => $arg->{job}, client => $arg->{client}, priority => $arg->{priority}, level => $arg->{level}, - storage => $storage, + storage => $arg->{storage}, pool => $arg->{pool}, fileset => $arg->{fileset}, when => $arg->{when}, @@ -4983,11 +5049,11 @@ sub check_job $l = $self->get_higher_level($l); my $evts = $sched->get_event($s); my $end = $sched->{end}; # this backup must have start before the next one - foreach my $evt (reverse @$evts) { my $all = $self->dbh_selectrow_hashref(" SELECT 1 - FROM Job JOIN Client USING (ClientId) LEFT JOIN Pool USING (PoolId) + FROM Job + JOIN Client USING (ClientId) LEFT JOIN Pool USING (PoolId) WHERE Job.StartTime >= '$evt' AND Job.StartTime < '$end' AND Job.Name = '$job' @@ -5050,10 +5116,11 @@ sub display_missing_job } } $self->display({ - id => $cur_id++, - title => "Missing Job (since $arg->{begin} to $arg->{end})", - list => $self->{tmp}, - wiki_url => $self->{info}->{wiki_url}, + id => $cur_id++, + title => "Missing Job (since $arg->{begin} to $arg->{end})", + list => $self->{tmp}, + wiki_url => $self->{info}->{wiki_url}, + missing_mode => 1, }, "scheduled_job.tpl"); delete $self->{tmp}; diff --git a/gui/bweb/script/regress.pl b/gui/bweb/script/regress.pl index 1b9828da43..8a287b1a9a 100755 --- a/gui/bweb/script/regress.pl +++ b/gui/bweb/script/regress.pl @@ -93,6 +93,12 @@ ok($c =~ m!(action=job_zoom;jobid=\d+)!, "Get the first JobId"); die "Can't get first jobid ($c)" unless $1; $job_url=$1; +# check missing view +ok($agent->follow_link(text_regex=>qr/Missing Jobs/), "Go to Missing Jobs page"); +$c=$agent->content; +like($c, qr/BackupCatalog/, "Check for BackupCatalog job"); +unlike($c, qr/backup/, "Check for backup job"); + # test job_zoom page # check for # - job log @@ -138,7 +144,7 @@ ok($agent->success,"Get job zoom"); ok($agent->form_name('delete'), "Find form"); $agent->click(); $c=$agent->content; ok($agent->success, "Delete it"); -like($c, qr!deleted!, "Check deleted message"); +like($c, qr!deleted from the catalog!, "Check deleted message"); $agent->get("$url?$job_url"); ok($agent->success,"Get job zoom"); diff --git a/gui/bweb/technotes-2.3 b/gui/bweb/technotes-2.3 index 08fdef8258..33d061372e 100644 --- a/gui/bweb/technotes-2.3 +++ b/gui/bweb/technotes-2.3 @@ -1,3 +1,9 @@ +07Nov08 +ebl Fix statistics page +ebl Add new "Cancel missing job" feature to be able + to mark missing job as failed in history table. +ebl Fix a couple of unchecked arguments. + 06Nov08 ebl Fix a Bconsole.pm with Expect bug on debian lenny ebl Fix in storage command diff --git a/gui/bweb/tpl/scheduled_job.tpl b/gui/bweb/tpl/scheduled_job.tpl index aa7d3a3f35..c76ab7703d 100644 --- a/gui/bweb/tpl/scheduled_job.tpl +++ b/gui/bweb/tpl/scheduled_job.tpl @@ -10,6 +10,10 @@ + + + __View doc____View doc__ @@ -17,6 +21,7 @@ + @@ -45,6 +50,7 @@ chkbox.onclick = function() { document.form1.pool.value = ''; document.form1.media.value = ''; document.form1.client.value = ''; + document.form1.when.value = ''; if (wiki_url) { document.getElementById('wiki').href=wiki_url + ''; }