Don't queue devices which are excluded by configuration or don't have the layers to support the operation

This commit is contained in:
Eric A. Miller
2014-01-03 16:58:45 -05:00
parent d05b55d419
commit b45510ae8f
2 changed files with 16 additions and 3 deletions

View File

@@ -23,6 +23,8 @@
This is to support some devices (HP?) which have plain numbers for port names 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) and Netdisco defaults to assuming this is a VLAN number (R. Kerr)
* Upgrade floatThead JS plugin to improve performance for large tables * 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] [BUG FIXES]

View File

@@ -16,15 +16,26 @@ use namespace::clean;
sub _walk_body { sub _walk_body {
my ($self, $job_type, $job) = @_; 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 $jobqueue = schema('netdisco')->resultset('Admin');
my $devices = schema('netdisco')->resultset('Device') my @devices = schema('netdisco')->resultset('Device')
->search({ip => { -not_in => ->search({ip => { -not_in =>
$jobqueue->search({ $jobqueue->search({
device => { '!=' => undef}, device => { '!=' => undef},
action => $job_type, action => $job_type,
status => { -like => 'queued%' }, status => { -like => 'queued%' },
})->get_column('device')->as_query })->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 { schema('netdisco')->resultset('Admin')->txn_do_locked(sub {
$jobqueue->populate([ $jobqueue->populate([
@@ -32,7 +43,7 @@ sub _walk_body {
device => $_, device => $_,
action => $job_type, action => $job_type,
status => 'queued', status => 'queued',
}} ($devices->all) }} (@filtered_devices)
]); ]);
}); });