implement ignore_layers, force_macsuck, force_arpnip config settings (#1002)

* implementation of ignore_layers, force_macsuck, force_arpnip and macwalk

* use new WalkJobs view to get devices needing macsuck

* also new query for discoverall, arpwalk, nbtwalk

* faux record has a last_defer stamp so we can see when the backend started

* fix typo
This commit is contained in:
Oliver Gorwits
2023-03-15 14:44:42 +00:00
committed by GitHub
parent 062895df10
commit 1d988bbf7c
12 changed files with 112 additions and 51 deletions

View File

@@ -5,7 +5,7 @@ use App::Netdisco::Worker::Plugin;
use aliased 'App::Netdisco::Worker::Status';
use App::Netdisco::JobQueue 'jq_insert';
use Dancer::Plugin::DBIC 'schema';
use App::Netdisco::Util::Permission 'check_acl_no';
register_worker({ phase => 'main' }, sub {
my ($job, $workerconf) = @_;
@@ -15,25 +15,29 @@ register_worker({ phase => 'main' }, sub {
# arpniped/macsucked, queue those jobs now
return unless $device->in_storage and $job->subaction eq 'with-nodes';
if (!defined $device->last_macsuck and $device->has_layer(2)) {
if (!defined $device->last_macsuck and ($device->has_layer(2)
or check_acl_no($device, 'force_macsuck')
or check_acl_no($device, 'ignore_layers'))) {
jq_insert({
device => $device->ip,
action => 'macsuck',
username => $job->username,
userip => $job->userip,
});
debug sprintf ' [%s] queued macsuck', $device;
}
if (!defined $device->last_arpnip and $device->has_layer(3)) {
if (!defined $device->last_arpnip and ($device->has_layer(3)
or check_acl_no($device, 'force_arpnip')
or check_acl_no($device, 'ignore_layers'))) {
jq_insert({
device => $device->ip,
action => 'arpnip',
username => $job->username,
userip => $job->userip,
});
debug sprintf ' [%s] queued arpnip', $device;
}
return Status->info("Queued macsuck and arpnip for $device.");
});
true;