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
 | 
			
		||||
 | 
			
		||||
  [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-53-54-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-7-8-PostgreSQL.sql
 | 
			
		||||
share/schema_versions/App-Netdisco-DB-8-9-PostgreSQL.sql
 | 
			
		||||
 
 | 
			
		||||
@@ -120,7 +120,7 @@
 | 
			
		||||
   "provides" : {
 | 
			
		||||
      "App::Netdisco" : {
 | 
			
		||||
         "file" : "lib/App/Netdisco.pm",
 | 
			
		||||
         "version" : "2.042000"
 | 
			
		||||
         "version" : "2.042002"
 | 
			
		||||
      },
 | 
			
		||||
      "App::Netdisco::AnyEvent::Nbtstat" : {
 | 
			
		||||
         "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm"
 | 
			
		||||
@@ -142,7 +142,7 @@
 | 
			
		||||
      },
 | 
			
		||||
      "App::Netdisco::DB" : {
 | 
			
		||||
         "file" : "lib/App/Netdisco/DB.pm",
 | 
			
		||||
         "version" : "55"
 | 
			
		||||
         "version" : "56"
 | 
			
		||||
      },
 | 
			
		||||
      "App::Netdisco::DB::ExplicitLocking" : {
 | 
			
		||||
         "file" : "lib/App/Netdisco/DB/ExplicitLocking.pm"
 | 
			
		||||
@@ -814,6 +814,6 @@
 | 
			
		||||
      "x_IRC" : "irc://irc.freenode.org/#netdisco",
 | 
			
		||||
      "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users"
 | 
			
		||||
   },
 | 
			
		||||
   "version" : "2.042000",
 | 
			
		||||
   "version" : "2.042002",
 | 
			
		||||
   "x_serialization_backend" : "JSON::PP version 2.97001"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								META.yml
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								META.yml
									
									
									
									
									
								
							@@ -23,7 +23,7 @@ name: App-Netdisco
 | 
			
		||||
provides:
 | 
			
		||||
  App::Netdisco:
 | 
			
		||||
    file: lib/App/Netdisco.pm
 | 
			
		||||
    version: '2.042000'
 | 
			
		||||
    version: '2.042002'
 | 
			
		||||
  App::Netdisco::AnyEvent::Nbtstat:
 | 
			
		||||
    file: lib/App/Netdisco/AnyEvent/Nbtstat.pm
 | 
			
		||||
  App::Netdisco::Backend::Job:
 | 
			
		||||
@@ -38,7 +38,7 @@ provides:
 | 
			
		||||
    file: lib/App/Netdisco/Configuration.pm
 | 
			
		||||
  App::Netdisco::DB:
 | 
			
		||||
    file: lib/App/Netdisco/DB.pm
 | 
			
		||||
    version: '55'
 | 
			
		||||
    version: '56'
 | 
			
		||||
  App::Netdisco::DB::ExplicitLocking:
 | 
			
		||||
    file: lib/App/Netdisco/DB/ExplicitLocking.pm
 | 
			
		||||
  App::Netdisco::DB::Result::Admin:
 | 
			
		||||
@@ -559,5 +559,5 @@ resources:
 | 
			
		||||
  homepage: http://netdisco.org/
 | 
			
		||||
  license: http://opensource.org/licenses/BSD-3-Clause
 | 
			
		||||
  repository: https://github.com/netdisco/netdisco
 | 
			
		||||
version: '2.042000'
 | 
			
		||||
version: '2.042002'
 | 
			
		||||
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
 | 
			
		||||
 
 | 
			
		||||
@@ -181,8 +181,21 @@ sub store_arpentries {
 | 
			
		||||
 | 
			
		||||
=head1 NAME
 | 
			
		||||
 | 
			
		||||
netdisco-sshcollector - Collect ARP data for Netdisco from devices without
 | 
			
		||||
full SNMP support
 | 
			
		||||
netdisco-sshcollector - DEPRECATED!
 | 
			
		||||
 | 
			
		||||
=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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
use 5.010_000;
 | 
			
		||||
 | 
			
		||||
our $VERSION = '2.042000';
 | 
			
		||||
our $VERSION = '2.042002';
 | 
			
		||||
use App::Netdisco::Configuration;
 | 
			
		||||
 | 
			
		||||
=head1 NAME
 | 
			
		||||
 
 | 
			
		||||
@@ -81,14 +81,35 @@ sub cancel {
 | 
			
		||||
  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
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
sub finalise_status {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
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 File::ShareDir 'dist_dir';
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package App::Netdisco::Util::DeviceAuth;
 | 
			
		||||
use Dancer qw/:syntax :script/;
 | 
			
		||||
use App::Netdisco::Util::DNS 'hostname_from_ip';
 | 
			
		||||
 | 
			
		||||
use Storable 'dclone';
 | 
			
		||||
use Try::Tiny;
 | 
			
		||||
 | 
			
		||||
use base 'Exporter';
 | 
			
		||||
@@ -67,8 +68,8 @@ sub fixup_device_auth {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  # import legacy sshcollector configuration
 | 
			
		||||
  my $sshcollector = (setting('sshcollector') || []);
 | 
			
		||||
  foreach my $stanza (@$sshcollector) {
 | 
			
		||||
  my @sshcollector = @{ dclone (setting('sshcollector') || []) };
 | 
			
		||||
  foreach my $stanza (@sshcollector) {
 | 
			
		||||
    # defaults
 | 
			
		||||
    $stanza->{driver} = 'cli';
 | 
			
		||||
    $stanza->{read} = 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ ajax '/ajax/control/admin/pseudodevice/add' => require_role admin => sub {
 | 
			
		||||
          ip => param('ip'),
 | 
			
		||||
          dns => param('dns'),
 | 
			
		||||
          vendor => 'netdisco',
 | 
			
		||||
          layers => '00000100',
 | 
			
		||||
          last_discover => \'now()',
 | 
			
		||||
        });
 | 
			
		||||
      return unless $device;
 | 
			
		||||
 
 | 
			
		||||
@@ -16,13 +16,10 @@ register_worker({ phase => 'check' }, sub {
 | 
			
		||||
  return Status->error("arpnip skipped: $device not yet discovered")
 | 
			
		||||
    unless $device->in_storage;
 | 
			
		||||
 | 
			
		||||
  return Status->defer("arpnip skipped: $device is pseudo-device")
 | 
			
		||||
    if $device->is_pseudo;
 | 
			
		||||
 | 
			
		||||
  return Status->defer("arpnip skipped: $device has no layer 3 capability")
 | 
			
		||||
  return Status->info("arpnip skipped: $device has no layer 3 capability")
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
  return Status->done('arpnip is able to run');
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,9 @@ register_worker({ phase => 'store' }, sub {
 | 
			
		||||
    $device->ip, scalar @{ vars->{'v6arps'} };
 | 
			
		||||
 | 
			
		||||
  $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 {
 | 
			
		||||
@@ -53,7 +55,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
 | 
			
		||||
  push @{ vars->{'v6arps'} },
 | 
			
		||||
    @{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)
 | 
			
		||||
@@ -97,7 +99,7 @@ register_worker({ phase => 'main', driver => 'cli' }, sub {
 | 
			
		||||
    push @{ vars->{'v6arps'} },
 | 
			
		||||
      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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,9 +11,8 @@ register_worker({ phase => 'main' }, sub {
 | 
			
		||||
  my ($job, $workerconf) = @_;
 | 
			
		||||
 | 
			
		||||
  my %queued = map {$_ => 1} jq_queued('arpnip');
 | 
			
		||||
  my @devices = schema('netdisco')->resultset('Device')->search({
 | 
			
		||||
    -or => [ 'vendor' => undef, 'vendor' => { '!=' => 'netdisco' }],
 | 
			
		||||
  })->has_layer('3')->get_column('ip')->all;
 | 
			
		||||
  my @devices = schema('netdisco')->resultset('Device')
 | 
			
		||||
    ->has_layer('3')->get_column('ip')->all;
 | 
			
		||||
  my @filtered_devices = grep {!exists $queued{$_}} @devices;
 | 
			
		||||
 | 
			
		||||
  jq_insert([
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ register_worker({ phase => 'check' }, sub {
 | 
			
		||||
  return Status->error("discover failed: no device param (need -d ?)")
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
  # runner has already called get_device to promote $job->device
 | 
			
		||||
@@ -24,7 +24,7 @@ register_worker({ phase => 'check' }, sub {
 | 
			
		||||
    if $device->in_storage
 | 
			
		||||
       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);
 | 
			
		||||
 | 
			
		||||
  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")
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
  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);
 | 
			
		||||
 | 
			
		||||
  return Status->defer("macsuck deferred: $device is not macsuckable")
 | 
			
		||||
  return Status->info("macsuck skipped: $device is not macsuckable")
 | 
			
		||||
    unless is_macsuckable_now($device);
 | 
			
		||||
 | 
			
		||||
  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')
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
  return Status->done('Nbtstat is able to run.');
 | 
			
		||||
 
 | 
			
		||||
@@ -97,8 +97,9 @@ A numeric constant for the status, to allow comparison.
 | 
			
		||||
sub level {
 | 
			
		||||
  my $self = shift;
 | 
			
		||||
  return (($self->status eq 'done')  ? 4
 | 
			
		||||
        : ($self->status eq 'info')  ? 3
 | 
			
		||||
        : ($self->status eq 'defer') ? 2 : 1);
 | 
			
		||||
        : ($self->status eq 'defer') ? 3
 | 
			
		||||
        : ($self->status eq 'info')  ? 2
 | 
			
		||||
        : ($self->status eq 'error') ? 1 : 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
1;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,5 @@
 | 
			
		||||
BEGIN;
 | 
			
		||||
 | 
			
		||||
UPDATE device SET layers = '00000100' WHERE vendor = 'netdisco';
 | 
			
		||||
 | 
			
		||||
COMMIT;
 | 
			
		||||
		Reference in New Issue
	
	Block a user