Don't queue devices which are excluded by configuration or don't have the layers to support the operation
This commit is contained in:
@@ -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]
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user