move all netdisco-do action to worker plugins
This commit is contained in:
19
lib/App/Netdisco/Worker/Plugin/Delete.pm
Normal file
19
lib/App/Netdisco/Worker/Plugin/Delete.pm
Normal file
@@ -0,0 +1,19 @@
|
||||
package App::Netdisco::Worker::Plugin::Delete;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use App::Netdisco::Worker::Plugin;
|
||||
use aliased 'App::Netdisco::Worker::Status';
|
||||
|
||||
use App::Netdisco::Util::Device 'delete_device';
|
||||
|
||||
register_worker({ primary => true }, 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);
|
||||
return Status->done(sprintf "Deleted device %s.", $device->ip);
|
||||
});
|
||||
|
||||
true;
|
||||
Reference in New Issue
Block a user