nodenames instead of nodeip2name

This commit is contained in:
Oliver Gorwits
2013-10-07 21:03:58 +01:00
parent fe8f3a1d99
commit 7944b8ccc3
5 changed files with 20 additions and 20 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 nodeip2name macwalk macsuck/],
Poller => [qw/discoverall discover arpwalk arpnip nodenames 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 nodeip2name macwalk macsuck/),
qw/discoverall discover arpwalk arpnip nodenames macwalk macsuck/),
(map {$_ => 'Interactive'}
qw/location contact portcontrol portname vlan power/)
};

View File

@@ -3,7 +3,7 @@ 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 is_nodeip2nameable/;
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';
@@ -33,7 +33,7 @@ after 'arpnip' => sub {
schema('netdisco')->txn_do(sub {
$jobqueue->create({
device => $device->ip,
action => 'nodeip2name',
action => 'nodenames',
status => 'queued',
username => $job->username,
userip => $job->userip,
@@ -41,8 +41,8 @@ after 'arpnip' => sub {
});
};
# run a nodeip2name job for one device
sub nodeip2name {
# run a nodenames job for one device
sub nodenames {
my ($self, $job) = @_;
my $host = NetAddr::IP::Lite->new($job->device);
@@ -50,16 +50,16 @@ sub nodeip2name {
my $jobqueue = schema('netdisco')->resultset('Admin');
if ($device->ip eq '0.0.0.0') {
return job_error("nodeip2name failed: no device param (need -d ?)");
return job_error("nodenames failed: no device param (need -d ?)");
}
unless (is_nodeip2nameable($device->ip)) {
return job_defer("nodeip2name deferred: $host is not nodeip2nameable");
unless (can_nodenames($device->ip)) {
return job_defer("nodenames deferred: $host is not nodenames");
}
resolve_node_names($device);
return job_done("Ended nodeip2name for ". $host->addr);
return job_done("Ended nodenames for ". $host->addr);
}
1;

View File

@@ -12,7 +12,7 @@ our @EXPORT_OK = qw/
check_no
is_discoverable
is_arpnipable
is_nodeip2nameable
can_nodenames
is_macsuckable
/;
our %EXPORT_TAGS = (all => \@EXPORT_OK);
@@ -196,12 +196,12 @@ sub is_arpnipable {
return 1;
}
=head2 is_nodeip2nameable( $ip )
=head2 can_nodenames( $ip )
Given an IP address, returns C<true> if Netdisco on this host is permitted by
the local configuration to resolve Node IPs to DNS names for the device.
The configuration items C<nodeip2name_no> and C<nodeip2name_only> are checked
The configuration items C<nodenames_no> and C<nodenames_only> are checked
against the given IP.
Returns false if the host is not permitted to do this job for the target
@@ -209,15 +209,15 @@ device.
=cut
sub is_nodeip2nameable {
sub can_nodenames {
my $ip = shift;
my $device = get_device($ip) or return 0;
return _bail_msg("is_nodeip2nameable: device matched nodeip2name_no")
if check_no($device, 'nodeip2name_no');
return _bail_msg("can_nodenames device matched nodenames_no")
if check_no($device, 'nodenames_no');
return _bail_msg("is_nodeip2nameable: device failed to match nodeip2name_only")
if check_no($device, 'nodeip2name_only');
return _bail_msg("can_nodenames: device failed to match nodenames_only")
if check_no($device, 'nodenames_only');
return 1;
}

View File

@@ -86,8 +86,8 @@ macsuck_min_age: 0
arpnip_no: []
arpnip_only: []
arpnip_min_age: 0
nodeip2name_no: []
nodeip2name_only: []
nodenames_no: []
nodenames_only: []
store_wireless_clients: true
store_modules: true
ignore_interfaces: