use run() mixin to exec action

This commit is contained in:
Oliver Gorwits
2017-09-03 19:04:20 +01:00
parent e0a666668a
commit 49b5274c33
2 changed files with 5 additions and 20 deletions

View File

@@ -105,13 +105,7 @@ unless ($action) {
use App::Netdisco::Util::Device
qw/get_device delete_device renumber_device/;
with 'App::Netdisco::Backend::Worker::Poller::Device';
with 'App::Netdisco::Backend::Worker::Poller::Arpnip';
with 'App::Netdisco::Backend::Worker::Poller::Macsuck';
with 'App::Netdisco::Backend::Worker::Poller::Nbtstat';
with 'App::Netdisco::Backend::Worker::Poller::Expiry';
with 'App::Netdisco::Backend::Worker::Interactive::DeviceActions';
with 'App::Netdisco::Backend::Worker::Interactive::PortActions';
with 'App::Netdisco::Backend::Runner';
eval { Module::Load::load 'App::Netdisco::Util::Graph' };
sub graph {
@@ -257,8 +251,7 @@ foreach my $host (@hostlist) {
try {
info sprintf '%s: %s started at %s',
$action, $actiontext, scalar localtime;
my $status = $worker->$action($job); # TODO
$status->update_job($job);
$worker->run($job);
}
catch {
$job->status('error');

View File

@@ -12,13 +12,7 @@ use Time::HiRes 'sleep';
use App::Netdisco::JobQueue qw/jq_defer jq_complete/;
# add dispatch methods for poller tasks
with 'App::Netdisco::Backend::Worker::Poller::Device',
'App::Netdisco::Backend::Worker::Poller::Arpnip',
'App::Netdisco::Backend::Worker::Poller::Macsuck',
'App::Netdisco::Backend::Worker::Poller::Nbtstat',
'App::Netdisco::Backend::Worker::Poller::Expiry',
'App::Netdisco::Backend::Worker::Interactive::DeviceActions',
'App::Netdisco::Backend::Worker::Interactive::PortActions';
with 'App::Netdisco::Backend::Runner';
sub worker_begin { (shift)->{started} = time }
@@ -31,16 +25,14 @@ sub worker_body {
my $job = $self->{queue}->dequeue(1);
next unless defined $job;
my $action = $job->action;
try {
$job->started(scalar localtime);
prctl sprintf 'nd2: #%s poll: #%s: %s',
$wid, $job->job, $job->summary;
info sprintf "pol (%s): starting %s job(%s) at %s",
$wid, $action, $job->job, $job->started;
my $status = $self->$action($job); # TODO
$status->update_job($job);
$wid, $job->action, $job->job, $job->started;
$self->run($job);
}
catch {
$job->status('error');