* Add macsuck worker to collect various PortAccessEntity (NAC) attributes * Incorporate PAE feedback on #937 * missing Result/Device.pm column added * pae_is... columns instead of pae_capabilities * moved most code to Util/PortAccessEntity.pm so the update can be done in discover and macsuck * Refactor PAE attributes during discover as separate Plugin * PortAccessEntity: don't use device->dns in log string * Fix "Experimental keys on scalar is now forbidden" test failure * Revamp pae_control and add missing attribute - device.pae_control (text) is now device.pae_is_enabled (bool) - also store pae_authconfig_port_control (port mode auto/force(un)Auth) * Fix "Experimental keys on scalar is now forbidden" test failure - ... again because of botched merge - at least perlgolfed away a set of curly braces * Update PortAccessEntity.pm * Incorporate @ollyg PR feedback * allow actions without transport to run when there are also no creds * initial refactor for separate gather, process, store phases for macsuck * factor out the vlan sanity check * additional help with log of action workers * cleanup logic in check macsuck * refactor to make main phases only * some fixes * implement file slurp. amazingly the whole thing works * remove outdated noop from test * treat error as critical, use cancel to suppress further drivers * big refactor to share mac sanity code to both paths * fix inverted logic on vlan sanity filter * some code tidy * fix error in default value * fix for vlan 0 nodes input from cli * ensure imported MACs are IEEE format * add api endpoint, no useful return status yet * exit status if error from nodes PUT * suppress other networked workers when direct workers are active * better log showing worker * fix status recording to get first error or last done message * implement arpnip API PUT * avoid package redeclaration error * make sure write API methods require admin status * add doc for passing JSON data to arpnip and macsuck * update manifest * remove option to do jobs in web handler; all by queue now * use job entry timestamp for offline queued jobs * fix store username and IP on api PUT * never de-duplicate user-submitted jobs; never reset DeviceSkip for offline jobs * myworker no longer needed * make logic cleaner Co-authored-by: Christian Ramseyer <ramseyer@netnea.com>
65 lines
1.8 KiB
Perl
65 lines
1.8 KiB
Perl
package App::Netdisco::Worker::Loader;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Module::Load ();
|
|
use Dancer qw/:moose :syntax/;
|
|
|
|
use Moo::Role;
|
|
use namespace::clean;
|
|
|
|
has [qw/workers_check
|
|
workers_early
|
|
workers_main
|
|
workers_user
|
|
workers_store
|
|
workers_late
|
|
transport_required/] => ( is => 'rw' );
|
|
|
|
sub load_workers {
|
|
my $self = shift;
|
|
my $action = $self->job->action or die "missing action\n";
|
|
|
|
my @core_plugins = @{ setting('worker_plugins') || [] };
|
|
my @user_plugins = @{ setting('extra_worker_plugins') || [] };
|
|
|
|
# load worker plugins for our action
|
|
foreach my $plugin (@user_plugins, @core_plugins) {
|
|
$plugin =~ s/^X::/+App::NetdiscoX::Worker::Plugin::/;
|
|
$plugin = 'App::Netdisco::Worker::Plugin::'. $plugin
|
|
if $plugin !~ m/^\+/;
|
|
$plugin =~ s/^\+//;
|
|
|
|
next unless $plugin =~ m/::Plugin::${action}(?:::|$)/i;
|
|
$ENV{ND2_LOG_PLUGINS} && debug "loading worker plugin $plugin";
|
|
Module::Load::load $plugin;
|
|
}
|
|
|
|
# now vars->{workers} is populated, we set the dispatch order
|
|
my $workers = vars->{'workers'}->{$action} || {};
|
|
my $driverless_main = 0;
|
|
#use DDP; p vars->{'workers'};
|
|
|
|
foreach my $phase (qw/check early main user store late/) {
|
|
my $pname = "workers_${phase}";
|
|
my @wset = ();
|
|
|
|
foreach my $namespace (sort keys %{ $workers->{$phase} }) {
|
|
foreach my $priority (sort {$b <=> $a}
|
|
keys %{ $workers->{$phase}->{$namespace} }) {
|
|
|
|
++$driverless_main if $phase eq 'main'
|
|
and ($priority == 0 or $priority == setting('driver_priority')->{'direct'});
|
|
push @wset, @{ $workers->{$phase}->{$namespace}->{$priority} };
|
|
}
|
|
}
|
|
|
|
$self->$pname( \@wset );
|
|
}
|
|
|
|
$self->transport_required( $driverless_main ? false : true );
|
|
}
|
|
|
|
true;
|