introduce noop and refactor checks in all workers

This commit is contained in:
Oliver Gorwits
2017-10-06 07:15:59 +01:00
parent 98463c8cad
commit 3af13f0dfe
26 changed files with 172 additions and 55 deletions

View File

@@ -7,9 +7,14 @@ use aliased 'App::Netdisco::Worker::Status';
use App::Netdisco::Util::Device 'delete_device';
register_worker({ stage => 'check' }, sub {
return Status->error('Missing device (-d).')
unless defined (shift)->device;
return Status->done('Delete 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;
$port = ($port ? 1 : 0);
delete_device($device, $port, $extra);