move discover and discoverall to worker plugins

This commit is contained in:
Oliver Gorwits
2017-09-09 22:26:04 +01:00
parent c6ebb7cf07
commit 5f2da69697
20 changed files with 1150 additions and 1116 deletions

View File

@@ -0,0 +1,30 @@
package App::Netdisco::Worker::Plugin::Discover;
use Dancer ':syntax';
use App::Netdisco::Worker::Plugin;
use aliased 'App::Netdisco::Worker::Status';
use App::Netdisco::Util::Device 'is_discoverable_now';
register_worker({ primary => true }, sub {
my ($job, $workerconf) = @_;
my $device = $job->device;
return Status->error('discover failed: unable to interpret device param')
unless defined $device;
my $host = $device->ip;
return Status->error("discover failed: no device param (need -d ?)")
if $host eq '0.0.0.0';
return Status->defer("discover skipped: $host is pseudo-device")
if $device->vendor and $device->vendor eq 'netdisco';
return Status->defer("discover deferred: $host is not discoverable")
unless is_discoverable_now($device);
return Status->done('discover is able to run.');
});
true;