async dns support

This commit is contained in:
Eric A. Miller
2013-10-15 22:55:44 -04:00
parent 325e59bade
commit 8946cf291b
10 changed files with 97 additions and 148 deletions

View File

@@ -22,7 +22,7 @@ sub capacity_for {
debug "checking local capacity for action $action";
my $action_map = {
Poller => [qw/discoverall discover arpwalk arpnip nodenames macwalk macsuck/],
Poller => [qw/discoverall discover arpwalk arpnip macwalk macsuck/],
Interactive => [qw/location contact portcontrol portname vlan power/],
};

View File

@@ -13,7 +13,7 @@ my $fqdn = hostfqdn || 'localhost';
my $role_map = {
(map {$_ => 'Poller'}
qw/discoverall discover arpwalk arpnip nodenames macwalk macsuck/),
qw/discoverall discover arpwalk arpnip macwalk macsuck/),
(map {$_ => 'Interactive'}
qw/location contact portcontrol portname vlan power/)
};

View File

@@ -1,17 +1,9 @@
package App::Netdisco::Daemon::Worker::Poller::Arpnip;
use Dancer::Plugin::DBIC 'schema';
use App::Netdisco::Core::Arpnip 'do_arpnip';
use App::Netdisco::Util::Device qw/get_device is_arpnipable can_nodenames/;
use App::Netdisco::Core::Arpnip 'resolve_node_names';
use App::Netdisco::Daemon::Util ':all';
use NetAddr::IP::Lite ':lower';
use App::Netdisco::Util::Device 'is_arpnipable';
use Role::Tiny;
use Class::Method::Modifiers;
use namespace::clean;
with 'App::Netdisco::Daemon::Worker::Poller::Common';
@@ -23,43 +15,4 @@ sub arpnip_layer { 3 }
sub arpwalk { (shift)->_walk_body('arpnip', @_) }
sub arpnip { (shift)->_single_body('arpnip', @_) }
after 'arpnip' => sub {
my ($self, $job) = @_;
my $host = NetAddr::IP::Lite->new($job->device);
my $device = get_device($host->addr);
my $jobqueue = schema('netdisco')->resultset('Admin');
schema('netdisco')->txn_do(sub {
$jobqueue->create({
device => $device->ip,
action => 'nodenames',
status => 'queued',
username => $job->username,
userip => $job->userip,
});
});
};
# run a nodenames job for one device
sub nodenames {
my ($self, $job) = @_;
my $host = NetAddr::IP::Lite->new($job->device);
my $device = get_device($host->addr);
my $jobqueue = schema('netdisco')->resultset('Admin');
if ($device->ip eq '0.0.0.0') {
return job_error("nodenames failed: no device param (need -d ?)");
}
unless (can_nodenames($device->ip)) {
return job_defer("nodenames deferred: cannot run for $host");
}
resolve_node_names($device);
return job_done("Ended nodenames for ". $host->addr);
}
1;