set up list of jobs the backend instance should skip
This commit is contained in:
@@ -8,7 +8,8 @@ use App::Netdisco::Util::Backend;
|
||||
use Role::Tiny;
|
||||
use namespace::clean;
|
||||
|
||||
use App::Netdisco::JobQueue qw/jq_locked jq_getsome jq_getsomep jq_lock/;
|
||||
use App::Netdisco::JobQueue
|
||||
qw/jq_locked jq_getsome jq_getsomep jq_lock jq_prime_skiplist/;
|
||||
|
||||
sub worker_begin {
|
||||
my $self = shift;
|
||||
@@ -19,6 +20,9 @@ sub worker_begin {
|
||||
|
||||
debug "entering Manager ($wid) worker_begin()";
|
||||
|
||||
# rebuild device skip hints
|
||||
jq_prime_skiplist;
|
||||
|
||||
# requeue jobs locally
|
||||
debug "mgr ($wid): searching for jobs booked to this processing node";
|
||||
my @jobs = jq_locked;
|
||||
|
||||
@@ -13,6 +13,7 @@ our @EXPORT_OK = qw/
|
||||
jq_getsomep
|
||||
jq_locked
|
||||
jq_queued
|
||||
jq_prime_skiplist
|
||||
jq_log
|
||||
jq_userlog
|
||||
jq_lock
|
||||
@@ -57,6 +58,12 @@ Netdisco job instance interface (see below).
|
||||
Returns a list of IP addresses of devices which currently have a job of the
|
||||
given C<$job_type> queued (e.g. C<discover>, C<arpnip>, etc).
|
||||
|
||||
=head2 jq_prime_skiplist()
|
||||
|
||||
Sets up a table of hints for the backend daemon manager to help avoid picking
|
||||
jobs from the queue that it cannot process due to C<*_no> configuration
|
||||
settings.
|
||||
|
||||
=head2 jq_log()
|
||||
|
||||
Returns a list of the most recent 50 jobs in the queue. Jobs are returned as
|
||||
|
||||
@@ -3,7 +3,11 @@ package App::Netdisco::JobQueue::PostgreSQL;
|
||||
use Dancer qw/:moose :syntax :script/;
|
||||
use Dancer::Plugin::DBIC 'schema';
|
||||
|
||||
use App::Netdisco::Util::Device
|
||||
qw/is_discoverable is_macsuckable is_arpnipable/;
|
||||
use App::Netdisco::Backend::Job;
|
||||
|
||||
|
||||
use Net::Domain 'hostfqdn';
|
||||
use Module::Load ();
|
||||
use Try::Tiny;
|
||||
@@ -15,6 +19,7 @@ our @EXPORT_OK = qw/
|
||||
jq_getsomep
|
||||
jq_locked
|
||||
jq_queued
|
||||
jq_prime_skiplist
|
||||
jq_log
|
||||
jq_userlog
|
||||
jq_lock
|
||||
@@ -89,6 +94,48 @@ sub jq_queued {
|
||||
})->get_column('device')->all;
|
||||
}
|
||||
|
||||
sub jq_prime_skiplist {
|
||||
my $fqdn = hostfqdn || 'localhost';
|
||||
my $rs = schema('netdisco')->resultset('DeviceSkip');
|
||||
my @d_actions = ('discover', @{ setting('job_prio')->{high} });
|
||||
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my @devices = schema('netdisco')->resultset('Device')->all;
|
||||
$rs->search({ backend => $fqdn })->delete;
|
||||
|
||||
foreach my $action (@d_actions) {
|
||||
$rs->populate([
|
||||
map {{
|
||||
backend => $fqdn,
|
||||
device => $_->ip,
|
||||
action => $action,
|
||||
skipover => \'true',
|
||||
}} grep { not is_discoverable($_) } @devices
|
||||
]);
|
||||
}
|
||||
|
||||
foreach my $action (qw/macsuck nbtstat/) {
|
||||
$rs->populate([
|
||||
map {{
|
||||
backend => $fqdn,
|
||||
device => $_->ip,
|
||||
action => $action,
|
||||
skipover => \'true',
|
||||
}} grep { not is_macsuckable($_) } @devices
|
||||
]);
|
||||
}
|
||||
|
||||
$rs->populate([
|
||||
map {{
|
||||
backend => $fqdn,
|
||||
device => $_->ip,
|
||||
action => 'arpnip',
|
||||
skipover => \'true',
|
||||
}} grep { not is_arpnipable($_) } @devices
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
sub jq_log {
|
||||
return schema('netdisco')->resultset('Admin')->search({}, {
|
||||
order_by => { -desc => [qw/entered device action/] },
|
||||
|
||||
Reference in New Issue
Block a user