add refresh poller job

This commit is contained in:
Oliver Gorwits
2013-04-01 20:00:36 +01:00
parent 05928e8cf6
commit ebb65996e6
2 changed files with 36 additions and 2 deletions

View File

@@ -2,13 +2,14 @@ package App::Netdisco::Daemon::Worker::Poller;
use Dancer qw/:moose :syntax :script/;
use Dancer::Plugin::DBIC 'schema';
use Try::Tiny;
use Role::Tiny;
use namespace::clean;
# add dispatch methods for poller tasks
# with 'App::Netdisco::Daemon::Worker::Poller::Discover';
with 'App::Netdisco::Daemon::Worker::Poller::Discover';
sub worker_body {
my $self = shift;
@@ -26,7 +27,6 @@ sub worker_body {
->new_result($candidate);
my $jid = $job->job;
my $target = 'set_'. $job->action;
next unless $self->can($target);
debug "poll ($wid): can ${target}() for job $jid";

View File

@@ -0,0 +1,34 @@
package App::Netdisco::Daemon::Worker::Poller::Discover;
use Dancer qw/:moose :syntax :script/;
use Dancer::Plugin::DBIC 'schema';
use App::Netdisco::Util::SNMP ':all';
use App::Netdisco::Daemon::Worker::Interactive::Util ':all';
use Role::Tiny;
use namespace::clean;
# queue a discover job for all devices known to Netdisco
sub refresh {
my ($self, $job) = @_;
my $devices = schema('netdisco')->resultset('Device')->get_column('ip');
schema('netdisco')->resultset('Admin')->populate([
map {{
device => $_,
action => 'discover',
status => 'queued',
}} ($devices->all)
]);
return done("Queued discover job for all devices");
}
sub discover {
my ($self, $job) = @_;
}
1;