pass action host list filtering to Util

This commit is contained in:
Oliver Gorwits
2019-06-09 22:15:10 +01:00
parent 0f1c264e41
commit 02569b0e92
2 changed files with 24 additions and 7 deletions

View File

@@ -2,9 +2,10 @@ package App::Netdisco::Backend::Role::Scheduler;
use Dancer qw/:moose :syntax :script/;
use NetAddr::IP;
use Algorithm::Cron;
use App::Netdisco::Util::MCE;
use App::Netdisco::Util::Device
qw/device_ips_matching device_ips_not_matching/;
use App::Netdisco::JobQueue qw/jq_insert/;
use Role::Tiny;
@@ -68,14 +69,12 @@ sub worker_body {
$win_start, $win_end, $sched->{when}->next_time($win_start);
next unless $sched->{when}->next_time($win_start) <= $win_end;
my $net = NetAddr::IP->new($sched->{device});
next if ($sched->{device}
and (!$net or $net->num == 0 or $net->addr eq '0.0.0.0'));
my @hostlist = device_ips_not_matching($sched->{no},
device_ips_matching($sched->{device} || $sched->{only}));
# TODO work for actions without a host/device
my @hostlist = map { (ref $_) ? $_->addr : undef }
(defined $sched->{device} ? ($net->hostenum) : (undef));
my @job_specs = ();
foreach my $host (@hostlist) {
push @job_specs, {
action => $real_action,