Merge branch 'master' into og-api-tokens-simple
This commit is contained in:
16
Changes
16
Changes
@@ -1,3 +1,19 @@
|
|||||||
|
2.042002 - 2019-03-20
|
||||||
|
|
||||||
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
|
* allow pseudo devices to arpnip
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
* the store worker phase will return more accurate status
|
||||||
|
|
||||||
|
2.042001 - 2019-03-18
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
* Do not clobber sshcollector config
|
||||||
|
|
||||||
2.042000 - 2019-03-17
|
2.042000 - 2019-03-17
|
||||||
|
|
||||||
[NEW FEATURES]
|
[NEW FEATURES]
|
||||||
|
|||||||
1
MANIFEST
1
MANIFEST
@@ -369,6 +369,7 @@ share/schema_versions/App-Netdisco-DB-51-52-PostgreSQL.sql
|
|||||||
share/schema_versions/App-Netdisco-DB-52-53-PostgreSQL.sql
|
share/schema_versions/App-Netdisco-DB-52-53-PostgreSQL.sql
|
||||||
share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql
|
share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql
|
||||||
share/schema_versions/App-Netdisco-DB-54-55-PostgreSQL.sql
|
share/schema_versions/App-Netdisco-DB-54-55-PostgreSQL.sql
|
||||||
|
share/schema_versions/App-Netdisco-DB-55-56-PostgreSQL.sql
|
||||||
share/schema_versions/App-Netdisco-DB-6-7-PostgreSQL.sql
|
share/schema_versions/App-Netdisco-DB-6-7-PostgreSQL.sql
|
||||||
share/schema_versions/App-Netdisco-DB-7-8-PostgreSQL.sql
|
share/schema_versions/App-Netdisco-DB-7-8-PostgreSQL.sql
|
||||||
share/schema_versions/App-Netdisco-DB-8-9-PostgreSQL.sql
|
share/schema_versions/App-Netdisco-DB-8-9-PostgreSQL.sql
|
||||||
|
|||||||
@@ -120,7 +120,7 @@
|
|||||||
"provides" : {
|
"provides" : {
|
||||||
"App::Netdisco" : {
|
"App::Netdisco" : {
|
||||||
"file" : "lib/App/Netdisco.pm",
|
"file" : "lib/App/Netdisco.pm",
|
||||||
"version" : "2.042000"
|
"version" : "2.042002"
|
||||||
},
|
},
|
||||||
"App::Netdisco::AnyEvent::Nbtstat" : {
|
"App::Netdisco::AnyEvent::Nbtstat" : {
|
||||||
"file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm"
|
"file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm"
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
},
|
},
|
||||||
"App::Netdisco::DB" : {
|
"App::Netdisco::DB" : {
|
||||||
"file" : "lib/App/Netdisco/DB.pm",
|
"file" : "lib/App/Netdisco/DB.pm",
|
||||||
"version" : "55"
|
"version" : "56"
|
||||||
},
|
},
|
||||||
"App::Netdisco::DB::ExplicitLocking" : {
|
"App::Netdisco::DB::ExplicitLocking" : {
|
||||||
"file" : "lib/App/Netdisco/DB/ExplicitLocking.pm"
|
"file" : "lib/App/Netdisco/DB/ExplicitLocking.pm"
|
||||||
@@ -814,6 +814,6 @@
|
|||||||
"x_IRC" : "irc://irc.freenode.org/#netdisco",
|
"x_IRC" : "irc://irc.freenode.org/#netdisco",
|
||||||
"x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users"
|
"x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users"
|
||||||
},
|
},
|
||||||
"version" : "2.042000",
|
"version" : "2.042002",
|
||||||
"x_serialization_backend" : "JSON::PP version 2.97001"
|
"x_serialization_backend" : "JSON::PP version 2.97001"
|
||||||
}
|
}
|
||||||
|
|||||||
6
META.yml
6
META.yml
@@ -23,7 +23,7 @@ name: App-Netdisco
|
|||||||
provides:
|
provides:
|
||||||
App::Netdisco:
|
App::Netdisco:
|
||||||
file: lib/App/Netdisco.pm
|
file: lib/App/Netdisco.pm
|
||||||
version: '2.042000'
|
version: '2.042002'
|
||||||
App::Netdisco::AnyEvent::Nbtstat:
|
App::Netdisco::AnyEvent::Nbtstat:
|
||||||
file: lib/App/Netdisco/AnyEvent/Nbtstat.pm
|
file: lib/App/Netdisco/AnyEvent/Nbtstat.pm
|
||||||
App::Netdisco::Backend::Job:
|
App::Netdisco::Backend::Job:
|
||||||
@@ -38,7 +38,7 @@ provides:
|
|||||||
file: lib/App/Netdisco/Configuration.pm
|
file: lib/App/Netdisco/Configuration.pm
|
||||||
App::Netdisco::DB:
|
App::Netdisco::DB:
|
||||||
file: lib/App/Netdisco/DB.pm
|
file: lib/App/Netdisco/DB.pm
|
||||||
version: '55'
|
version: '56'
|
||||||
App::Netdisco::DB::ExplicitLocking:
|
App::Netdisco::DB::ExplicitLocking:
|
||||||
file: lib/App/Netdisco/DB/ExplicitLocking.pm
|
file: lib/App/Netdisco/DB/ExplicitLocking.pm
|
||||||
App::Netdisco::DB::Result::Admin:
|
App::Netdisco::DB::Result::Admin:
|
||||||
@@ -559,5 +559,5 @@ resources:
|
|||||||
homepage: http://netdisco.org/
|
homepage: http://netdisco.org/
|
||||||
license: http://opensource.org/licenses/BSD-3-Clause
|
license: http://opensource.org/licenses/BSD-3-Clause
|
||||||
repository: https://github.com/netdisco/netdisco
|
repository: https://github.com/netdisco/netdisco
|
||||||
version: '2.042000'
|
version: '2.042002'
|
||||||
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
|
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
|
||||||
|
|||||||
@@ -181,8 +181,21 @@ sub store_arpentries {
|
|||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
netdisco-sshcollector - Collect ARP data for Netdisco from devices without
|
netdisco-sshcollector - DEPRECATED!
|
||||||
full SNMP support
|
|
||||||
|
=head1 DEPRECATION NOTICE
|
||||||
|
|
||||||
|
The functionality of this standalone script has been incorporated into Netdisco core.
|
||||||
|
|
||||||
|
Please read the deprecation notice if you are using C<netdisco-sshcollector>:
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item *
|
||||||
|
|
||||||
|
https://github.com/netdisco/netdisco/wiki/sshcollector-Deprecation
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use 5.010_000;
|
use 5.010_000;
|
||||||
|
|
||||||
our $VERSION = '2.042000';
|
our $VERSION = '2.042002';
|
||||||
use App::Netdisco::Configuration;
|
use App::Netdisco::Configuration;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|||||||
@@ -81,14 +81,35 @@ sub cancel {
|
|||||||
return Status->error($msg);
|
return Status->error($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head2 best_status
|
||||||
|
|
||||||
|
Find the best status so far. The process is to track back from the last worker
|
||||||
|
and find the highest scoring status, skipping the check phase.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub best_status {
|
||||||
|
my $job = shift;
|
||||||
|
my $cur_level = 0;
|
||||||
|
my $cur_status = '';
|
||||||
|
|
||||||
|
foreach my $status (reverse @{ $job->_statuslist }) {
|
||||||
|
next if $status->phase
|
||||||
|
and $status->phase !~ m/^(?:early|main|store|late)$/;
|
||||||
|
|
||||||
|
if ($status->level >= $cur_level) {
|
||||||
|
$cur_level = $status->level;
|
||||||
|
$cur_status = $status->status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cur_status;
|
||||||
|
}
|
||||||
|
|
||||||
=head2 finalise_status
|
=head2 finalise_status
|
||||||
|
|
||||||
Find the best status and log it into the job's C<status> and C<log> slots.
|
Find the best status and log it into the job's C<status> and C<log> slots.
|
||||||
|
|
||||||
The process is to track back from the last worker and find the best status,
|
|
||||||
which is C<done> in early or main phases, or else any status in any non-user
|
|
||||||
phase.
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub finalise_status {
|
sub finalise_status {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
|
|||||||
);
|
);
|
||||||
|
|
||||||
our # try to hide from kwalitee
|
our # try to hide from kwalitee
|
||||||
$VERSION = 55; # schema version used for upgrades, keep as integer
|
$VERSION = 56; # schema version used for upgrades, keep as integer
|
||||||
|
|
||||||
use Path::Class;
|
use Path::Class;
|
||||||
use File::ShareDir 'dist_dir';
|
use File::ShareDir 'dist_dir';
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package App::Netdisco::Util::DeviceAuth;
|
|||||||
use Dancer qw/:syntax :script/;
|
use Dancer qw/:syntax :script/;
|
||||||
use App::Netdisco::Util::DNS 'hostname_from_ip';
|
use App::Netdisco::Util::DNS 'hostname_from_ip';
|
||||||
|
|
||||||
|
use Storable 'dclone';
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
|
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
@@ -67,8 +68,8 @@ sub fixup_device_auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# import legacy sshcollector configuration
|
# import legacy sshcollector configuration
|
||||||
my $sshcollector = (setting('sshcollector') || []);
|
my @sshcollector = @{ dclone (setting('sshcollector') || []) };
|
||||||
foreach my $stanza (@$sshcollector) {
|
foreach my $stanza (@sshcollector) {
|
||||||
# defaults
|
# defaults
|
||||||
$stanza->{driver} = 'cli';
|
$stanza->{driver} = 'cli';
|
||||||
$stanza->{read} = 1;
|
$stanza->{read} = 1;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ ajax '/ajax/control/admin/pseudodevice/add' => require_role admin => sub {
|
|||||||
ip => param('ip'),
|
ip => param('ip'),
|
||||||
dns => param('dns'),
|
dns => param('dns'),
|
||||||
vendor => 'netdisco',
|
vendor => 'netdisco',
|
||||||
|
layers => '00000100',
|
||||||
last_discover => \'now()',
|
last_discover => \'now()',
|
||||||
});
|
});
|
||||||
return unless $device;
|
return unless $device;
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ register_worker({ phase => 'check' }, sub {
|
|||||||
return Status->error("arpnip skipped: $device not yet discovered")
|
return Status->error("arpnip skipped: $device not yet discovered")
|
||||||
unless $device->in_storage;
|
unless $device->in_storage;
|
||||||
|
|
||||||
return Status->defer("arpnip skipped: $device is pseudo-device")
|
return Status->info("arpnip skipped: $device has no layer 3 capability")
|
||||||
if $device->is_pseudo;
|
|
||||||
|
|
||||||
return Status->defer("arpnip skipped: $device has no layer 3 capability")
|
|
||||||
unless $device->has_layer(3);
|
unless $device->has_layer(3);
|
||||||
|
|
||||||
return Status->defer("arpnip deferred: $device is not arpnipable")
|
return Status->info("arpnip skipped: $device is not arpnipable")
|
||||||
unless is_arpnipable_now($device);
|
unless is_arpnipable_now($device);
|
||||||
|
|
||||||
return Status->done('arpnip is able to run');
|
return Status->done('arpnip is able to run');
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ register_worker({ phase => 'store' }, sub {
|
|||||||
$device->ip, scalar @{ vars->{'v6arps'} };
|
$device->ip, scalar @{ vars->{'v6arps'} };
|
||||||
|
|
||||||
$device->update({last_arpnip => \$now});
|
$device->update({last_arpnip => \$now});
|
||||||
return Status->done("Ended arpnip for $device");
|
|
||||||
|
my $status = $job->best_status;
|
||||||
|
return Status->$status("Ended arpnip for $device");
|
||||||
});
|
});
|
||||||
|
|
||||||
register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
||||||
@@ -53,7 +55,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
push @{ vars->{'v6arps'} },
|
push @{ vars->{'v6arps'} },
|
||||||
@{get_arps_snmp($device, $snmp->ipv6_n2p_mac, $snmp->ipv6_n2p_addr) };
|
@{get_arps_snmp($device, $snmp->ipv6_n2p_mac, $snmp->ipv6_n2p_addr) };
|
||||||
|
|
||||||
return Status->info("Gathered arp caches from $device");
|
return Status->done("Gathered arp caches from $device");
|
||||||
});
|
});
|
||||||
|
|
||||||
# get an arp table (v4 or v6)
|
# get an arp table (v4 or v6)
|
||||||
@@ -97,7 +99,7 @@ register_worker({ phase => 'main', driver => 'cli' }, sub {
|
|||||||
push @{ vars->{'v6arps'} },
|
push @{ vars->{'v6arps'} },
|
||||||
grep { NetAddr::IP::Lite->new($_->{ip})->bits == 128 } @arps;
|
grep { NetAddr::IP::Lite->new($_->{ip})->bits == 128 } @arps;
|
||||||
|
|
||||||
return Status->info("Gathered arp caches from $device");
|
return Status->done("Gathered arp caches from $device");
|
||||||
});
|
});
|
||||||
|
|
||||||
sub get_arps_cli {
|
sub get_arps_cli {
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ register_worker({ phase => 'main' }, sub {
|
|||||||
my ($job, $workerconf) = @_;
|
my ($job, $workerconf) = @_;
|
||||||
|
|
||||||
my %queued = map {$_ => 1} jq_queued('arpnip');
|
my %queued = map {$_ => 1} jq_queued('arpnip');
|
||||||
my @devices = schema('netdisco')->resultset('Device')->search({
|
my @devices = schema('netdisco')->resultset('Device')
|
||||||
-or => [ 'vendor' => undef, 'vendor' => { '!=' => 'netdisco' }],
|
->has_layer('3')->get_column('ip')->all;
|
||||||
})->has_layer('3')->get_column('ip')->all;
|
|
||||||
my @filtered_devices = grep {!exists $queued{$_}} @devices;
|
my @filtered_devices = grep {!exists $queued{$_}} @devices;
|
||||||
|
|
||||||
jq_insert([
|
jq_insert([
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ register_worker({ phase => 'check' }, sub {
|
|||||||
return Status->error("discover failed: no device param (need -d ?)")
|
return Status->error("discover failed: no device param (need -d ?)")
|
||||||
if $device->ip eq '0.0.0.0';
|
if $device->ip eq '0.0.0.0';
|
||||||
|
|
||||||
return Status->defer("discover skipped: $device is pseudo-device")
|
return Status->info("discover skipped: $device is pseudo-device")
|
||||||
if $device->is_pseudo;
|
if $device->is_pseudo;
|
||||||
|
|
||||||
# runner has already called get_device to promote $job->device
|
# runner has already called get_device to promote $job->device
|
||||||
@@ -24,7 +24,7 @@ register_worker({ phase => 'check' }, sub {
|
|||||||
if $device->in_storage
|
if $device->in_storage
|
||||||
and ($job->subaction eq 'with-nodes' and not $job->username);
|
and ($job->subaction eq 'with-nodes' and not $job->username);
|
||||||
|
|
||||||
return Status->defer("discover deferred: $device is not discoverable")
|
return Status->info("discover skipped: $device is not discoverable")
|
||||||
unless is_discoverable_now($device);
|
unless is_discoverable_now($device);
|
||||||
|
|
||||||
return Status->done('Discover is able to run.');
|
return Status->done('Discover is able to run.');
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ register_worker({ phase => 'check' }, sub {
|
|||||||
return Status->error("macsuck skipped: $device not yet discovered")
|
return Status->error("macsuck skipped: $device not yet discovered")
|
||||||
unless $device->in_storage;
|
unless $device->in_storage;
|
||||||
|
|
||||||
return Status->defer("macsuck skipped: $device is pseudo-device")
|
return Status->info("macsuck skipped: $device is pseudo-device")
|
||||||
if $device->is_pseudo;
|
if $device->is_pseudo;
|
||||||
|
|
||||||
return Status->defer("macsuck skipped: $device has no layer 2 capability")
|
return Status->info("macsuck skipped: $device has no layer 2 capability")
|
||||||
unless $device->has_layer(2);
|
unless $device->has_layer(2);
|
||||||
|
|
||||||
return Status->defer("macsuck deferred: $device is not macsuckable")
|
return Status->info("macsuck skipped: $device is not macsuckable")
|
||||||
unless is_macsuckable_now($device);
|
unless is_macsuckable_now($device);
|
||||||
|
|
||||||
return Status->done('Macsuck is able to run.');
|
return Status->done('Macsuck is able to run.');
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ register_worker({ phase => 'check' }, sub {
|
|||||||
return Status->error('nbtstat failed: unable to interpret device param')
|
return Status->error('nbtstat failed: unable to interpret device param')
|
||||||
unless defined $job->device;
|
unless defined $job->device;
|
||||||
|
|
||||||
return Status->defer(sprintf 'nbtstat deferred: %s is not macsuckable', $job->device->ip)
|
return Status->info(sprintf 'nbtstat skipped: %s is not macsuckable', $job->device->ip)
|
||||||
unless is_macsuckable($job->device);
|
unless is_macsuckable($job->device);
|
||||||
|
|
||||||
return Status->done('Nbtstat is able to run.');
|
return Status->done('Nbtstat is able to run.');
|
||||||
|
|||||||
@@ -97,8 +97,9 @@ A numeric constant for the status, to allow comparison.
|
|||||||
sub level {
|
sub level {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return (($self->status eq 'done') ? 4
|
return (($self->status eq 'done') ? 4
|
||||||
: ($self->status eq 'info') ? 3
|
: ($self->status eq 'defer') ? 3
|
||||||
: ($self->status eq 'defer') ? 2 : 1);
|
: ($self->status eq 'info') ? 2
|
||||||
|
: ($self->status eq 'error') ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
UPDATE device SET layers = '00000100' WHERE vendor = 'netdisco';
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
Reference in New Issue
Block a user