From c3f5508471218cf5444b8d84370a18614943eb11 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 6 Dec 2007 21:12:14 +0000 Subject: [PATCH] ebl Add first action using Bweb::Sched() git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6024 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/cgi/bweb.pl | 3 +++ gui/bweb/lib/Bweb.pm | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/gui/bweb/cgi/bweb.pl b/gui/bweb/cgi/bweb.pl index bb45fa700a..1dc1a42b02 100755 --- a/gui/bweb/cgi/bweb.pl +++ b/gui/bweb/cgi/bweb.pl @@ -454,6 +454,9 @@ if ($action eq 'begin') { # main display } elsif ($action eq 'fileset_view') { $bweb->fileset_view(); +} elsif ($action eq 'next_job2') { + $bweb->display_next_job(); + } elsif ($action eq 'overview') { $bweb->can_do('r_view_job'); print "
\n"; diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 7f12f43f0a..0eec8358c4 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -1021,7 +1021,7 @@ use base q/Bweb::Gui/; Bweb::Sched() - Bweb package that parse show schedule ouput - new Bweb::Sched(format => '%Y-%m-%d'); + new Bweb::Sched(format => '%Y-%m-%d', year => 2008); =head2 USAGE @@ -1132,7 +1132,7 @@ sub parse_scheds # we get all values (0 1 4 9) $elt->{$k}=[split (/\s/,$v)]; } - # we make a bitmap for this kind of data (0 0 1 0 0 0 1) for a quick access + # we make a bitmap for this kind of data (0 0 1 0 0 0 1) for a quick access elsif ($ligne =~ /(wday|wom|woy)=(.+)/) { my ($k,$v) = ($1,$2); foreach my $e (split (/\s/,$v)) { @@ -1159,7 +1159,6 @@ sub get_events my ($self, $s,$format) = @_; my $year = $self->{year} || ((localtime)[5] + 1900); $format = $format || '%u-%02u-%02u %02u:%02u'; - my @ret; foreach my $m (@{$s->{month}}) # mois de l'annee { @@ -4521,4 +4520,34 @@ sub run_job_now print "
You can follow job (jobid=$jobid) execution here "; } +sub display_next_job +{ + my ($self) = @_; + my $arg = $self->get_form(qw/job/); + if (!$arg->{job}) { + return $self->error("Can't get job name"); + } + + my $b = $self->get_bconsole(); + + my $job = $b->send_cmd("show job=\"$arg->{job}\""); + if ($job !~ /Schedule: name=([\w\d\-]+)/s) { + return $self->error("Can't get $arg->{job} schedule"); + } + my $jsched = $1; + + my $out = $b->send_cmd("show schedule=\"$jsched\""); + my $sched = new Bweb::Sched(); + $sched->parse_scheds(split(/\r?\n/, $out)); + + my $ss = $sched->get_scheds($jsched); + + foreach my $s (@$ss) { + my $level = $sched->get_level($s); + my $pool = $sched->get_pool($s); + my $evt = $sched->get_event($s); + print "$level on $pool
", Data::Dumper::Dumper($evt), "

"; + } +} + 1; -- 2.39.5