introduce noop and refactor checks in all workers
This commit is contained in:
@@ -8,9 +8,14 @@ use Data::Printer ();
|
||||
use App::Netdisco::Transport::SNMP;
|
||||
|
||||
register_worker({ stage => 'check' }, sub {
|
||||
return Status->error('Missing device (-d).')
|
||||
unless defined (shift)->device;
|
||||
return Status->done('Show is able to run');
|
||||
});
|
||||
|
||||
register_worker({ stage => 'main' }, sub {
|
||||
my ($job, $workerconf) = @_;
|
||||
my ($device, $port, $extra) = map {$job->$_} qw/device port extra/;
|
||||
return Status->error('Missing device (-d).') if !defined $device;
|
||||
|
||||
$extra ||= 'interfaces'; my $class = undef;
|
||||
($class, $extra) = split(/::([^:]+)$/, $extra);
|
||||
@@ -26,7 +31,7 @@ register_worker({ stage => 'check' }, sub {
|
||||
Data::Printer::p($i->$extra);
|
||||
|
||||
return Status->done(
|
||||
sprintf "Showed %s response from %s.", $extra, $device->ip);
|
||||
sprintf "Showed %s response from %s", $extra, $device->ip);
|
||||
});
|
||||
|
||||
true;
|
||||
|
||||
Reference in New Issue
Block a user