diff --git a/lib/App/Netdisco/Worker/Plugin/Arpnip.pm b/lib/App/Netdisco/Worker/Plugin/Arpnip.pm index 1d820c5e..d678f745 100644 --- a/lib/App/Netdisco/Worker/Plugin/Arpnip.pm +++ b/lib/App/Netdisco/Worker/Plugin/Arpnip.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Device 'is_arpnipable_now'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my $device = $job->device; diff --git a/lib/App/Netdisco/Worker/Plugin/Arpnip/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Arpnip/Nodes.pm index c15d5427..85cf3179 100644 --- a/lib/App/Netdisco/Worker/Plugin/Arpnip/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Arpnip/Nodes.pm @@ -11,7 +11,7 @@ use Dancer::Plugin::DBIC 'schema'; use Time::HiRes 'gettimeofday'; use NetAddr::MAC (); -register_worker({ stage => 'init', driver => 'snmp' }, sub { +register_worker({ stage => 'check', driver => 'snmp' }, sub { my ($job, $workerconf) = @_; my $device = $job->device; diff --git a/lib/App/Netdisco/Worker/Plugin/Arpwalk.pm b/lib/App/Netdisco/Worker/Plugin/Arpwalk.pm index c8ee9dd2..9305a336 100644 --- a/lib/App/Netdisco/Worker/Plugin/Arpwalk.pm +++ b/lib/App/Netdisco/Worker/Plugin/Arpwalk.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::JobQueue qw/jq_queued jq_insert/; use Dancer::Plugin::DBIC 'schema'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my %queued = map {$_ => 1} jq_queued('arpnip'); diff --git a/lib/App/Netdisco/Worker/Plugin/Delete.pm b/lib/App/Netdisco/Worker/Plugin/Delete.pm index 1b8078fa..cbdba621 100644 --- a/lib/App/Netdisco/Worker/Plugin/Delete.pm +++ b/lib/App/Netdisco/Worker/Plugin/Delete.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Device 'delete_device'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my ($device, $port, $extra) = map {$job->$_} qw/device port extra/; return Status->error('Missing device (-d).') if !defined $device; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover.pm b/lib/App/Netdisco/Worker/Plugin/Discover.pm index 79474023..c6b89c2a 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Device 'is_discoverable_now'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my $device = $job->device; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index 7c636ce5..a70c5038 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -12,7 +12,7 @@ use Dancer::Plugin::DBIC 'schema'; use NetAddr::IP::Lite ':lower'; use Encode; -register_worker({ stage => 'init', driver => 'snmp' }, sub { +register_worker({ stage => 'check', driver => 'snmp' }, sub { my ($job, $workerconf) = @_; my $device = $job->device; diff --git a/lib/App/Netdisco/Worker/Plugin/DiscoverAll.pm b/lib/App/Netdisco/Worker/Plugin/DiscoverAll.pm index 07472fb6..57497ead 100644 --- a/lib/App/Netdisco/Worker/Plugin/DiscoverAll.pm +++ b/lib/App/Netdisco/Worker/Plugin/DiscoverAll.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::JobQueue qw/jq_queued jq_insert/; use Dancer::Plugin::DBIC 'schema'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my %queued = map {$_ => 1} jq_queued('discover'); diff --git a/lib/App/Netdisco/Worker/Plugin/Expire.pm b/lib/App/Netdisco/Worker/Plugin/Expire.pm index ded1bbb4..ce550174 100644 --- a/lib/App/Netdisco/Worker/Plugin/Expire.pm +++ b/lib/App/Netdisco/Worker/Plugin/Expire.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use Dancer::Plugin::DBIC 'schema'; use App::Netdisco::Util::Statistics 'update_stats'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; if (setting('expire_devices') and setting('expire_devices') > 0) { diff --git a/lib/App/Netdisco/Worker/Plugin/ExpireNodes.pm b/lib/App/Netdisco/Worker/Plugin/ExpireNodes.pm index c8df685c..733fd93b 100644 --- a/lib/App/Netdisco/Worker/Plugin/ExpireNodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/ExpireNodes.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use Dancer::Plugin::DBIC 'schema'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; return Status->error('nbtstat failed: unable to interpret device param') diff --git a/lib/App/Netdisco/Worker/Plugin/Graph.pm b/lib/App/Netdisco/Worker/Plugin/Graph.pm index 8e0f20f6..8eac6ab8 100644 --- a/lib/App/Netdisco/Worker/Plugin/Graph.pm +++ b/lib/App/Netdisco/Worker/Plugin/Graph.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Graph (); -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; App::Netdisco::Util::Graph::graph(); return Status->done('Generated graph data.'); diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck.pm index b760070c..db9cb752 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Device 'is_macsuckable_now'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my $device = $job->device; diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm index 15258238..3e262016 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm @@ -14,7 +14,7 @@ use Dancer::Plugin::DBIC 'schema'; use Time::HiRes 'gettimeofday'; use Scope::Guard 'guard'; -register_worker({ stage => 'init', driver => 'snmp' }, sub { +register_worker({ stage => 'check', driver => 'snmp' }, sub { my ($job, $workerconf) = @_; my $device = $job->device; diff --git a/lib/App/Netdisco/Worker/Plugin/Macwalk.pm b/lib/App/Netdisco/Worker/Plugin/Macwalk.pm index 867425fe..83f6637e 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macwalk.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macwalk.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::JobQueue qw/jq_queued jq_insert/; use Dancer::Plugin::DBIC 'schema'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my %queued = map {$_ => 1} jq_queued('macsuck'); diff --git a/lib/App/Netdisco/Worker/Plugin/Monitor.pm b/lib/App/Netdisco/Worker/Plugin/Monitor.pm index fcc02937..327a1d57 100644 --- a/lib/App/Netdisco/Worker/Plugin/Monitor.pm +++ b/lib/App/Netdisco/Worker/Plugin/Monitor.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::NodeMonitor (); -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; App::Netdisco::Util::NodeMonitor::monitor(); return Status->done('Generated monitor data.'); diff --git a/lib/App/Netdisco/Worker/Plugin/Nbtstat.pm b/lib/App/Netdisco/Worker/Plugin/Nbtstat.pm index 50ccda59..bc933107 100644 --- a/lib/App/Netdisco/Worker/Plugin/Nbtstat.pm +++ b/lib/App/Netdisco/Worker/Plugin/Nbtstat.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Device 'is_macsuckable'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; return Status->error('nbtstat failed: unable to interpret device param') diff --git a/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm b/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm index 522675d7..1db6421e 100644 --- a/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm +++ b/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm @@ -9,7 +9,7 @@ use App::Netdisco::Util::Node 'is_nbtstatable'; use Dancer::Plugin::DBIC 'schema'; use Time::HiRes 'gettimeofday'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my $host = $job->device->ip; diff --git a/lib/App/Netdisco/Worker/Plugin/Nbtwalk.pm b/lib/App/Netdisco/Worker/Plugin/Nbtwalk.pm index 5a61ea23..e3a2a63b 100644 --- a/lib/App/Netdisco/Worker/Plugin/Nbtwalk.pm +++ b/lib/App/Netdisco/Worker/Plugin/Nbtwalk.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::JobQueue qw/jq_queued jq_insert/; use Dancer::Plugin::DBIC 'schema'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my %queued = map {$_ => 1} jq_queued('nbtstat'); diff --git a/lib/App/Netdisco/Worker/Plugin/Psql.pm b/lib/App/Netdisco/Worker/Plugin/Psql.pm index bdbf4d2e..24368141 100644 --- a/lib/App/Netdisco/Worker/Plugin/Psql.pm +++ b/lib/App/Netdisco/Worker/Plugin/Psql.pm @@ -4,7 +4,7 @@ use Dancer ':syntax'; use App::Netdisco::Worker::Plugin; use aliased 'App::Netdisco::Worker::Status'; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my ($device, $port, $extra) = map {$job->$_} qw/device port extra/; diff --git a/lib/App/Netdisco/Worker/Plugin/Renumber.pm b/lib/App/Netdisco/Worker/Plugin/Renumber.pm index 6b27b2ec..77f3f378 100644 --- a/lib/App/Netdisco/Worker/Plugin/Renumber.pm +++ b/lib/App/Netdisco/Worker/Plugin/Renumber.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use NetAddr::IP qw/:rfc3021 :lower/; use App::Netdisco::Util::Device qw/get_device renumber_device/; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my ($device, $port, $extra) = map {$job->$_} qw/device port extra/; return Status->error('Missing device (-d).') if !defined $device; diff --git a/lib/App/Netdisco/Worker/Plugin/Show.pm b/lib/App/Netdisco/Worker/Plugin/Show.pm index d81310c4..20d13505 100644 --- a/lib/App/Netdisco/Worker/Plugin/Show.pm +++ b/lib/App/Netdisco/Worker/Plugin/Show.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use Data::Printer (); use App::Netdisco::Transport::SNMP; -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; my ($device, $port, $extra) = map {$job->$_} qw/device port extra/; return Status->error('Missing device (-d).') if !defined $device; diff --git a/lib/App/Netdisco/Worker/Plugin/Stats.pm b/lib/App/Netdisco/Worker/Plugin/Stats.pm index b59796b4..25553b34 100644 --- a/lib/App/Netdisco/Worker/Plugin/Stats.pm +++ b/lib/App/Netdisco/Worker/Plugin/Stats.pm @@ -6,7 +6,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Util::Statistics (); -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; App::Netdisco::Util::Statistics::update_stats(); return Status->done('Updated statistics.'); diff --git a/lib/App/Netdisco/Worker/Plugin/Test.pm b/lib/App/Netdisco/Worker/Plugin/Test.pm index 70bb7cf0..4cc009f6 100644 --- a/lib/App/Netdisco/Worker/Plugin/Test.pm +++ b/lib/App/Netdisco/Worker/Plugin/Test.pm @@ -10,10 +10,10 @@ register_worker({ stage => 'second' }, sub { return Status->done('Test (second) ran successfully.'); }); -register_worker({ stage => 'init' }, sub { +register_worker({ stage => 'check' }, sub { my ($job, $workerconf) = @_; - debug 'Test (init) ran successfully.'; - return Status->done('Test (init) ran successfully.'); + debug 'Test (check) ran successfully.'; + return Status->done('Test (check) ran successfully.'); }); register_worker({ stage => 'first' }, sub { diff --git a/lib/App/Netdisco/Worker/Runner.pm b/lib/App/Netdisco/Worker/Runner.pm index 72989b44..15abdd55 100644 --- a/lib/App/Netdisco/Worker/Runner.pm +++ b/lib/App/Netdisco/Worker/Runner.pm @@ -64,11 +64,11 @@ sub run { @{ (setting('_nd2worker_hooks') || []) }; foreach my $phase ("nd2_${action}", @phase_hooks) { - foreach my $stage (qw/init first second/) { + foreach my $stage (qw/check first second/) { my $hookname = "${phase}_${stage}"; next unless scalar @{ $store->get_hooks_for($hookname) }; $self->run_workers($hookname); - return if $stage eq 'init' and $self->jobstat->not_ok; + return if $stage eq 'check' and $self->jobstat->not_ok; } } } @@ -77,7 +77,7 @@ sub run_workers { my $self = shift; my $hook = shift or return $self->jobstat->error('missing hook param'); my $store = Dancer::Factory::Hook->instance(); - my $init = ($hook =~ m/_init$/); + my $check = ($hook =~ m/_check$/); return unless scalar @{ $store->get_hooks_for($hook) }; debug "running workers for hook: $hook"; @@ -87,11 +87,11 @@ sub run_workers { my $retval = $worker->($self->job); # could die or return undef or a scalar or Status or another class $self->jobstat($retval) - if $init and ref $retval eq 'App::Netdisco::Worker::Status'; + if $check and ref $retval eq 'App::Netdisco::Worker::Status'; } - catch { $self->jobstat->error($_) if $init }; + catch { $self->jobstat->error($_) if $check }; - last if $init and $self->jobstat->is_ok; + last if $check and $self->jobstat->is_ok; } }