From b45510ae8fcd2680059508e90ed923806529e65e Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Fri, 3 Jan 2014 16:58:45 -0500 Subject: [PATCH] Don't queue devices which are excluded by configuration or don't have the layers to support the operation --- Netdisco/Changes | 2 ++ .../App/Netdisco/Daemon/Worker/Poller/Common.pm | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 4e36acaf..a825be68 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -23,6 +23,8 @@ This is to support some devices (HP?) which have plain numbers for port names and Netdisco defaults to assuming this is a VLAN number (R. Kerr) * Upgrade floatThead JS plugin to improve performance for large tables + * Don't queue devices which are excluded by configuration or don't have the + layers to support the operation [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Common.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Common.pm index 9997e5c2..ae2c2338 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Common.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Common.pm @@ -16,15 +16,26 @@ use namespace::clean; sub _walk_body { my ($self, $job_type, $job) = @_; + my $action_method = $job_type .'_action'; + my $job_action = $self->$action_method; + + my $layer_method = $job_type .'_layer'; + my $job_layer = $self->$layer_method; + my $jobqueue = schema('netdisco')->resultset('Admin'); - my $devices = schema('netdisco')->resultset('Device') + my @devices = schema('netdisco')->resultset('Device') ->search({ip => { -not_in => $jobqueue->search({ device => { '!=' => undef}, action => $job_type, status => { -like => 'queued%' }, })->get_column('device')->as_query - }})->get_column('ip'); + }})->has_layer($job_layer)->get_column('ip')->all; + + my $filter_method = $job_type .'_filter'; + my $job_filter = $self->$filter_method; + + my @filtered_devices = grep {$job_filter->($_)} @devices; schema('netdisco')->resultset('Admin')->txn_do_locked(sub { $jobqueue->populate([ @@ -32,7 +43,7 @@ sub _walk_body { device => $_, action => $job_type, status => 'queued', - }} ($devices->all) + }} (@filtered_devices) ]); });