From 1ff34c39e6e8b6c250dd2ab9c68aa63e817bfcf5 Mon Sep 17 00:00:00 2001 From: inphobia Date: Tue, 1 Jan 2019 17:37:52 +0100 Subject: [PATCH 01/64] correct public key documentation whitespace cleanup (now passes podchecker) openssh is also required reference config file with F<> --- bin/netdisco-sshcollector | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/bin/netdisco-sshcollector b/bin/netdisco-sshcollector index 04b66052..29c0e154 100755 --- a/bin/netdisco-sshcollector +++ b/bin/netdisco-sshcollector @@ -185,7 +185,7 @@ full SNMP support # install dependencies: ~/bin/localenv cpanm --notest Net::OpenSSH Expect - + # run manually, or add to cron: ~/bin/netdisco-sshcollector [-DQO] [-w ] @@ -209,10 +209,10 @@ Currently, ARP tables can be retrieved from the following device classes: =item * L - Cisco IOS -=item * L - Cisco NXOS - =item * L - Cisco IOS XR +=item * L - Cisco NXOS + =item * L - F5 Networks BigIP =item * L - FreeBSD @@ -227,8 +227,8 @@ The collected arp entries are then directly stored in the netdisco database. =head1 CONFIGURATION -The following should go into your Netdisco 2 configuration file, "C<< -~/environments/deployment.yml >>" +The following should go into your Netdisco configuration file, +F<~/environments/deployment.yml>. =over 4 @@ -236,7 +236,7 @@ The following should go into your Netdisco 2 configuration file, "C<< Data is collected from the machines specified in this setting. The format is a list of dictionaries. The keys C, C, C, and C -are required. Optionally the C key can be used instead of the +are required. Optionally the C key can be used instead of the C. For example: sshcollector: @@ -246,14 +246,16 @@ C. For example: platform: IOS - hostname: 'core-router.example.com' user: oliver - password: letmein + password: platform: IOS Platform is the final part of the classname to be instantiated to query the host, e.g. platform B will be queried using C. -If the password is "-", public key authentication will be attempted. +If the password is blank, public key authentication will be attempted with the +default key for the netdisco user. Password protected keys are currently not +supported. =back @@ -294,7 +296,7 @@ B and B datatypes in PostgreSQL can handle. =item C<-D> -Netdisco debug log level +Netdisco debug log level. =item C<-Q> @@ -302,7 +304,7 @@ L trace enabled. =item C<-O> -L trace enabled +L trace enabled. =item C<-w> @@ -310,9 +312,8 @@ Set maximum parallel workers for L. The default is B. =item C<-d device> -Only run for a single device. Takes an IP or hostname, must exactly match the value -in the config file. - +Only run for a single device. Takes an IP or hostname, must exactly match the +value in the config file. =back @@ -326,6 +327,8 @@ in the config file. =item L +=item L + =back - + =cut From 505b7b5625c1317d361c3a8fa6ca2b655242b5e0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 2 Jan 2019 20:21:34 +0000 Subject: [PATCH 02/64] #471 fix bug in checking if there are OSPF router IDs to poll --- lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm index a12d6b3d..794eba21 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm @@ -22,8 +22,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $eigrp_peers = $snmp->eigrp_peers || {}; return Status->info(" [$device] neigh - no BGP, OSPF, or EIGRP peers") - unless ((scalar values %$ospf_peers) or (scalar values %$bgp_peers) - or (scalar values %$eigrp_peers)); + unless ((scalar values %$ospf_peers) or (scalar values %$ospf_peer_id) + or (scalar values %$bgp_peers) or (scalar values %$eigrp_peers)); my $count = 0; foreach my $ip ((values %$ospf_peers), (values %$ospf_routers), From d614382fcd1676c8f8d44724db0ad60761b59f52 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 2 Jan 2019 20:37:19 +0000 Subject: [PATCH 03/64] #436 new SQL query for neigbor map to allow mismatched/one-way links (Linwood-F) --- .../Netdisco/DB/Result/Virtual/DeviceLinks.pm | 75 +++++++++++++------ 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm index f59c315a..a503a3ae 100644 --- a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm +++ b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm @@ -15,32 +15,59 @@ __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); __PACKAGE__->table('device_links'); __PACKAGE__->result_source_instance->is_virtual(1); __PACKAGE__->result_source_instance->view_definition(< Date: Wed, 2 Jan 2019 20:54:50 +0000 Subject: [PATCH 04/64] fix to the fix for ospf_routers discovery --- lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm index 794eba21..058492ce 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm @@ -22,11 +22,11 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $eigrp_peers = $snmp->eigrp_peers || {}; return Status->info(" [$device] neigh - no BGP, OSPF, or EIGRP peers") - unless ((scalar values %$ospf_peers) or (scalar values %$ospf_peer_id) + unless ((scalar values %$ospf_peers) or (scalar values %$ospf_routers) or (scalar values %$bgp_peers) or (scalar values %$eigrp_peers)); my $count = 0; - foreach my $ip ((values %$ospf_peers), (values %$ospf_routers), + foreach my $ip ((values %$ospf_peers), (values %ospf_routers), (values %$bgp_peers), (values %$eigrp_peers)) { my $peer = get_device($ip); next if $peer->in_storage or not is_discoverable($peer); From 3769b7b66b2decefe602321ebd3787c8fa55629a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 2 Jan 2019 20:56:41 +0000 Subject: [PATCH 05/64] fix to the fix for ospf_routers discovery --- lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm index 058492ce..25934ec5 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors/Routed.pm @@ -26,7 +26,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { or (scalar values %$bgp_peers) or (scalar values %$eigrp_peers)); my $count = 0; - foreach my $ip ((values %$ospf_peers), (values %ospf_routers), + foreach my $ip ((values %$ospf_peers), (values %$ospf_routers), (values %$bgp_peers), (values %$eigrp_peers)) { my $peer = get_device($ip); next if $peer->in_storage or not is_discoverable($peer); From 5bc0afa2f5e8998f61bb3b33fb4d6e9019a25166 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 2 Jan 2019 21:44:36 +0000 Subject: [PATCH 06/64] #476 log on delete for rows from related tables --- lib/App/Netdisco/DB/ResultSet/Device.pm | 24 +++++++++++++++++++-- lib/App/Netdisco/DB/ResultSet/DevicePort.pm | 19 +++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 1d755de3..bf3eab04 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -3,7 +3,10 @@ use base 'App::Netdisco::DB::ResultSet'; use strict; use warnings; + +use Try::Tiny; use NetAddr::IP::Lite ':lower'; +require Dancer::Logger; =head1 ADDITIONAL METHODS @@ -591,12 +594,23 @@ handle the removal or archiving of nodes. =cut +sub _plural { (shift || 0) == 1 ? 'entry' : 'entries' }; + sub delete { my $self = shift; my $schema = $self->result_source->schema; my $devices = $self->search(undef, { columns => 'ip' }); + my $ip = undef; + { + no autovivification; + try { $ip ||= $devices->{attrs}->{where}->{ip} }; + try { $ip ||= $devices->{attrs}->{where}->{'me.ip'} }; + } + die "cannot find IP address in \$devices query for delete\n" + unless $ip; + foreach my $set (qw/ DeviceIp DeviceVlan @@ -604,9 +618,12 @@ sub delete { DeviceModule Community /) { - $schema->resultset($set)->search( + my $gone = $schema->resultset($set)->search( { ip => { '-in' => $devices->as_query } }, )->delete; + + Dancer::Logger::debug sprintf ' [%s] db/device - removed %d %s from %s', + $ip, $gone, _plural($gone), $set if defined Dancer::Logger::logger(); } foreach my $set (qw/ @@ -618,13 +635,16 @@ sub delete { )->delete; } - $schema->resultset('Topology')->search({ + my $gone = $schema->resultset('Topology')->search({ -or => [ { dev1 => { '-in' => $devices->as_query } }, { dev2 => { '-in' => $devices->as_query } }, ], })->delete; + Dancer::Logger::debug sprintf ' [%s] db/device - removed %d manual topology %s', + $ip, $gone, _plural($gone) if defined Dancer::Logger::logger(); + $schema->resultset('DevicePort')->search( { ip => { '-in' => $devices->as_query } }, )->delete(@_); diff --git a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm index cf0c978c..7ae80b5a 100644 --- a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm +++ b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm @@ -4,6 +4,9 @@ use base 'App::Netdisco::DB::ResultSet'; use strict; use warnings; +use Try::Tiny; +require Dancer::Logger; + __PACKAGE__->load_components(qw/ +App::Netdisco::DB::ExplicitLocking /); @@ -222,12 +225,23 @@ handle the removal or archiving of nodes. =cut +sub _plural { (shift || 0) == 1 ? 'entry' : 'entries' }; + sub delete { my $self = shift; my $schema = $self->result_source->schema; my $ports = $self->search(undef, { columns => 'ip' }); + my $ip = undef; + { + no autovivification; + try { $ip ||= ${ $ports->{attrs}->{where}->{ip}->{'-in'} }->[1]->[1] }; + try { $ip ||= $ports->{attrs}->{where}->{'me.ip'} }; + } + die "cannot find IP address in \$ports query for delete\n" + unless $ip; + foreach my $set (qw/ DevicePortPower DevicePortProperties @@ -235,9 +249,12 @@ sub delete { DevicePortWireless DevicePortSsid /) { - $schema->resultset($set)->search( + my $gone = $schema->resultset($set)->search( { ip => { '-in' => $ports->as_query }}, )->delete; + + Dancer::Logger::debug sprintf ' [%s] db/ports - removed %d port %s from %s', + $ip, $gone, _plural($gone), $set if defined Dancer::Logger::logger(); } $schema->resultset('Node')->search( From de27866077533c002dd17e6f797c8a98c3a50c0c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 2 Jan 2019 21:55:19 +0000 Subject: [PATCH 07/64] update Build.PL to include autovivification dependency --- Build.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/Build.PL b/Build.PL index 6cf49a9a..ded87058 100644 --- a/Build.PL +++ b/Build.PL @@ -17,6 +17,7 @@ Module::Build->new( }, requires => { 'aliased' => '0', + 'autovivification' => '0', 'namespace::clean' => '0.24', 'version' => '0.9902', 'Algorithm::Cron' => '0.07', From ccb0f0c78a98279457ea74b53ded656d0437a6b6 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 2 Jan 2019 22:36:59 +0000 Subject: [PATCH 08/64] #475 fix discover plugins do not respect ignore* config --- .../Worker/Plugin/Discover/Neighbors.pm | 10 ++++--- .../Worker/Plugin/Discover/PortPower.pm | 15 ++++++++--- .../Worker/Plugin/Discover/PortProperties.pm | 27 +++++++++++++++++++ .../Worker/Plugin/Discover/Properties.pm | 4 +++ .../Netdisco/Worker/Plugin/Discover/VLANs.pm | 13 +++++++-- .../Worker/Plugin/Discover/Wireless.pm | 16 +++++++++++ .../Netdisco/Worker/Plugin/Macsuck/Nodes.pm | 3 +++ 7 files changed, 80 insertions(+), 8 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index 570b951b..16ccb9a7 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -127,6 +127,10 @@ sub store_neighbors { my $c_id = $snmp->c_id; my $c_platform = $snmp->c_platform; + # cache the device ports to save hitting the database for many single rows + my $device_ports = vars->{'device_ports'} + || { map {($_->port => $_)} $device->ports->all }; + # v4 and v6 neighbor tables my $c_ip = ($snmp->c_ip || {}); my %c_ipv6 = %{ ($snmp->can('hasLLDP') and $snmp->hasLLDP) @@ -144,9 +148,9 @@ sub store_neighbors { next; } - my $port = $interfaces->{ $c_if->{$entry} }; - my $portrow = schema('netdisco')->resultset('DevicePort') - ->single({ip => $device->ip, port => $port}); + # WRT #475 this is SAFE because we check against known ports below + my $port = $interfaces->{ $c_if->{$entry} } or next; + my $portrow = $device_ports->{$port}; if (!defined $portrow) { info sprintf ' [%s] neigh - local port %s not in database!', diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm index c355224e..8fc2e34b 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm @@ -32,6 +32,10 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { }; } + # cache the device ports to save hitting the database for many single rows + my $device_ports = vars->{'device_ports'} + || { map {($_->port => $_)} $device->ports->all }; + my $interfaces = $snmp->interfaces; my $p_ifindex = $snmp->peth_port_ifindex; my $p_admin = $snmp->peth_port_admin; @@ -42,11 +46,16 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { # build device port power info suitable for DBIC my @portpower; foreach my $entry (keys %$p_ifindex) { - my $port = $interfaces->{ $p_ifindex->{$entry} }; - next unless $port; + # WRT #475 this is SAFE because we check against known ports below + my $port = $interfaces->{ $p_ifindex->{$entry} } or next; + + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] power - local port %s not in database!', + $device->ip, $port; + next; + } my ($module) = split m/\./, $entry; - push @portpower, { port => $port, module => $module, diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm index 1680feac..8693e657 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm @@ -21,10 +21,20 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $interfaces = $snmp->interfaces || {}; my %properties = (); + # cache the device ports to save hitting the database for many single rows + my $device_ports = vars->{'device_ports'} + || { map {($_->port => $_)} $device->ports->all }; + my $raw_speed = $snmp->i_speed_raw || {}; foreach my $idx (keys %$raw_speed) { my $port = $interfaces->{$idx} or next; + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] properties/speed - local port %s not in database!', + $device->ip, $port; + next; + } + $properties{ $port }->{raw_speed} = $raw_speed->{$idx}; } @@ -32,6 +42,12 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$err_cause) { my $port = $interfaces->{$idx} or next; + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] properties/errdis - local port %s not in database!', + $device->ip, $port; + next; + } + $properties{ $port }->{error_disable_cause} = $err_cause->{$idx}; } @@ -39,6 +55,12 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$faststart) { my $port = $interfaces->{$idx} or next; + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] properties/faststart - local port %s not in database!', + $device->ip, $port; + next; + } + $properties{ $port }->{faststart} = $faststart->{$idx}; } @@ -54,6 +76,11 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$c_if) { my $port = $interfaces->{ $c_if->{$idx} } or next; + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] properties/lldpcap - local port %s not in database!', + $device->ip, $port; + next; + } my $remote_cap = $c_cap->{$idx} || []; my $remote_type = Encode::decode('UTF-8', $c_platform->{$idx} || ''); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index f2537ca7..f10808fb 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -252,6 +252,10 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { $device->update_or_insert(undef, {for => 'update'}); $device->ports->populate([values %interfaces]); + # cache for later phases of the discovery + vars->{'device_ports'} = { map {($_->port => $_)} + $device->ports->search(undef, {columns => 'port'})->all }; + return Status->info(sprintf ' [%s] interfaces - added %d new interfaces', $device->ip, scalar values %interfaces); }); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm b/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm index 0445661e..f5b1d734 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm @@ -33,6 +33,10 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { }; } + # cache the device ports to save hitting the database for many single rows + my $device_ports = vars->{'device_ports'} + || { map {($_->port => $_)} $device->ports->all }; + my $i_vlan = $snmp->i_vlan; my $i_vlan_membership = $snmp->i_vlan_membership; my $i_vlan_type = $snmp->i_vlan_type; @@ -42,8 +46,13 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my @portvlans = (); foreach my $entry (keys %$i_vlan_membership) { my %port_vseen = (); - my $port = $interfaces->{$entry}; - next unless defined $port; + my $port = $interfaces->{$entry} or next; + + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] vlans - local port %s not in database!', + $device->ip, $port; + next; + } my $type = $i_vlan_type->{$entry}; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm index a86640af..b80fbc8c 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm @@ -18,6 +18,10 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $ssidlist = $snmp->i_ssidlist; return unless scalar keys %$ssidlist; + # cache the device ports to save hitting the database for many single rows + my $device_ports = vars->{'device_ports'} + || { map {($_->port => $_)} $device->ports->all }; + my $interfaces = $snmp->interfaces; my $ssidbcast = $snmp->i_ssidbcast; my $ssidmac = $snmp->i_ssidmac; @@ -36,6 +40,12 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { next; } + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] wireless - local port %s not in database!', + $device->ip, $port; + next; + } + push @ssids, { port => $port, ssid => $ssidlist->{$entry}, @@ -64,6 +74,12 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { next; } + if (!defined $device_ports->{$port}) { + info sprintf ' [%s] wireless - local port %s not in database!', + $device->ip, $port; + next; + } + push @channels, { port => $port, channel => $channel->{$entry}, diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm index b46e78a4..ba8da6e9 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm @@ -299,6 +299,8 @@ sub walk_fwtable { next; } + # WRT #475 this is SAFE because we check against known ports below + # but we do need the SNMP interface IDs to get the job done my $port = $interfaces->{$iid}; unless (defined $port) { @@ -318,6 +320,7 @@ sub walk_fwtable { # this uses the cached $ports resultset to limit hits on the db my $device_port = $device_ports->{$port}; + # WRT #475 ... see? :-) unless (defined $device_port) { debug sprintf ' [%s] macsuck %s - port %s is not in database - skipping.', From 879237ff629bd924ce26cb84f91135949ee2fcd9 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Thu, 3 Jan 2019 01:19:09 +0100 Subject: [PATCH 09/64] getting a head start on 2.040003 changes since things are moving fast, alrdy add what has been done. --- Changes | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Changes b/Changes index 358c0e9e..691f6d1c 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,20 @@ +2.040003 - xxx + + [ENHANCEMENTS] + + * #408 makerancidconf improvements readded with some additional tweaks, somehow it + got lost in 2.039029 (earendilfr, inphobia) + * #436 make neighbor matching less strict, no longer is it required to match all parameters + (port name, device name) exactly before creating a link between devices. (linwood-f) + + [BUG FIXES] + + * #475 all discover plugins should now respect ignore_interfaces, ignore_notpresent_types & + ignore_private_nets. as a bonus discovery data is now cached for less db load (ollyg) + * #476 also log when plugins delete related tables. (ollyg) + * #471 redux ospf discovery will now keep on working instead of stopping after a few runs. (ollyg) + * better explain public key auth with netdisco-sshcollector (inphobia) + 2.040002 - 2018-12-30 [BUG FIXES] From a8b88220e7e409b3cd505d4113584a9dc1839cee Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Thu, 3 Jan 2019 01:20:49 +0100 Subject: [PATCH 10/64] perhaps i can sneak my name in here too :) --- lib/App/Netdisco.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index 7904c0b0..cd04fdf5 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -312,7 +312,7 @@ of Waikato, Hamilton NZ), Dusty Hall (Auburn U), Jon Monroe (center pointe), Alexander Barthel, Bill Anderson, Alexander Hartmaier (t-systems.at), Justin Hunter (Arizona State U), Jethro Binks (U of Strathclyde, Glasgow), Jordi Guijarro (UAB.es), Sam Stickland (spacething.org), Stefan Radman (CTBTO.org), -Clint Wise, Max Kosmach, and Bernhard Augenstein. +Clint Wise, Max Kosmach, Bernhard Augenstein and Nick Nauwelaerts (aquafin.be). We probably forgot some names - sorry about that :-(. From 272901204b972d70836cf96d4e616c412c9b14e6 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Thu, 3 Jan 2019 20:45:43 +0100 Subject: [PATCH 11/64] remote stray firefox said: XML Parsing Error: mismatched tag. Expected: . Location: http://xxx/ajax/content/statistics Line Number 59, Column 17: you know what, it was right. --- share/views/ajax/statistics.tt | 1 - 1 file changed, 1 deletion(-) diff --git a/share/views/ajax/statistics.tt b/share/views/ajax/statistics.tt index 524f390d..d8bd1d3b 100644 --- a/share/views/ajax/statistics.tt +++ b/share/views/ajax/statistics.tt @@ -57,7 +57,6 @@ PostgreSQL [% stats.pg_ver | html_entity %] - Perl From 7811c321470fe9c78d102dd91eef934e9e654af2 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 3 Jan 2019 22:56:17 +0000 Subject: [PATCH 12/64] fix cached ports list which needs to be complete rows for Neighbors.pm to work --- lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index f10808fb..5f7726b2 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -253,8 +253,8 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { $device->ports->populate([values %interfaces]); # cache for later phases of the discovery - vars->{'device_ports'} = { map {($_->port => $_)} - $device->ports->search(undef, {columns => 'port'})->all }; + vars->{'device_ports'} = + { map {($_->port => $_)} $device->ports->all }; return Status->info(sprintf ' [%s] interfaces - added %d new interfaces', $device->ip, scalar values %interfaces); From 1dc3e70e37e0eadc1d3b51953d7598200b0de2a3 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 3 Jan 2019 22:59:33 +0000 Subject: [PATCH 13/64] fix to hopefully catch txrate and rate being scalar not list, as reported by inphobia --- lib/App/Netdisco/Worker/Plugin/Macsuck/WirelessNodes.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/WirelessNodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/WirelessNodes.pm index 44c7d5b5..454bc4c3 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/WirelessNodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/WirelessNodes.pm @@ -41,11 +41,11 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { next unless defined $mac; # avoid null entries # there can be more rows in txrate than other tables - my $txrate = defined $txrates->[$#$txrates] + my $txrate = (ref $txrates and defined $txrates->[$#$txrates]) ? int($txrates->[$#$txrates]) : undef; - my $maxrate = defined $rates->[$#$rates] + my $maxrate = (ref $rates and defined $rates->[$#$rates]) ? int($rates->[$#$rates]) : undef; From b3f6ffe0d7a0b1197f26ee19c0c4206b17bab97b Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 3 Jan 2019 23:12:52 +0000 Subject: [PATCH 14/64] #424 column name is "Connected Nodes & Devices" when both are shown --- share/views/ajax/device/ports.tt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/share/views/ajax/device/ports.tt b/share/views/ajax/device/ports.tt index afd86b4f..1c4a3be9 100644 --- a/share/views/ajax/device/ports.tt +++ b/share/views/ajax/device/ports.tt @@ -12,7 +12,15 @@ [% th_class = ' class="portsort"' %] [% END %] + [% IF item.name == 'c_neighbors' %] + [% IF params.c_nodes %] + Connected Nodes & Devices + [% ELSE %] + Connected Devices + [% END %] + [% ELSE %] [% item.label | html_entity %] + [% END %] [% END %] From 23a87f19fdb224a59d71aa9a6f03acc180ebb3f4 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 3 Jan 2019 23:29:14 +0000 Subject: [PATCH 15/64] be less strict about finding the IP for logging --- lib/App/Netdisco/DB/ResultSet/Device.pm | 3 +-- lib/App/Netdisco/DB/ResultSet/DevicePort.pm | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index bf3eab04..27e6defc 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -608,8 +608,7 @@ sub delete { try { $ip ||= $devices->{attrs}->{where}->{ip} }; try { $ip ||= $devices->{attrs}->{where}->{'me.ip'} }; } - die "cannot find IP address in \$devices query for delete\n" - unless $ip; + $ip ||= 'netdisco'; foreach my $set (qw/ DeviceIp diff --git a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm index 7ae80b5a..3ae4f80f 100644 --- a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm +++ b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm @@ -239,8 +239,7 @@ sub delete { try { $ip ||= ${ $ports->{attrs}->{where}->{ip}->{'-in'} }->[1]->[1] }; try { $ip ||= $ports->{attrs}->{where}->{'me.ip'} }; } - die "cannot find IP address in \$ports query for delete\n" - unless $ip; + $ip ||= 'netdisco'; foreach my $set (qw/ DevicePortPower From 7f1074ff842dde23a59c53017bef38ccb5ddc89a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 7 Jan 2019 22:47:13 +0000 Subject: [PATCH 16/64] #479 attempt better cache control for device ports --- lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm | 10 ++++++---- lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index 16ccb9a7..ce5c8f47 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -114,6 +114,7 @@ sub store_neighbors { or return (); # already checked! # first allow any manually configured topology to be set + # and do this before we cache the rows in vars->{'device_ports'} set_manual_topology($device); if (!defined $snmp->has_topo) { @@ -128,8 +129,9 @@ sub store_neighbors { my $c_platform = $snmp->c_platform; # cache the device ports to save hitting the database for many single rows - my $device_ports = vars->{'device_ports'} - || { map {($_->port => $_)} $device->ports->all }; + vars->{'device_ports'} = + { map {($_->port => $_)} $device->ports->reset->all }; + my $device_ports = vars->{'device_ports'}; # v4 and v6 neighbor tables my $c_ip = ($snmp->c_ip || {}); @@ -256,14 +258,14 @@ sub store_neighbors { $device->ip, $port, $remote_ip; } - $portrow->update({ + $portrow = $portrow->update({ remote_ip => $remote_ip, remote_port => $remote_port, remote_type => $remote_type, remote_id => $remote_id, is_uplink => \"true", manual_topo => \"false", - }); + })->discard_changes(); # update master of our aggregate to be a neighbor of # the master on our peer device (a lot of iffs to get there...). diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index 5f7726b2..f2537ca7 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -252,10 +252,6 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { $device->update_or_insert(undef, {for => 'update'}); $device->ports->populate([values %interfaces]); - # cache for later phases of the discovery - vars->{'device_ports'} = - { map {($_->port => $_)} $device->ports->all }; - return Status->info(sprintf ' [%s] interfaces - added %d new interfaces', $device->ip, scalar values %interfaces); }); From 1b2592321d524b3ba68535a9fe7f51ffc9d6e3fb Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 7 Jan 2019 22:51:05 +0000 Subject: [PATCH 17/64] address https://metacpan.org/pod/distribution/perl/pod/perldelta.pod#Removal-of-use-vars --- lib/App/Netdisco/Web/GenericReport.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Web/GenericReport.pm b/lib/App/Netdisco/Web/GenericReport.pm index 800fa2ef..6e2f5855 100644 --- a/lib/App/Netdisco/Web/GenericReport.pm +++ b/lib/App/Netdisco/Web/GenericReport.pm @@ -9,7 +9,7 @@ use App::Netdisco::Web::Plugin; use Path::Class 'file'; use Safe; -use vars qw/$config @data/; +our ($config, @data); foreach my $report (@{setting('reports')}) { my $r = $report->{tag}; From 98a5e2c4079e2bb3ea4dbfa9668e8387ce0c7c78 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Tue, 8 Jan 2019 01:50:21 +0100 Subject: [PATCH 18/64] #479 part 2, use debug logging instead of info (#480) #479 part 2, use debug instead of info logging. 2 whitespace cleanups also included, as well as rewording props -> properties like in the rest of portproperties.pm --- .../Worker/Plugin/Discover/Neighbors.pm | 18 +++++++++--------- .../Worker/Plugin/Discover/PortPower.pm | 2 +- .../Worker/Plugin/Discover/PortProperties.pm | 12 ++++++------ .../Worker/Plugin/Discover/Properties.pm | 4 ++-- .../Netdisco/Worker/Plugin/Discover/VLANs.pm | 2 +- .../Worker/Plugin/Discover/Wireless.pm | 4 ++-- .../Netdisco/Worker/Plugin/Macsuck/Nodes.pm | 1 - lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm | 1 - 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index ce5c8f47..6a64b8ee 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -155,7 +155,7 @@ sub store_neighbors { my $portrow = $device_ports->{$port}; if (!defined $portrow) { - info sprintf ' [%s] neigh - local port %s not in database!', + debug sprintf ' [%s] neigh - local port %s already skipped, ignoring', $device->ip, $port; next; } @@ -167,7 +167,7 @@ sub store_neighbors { } if ($portrow->manual_topo) { - info sprintf ' [%s] neigh - %s has manually defined topology', + debug sprintf ' [%s] neigh - %s has manually defined topology', $device->ip, $port; next; } @@ -181,7 +181,7 @@ sub store_neighbors { my $r_netaddr = NetAddr::IP::Lite->new($remote_ip); if ($r_netaddr and ($r_netaddr->addr ne $remote_ip)) { - info sprintf ' [%s] neigh - IP on %s: using %s as canonical form of %s', + debug sprintf ' [%s] neigh - IP on %s: using %s as canonical form of %s', $device->ip, $port, $r_netaddr->addr, $remote_ip; $remote_ip = $r_netaddr->addr; } @@ -195,7 +195,7 @@ sub store_neighbors { if ($remote_id) { my $devices = schema('netdisco')->resultset('Device'); my $neigh = $devices->single({name => $remote_id}); - info sprintf + debug sprintf ' [%s] neigh - bad address %s on port %s, searching for %s instead', $device->ip, $remote_ip, $port, $remote_id; @@ -213,7 +213,7 @@ sub store_neighbors { (my $tmpid = $remote_id) =~ s/.*\(([0-9a-f]{6})-([0-9a-f]{6})\).*/$1$2/; my $mac = NetAddr::MAC->new(mac => $tmpid); if ($mac and not $mac->errstr) { - info sprintf + debug sprintf ' [%s] neigh - trying to find neighbor %s by MAC %s', $device->ip, $remote_id, $mac->as_ieee; $neigh = $devices->single({mac => $mac->as_ieee}); @@ -227,17 +227,17 @@ sub store_neighbors { if ($neigh) { $remote_ip = $neigh->ip; - info sprintf ' [%s] neigh - found %s with IP %s', + debug sprintf ' [%s] neigh - found %s with IP %s', $device->ip, $remote_id, $remote_ip; } else { - info sprintf ' [%s] neigh - could not find %s, skipping', + debug sprintf ' [%s] neigh - could not find %s, skipping', $device->ip, $remote_id; next; } } else { - info sprintf ' [%s] neigh - skipping unuseable address %s on port %s', + debug sprintf ' [%s] neigh - skipping unuseable address %s on port %s', $device->ip, $remote_ip, $port; next; } @@ -254,7 +254,7 @@ sub store_neighbors { $remote_port =~ s/[^\d\s\/\.,()\w:-]+//gi; } else { - info sprintf ' [%s] neigh - no remote port found for port %s at %s', + debug sprintf ' [%s] neigh - no remote port found for port %s at %s', $device->ip, $port, $remote_ip; } diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm index 8fc2e34b..59a9d81b 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortPower.pm @@ -50,7 +50,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $port = $interfaces->{ $p_ifindex->{$entry} } or next; if (!defined $device_ports->{$port}) { - info sprintf ' [%s] power - local port %s not in database!', + debug sprintf ' [%s] power - local port %s already skipped, ignoring', $device->ip, $port; next; } diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm index 8693e657..108d8046 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm @@ -30,7 +30,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$raw_speed) { my $port = $interfaces->{$idx} or next; if (!defined $device_ports->{$port}) { - info sprintf ' [%s] properties/speed - local port %s not in database!', + debug sprintf ' [%s] properties/speed - local port %s already skipped, ignoring', $device->ip, $port; next; } @@ -43,7 +43,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$err_cause) { my $port = $interfaces->{$idx} or next; if (!defined $device_ports->{$port}) { - info sprintf ' [%s] properties/errdis - local port %s not in database!', + debug sprintf ' [%s] properties/errdis - local port %s already skipped, ignoring', $device->ip, $port; next; } @@ -56,7 +56,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$faststart) { my $port = $interfaces->{$idx} or next; if (!defined $device_ports->{$port}) { - info sprintf ' [%s] properties/faststart - local port %s not in database!', + debug sprintf ' [%s] properties/faststart - local port %s already skipped, ignoring', $device->ip, $port; next; } @@ -77,7 +77,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { foreach my $idx (keys %$c_if) { my $port = $interfaces->{ $c_if->{$idx} } or next; if (!defined $device_ports->{$port}) { - info sprintf ' [%s] properties/lldpcap - local port %s not in database!', + debug sprintf ' [%s] properties/lldpcap - local port %s already skipped, ignoring', $device->ip, $port; next; } @@ -106,12 +106,12 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { schema('netdisco')->txn_do(sub { my $gone = $device->properties_ports->delete; - debug sprintf ' [%s] props - removed %d ports with properties', + debug sprintf ' [%s] properties - removed %d ports with properties', $device->ip, $gone; $device->properties_ports->populate( [map {{ port => $_, %{ $properties{$_} } }} keys %properties] ); - return Status->info(sprintf ' [%s] props - added %d new port properties', + return Status->info(sprintf ' [%s] properties - added %d new port properties', $device->ip, scalar keys %properties); }); }); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index f2537ca7..63240c3d 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -151,7 +151,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { if (defined $snmp->snmpEngineTime) { $dev_uptime_wrapped = int( $snmp->snmpEngineTime * 100 / 2**32 ); if ($dev_uptime_wrapped > 0) { - info sprintf ' [%s] interface - device uptime wrapped %d times - correcting', + debug sprintf ' [%s] interfaces - device uptime wrapped %d times - correcting', $device->ip, $dev_uptime_wrapped; $device->uptime( $dev_uptime + $dev_uptime_wrapped * 2**32 ); } @@ -190,7 +190,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { my $lc = $i_lastchange->{$entry} || 0; if (not $dev_uptime_wrapped and $lc > $dev_uptime) { - info sprintf ' [%s] interfaces - device uptime wrapped (%s) - correcting', + debug sprintf ' [%s] interfaces - device uptime wrapped (%s) - correcting', $device->ip, $port; $device->uptime( $dev_uptime + 2**32 ); $dev_uptime_wrapped = 1; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm b/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm index f5b1d734..70bf26d2 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/VLANs.pm @@ -49,7 +49,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $port = $interfaces->{$entry} or next; if (!defined $device_ports->{$port}) { - info sprintf ' [%s] vlans - local port %s not in database!', + debug sprintf ' [%s] vlans - local port %s already skipped, ignoring', $device->ip, $port; next; } diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm index b80fbc8c..153b736e 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Wireless.pm @@ -41,7 +41,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { } if (!defined $device_ports->{$port}) { - info sprintf ' [%s] wireless - local port %s not in database!', + debug sprintf ' [%s] wireless - local port %s already skipped, ignoring', $device->ip, $port; next; } @@ -75,7 +75,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { } if (!defined $device_ports->{$port}) { - info sprintf ' [%s] wireless - local port %s not in database!', + debug sprintf ' [%s] wireless - local port %s already skipped, ignoring', $device->ip, $port; next; } diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm index ba8da6e9..0b150d1c 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm @@ -248,7 +248,6 @@ sub get_vlan_list { # check in use by a port on this device if (!$vlans{$vlan} && !setting('macsuck_all_vlans')) { - debug sprintf ' [%s] macsuck VLAN %s/%s - not in use by any port - skipping.', $device->ip, $vlan, $name; diff --git a/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm b/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm index 7b12ebea..5ccfaa2b 100644 --- a/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm +++ b/lib/App/Netdisco/Worker/Plugin/Nbtstat/Core.pm @@ -47,4 +47,3 @@ register_worker({ phase => 'main' }, sub { }); true; - From 40df018ead5bd6f59606b3ef47095e44e361d095 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Tue, 8 Jan 2019 21:53:17 +0100 Subject: [PATCH 19/64] also make os a link in device details (#482) --- share/views/ajax/device/details.tt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/share/views/ajax/device/details.tt b/share/views/ajax/device/details.tt index 6e6e611b..95720225 100644 --- a/share/views/ajax/device/details.tt +++ b/share/views/ajax/device/details.tt @@ -50,10 +50,12 @@ OS / Version - [% d.os | html_entity %] / - [% d.os_ver | html_entity %] + + [% d.os | html_entity %] + / + [% d.os_ver | html_entity %] From 8f952ce2e3442f5cda4398af08e51a2d1479e5c1 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Tue, 8 Jan 2019 21:53:46 +0100 Subject: [PATCH 20/64] option to fix #457 (#481) * move things to debug logging instead of info * use message which was discussed * fix for address table sorting --- share/views/ajax/device/addresses.tt | 2 +- share/views/ajax/report/apclients.tt | 4 ++-- share/views/ajax/report/apradiochannelpower.tt | 4 ++-- share/views/ajax/report/duplexmismatch.tt | 8 ++++---- share/views/ajax/report/halfduplex.tt | 4 ++-- share/views/ajax/report/nodesdiscovered.tt | 4 ++-- share/views/ajax/report/portadmindown.tt | 4 ++-- share/views/ajax/report/portblocking.tt | 4 ++-- share/views/ajax/report/portmultinodes.tt | 4 ++-- share/views/ajax/report/portvlanmismatch.tt | 12 ++++++------ 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/share/views/ajax/device/addresses.tt b/share/views/ajax/device/addresses.tt index 448bc385..9ab40efc 100644 --- a/share/views/ajax/device/addresses.tt +++ b/share/views/ajax/device/addresses.tt @@ -32,7 +32,7 @@ $(document).ready(function() { "render": function(data, type, row, meta) { return type === 'display' ? '' + he.encode(data || '') + '' : - data; + he.encode(data || ''); } }, { "data": 'name', diff --git a/share/views/ajax/report/apclients.tt b/share/views/ajax/report/apclients.tt index c3fc8cd3..bcfef160 100644 --- a/share/views/ajax/report/apclients.tt +++ b/share/views/ajax/report/apclients.tt @@ -41,8 +41,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'ssid', diff --git a/share/views/ajax/report/apradiochannelpower.tt b/share/views/ajax/report/apradiochannelpower.tt index 3a283562..6faf2299 100644 --- a/share/views/ajax/report/apradiochannelpower.tt +++ b/share/views/ajax/report/apradiochannelpower.tt @@ -59,8 +59,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'port_name', diff --git a/share/views/ajax/report/duplexmismatch.tt b/share/views/ajax/report/duplexmismatch.tt index 17548fc3..7d36bfd2 100644 --- a/share/views/ajax/report/duplexmismatch.tt +++ b/share/views/ajax/report/duplexmismatch.tt @@ -27,8 +27,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'left_duplex', @@ -45,8 +45,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'right_duplex', diff --git a/share/views/ajax/report/halfduplex.tt b/share/views/ajax/report/halfduplex.tt index 4427ce99..8816d758 100644 --- a/share/views/ajax/report/halfduplex.tt +++ b/share/views/ajax/report/halfduplex.tt @@ -25,8 +25,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'name', diff --git a/share/views/ajax/report/nodesdiscovered.tt b/share/views/ajax/report/nodesdiscovered.tt index 98db813e..841d17f2 100644 --- a/share/views/ajax/report/nodesdiscovered.tt +++ b/share/views/ajax/report/nodesdiscovered.tt @@ -27,8 +27,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'remote_id', diff --git a/share/views/ajax/report/portadmindown.tt b/share/views/ajax/report/portadmindown.tt index 9a8c516c..207be63a 100644 --- a/share/views/ajax/report/portadmindown.tt +++ b/share/views/ajax/report/portadmindown.tt @@ -25,8 +25,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'description', diff --git a/share/views/ajax/report/portblocking.tt b/share/views/ajax/report/portblocking.tt index 5ff08dc9..7632eb3d 100644 --- a/share/views/ajax/report/portblocking.tt +++ b/share/views/ajax/report/portblocking.tt @@ -26,8 +26,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'description', diff --git a/share/views/ajax/report/portmultinodes.tt b/share/views/ajax/report/portmultinodes.tt index 8b45c411..30ccb6ad 100644 --- a/share/views/ajax/report/portmultinodes.tt +++ b/share/views/ajax/report/portmultinodes.tt @@ -26,8 +26,8 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'description', diff --git a/share/views/ajax/report/portvlanmismatch.tt b/share/views/ajax/report/portvlanmismatch.tt index 6f276177..80a17501 100644 --- a/share/views/ajax/report/portvlanmismatch.tt +++ b/share/views/ajax/report/portvlanmismatch.tt @@ -20,27 +20,27 @@ $(document).ready(function() { { "data": 'left_device', "render": function(data, type, row, meta) { - return '' + he.encode(data) + ''; } + return '' + he.encode(data || '') + ''; } }, { "data": 'left_port', "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; } + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'left_vlans' }, { "data": 'right_device', "render": function(data, type, row, meta) { - return '' + he.encode(data) + ''; } + return '' + he.encode(data || '') + ''; } }, { "data": 'right_port', "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : - data; } + '' + he.encode(data || '') + '' : + he.encode(data || ''); } }, { "data": 'right_vlans' } From cf93219b429cb93c2cf91589f4ce03be452159de Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 8 Jan 2019 21:19:08 +0000 Subject: [PATCH 21/64] #420 change to better column name --- share/views/ajax/report/ipinventory.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/views/ajax/report/ipinventory.tt b/share/views/ajax/report/ipinventory.tt index 7ff4a98f..bf48181f 100644 --- a/share/views/ajax/report/ipinventory.tt +++ b/share/views/ajax/report/ipinventory.tt @@ -1,7 +1,7 @@ - + From 562d525b78e7a1b7bce08f4d9ef1eeef75918d21 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 8 Jan 2019 21:27:15 +0000 Subject: [PATCH 22/64] #420 allow sidebar default to be overridden --- share/views/sidebar/report/ipinventory.tt | 2 +- share/views/sidebar/report/moduleinventory.tt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/views/sidebar/report/ipinventory.tt b/share/views/sidebar/report/ipinventory.tt index c5c01e25..b8ddb524 100644 --- a/share/views/sidebar/report/ipinventory.tt +++ b/share/views/sidebar/report/ipinventory.tt @@ -46,7 +46,7 @@ rel="tooltip" data-placement="left" data-offset="5" data-title="Applies to IPv4 Only">
NodeIP Address MAC Address DNS Last Used
+ + + + + + +
VLAN IDVLAN Name
+ + diff --git a/share/views/ajax/device/vlans_csv.tt b/share/views/ajax/device/vlans_csv.tt new file mode 100644 index 00000000..51bb160c --- /dev/null +++ b/share/views/ajax/device/vlans_csv.tt @@ -0,0 +1,10 @@ +[% USE CSV -%] +[% CSV.dump([ 'VLAN ID' 'VLAN Name' ]) %] + +[% FOREACH row IN results %] + [% mylist = [] %] + [% mylist.push(row.vlan) %] + [% mylist.push(row.description) %] + [% CSV.dump(mylist) %] + +[% END %] diff --git a/share/views/ajax/search/port.tt b/share/views/ajax/search/port.tt index 25c1a1cc..99635b8d 100644 --- a/share/views/ajax/search/port.tt +++ b/share/views/ajax/search/port.tt @@ -4,7 +4,7 @@ Status Name Port - Vlan + VLAN Speed Last Change diff --git a/share/views/ajax/search/port_csv.tt b/share/views/ajax/search/port_csv.tt index e9aa5db8..5ac669ee 100644 --- a/share/views/ajax/search/port_csv.tt +++ b/share/views/ajax/search/port_csv.tt @@ -1,5 +1,5 @@ [% USE CSV -%] -[% CSV.dump([ 'Name' 'Port' 'Description' 'Vlan' ]) %] +[% CSV.dump([ 'Name' 'Port' 'Description' 'VLAN' ]) %] [% FOREACH row IN results %] [% mylist = [] %] diff --git a/share/views/ajax/search/vlan.tt b/share/views/ajax/search/vlan.tt index aa75ce85..aa81060d 100644 --- a/share/views/ajax/search/vlan.tt +++ b/share/views/ajax/search/vlan.tt @@ -1,7 +1,7 @@ - + diff --git a/share/views/ajax/search/vlan_csv.tt b/share/views/ajax/search/vlan_csv.tt index 1d095856..82b0e33e 100644 --- a/share/views/ajax/search/vlan_csv.tt +++ b/share/views/ajax/search/vlan_csv.tt @@ -1,5 +1,5 @@ [% USE CSV -%] -[% CSV.dump([ 'Vlan' 'Device' 'Description' 'Model' 'OS' 'Vendor' ]) %] +[% CSV.dump([ 'VLAN' 'Device' 'Description' 'Model' 'OS' 'Vendor' ]) %] [% FOREACH row IN results %] [% mylist = [] %] From 89b8f8c0ce6f6d71acc1e191a4381d2ad8aeb523 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Mon, 14 Jan 2019 23:02:08 +0100 Subject: [PATCH 26/64] allow snmp::info base class in netdisco-do (#486) * allow the use of base snmp::info * dont use . * should have been: dont use $_ * also document some extra features * reword --- bin/netdisco-do | 20 ++++++++++++++++++-- lib/App/Netdisco/Worker/Plugin/Show.pm | 15 ++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/bin/netdisco-do b/bin/netdisco-do index a720361b..9396f61f 100755 --- a/bin/netdisco-do +++ b/bin/netdisco-do @@ -301,14 +301,30 @@ the leaf (such as C or C). If you wish to test with a device class other than that discovered, prefix the leaf with the class short name, for example "C" or -"C". +"C". Using "C<::>" as the start of the prefix will test +against the base "C" class. + +As well, SNMP object names can be used as an argument for "C<-e>", so you can +use C for example, which will use the netdisco-mibs files for +translations. + +All "C<-e>" parameters are case sensitive. ~/bin/netdisco-do show -d 192.0.2.1 -e interfaces ~/bin/netdisco-do show -d 192.0.2.1 -e Layer2::HP::interfaces + ~/bin/netdisco-do show -d 192.0.2.1 -e ::interfaces + ~/bin/netdisco-do show -d 192.0.2.1 -e ifName -A parameter may be passed to the C method in the C<-p> parameter: +A parameter may be passed to the C method or SNMP object in the +"C<-p>" parameter: ~/bin/netdisco-do show -d 192.0.2.1 -e has_layer -p 3 + ~/bin/netdisco-do show -d 192.0.2.1 -e ifName -p 2 + +The "C<-e>" parameter C will show the used configuration for the +specified device. + + ~/bin/netdisco-do show -d 192.0.2.1 -e specify =head2 psql diff --git a/lib/App/Netdisco/Worker/Plugin/Show.pm b/lib/App/Netdisco/Worker/Plugin/Show.pm index 52a2ca55..6ec90b90 100644 --- a/lib/App/Netdisco/Worker/Plugin/Show.pm +++ b/lib/App/Netdisco/Worker/Plugin/Show.pm @@ -18,13 +18,14 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my ($device, $port, $extra) = map {$job->$_} qw/device port extra/; $extra ||= 'interfaces'; my $class = undef; - ($class, $extra) = split(/::([^:]+)$/, $extra); - if ($class and $extra) { - $class = 'SNMP::Info::'.$class; - } - else { - $extra = $class; - undef $class; + my @values = split /::/, $extra; + $extra = pop @values; + if (scalar(@values)) { + $class = "SNMP::Info"; + foreach my $v (@values) { + last if ($v eq ''); + $class = $class.'::'.$v; + } } my $i = App::Netdisco::Transport::SNMP->reader_for($device, $class); From 6c617a3d55880546723189ee608d2423d25873a4 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 18 Jan 2019 07:08:47 +0000 Subject: [PATCH 27/64] release 2.040003 --- Changes | 31 +++++++++++++++++-------------- META.json | 8 ++++++-- META.yml | 7 +++++-- lib/App/Netdisco.pm | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Changes b/Changes index 26f0100d..708c7b09 100644 --- a/Changes +++ b/Changes @@ -1,26 +1,29 @@ -2.040003 - xxx +2.040003 - 2019-01-18 [NEW FEATURES] - * #482 operating system is now a link in device details (inphobia) + * #485 new "VLANs" device tab showing a VLAN report (inphobia) [ENHANCEMENTS] - * #408, #417 & 477 makerancidconf improvements: readded with some additional tweaks, somehow - they got lost in 2.039029. (earendilfr, inphobia) - * #436 make neighbor matching less strict, no longer is it required to match all parameters - (port name, device name) exactly before creating a link between devices. (linwood-f) + * #408, #417 & 477 makerancidconf improvements re-added (earendilfr, inphobia) + * #420 IP Inventory Node column renamed to IP Address (ollyg) + * #420 sidebar defaults for IP Inventory report can be overridden (ollyg) + * #424 column name is "Connected Nodes & Devices" when both are shown (ollyg) + * #436 make neighbor matching less strict in netmap (linwood-f) + * #482 operating system is now a link in device details (inphobia) + * #486 allow snmp::info base class in netdisco-do (inphobia) [BUG FIXES] - * #475 all discover plugins should now respect ignore_interfaces, ignore_notpresent_types & - ignore_private_nets. as a bonus discovery data is now cached for less db load. (ollyg) - * #476 also log when plugins delete related tables. (ollyg) - * #471-redux ospf discovery will now keep on working instead of stopping after a few - runs. (ollyg) - * #474 better explain public key auth with netdisco-sshcollector. (inphobia) - * #457 make sorting work on interface in device/adresses when interface was undefined. also - went through all other portsort callers to make sure parameters are always defined. (inphobia) + * #457 make sorting work for adresses when interface was undefined (inphobia) + * #471-redux ospf discovery will now keep on working (ollyg) + * #474 better explain public key auth with netdisco-sshcollector (inphobia) + * #475, #479 all discover plugins should now respect ignore_* for interfaces (ollyg) + * #476 debug log when deleting rows from related tables (ollyg) + * Fix to catch when txrate on wifi is scalar and not a list + * Remove 'use vars' which is deprecated in Perl + * Various documentation improvements (inphobia) 2.040002 - 2018-12-30 diff --git a/META.json b/META.json index e58fa24c..d25d2b90 100644 --- a/META.json +++ b/META.json @@ -102,6 +102,7 @@ "YAML" : "0.84", "YAML::XS" : "0.41", "aliased" : "0", + "autovivification" : "0", "namespace::clean" : "0.24", "version" : "0.9902" } @@ -117,7 +118,7 @@ "provides" : { "App::Netdisco" : { "file" : "lib/App/Netdisco.pm", - "version" : "2.040002" + "version" : "2.040003" }, "App::Netdisco::AnyEvent::Nbtstat" : { "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" @@ -531,6 +532,9 @@ "App::Netdisco::Web::Plugin::Device::Ports" : { "file" : "lib/App/Netdisco/Web/Plugin/Device/Ports.pm" }, + "App::Netdisco::Web::Plugin::Device::Vlans" : { + "file" : "lib/App/Netdisco/Web/Plugin/Device/Vlans.pm" + }, "App::Netdisco::Web::Plugin::Inventory" : { "file" : "lib/App/Netdisco/Web/Plugin/Inventory.pm" }, @@ -796,6 +800,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, - "version" : "2.040002", + "version" : "2.040003", "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index 190948b6..42d85541 100644 --- a/META.yml +++ b/META.yml @@ -22,7 +22,7 @@ name: App-Netdisco provides: App::Netdisco: file: lib/App/Netdisco.pm - version: '2.040002' + version: '2.040003' App::Netdisco::AnyEvent::Nbtstat: file: lib/App/Netdisco/AnyEvent/Nbtstat.pm App::Netdisco::Backend::Job: @@ -298,6 +298,8 @@ provides: file: lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm App::Netdisco::Web::Plugin::Device::Ports: file: lib/App/Netdisco/Web/Plugin/Device/Ports.pm + App::Netdisco::Web::Plugin::Device::Vlans: + file: lib/App/Netdisco/Web/Plugin/Device/Vlans.pm App::Netdisco::Web::Plugin::Inventory: file: lib/App/Netdisco/Web/Plugin/Inventory.pm App::Netdisco::Web::Plugin::Report::ApChannelDist: @@ -537,6 +539,7 @@ requires: YAML: '0.84' YAML::XS: '0.41' aliased: '0' + autovivification: '0' namespace::clean: '0.24' version: '0.9902' resources: @@ -546,5 +549,5 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/netdisco/netdisco -version: '2.040002' +version: '2.040003' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index cd04fdf5..d88cdab0 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010_000; -our $VERSION = '2.040002'; +our $VERSION = '2.040003'; use App::Netdisco::Configuration; =head1 NAME From e6d087ef5f1f132bf131f65db39ee9747f1f0d87 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Thu, 24 Jan 2019 15:12:06 +0100 Subject: [PATCH 28/64] fix for #491 (untested) (#492) * move things to debug logging instead of info * use message which was discussed * merge master * fix for #491. also use doublequotes in sprintf in portcontrol.pm line 59, else $device will not be printed --- lib/App/Netdisco/Worker/Plugin/PortControl.pm | 8 ++++---- lib/App/Netdisco/Worker/Plugin/Power.pm | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/PortControl.pm b/lib/App/Netdisco/Worker/Plugin/PortControl.pm index f767a874..a2607c9a 100644 --- a/lib/App/Netdisco/Worker/Plugin/PortControl.pm +++ b/lib/App/Netdisco/Worker/Plugin/PortControl.pm @@ -17,9 +17,9 @@ register_worker({ phase => 'check' }, sub { or return Status->error(sprintf "Unknown port name [%s] on device %s", $job->port, $job->device); - my $vlan_reconfig_check = vlan_reconfig_check(vars->{'port'}); - return Status->error("Cannot alter vlan: $vlan_reconfig_check") - if $vlan_reconfig_check; + my $port_reconfig_check = port_reconfig_check(vars->{'port'}); + return Status->error("Cannot alter port: $port_reconfig_check") + if $port_reconfig_check; return Status->done('PortControl is able to run'); }); @@ -56,7 +56,7 @@ sub _action { my $rv = $snmp->set_i_up_admin($data, $iid); if (!defined $rv) { - return Status->error(sprintf 'Failed to set [%s] up_admin to [%s] on $device: %s', + return Status->error(sprintf "Failed to set [%s] up_admin to [%s] on $device: %s", $pn, $data, ($snmp->error || '')); } diff --git a/lib/App/Netdisco/Worker/Plugin/Power.pm b/lib/App/Netdisco/Worker/Plugin/Power.pm index 81099b48..b6789698 100644 --- a/lib/App/Netdisco/Worker/Plugin/Power.pm +++ b/lib/App/Netdisco/Worker/Plugin/Power.pm @@ -19,9 +19,9 @@ register_worker({ phase => 'check' }, sub { or return Status->error(sprintf "Unknown port name [%s] on device %s", $job->port, $job->device); - my $vlan_reconfig_check = vlan_reconfig_check(vars->{'port'}); - return Status->error("Cannot alter vlan: $vlan_reconfig_check") - if $vlan_reconfig_check; + my $port_reconfig_check = port_reconfig_check(vars->{'port'}); + return Status->error("Cannot alter port: $port_reconfig_check") + if $port_reconfig_check; return Status->error("No PoE service on port [$pn] on device $device") unless vars->{'port'}->power; @@ -40,7 +40,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { # snmp connect using rw community my $snmp = App::Netdisco::Transport::SNMP->writer_for($device) - or return Status->defer("failed to connect to $device to update vlan"); + or return Status->defer("failed to connect to $device to set power"); my $powerid = get_powerid($snmp, vars->{'port'}) or return Status->error("failed to get power ID for [$pn] from $device"); From fe70b01bcc3e409162a3dec06bfd8fb0d77bdd91 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Sat, 26 Jan 2019 23:09:55 +0100 Subject: [PATCH 29/64] i think end anchor should be in the if clause (#493) --- share/views/ajax/device/ports.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/views/ajax/device/ports.tt b/share/views/ajax/device/ports.tt index 1c4a3be9..e2498226 100644 --- a/share/views/ajax/device/ports.tt +++ b/share/views/ajax/device/ports.tt @@ -369,8 +369,8 @@ - [% END %] + [% END %] [% END %] From 914e484b335de9348f5b7ff42a542d31f977073a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 26 Jan 2019 23:23:12 +0000 Subject: [PATCH 30/64] #490 use new checks for uplink and phone on port --- lib/App/Netdisco/Util/Port.pm | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/App/Netdisco/Util/Port.pm b/lib/App/Netdisco/Util/Port.pm index 62b72f8e..383e893b 100644 --- a/lib/App/Netdisco/Util/Port.pm +++ b/lib/App/Netdisco/Util/Port.pm @@ -105,7 +105,8 @@ sub port_reconfig_check { # uplink check return "forbidden: port [$name] on [$ip] is an uplink" - if $port->remote_type and not $has_phone and not setting('portctl_uplinks'); + if ($port->is_uplink or $port->remote_type) + and not $has_phone and not setting('portctl_uplinks'); # phone check return "forbidden: port [$name] on [$ip] is a phone" @@ -215,18 +216,10 @@ sub is_vlan_interface { Returns true if the C<$port> L object has a phone connected. -This uses a simple check on the I of the remote connected device, and -therefore might sometimes return a false-negative result. - =cut sub port_has_phone { - my $port = shift; - - my $has_phone = ($port->remote_type - and $port->remote_type =~ /ip.phone/i) ? 1 : 0; - - return $has_phone; + return (shift)->with_properties->remote_is_phone; } 1; From dc9feb747fe578d6e00af61f4d7710f7644c16ac Mon Sep 17 00:00:00 2001 From: Christian Ramseyer Date: Tue, 29 Jan 2019 23:40:43 +0100 Subject: [PATCH 31/64] Merge ASA.PM patch by stromsoe (#494} * Embedded # characters in the output for show names cause sshcollector not to collect any ARP entries on the ASA platform, since the $prompt variable matches in the middle of the output. Fix is to modify $prompt to match end-of-line. * Changing the terminal pager length should be done before sending show names instead of after. * Matching on IP address to see if a name needs to be mapped should include start and end field markers, in the event that the name returned from "show arp" embeds an IP address (eg, "abc1.2.3.4xyz") --- lib/App/Netdisco/SSHCollector/Platform/ASA.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/App/Netdisco/SSHCollector/Platform/ASA.pm b/lib/App/Netdisco/SSHCollector/Platform/ASA.pm index d28373bf..c0a4e540 100644 --- a/lib/App/Netdisco/SSHCollector/Platform/ASA.pm +++ b/lib/App/Netdisco/SSHCollector/Platform/ASA.pm @@ -75,21 +75,21 @@ sub arpnip { $expect->send( $args->{enable_password} ."\n" ); } - $prompt = qr/#/; + $prompt = qr/#\s*$/; ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt); + $expect->send("terminal pager 2147483647\n"); + ($pos, $error, $match, $before, $after) = $expect->expect(5, -re, $prompt); + $expect->send("show names\n"); ($pos, $error, $match, $before, $after) = $expect->expect(60, -re, $prompt); my @names = split(m/\n/, $before); - $expect->send("terminal pager 2147483647\n"); - ($pos, $error, $match, $before, $after) = $expect->expect(5, -re, $prompt); - $expect->send("show arp\n"); ($pos, $error, $match, $before, $after) = $expect->expect(60, -re, $prompt); + my @lines = split(m/\n/, $before); my @arpentries = (); - my @lines = split(m/\n/, $before); # ifname 192.0.2.1 0011.2233.4455 123 my $linereg = qr/[A-z0-9\-\.]+\s([A-z0-9\-\.]+)\s @@ -98,7 +98,7 @@ sub arpnip { foreach my $line (@lines) { if ($line =~ $linereg) { my ($ip, $mac) = ($1, $2); - if ($ip !~ m/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) { + if ($ip !~ m/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/) { foreach my $name (@names) { if ($name =~ qr/name\s([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s([\w-]*)/x) { if ($ip eq $2) { @@ -107,7 +107,7 @@ sub arpnip { } } } - if ($ip =~ m/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) { + if ($ip =~ m/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/) { push @arpentries, { mac => $mac, ip => $ip }; } } From 1620feaa6aa9f3e2f1613d2cb2b79f99df2227b1 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Fri, 22 Feb 2019 22:53:20 +0100 Subject: [PATCH 32/64] tiny typo iteself -> itself --- lib/App/Netdisco/Util/Device.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Util/Device.pm b/lib/App/Netdisco/Util/Device.pm index a4b481fe..a6af95fa 100644 --- a/lib/App/Netdisco/Util/Device.pm +++ b/lib/App/Netdisco/Util/Device.pm @@ -100,8 +100,8 @@ sub delete_device { =head2 renumber_device( $current_ip, $new_ip ) Will update all records in Netdisco referring to the device with -C<$current_ip> to use C<$new_ip> instead, followed by renumbering the device -iteself. +C<$current_ip> to use C<$new_ip> instead, followed by renumbering the +device itself. Returns true if the transaction completes, else returns false. From 24a7e8047032bc99cacf3670d0b8ef89eda29e0b Mon Sep 17 00:00:00 2001 From: ram Date: Thu, 21 Feb 2019 22:15:12 +0100 Subject: [PATCH 33/64] PR for #510 - store ifindex in device_port --- lib/App/Netdisco/DB.pm | 2 +- lib/App/Netdisco/DB/Result/DevicePort.pm | 2 ++ lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 1 + share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql diff --git a/lib/App/Netdisco/DB.pm b/lib/App/Netdisco/DB.pm index 008b5369..5c589386 100644 --- a/lib/App/Netdisco/DB.pm +++ b/lib/App/Netdisco/DB.pm @@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces( ); our # try to hide from kwalitee - $VERSION = 53; # schema version used for upgrades, keep as integer + $VERSION = 54; # schema version used for upgrades, keep as integer use Path::Class; use File::ShareDir 'dist_dir'; diff --git a/lib/App/Netdisco/DB/Result/DevicePort.pm b/lib/App/Netdisco/DB/Result/DevicePort.pm index 216cf869..73f8d659 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -69,6 +69,8 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 1 }, "lastchange", { data_type => "bigint", is_nullable => 1 }, + "ifindex", + { data_type => "bigint", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("port", "ip"); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index 63240c3d..a8722ef4 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -229,6 +229,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { type => $i_type->{$entry}, vlan => $i_vlan->{$entry}, pvid => $i_vlan->{$entry}, + ifindex => $entry, is_master => 'false', slave_of => undef, lastchange => $lc, diff --git a/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql new file mode 100644 index 00000000..c259afc5 --- /dev/null +++ b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE device_port ADD COLUMN "ifindex" bigint; + +COMMIT; From c2600ac550fb8311818f439a7e527017605f7124 Mon Sep 17 00:00:00 2001 From: ram Date: Sat, 23 Feb 2019 15:13:44 +0100 Subject: [PATCH 34/64] Change location of ifindex to DevicePortProperties * instead of DevicePort * as requested by Oliver in PR #513 review --- lib/App/Netdisco/DB/Result/DevicePort.pm | 2 -- lib/App/Netdisco/DB/Result/DevicePortProperties.pm | 2 ++ .../Netdisco/Worker/Plugin/Discover/PortProperties.pm | 11 +++++++++++ lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 1 - .../App-Netdisco-DB-53-54-PostgreSQL.sql | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/DevicePort.pm b/lib/App/Netdisco/DB/Result/DevicePort.pm index 73f8d659..216cf869 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -69,8 +69,6 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 1 }, "lastchange", { data_type => "bigint", is_nullable => 1 }, - "ifindex", - { data_type => "bigint", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("port", "ip"); diff --git a/lib/App/Netdisco/DB/Result/DevicePortProperties.pm b/lib/App/Netdisco/DB/Result/DevicePortProperties.pm index 81ea937b..b25fdaaf 100644 --- a/lib/App/Netdisco/DB/Result/DevicePortProperties.pm +++ b/lib/App/Netdisco/DB/Result/DevicePortProperties.pm @@ -29,6 +29,8 @@ __PACKAGE__->add_columns( { data_type => "bigint", is_nullable => 1 }, "faststart", { data_type => "boolean", is_nullable => 1 }, + "ifindex", + { data_type => "bigint", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("port", "ip"); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm index 108d8046..8b492021 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm @@ -101,6 +101,17 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { $properties{ $port }->{remote_serial} = $rem_serial->{ $idx }; } + foreach my $idx (keys %$interfaces) { + my $port = $interfaces->{$idx} or next; + if (!defined $device_ports->{$port}) { + debug sprintf ' [%s] properties/ifindex - local port %s already skipped, ignoring', + $device->ip, $port; + next; + } + + $properties{ $port }->{ifindex} = $idx; + } + return Status->info(" [$device] no port properties to record") unless scalar keys %properties; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index a8722ef4..63240c3d 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -229,7 +229,6 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { type => $i_type->{$entry}, vlan => $i_vlan->{$entry}, pvid => $i_vlan->{$entry}, - ifindex => $entry, is_master => 'false', slave_of => undef, lastchange => $lc, diff --git a/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql index c259afc5..64454a87 100644 --- a/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql +++ b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql @@ -1,5 +1,5 @@ BEGIN; -ALTER TABLE device_port ADD COLUMN "ifindex" bigint; +ALTER TABLE device_port_properties ADD COLUMN "ifindex" bigint; COMMIT; From 3f211650b89e58c80d862632faf6c9529c6f8b27 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Fri, 1 Mar 2019 12:34:42 +0100 Subject: [PATCH 35/64] last pieces for db schema upgrade last piece of #510 --- MANIFEST | 1 + META.json | 4 ++-- META.yml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MANIFEST b/MANIFEST index 338458ca..32b20851 100644 --- a/MANIFEST +++ b/MANIFEST @@ -364,6 +364,7 @@ share/schema_versions/App-Netdisco-DB-5-6-PostgreSQL.sql share/schema_versions/App-Netdisco-DB-50-51-PostgreSQL.sql 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-6-7-PostgreSQL.sql share/schema_versions/App-Netdisco-DB-7-8-PostgreSQL.sql share/schema_versions/App-Netdisco-DB-8-9-PostgreSQL.sql diff --git a/META.json b/META.json index d25d2b90..26b7cba6 100644 --- a/META.json +++ b/META.json @@ -140,7 +140,7 @@ }, "App::Netdisco::DB" : { "file" : "lib/App/Netdisco/DB.pm", - "version" : "53" + "version" : "54" }, "App::Netdisco::DB::ExplicitLocking" : { "file" : "lib/App/Netdisco/DB/ExplicitLocking.pm" @@ -801,5 +801,5 @@ "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, "version" : "2.040003", - "x_serialization_backend" : "JSON::PP version 2.97001" + "x_serialization_backend" : "JSON::PP version 4.02" } diff --git a/META.yml b/META.yml index 42d85541..6fd33dec 100644 --- a/META.yml +++ b/META.yml @@ -37,7 +37,7 @@ provides: file: lib/App/Netdisco/Configuration.pm App::Netdisco::DB: file: lib/App/Netdisco/DB.pm - version: '53' + version: '54' App::Netdisco::DB::ExplicitLocking: file: lib/App/Netdisco/DB/ExplicitLocking.pm App::Netdisco::DB::Result::Admin: From 77decc23b73cbcda0cd0516fdc73972cda622a0b Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 14:45:37 +0000 Subject: [PATCH 36/64] #514 inconsistent results in ip inventory (inphobia) --- lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm b/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm index 315db783..437462ae 100644 --- a/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm +++ b/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm @@ -110,7 +110,7 @@ get '/ajax/content/report/ipinventory' => require_login sub { 'ip', 'mac', 'dns', 'time_last', 'time_first', 'active', 'node', 'age' ], - order_by => [{-asc => 'ip'}, {-desc => 'active'}], + order_by => [{-asc => 'ip'}, {-desc => 'active'}, {-asc => 'node'}], } )->as_query; From d4c7579c101d693827da2f3fad533ad725f97ba0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 14:47:49 +0000 Subject: [PATCH 37/64] #522 TypeAhead.pm can reference empty data (inphobia) --- lib/App/Netdisco/Web/TypeAhead.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Web/TypeAhead.pm b/lib/App/Netdisco/Web/TypeAhead.pm index 3994302e..40c7da62 100644 --- a/lib/App/Netdisco/Web/TypeAhead.pm +++ b/lib/App/Netdisco/Web/TypeAhead.pm @@ -49,7 +49,7 @@ ajax '/ajax/data/port/typeahead' => require_login sub { if $port; my $results = [ - map {{ label => (sprintf "%s (%s)", $_->port, $_->name), value => $_->port }} + map {{ label => (sprintf "%s (%s)", $_->port, ($_->name || '')), value => $_->port }} sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } $set->all ]; From 1265bc8470911d90c7c446c64976207c3285a151 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 14:52:21 +0000 Subject: [PATCH 38/64] #520 catch slave ports defined without a master --- lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index 63240c3d..95d2340d 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -238,6 +238,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { # must do this after building %interfaces so that we can set is_master foreach my $sidx (keys %$agg_ports) { my $slave = $interfaces->{$sidx} or next; + next unless defined $agg_ports->{$sidx}; # slave without a master?! my $master = $interfaces->{ $agg_ports->{$sidx} } or next; next unless exists $interfaces{$slave} and exists $interfaces{$master}; From ca3fd8f466f144f76a9df6d760a5d8f34ae14621 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 15:00:18 +0000 Subject: [PATCH 39/64] #505 device renumber should update device port properties and device skips --- lib/App/Netdisco/DB/Result/Device.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Device.pm b/lib/App/Netdisco/DB/Result/Device.pm index a6e06545..e7d431a7 100644 --- a/lib/App/Netdisco/DB/Result/Device.pm +++ b/lib/App/Netdisco/DB/Result/Device.pm @@ -262,20 +262,25 @@ sub renumber { foreach my $set (qw/ DeviceIp DeviceModule - DevicePower - DeviceVlan DevicePort DevicePortLog DevicePortPower + DevicePortProperties DevicePortSsid DevicePortVlan DevicePortWireless + DevicePower + DeviceVlan /) { $schema->resultset($set) ->search({ip => $old_ip}) ->update({ip => $new_ip}); } + $schema->resultset('DeviceSkip') + ->search({device => $old_ip}) + ->update({device => $new_ip}); + $schema->resultset('DevicePort') ->search({remote_ip => $old_ip}) ->update({remote_ip => $new_ip}); From 9952f0c6c723359c7c1e29abfc0dcad30a52c083 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 15:02:12 +0000 Subject: [PATCH 40/64] #499 netdisco-do renumber reports wrong ip (inphobia) --- lib/App/Netdisco/Util/Device.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Util/Device.pm b/lib/App/Netdisco/Util/Device.pm index a6af95fa..47f4a920 100644 --- a/lib/App/Netdisco/Util/Device.pm +++ b/lib/App/Netdisco/Util/Device.pm @@ -120,7 +120,7 @@ sub renumber_device { schema('netdisco')->resultset('UserLog')->create({ username => session('logged_in_user'), userip => scalar eval {request->remote_address}, - event => (sprintf "Renumber device %s to %s", $device->ip, $new_ip), + event => (sprintf "Renumber device %s to %s", $ip, $new_ip), }); $happy = 1; From 78e30a7926dbec941860420348c917ae823146f3 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 16:28:15 +0000 Subject: [PATCH 41/64] #500 filtering in device/ports on native vlan duplicates entries --- lib/App/Netdisco/Web/Plugin/Device/Ports.pm | 57 +++++++++++---------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index b5276052..be5f98ea 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -25,25 +25,6 @@ get '/ajax/content/device/ports' => require_login sub { if ($f) { if (($prefer eq 'vlan') or (not $prefer and $f =~ m/^\d+$/)) { return unless $f =~ m/^\d+$/; - - if (param('invert')) { - $set = $set->search({ - 'me.vlan' => { '!=' => $f }, - 'port_vlans.vlan' => [ - '-or' => { '!=' => $f }, { '=' => undef } - ], - }, { join => 'port_vlans' }); - } - else { - $set = $set->search({ - -or => { - 'me.vlan' => $f, - 'port_vlans.vlan' => $f, - }, - }, { join => 'port_vlans' }); - } - - return unless $set->count; } else { if (param('partial')) { @@ -120,7 +101,7 @@ get '/ajax/content/device/ports' => require_login sub { # now begin to join tables depending on the selected columns/options # get vlans on the port - # leave this query dormant (lazy) unless c_vmember is set + # leave this query dormant (lazy) unless c_vmember is set or vlan filtering my $vlans = $set->search({}, { select => [ 'port', @@ -131,7 +112,7 @@ get '/ajax/content/device/ports' => require_login sub { group_by => 'me.port', }); - if (param('c_vmember')) { + if (param('c_vmember') or ($prefer eq 'vlan') or (not $prefer and $f =~ m/^\d+$/)) { $vlans = { map {( $_->port => { # DBIC smart enough to work out this should be an arrayref :) @@ -194,13 +175,37 @@ get '/ajax/content/device/ports' => require_login sub { # also get remote LLDP inventory if asked for $set = $set->with_remote_inventory if param('n_inventory'); - # sort ports (empty set would be a 'no records' msg) - my $results = [ sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } $set->all ]; - return unless scalar @$results; + # run query + my @results = $set->all; + + # filter for tagged vlan using existing agg query, + # which is better than join inflation + if (($prefer eq 'vlan') or (not $prefer and $f =~ m/^\d+$/)) { + if (param('invert')) { + @results = grep { + (!defined $_->vlan or $_->vlan ne $f) + and + (0 == scalar grep {defined and $_ ne $f} @{ $vlans->{$_->port}->{vlan_set} }) + } @results; + } + else { + @results = grep { + ($_->vlan eq $f) + or + (scalar grep {defined and $_ eq $f} @{ $vlans->{$_->port}->{vlan_set} }) + } @results; + } + } + + # sort ports + @results = sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } @results; + + # empty set would be a 'no records' msg + return unless scalar @results; if (request->is_ajax) { template 'ajax/device/ports.tt', { - results => $results, + results => \@results, nodes => $nodes_name, ips => $ips_name, device => $device, @@ -210,7 +215,7 @@ get '/ajax/content/device/ports' => require_login sub { else { header( 'Content-Type' => 'text/comma-separated-values' ); template 'ajax/device/ports_csv.tt', { - results => $results, + results => \@results, nodes => $nodes_name, ips => $ips_name, device => $device, From ce1b847ceabb3cb8ec6bac370071d55acd40dc48 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 18:47:44 +0000 Subject: [PATCH 42/64] fix bug showing no nodes when only one matches in netmap --- lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm index bc1e3aec..612eebc6 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm @@ -219,8 +219,9 @@ ajax '/ajax/data/device/netmap' => require_login sub { DEVICE: while (my $device = $devices->next) { # if in neighbors or vlan mode then use %ok_dev to filter - next DEVICE if (($mapshow eq 'neighbors') or $vlan) - and (not $ok_dev{$device->ip}); + next DEVICE if ($device->ip ne $qdev->ip) + and (($mapshow eq 'neighbors') or $vlan) + and (not $ok_dev{$device->ip}); # showing only neighbors but no link # if location picked then filter next DEVICE if ((scalar @lgrplist) and ((!defined $device->location) From a1f95028caf3d59133dac0bb43fd9d26c44a9dfb Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Sat, 2 Mar 2019 19:54:22 +0100 Subject: [PATCH 43/64] catch up with changes noticed that rc-sshcollector-core received updates to changes, add them here as well. didn't mention #499 & #522 --- Changes | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Changes b/Changes index 708c7b09..477ce63f 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,20 @@ +2.04xxxx - 2019-xx-xx + + [ENHANCEMENTS] + + * #490 use new checks for ports having phones + * #494 update Cisco ASA ssh collector (stromsoe) + * #510 store ifindex in Device Port Properties table (rc9000) + + [BUG FIXES] + + * #492 Port Control uses VLAN config check (inphobia) + * #493 HTML tag fix (inphobia) + * #500 no more duplicate entries in vlan filter (ollyg) + * #505 renumbering device missed a few tables (ollyg) + * #514 ipinventory report returns consistent data (inphobia) + * #520 make sure aggports have a master<->slave (ollyg) + 2.040003 - 2019-01-18 [NEW FEATURES] From e7aacddbc615a48e5dd204b9dc32a5deadbdefea Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 20:01:05 +0000 Subject: [PATCH 44/64] #498 Map with VLAN filter omits unconnected devices --- lib/App/Netdisco/DB/ResultSet/Device.pm | 14 +++++------ .../Netdisco/Web/Plugin/Device/Neighbors.pm | 23 ++++++++----------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 27e6defc..271eeda6 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -47,16 +47,16 @@ sub with_times { ->search({}, { '+columns' => { - uptime_age => \("replace(age(timestamp 'epoch' + uptime / 100 * interval '1 second', " + uptime_age => \("replace(age(timestamp 'epoch' + me.uptime / 100 * interval '1 second', " ."timestamp '1970-01-01 00:00:00-00')::text, 'mon', 'month')"), first_seen_stamp => \"to_char(me.creation, 'YYYY-MM-DD HH24:MI')", - last_discover_stamp => \"to_char(last_discover, 'YYYY-MM-DD HH24:MI')", - last_macsuck_stamp => \"to_char(last_macsuck, 'YYYY-MM-DD HH24:MI')", - last_arpnip_stamp => \"to_char(last_arpnip, 'YYYY-MM-DD HH24:MI')", + last_discover_stamp => \"to_char(me.last_discover, 'YYYY-MM-DD HH24:MI')", + last_macsuck_stamp => \"to_char(me.last_macsuck, 'YYYY-MM-DD HH24:MI')", + last_arpnip_stamp => \"to_char(me.last_arpnip, 'YYYY-MM-DD HH24:MI')", since_first_seen => \"extract(epoch from (age(now(), me.creation)))", - since_last_discover => \"extract(epoch from (age(now(), last_discover)))", - since_last_macsuck => \"extract(epoch from (age(now(), last_macsuck)))", - since_last_arpnip => \"extract(epoch from (age(now(), last_arpnip)))", + since_last_discover => \"extract(epoch from (age(now(), me.last_discover)))", + since_last_macsuck => \"extract(epoch from (age(now(), me.last_macsuck)))", + since_last_arpnip => \"extract(epoch from (age(now(), me.last_arpnip)))", }, }); } diff --git a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm index 612eebc6..5a1624be 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm @@ -179,17 +179,6 @@ ajax '/ajax/data/device/netmap' => require_login sub { ]) : ()) }, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }); - if ($vlan) { - $links = $links->search({ - -or => [ - { 'left_vlans.vlan' => $vlan }, - { 'right_vlans.vlan' => $vlan }, - ], - }, { - join => [qw/left_vlans right_vlans/], - }); - } - while (my $link = $links->next) { push @{$data{'links'}}, { FROMID => $link->{left_ip}, @@ -217,10 +206,18 @@ ajax '/ajax/data/device/netmap' => require_login sub { join => 'throughput', })->with_times; + # filter by vlan for all or neighbors only + if ($vlan) { + $devices = $devices->search( + { 'vlans.vlan' => $vlan }, + { join => 'vlans' } + ); + } + DEVICE: while (my $device = $devices->next) { - # if in neighbors or vlan mode then use %ok_dev to filter + # if in neighbors mode then use %ok_dev to filter next DEVICE if ($device->ip ne $qdev->ip) - and (($mapshow eq 'neighbors') or $vlan) + and ($mapshow eq 'neighbors') and (not $ok_dev{$device->ip}); # showing only neighbors but no link # if location picked then filter From a643820a6200a7439724158a6817f3858732050c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 21:54:27 +0000 Subject: [PATCH 45/64] #428 Port-Channels not showing in netmap --- .../Netdisco/DB/Result/Virtual/DeviceLinks.pm | 20 ++++++++++--------- .../Netdisco/Web/Plugin/Device/Neighbors.pm | 19 +++++++----------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm index a503a3ae..9d2339ca 100644 --- a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm +++ b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm @@ -22,8 +22,8 @@ __PACKAGE__->result_source_instance->view_definition(<result_source_instance->view_definition(<result_source_instance->view_definition(<result_source_instance->view_definition(<{left_dns} || $link->{left_name} || $link->{left_ip})) =~ s/$domain$//; (my $right_name = lc($link->{right_dns} || $link->{right_name} || $link->{right_ip})) =~ s/$domain$//; - if ($link->{aggports} == 1) { - return sprintf '%s:%s (%s)
%s:%s (%s)', - $left_name, $link->{left_port}->[0], - ($link->{left_descr}->[0] || 'no description'), - $right_name, $link->{right_port}->[0], - ($link->{right_descr}->[0] || 'no description'); - } - else { - return sprintf '%s:(%s)
%s:(%s)', - $left_name, join(',', @{$link->{left_port}}), - $right_name, join(',', @{$link->{right_port}}); - } + my @zipped = List::MoreUtils::zip6 + @{$link->{left_port}}, @{$link->{left_descr}}, + @{$link->{right_port}}, @{$link->{right_descr}}; + + return join '

', map { sprintf '%s:%s (%s)
%s:%s (%s)', + $left_name, $_->[0], ($_->[1] || 'no description'), + $right_name, $_->[2], ($_->[3] || 'no description') } @zipped; } ajax '/ajax/data/device/netmap' => require_login sub { From 7a8bcb094e4d48dd0d900d275ca5ce781ddb42ba Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 22:23:39 +0000 Subject: [PATCH 46/64] #521 Search Node Date Range not working --- .../Netdisco/Web/Plugin/Report/IpInventory.pm | 2 +- lib/App/Netdisco/Web/Plugin/Search/Node.pm | 48 ++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm b/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm index 437462ae..0fc809f0 100644 --- a/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm +++ b/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm @@ -115,7 +115,7 @@ get '/ajax/content/report/ipinventory' => require_login sub { )->as_query; my $rs; - if ( $start && $end ) { + if ( $start and $end ) { $start = $start . ' 00:00:00'; $end = $end . ' 23:59:59'; diff --git a/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/lib/App/Netdisco/Web/Plugin/Search/Node.pm index 45394e2c..090802a5 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -27,35 +27,51 @@ ajax '/ajax/content/search/node' => require_login sub { my @active = (param('archived') ? () : (-bool => 'active')); my (@times, @wifitimes, @porttimes); - if ($start and $end) { + if ( $start and $end ) { $start = $start . ' 00:00:00'; $end = $end . ' 23:59:59'; + if ($agenot) { @times = (-or => [ - time_first => [ { '<', $start }, undef ], - time_last => { '>', $end }, + time_first => [ undef ], + time_last => [ { '<', $start }, { '>', $end } ] ]); @wifitimes = (-or => [ - time_last => { '<', $start }, - time_last => { '>', $end }, + time_first => [ undef ], + time_last => [ { '<', $start }, { '>', $end } ] ]); @porttimes = (-or => [ - creation => { '<', $start }, - creation => { '>', $end }, + creation => [ undef ], + creation => [ { '<', $start }, { '>', $end } ] ]); } else { - @times = (-and => [ - time_first => { '>=', $start }, - time_last => { '<=', $end }, + @times = (-or => [ + -and => [ + time_first => undef, + time_last => undef, + ], + -and => [ + time_last => { '>=', $start }, + time_last => { '<=', $end }, + ], ]); - @wifitimes = (-and => [ - time_last => { '>=', $start }, - time_last => { '<=', $end }, + @wifitimes = (-or => [ + -and => [ + time_first => undef, + time_last => undef, + ], + -and => [ + time_last => { '>=', $start }, + time_last => { '<=', $end }, + ], ]); - @porttimes = (-and => [ - creation => { '>=', $start }, - creation => { '<=', $end }, + @porttimes = (-or => [ + creation => undef, + -and => [ + creation => { '>=', $start }, + creation => { '<=', $end }, + ], ]); } } From ef560fb59aebf4f7cf64487931d41b6f5aa83d92 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 22:41:40 +0000 Subject: [PATCH 47/64] #506 relax device renumber so it works for an alias --- lib/App/Netdisco/DB/Result/Device.pm | 2 ++ lib/App/Netdisco/Worker/Plugin.pm | 6 +++--- lib/App/Netdisco/Worker/Plugin/Renumber.pm | 8 ++++---- lib/App/Netdisco/Worker/Runner.pm | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Device.pm b/lib/App/Netdisco/DB/Result/Device.pm index e7d431a7..412ecdaa 100644 --- a/lib/App/Netdisco/DB/Result/Device.pm +++ b/lib/App/Netdisco/DB/Result/Device.pm @@ -277,6 +277,8 @@ sub renumber { ->update({ip => $new_ip}); } + $schema->resultset('DeviceSkip') + ->search({device => $new_ip})->delete; $schema->resultset('DeviceSkip') ->search({device => $old_ip}) ->update({device => $new_ip}); diff --git a/lib/App/Netdisco/Worker/Plugin.pm b/lib/App/Netdisco/Worker/Plugin.pm index 8f05a7c4..44999403 100644 --- a/lib/App/Netdisco/Worker/Plugin.pm +++ b/lib/App/Netdisco/Worker/Plugin.pm @@ -74,9 +74,9 @@ register 'register_worker' => sub { push @newuserconf, dclone $stanza; } - # per-device action but no device creds available - return $job->add_status( Status->info('skip: driver or action not applicable') ) - if 0 == scalar @newuserconf; + # # per-device action but no device creds available + # return $job->add_status( Status->info('skip: driver or action not applicable') ) + # if 0 == scalar @newuserconf; } # back up and restore device_auth diff --git a/lib/App/Netdisco/Worker/Plugin/Renumber.pm b/lib/App/Netdisco/Worker/Plugin/Renumber.pm index c3b815ba..e768002e 100644 --- a/lib/App/Netdisco/Worker/Plugin/Renumber.pm +++ b/lib/App/Netdisco/Worker/Plugin/Renumber.pm @@ -28,10 +28,10 @@ register_worker({ phase => 'main' }, sub { my $old_ip = $device->ip; my $new_ip = NetAddr::IP->new($extra); - my $new_dev = get_device($new_ip->addr); - if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) { - return Status->error(sprintf "Already know new device as: %s.", $new_dev->ip); - } + #my $new_dev = get_device($new_ip->addr); + #if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) { + # return Status->error(sprintf "Already know new device as: %s.", $new_dev->ip); + #} renumber_device($device, $new_ip); return Status->done(sprintf 'Renumbered device %s to %s (%s).', diff --git a/lib/App/Netdisco/Worker/Runner.pm b/lib/App/Netdisco/Worker/Runner.pm index 193281ca..4cdbf041 100644 --- a/lib/App/Netdisco/Worker/Runner.pm +++ b/lib/App/Netdisco/Worker/Runner.pm @@ -49,9 +49,9 @@ sub run { push @newuserconf, dclone $stanza; } - # per-device action but no device creds available - return $job->add_status( Status->defer('deferred job with no device creds') ) - if 0 == scalar @newuserconf; + # # per-device action but no device creds available + # return $job->add_status( Status->defer('deferred job with no device creds') ) + # if 0 == scalar @newuserconf; } # back up and restore device_auth From 57cb6ddb707b938b8a5c0d39a52b9e4c8a8892da Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 09:19:39 +0000 Subject: [PATCH 48/64] fix for over-eager fix to #506 --- lib/App/Netdisco/Worker/Plugin/Renumber.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Renumber.pm b/lib/App/Netdisco/Worker/Plugin/Renumber.pm index e768002e..c3b815ba 100644 --- a/lib/App/Netdisco/Worker/Plugin/Renumber.pm +++ b/lib/App/Netdisco/Worker/Plugin/Renumber.pm @@ -28,10 +28,10 @@ register_worker({ phase => 'main' }, sub { my $old_ip = $device->ip; my $new_ip = NetAddr::IP->new($extra); - #my $new_dev = get_device($new_ip->addr); - #if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) { - # return Status->error(sprintf "Already know new device as: %s.", $new_dev->ip); - #} + my $new_dev = get_device($new_ip->addr); + if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) { + return Status->error(sprintf "Already know new device as: %s.", $new_dev->ip); + } renumber_device($device, $new_ip); return Status->done(sprintf 'Renumbered device %s to %s (%s).', From 2bae91f1b669e2901ebcb59696fdaa562c0396b7 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 12:01:34 +0000 Subject: [PATCH 49/64] rename match_devicetype() to match_to_setting() --- lib/App/Netdisco/Util/Device.pm | 8 ++++---- lib/App/Netdisco/Web/Device.pm | 4 ++-- .../Netdisco/Worker/Plugin/Discover/PortProperties.pm | 10 +++++----- lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/App/Netdisco/Util/Device.pm b/lib/App/Netdisco/Util/Device.pm index 47f4a920..d14b7a7d 100644 --- a/lib/App/Netdisco/Util/Device.pm +++ b/lib/App/Netdisco/Util/Device.pm @@ -10,7 +10,7 @@ our @EXPORT_OK = qw/ get_device delete_device renumber_device - match_devicetype + match_to_setting is_discoverable is_discoverable_now is_arpnipable is_arpnipable_now is_macsuckable is_macsuckable_now @@ -129,7 +129,7 @@ sub renumber_device { return $happy; } -=head2 match_devicetype( $type, $setting_name ) +=head2 match_to_setting( $type, $setting_name ) Given a C<$type> (which may be any text value), returns true if any of the list of regular expressions in C<$setting_name> is matched, otherwise returns @@ -137,7 +137,7 @@ false. =cut -sub match_devicetype { +sub match_to_setting { my ($type, $setting_name) = @_; return 0 unless $type and $setting_name; return (scalar grep {$type =~ m/$_/} @@ -165,7 +165,7 @@ sub is_discoverable { my ($ip, $remote_type) = @_; my $device = get_device($ip) or return 0; - if (match_devicetype($remote_type, 'discover_no_type')) { + if (match_to_setting($remote_type, 'discover_no_type')) { return _bail_msg("is_discoverable: $device matched discover_no_type"); } diff --git a/lib/App/Netdisco/Web/Device.pm b/lib/App/Netdisco/Web/Device.pm index e4cfdd00..010ed550 100644 --- a/lib/App/Netdisco/Web/Device.pm +++ b/lib/App/Netdisco/Web/Device.pm @@ -7,7 +7,7 @@ use Dancer::Plugin::Auth::Extensible; use URI (); use URL::Encode 'url_params_mixed'; -use App::Netdisco::Util::Device 'match_devicetype'; +use App::Netdisco::Util::Device 'match_to_setting'; # build view settings for port connected nodes and devices set('connected_properties' => [ @@ -20,7 +20,7 @@ hook 'before_template' => sub { my $tokens = shift; # allow checking of discoverability of remote connected device - $tokens->{has_snmp} = sub { not match_devicetype(shift, 'discover_no_type') }; + $tokens->{has_snmp} = sub { not match_to_setting(shift, 'discover_no_type') }; my $defaults = var('sidebar_defaults')->{'device_ports'} or return; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm index 8b492021..5803cc6c 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm @@ -8,7 +8,7 @@ use App::Netdisco::Transport::SNMP (); use Dancer::Plugin::DBIC 'schema'; use Encode; -use App::Netdisco::Util::Device 'match_devicetype'; +use App::Netdisco::Util::Device 'match_to_setting'; register_worker({ phase => 'main', driver => 'snmp' }, sub { my ($job, $workerconf) = @_; @@ -86,12 +86,12 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $remote_type = Encode::decode('UTF-8', $c_platform->{$idx} || ''); $properties{ $port }->{remote_is_wap} = 'true' - if scalar grep {match_devicetype($_, 'wap_capabilities')} @$remote_cap - or match_devicetype($remote_type, 'wap_platforms'); + if scalar grep {match_to_setting($_, 'wap_capabilities')} @$remote_cap + or match_to_setting($remote_type, 'wap_platforms'); $properties{ $port }->{remote_is_phone} = 'true' - if scalar grep {match_devicetype($_, 'phone_capabilities')} @$remote_cap - or match_devicetype($remote_type, 'phone_platforms'); + if scalar grep {match_to_setting($_, 'phone_capabilities')} @$remote_cap + or match_to_setting($remote_type, 'phone_platforms'); next unless scalar grep {defined && m/^inventory$/} @{ $rem_media_cap->{$idx} }; diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm index 0b150d1c..9ea9dfb9 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm @@ -7,7 +7,7 @@ use aliased 'App::Netdisco::Worker::Status'; use App::Netdisco::Transport::SNMP (); use App::Netdisco::Util::Permission 'check_acl_no'; use App::Netdisco::Util::PortMAC 'get_port_macs'; -use App::Netdisco::Util::Device 'match_devicetype'; +use App::Netdisco::Util::Device 'match_to_setting'; use App::Netdisco::Util::Node 'check_mac'; use App::Netdisco::Util::SNMP 'snmp_comm_reindex'; use Dancer::Plugin::DBIC 'schema'; @@ -342,7 +342,7 @@ sub walk_fwtable { # neighbors otherwise it would kill the DB with device lookups. my $neigh_cannot_macsuck = eval { # can fail check_acl_no(($device_port->neighbor || "0 but true"), 'macsuck_unsupported') || - match_devicetype($device_port->remote_type, 'macsuck_unsupported_type') }; + match_to_setting($device_port->remote_type, 'macsuck_unsupported_type') }; if ($device_port->is_uplink) { if ($neigh_cannot_macsuck) { From 09d29954d211ad1e6c1911fb4d43df8980a00bae Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 12:26:50 +0000 Subject: [PATCH 50/64] #512 fix regression in phone/wap discovery exclusion --- lib/App/Netdisco/Util/Device.pm | 16 +++++++++++----- share/config.yml | 6 +++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/App/Netdisco/Util/Device.pm b/lib/App/Netdisco/Util/Device.pm index d14b7a7d..8707fde4 100644 --- a/lib/App/Netdisco/Util/Device.pm +++ b/lib/App/Netdisco/Util/Device.pm @@ -154,8 +154,9 @@ the local configuration to discover the device. The configuration items C and C are checked against the given IP. -If C<$device_type> is also given, then C will also be -checked. +If C<$device_type> is also given, then C will be checked. +Also respects C and C if either are set to +false. Returns false if the host is not permitted to discover the target device. @@ -165,9 +166,14 @@ sub is_discoverable { my ($ip, $remote_type) = @_; my $device = get_device($ip) or return 0; - if (match_to_setting($remote_type, 'discover_no_type')) { - return _bail_msg("is_discoverable: $device matched discover_no_type"); - } + return _bail_msg("is_discoverable: $device matches wap_platforms but discover_waps is not enabled") + if (match_to_setting($remote_type, 'wap_platforms') and not setting('discover_waps')); + + return _bail_msg("is_discoverable: $device matches phone_platforms but discover_phones is not enabled") + if (match_to_setting($remote_type, 'phone_platforms') and not setting('discover_phones')); + + return _bail_msg("is_discoverable: $device matched discover_no_type") + if (match_to_setting($remote_type, 'discover_no_type')); return _bail_msg("is_discoverable: $device matched discover_no") if check_acl_no($device, 'discover_no'); diff --git a/share/config.yml b/share/config.yml index be6950f2..24b31d66 100644 --- a/share/config.yml +++ b/share/config.yml @@ -229,9 +229,9 @@ devices_no: [] devices_only: [] discover_no: [] discover_only: [] -discover_no_type: - - '(?i)phone' - - '(?i)(?:wap|wireless)' +discover_no_type: [] +discover_waps: true +discover_phones: false discover_min_age: 0 macsuck_no: [] macsuck_only: [] From 9c956466f3bf2e799412fef5b61966fb2878bc49 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 12:32:07 +0000 Subject: [PATCH 51/64] also update default config for new discover_phones and discover_waps settings --- share/environments/deployment.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/share/environments/deployment.yml b/share/environments/deployment.yml index cd792907..a1147c97 100644 --- a/share/environments/deployment.yml +++ b/share/environments/deployment.yml @@ -39,20 +39,18 @@ device_auth: # ¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸ +# +# SOME MORE INTERESTING SETTINGS WHERE THE DEFAULTS ARE PROBABLY OKAY +# # ¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸ -# --------------------------------------------------------------- -# OTHER INTERESTING SETTINGS WHERE THE DEFAULTS ARE PROBABLY OKAY -# --------------------------------------------------------------- - -# do not discover IP Phones or Wireless Access Points. +# discover Wireless Access Points, but not IP Phones # usually these are visible as device neighbors but don't support # SNMP, which just clogs up the job queue. # ``````````````````````````````````````````````````````````````` -#discover_no_type: -# - '(?i)phone' -# - '(?i)(?:wap|wireless)' +#discover_waps: true +#disover_phones: false # this is the schedule for automatically keeping netdisco up-to-date; # these are good defaults, so only uncomment if needing to change. From 189d234b55c01b8e7def428bed9c4be35022ea59 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 12:47:38 +0000 Subject: [PATCH 52/64] check discover_no_type and friends earlier on in neighbors list build --- .../Worker/Plugin/Discover/Neighbors.pm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index 6a64b8ee..afda0133 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -45,7 +45,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { # only enqueue if device is not already discovered, # discover_* config permits the discovery foreach my $neighbor (@to_discover) { - my ($ip, $remote_type, $remote_id) = @$neighbor; + my ($ip, $remote_id) = @$neighbor; if ($seen_ip{ $ip }++) { debug sprintf ' queue - skip: IP %s is already queued from %s', @@ -63,13 +63,6 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { my $newdev = get_device($ip); next if $newdev->in_storage; - if (not is_discoverable($newdev, $remote_type)) { - debug sprintf - ' queue - skip: %s of type [%s] excluded by discover_* config', - $ip, ($remote_type || ''); - next; - } - # risk of things going wrong...? # https://quickview.cloudapps.cisco.com/quickview/bug/CSCur12254 @@ -246,7 +239,15 @@ sub store_neighbors { # what we came here to do.... discover the neighbor debug sprintf ' [%s] neigh - %s with ID [%s] on %s', $device->ip, $remote_ip, ($remote_id || ''), $port; - push @to_discover, [$remote_ip, $remote_type, $remote_id]; + + if (is_discoverable($remote_ip, $remote_type)) { + push @to_discover, [$remote_ip, $remote_id]; + } + else { + debug sprintf + ' [%s] neigh - skip: %s of type [%s] excluded by discover_* config', + $device->ip, $remote_ip, ($remote_type || ''); + } $remote_port = $c_port->{$entry}; if (defined $remote_port) { From b83e614c851beafd68d131999698023c5380338c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 13:00:36 +0000 Subject: [PATCH 53/64] make discover_{phones,waps} work with LLDP capabilities as well --- lib/App/Netdisco/Util/Device.pm | 14 ++++++++++---- .../Netdisco/Worker/Plugin/Discover/Neighbors.pm | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/App/Netdisco/Util/Device.pm b/lib/App/Netdisco/Util/Device.pm index 8707fde4..e0fbd211 100644 --- a/lib/App/Netdisco/Util/Device.pm +++ b/lib/App/Netdisco/Util/Device.pm @@ -146,7 +146,7 @@ sub match_to_setting { sub _bail_msg { debug $_[0]; return 0; } -=head2 is_discoverable( $ip, $device_type? ) +=head2 is_discoverable( $ip, [$device_type, \@device_capabilities]? ) Given an IP address, returns C if Netdisco on this host is permitted by the local configuration to discover the device. @@ -163,14 +163,20 @@ Returns false if the host is not permitted to discover the target device. =cut sub is_discoverable { - my ($ip, $remote_type) = @_; + my ($ip, $remote_type, $remote_cap) = @_; my $device = get_device($ip) or return 0; + $remote_type ||= ''; + $remote_cap ||= []; return _bail_msg("is_discoverable: $device matches wap_platforms but discover_waps is not enabled") - if (match_to_setting($remote_type, 'wap_platforms') and not setting('discover_waps')); + if ((not setting('discover_waps')) and + (match_to_setting($remote_type, 'wap_platforms') or + scalar grep {match_to_setting($_, 'wap_capabilities')} @$remote_cap)); return _bail_msg("is_discoverable: $device matches phone_platforms but discover_phones is not enabled") - if (match_to_setting($remote_type, 'phone_platforms') and not setting('discover_phones')); + if ((not setting('discover_phones')) and + (match_to_setting($remote_type, 'phone_platforms') or + scalar grep {match_to_setting($_, 'phone_capabilities')} @$remote_cap)); return _bail_msg("is_discoverable: $device matched discover_no_type") if (match_to_setting($remote_type, 'discover_no_type')); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index afda0133..6489ee43 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -169,6 +169,7 @@ sub store_neighbors { my $remote_port = undef; my $remote_type = Encode::decode('UTF-8', $c_platform->{$entry} || ''); my $remote_id = Encode::decode('UTF-8', $c_id->{$entry}); + my $remote_cap = $c_cap->{$entry} || []; next unless $remote_ip; my $r_netaddr = NetAddr::IP::Lite->new($remote_ip); @@ -240,7 +241,7 @@ sub store_neighbors { debug sprintf ' [%s] neigh - %s with ID [%s] on %s', $device->ip, $remote_ip, ($remote_id || ''), $port; - if (is_discoverable($remote_ip, $remote_type)) { + if (is_discoverable($remote_ip, $remote_type, $remote_cap)) { push @to_discover, [$remote_ip, $remote_id]; } else { From ac381e080235b2efc0878b4ccfaa5c2d6901b2ff Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 14:13:20 +0000 Subject: [PATCH 54/64] #506 was a red herring --- lib/App/Netdisco/Worker/Plugin.pm | 6 +++--- lib/App/Netdisco/Worker/Runner.pm | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin.pm b/lib/App/Netdisco/Worker/Plugin.pm index 44999403..8f05a7c4 100644 --- a/lib/App/Netdisco/Worker/Plugin.pm +++ b/lib/App/Netdisco/Worker/Plugin.pm @@ -74,9 +74,9 @@ register 'register_worker' => sub { push @newuserconf, dclone $stanza; } - # # per-device action but no device creds available - # return $job->add_status( Status->info('skip: driver or action not applicable') ) - # if 0 == scalar @newuserconf; + # per-device action but no device creds available + return $job->add_status( Status->info('skip: driver or action not applicable') ) + if 0 == scalar @newuserconf; } # back up and restore device_auth diff --git a/lib/App/Netdisco/Worker/Runner.pm b/lib/App/Netdisco/Worker/Runner.pm index 4cdbf041..193281ca 100644 --- a/lib/App/Netdisco/Worker/Runner.pm +++ b/lib/App/Netdisco/Worker/Runner.pm @@ -49,9 +49,9 @@ sub run { push @newuserconf, dclone $stanza; } - # # per-device action but no device creds available - # return $job->add_status( Status->defer('deferred job with no device creds') ) - # if 0 == scalar @newuserconf; + # per-device action but no device creds available + return $job->add_status( Status->defer('deferred job with no device creds') ) + if 0 == scalar @newuserconf; } # back up and restore device_auth From 6cdfd80d10975c22a9aa2050a02e2ed45dbad3c6 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 14:34:00 +0000 Subject: [PATCH 55/64] allow undiscovered neighbors report to use discover_{waps,phones} setting --- lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm | 6 ++++++ .../Netdisco/Web/Plugin/AdminTask/UndiscoveredNeighbors.pm | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm b/lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm index 1fe1c1d5..4cde1ffc 100644 --- a/lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm +++ b/lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm @@ -15,6 +15,7 @@ __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL'); d.ip, d.name, d.dns, p.port, p.name AS port_description, p.remote_ip, p.remote_id, p.remote_type, p.remote_port, + dpp.remote_is_wap, dpp.remote_is_phone, l.log AS comment, a.log, a.finished @@ -23,6 +24,7 @@ __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL'); INNER JOIN device d USING (ip) LEFT OUTER JOIN device_skip ds ON ('discover' = ANY(ds.actionset) AND p.remote_ip = ds.device) + LEFT OUTER JOIN device_port_properties dpp USING (ip, port) LEFT OUTER JOIN device_port_log l USING (ip, port) LEFT OUTER JOIN admin a ON (p.remote_ip = a.device AND a.action = 'discover') @@ -58,6 +60,10 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "remote_id", { data_type => "text", is_nullable => 1 }, + "remote_is_wap", + { data_type => "boolean", is_nullable => 1 }, + "remote_is_phone", + { data_type => "boolean", is_nullable => 1 }, "comment", { data_type => "text", is_nullable => 1 }, "log", diff --git a/lib/App/Netdisco/Web/Plugin/AdminTask/UndiscoveredNeighbors.pm b/lib/App/Netdisco/Web/Plugin/AdminTask/UndiscoveredNeighbors.pm index d409d3cb..293d2525 100644 --- a/lib/App/Netdisco/Web/Plugin/AdminTask/UndiscoveredNeighbors.pm +++ b/lib/App/Netdisco/Web/Plugin/AdminTask/UndiscoveredNeighbors.pm @@ -27,6 +27,8 @@ get '/ajax/content/admin/undiscoveredneighbors' => require_role admin => sub { # create a new row object to avoid hitting the DB in get_device() my $dev = schema('netdisco')->resultset('Device')->new({ip => $r->{remote_ip}}); next unless is_discoverable( $dev, $r->{remote_type} ); + next if (not setting('discover_waps')) and $r->{remote_is_wap}; + next if (not setting('discover_phones')) and $r->{remote_is_phone}; push @discoverable_results, $r; } return unless scalar @discoverable_results; From e9efc45182f590ea94ddd2928e8156162d022b0d Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Mar 2019 14:56:48 +0000 Subject: [PATCH 56/64] release 2.040004 --- Build.PL | 2 +- Changes | 19 +++++++++++++++---- META.json | 8 ++++---- META.yml | 6 +++--- lib/App/Netdisco.pm | 2 +- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Build.PL b/Build.PL index ded87058..8b2de830 100644 --- a/Build.PL +++ b/Build.PL @@ -72,7 +72,7 @@ Module::Build->new( 'Starman' => '0.4008', 'Storable' => '0', 'Sys::SigAction' => '0', - 'SNMP::Info' => '3.64', + 'SNMP::Info' => '3.65', 'SQL::Abstract' => '1.85', 'SQL::Translator' => '0.11024', 'Template' => '2.24', diff --git a/Changes b/Changes index 477ce63f..33075ea6 100644 --- a/Changes +++ b/Changes @@ -1,19 +1,30 @@ -2.04xxxx - 2019-xx-xx +2.040004 - 2019-03-03 + + [NEW FEATURES] + + * #510 store ifindex in Device Port Properties table (rc9000) + * new discover_waps and discover_phones boolean settings (ollyg) [ENHANCEMENTS] - * #490 use new checks for ports having phones + * #428 Port-Channels now showing in netmap (ollyg) + * #490 use new LLDP capability checks for ports having phones (ollyg) * #494 update Cisco ASA ssh collector (stromsoe) - * #510 store ifindex in Device Port Properties table (rc9000) [BUG FIXES] - * #492 Port Control uses VLAN config check (inphobia) + * #492 Port Control incorrectly uses VLAN config check (inphobia) * #493 HTML tag fix (inphobia) + * #498 Map with VLAN filter omits unconnected devices (ollyg) + * #499 netdisco-do renumber reports wrong ip (inphobia) * #500 no more duplicate entries in vlan filter (ollyg) * #505 renumbering device missed a few tables (ollyg) + * #512 fix regression in phone/wap discovery exclusion (ollyg) * #514 ipinventory report returns consistent data (inphobia) * #520 make sure aggports have a master<->slave (ollyg) + * #521 Search Node Date Range not working (ollyg) + * #522 TypeAhead.pm can reference empty data (inphobia) + * fix bug showing no nodes when only one matches in netmap (ollyg) 2.040003 - 2019-01-18 diff --git a/META.json b/META.json index 26b7cba6..a3532e86 100644 --- a/META.json +++ b/META.json @@ -81,7 +81,7 @@ "Plack::Middleware::ReverseProxy" : "0.15", "Pod::Usage" : "0", "Role::Tiny" : "1.002005", - "SNMP::Info" : "3.64", + "SNMP::Info" : "3.65", "SQL::Abstract" : "1.85", "SQL::Translator" : "0.11024", "Scope::Guard" : "0", @@ -118,7 +118,7 @@ "provides" : { "App::Netdisco" : { "file" : "lib/App/Netdisco.pm", - "version" : "2.040003" + "version" : "2.040004" }, "App::Netdisco::AnyEvent::Nbtstat" : { "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" @@ -800,6 +800,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, - "version" : "2.040003", - "x_serialization_backend" : "JSON::PP version 4.02" + "version" : "2.040004", + "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index 6fd33dec..ea2fba17 100644 --- a/META.yml +++ b/META.yml @@ -22,7 +22,7 @@ name: App-Netdisco provides: App::Netdisco: file: lib/App/Netdisco.pm - version: '2.040003' + version: '2.040004' App::Netdisco::AnyEvent::Nbtstat: file: lib/App/Netdisco/AnyEvent/Nbtstat.pm App::Netdisco::Backend::Job: @@ -518,7 +518,7 @@ requires: Plack::Middleware::ReverseProxy: '0.15' Pod::Usage: '0' Role::Tiny: '1.002005' - SNMP::Info: '3.64' + SNMP::Info: '3.65' SQL::Abstract: '1.85' SQL::Translator: '0.11024' Scope::Guard: '0' @@ -549,5 +549,5 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/netdisco/netdisco -version: '2.040003' +version: '2.040004' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index d88cdab0..2e47b040 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010_000; -our $VERSION = '2.040003'; +our $VERSION = '2.040004'; use App::Netdisco::Configuration; =head1 NAME From 0c98318a4508d9c91a8d1182b38e556454f9c9fa Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 4 Mar 2019 09:57:18 +0000 Subject: [PATCH 57/64] #526 fix discover syntax bug --- lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index 6489ee43..a546a58d 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm @@ -120,6 +120,7 @@ sub store_neighbors { my $c_port = $snmp->c_port; my $c_id = $snmp->c_id; my $c_platform = $snmp->c_platform; + my $c_cap = $snmp->c_cap; # cache the device ports to save hitting the database for many single rows vars->{'device_ports'} = From 6e7de3fff3719720da72db76801c9e2e45b5be78 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 4 Mar 2019 09:59:41 +0000 Subject: [PATCH 58/64] release 2.040005 --- Changes | 6 ++++++ META.json | 4 ++-- META.yml | 4 ++-- lib/App/Netdisco.pm | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 33075ea6..3bc8d770 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.040005 - 2019-03-04 + + [BUG FIXES] + + * #526 fix discover syntax bug + 2.040004 - 2019-03-03 [NEW FEATURES] diff --git a/META.json b/META.json index a3532e86..8bcef558 100644 --- a/META.json +++ b/META.json @@ -118,7 +118,7 @@ "provides" : { "App::Netdisco" : { "file" : "lib/App/Netdisco.pm", - "version" : "2.040004" + "version" : "2.040005" }, "App::Netdisco::AnyEvent::Nbtstat" : { "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" @@ -800,6 +800,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, - "version" : "2.040004", + "version" : "2.040005", "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index ea2fba17..0d493cfe 100644 --- a/META.yml +++ b/META.yml @@ -22,7 +22,7 @@ name: App-Netdisco provides: App::Netdisco: file: lib/App/Netdisco.pm - version: '2.040004' + version: '2.040005' App::Netdisco::AnyEvent::Nbtstat: file: lib/App/Netdisco/AnyEvent/Nbtstat.pm App::Netdisco::Backend::Job: @@ -549,5 +549,5 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/netdisco/netdisco -version: '2.040004' +version: '2.040005' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index 2e47b040..c30f8700 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010_000; -our $VERSION = '2.040004'; +our $VERSION = '2.040005'; use App::Netdisco::Configuration; =head1 NAME From e09dab53622960bee715d9d423ed2dee91b2e36c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 4 Mar 2019 11:39:12 +0000 Subject: [PATCH 59/64] #527 update List::MoreUtils version requirement --- Build.PL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build.PL b/Build.PL index 8b2de830..3d7fdeb6 100644 --- a/Build.PL +++ b/Build.PL @@ -46,7 +46,7 @@ Module::Build->new( 'JSON' => '2.90', 'JSON::XS' => '3.01', 'List::Util' => '1.49', - 'List::MoreUtils' => '0.33', + 'List::MoreUtils' => '0.428', 'MIME::Base64' => '3.13', 'Module::Load' => '0.32', 'Moo' => '1.001000', From 48857ae3002536b469acb678292981377b960b65 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 4 Mar 2019 12:03:31 +0000 Subject: [PATCH 60/64] release 2.040006 --- Changes | 6 ++++++ META.json | 6 +++--- META.yml | 6 +++--- lib/App/Netdisco.pm | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 3bc8d770..f8a2cb73 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.040006 - 2019-03-04 + + [BUG FIXES] + + * #527 update List::MoreUtils version requirement + 2.040005 - 2019-03-04 [BUG FIXES] diff --git a/META.json b/META.json index 8bcef558..5b18dc40 100644 --- a/META.json +++ b/META.json @@ -60,7 +60,7 @@ "IO::Socket::SSL" : "2.048", "JSON" : "2.90", "JSON::XS" : "3.01", - "List::MoreUtils" : "0.33", + "List::MoreUtils" : "0.428", "List::Util" : "1.49", "MCE" : "1.703", "MIME::Base64" : "3.13", @@ -118,7 +118,7 @@ "provides" : { "App::Netdisco" : { "file" : "lib/App/Netdisco.pm", - "version" : "2.040005" + "version" : "2.040006" }, "App::Netdisco::AnyEvent::Nbtstat" : { "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" @@ -800,6 +800,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, - "version" : "2.040005", + "version" : "2.040006", "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index 0d493cfe..a5071bc5 100644 --- a/META.yml +++ b/META.yml @@ -22,7 +22,7 @@ name: App-Netdisco provides: App::Netdisco: file: lib/App/Netdisco.pm - version: '2.040005' + version: '2.040006' App::Netdisco::AnyEvent::Nbtstat: file: lib/App/Netdisco/AnyEvent/Nbtstat.pm App::Netdisco::Backend::Job: @@ -497,7 +497,7 @@ requires: IO::Socket::SSL: '2.048' JSON: '2.90' JSON::XS: '3.01' - List::MoreUtils: '0.33' + List::MoreUtils: '0.428' List::Util: '1.49' MCE: '1.703' MIME::Base64: '3.13' @@ -549,5 +549,5 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/netdisco/netdisco -version: '2.040005' +version: '2.040006' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index c30f8700..bca470bc 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010_000; -our $VERSION = '2.040005'; +our $VERSION = '2.040006'; use App::Netdisco::Configuration; =head1 NAME From e3af64df77613b98c5efde9d5e7381ab0f5de52d Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 6 Mar 2019 18:42:47 +0000 Subject: [PATCH 61/64] #521-redux fix wifi date search --- Changes | 6 ++++++ lib/App/Netdisco/Web/Plugin/Search/Node.pm | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index f8a2cb73..4f29f214 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.040007 - 2019-03-06 + + [BUG FIXES] + + * #521-redux Search Node Date Range not working (ollyg) + 2.040006 - 2019-03-04 [BUG FIXES] diff --git a/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/lib/App/Netdisco/Web/Plugin/Search/Node.pm index 090802a5..6b74c86d 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -37,8 +37,8 @@ ajax '/ajax/content/search/node' => require_login sub { time_last => [ { '<', $start }, { '>', $end } ] ]); @wifitimes = (-or => [ - time_first => [ undef ], - time_last => [ { '<', $start }, { '>', $end } ] + time_last => [ undef ], + time_last => [ { '<', $start }, { '>', $end } ], ]); @porttimes = (-or => [ creation => [ undef ], @@ -57,10 +57,7 @@ ajax '/ajax/content/search/node' => require_login sub { ], ]); @wifitimes = (-or => [ - -and => [ - time_first => undef, - time_last => undef, - ], + time_last => undef, -and => [ time_last => { '>=', $start }, time_last => { '<=', $end }, From 249f05165fd25bdd43802a95c523f0486fc013de Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 6 Mar 2019 18:43:31 +0000 Subject: [PATCH 62/64] release 2.040007 --- META.json | 4 ++-- META.yml | 4 ++-- lib/App/Netdisco.pm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/META.json b/META.json index 5b18dc40..c19aca81 100644 --- a/META.json +++ b/META.json @@ -118,7 +118,7 @@ "provides" : { "App::Netdisco" : { "file" : "lib/App/Netdisco.pm", - "version" : "2.040006" + "version" : "2.040007" }, "App::Netdisco::AnyEvent::Nbtstat" : { "file" : "lib/App/Netdisco/AnyEvent/Nbtstat.pm" @@ -800,6 +800,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/netdisco-users" }, - "version" : "2.040006", + "version" : "2.040007", "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index a5071bc5..f7cb0c94 100644 --- a/META.yml +++ b/META.yml @@ -22,7 +22,7 @@ name: App-Netdisco provides: App::Netdisco: file: lib/App/Netdisco.pm - version: '2.040006' + version: '2.040007' App::Netdisco::AnyEvent::Nbtstat: file: lib/App/Netdisco/AnyEvent/Nbtstat.pm App::Netdisco::Backend::Job: @@ -549,5 +549,5 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/netdisco/netdisco -version: '2.040006' +version: '2.040007' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/lib/App/Netdisco.pm b/lib/App/Netdisco.pm index bca470bc..cecfe6ae 100644 --- a/lib/App/Netdisco.pm +++ b/lib/App/Netdisco.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010_000; -our $VERSION = '2.040006'; +our $VERSION = '2.040007'; use App::Netdisco::Configuration; =head1 NAME From fdafbb735e3beb018ccc80a4aeb0bf477ff3dc5e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 11 Mar 2019 17:39:53 +0000 Subject: [PATCH 63/64] test compilation of all scripts and modules passes --- Build.PL | 1 + xt/00-compile.t | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 xt/00-compile.t diff --git a/Build.PL b/Build.PL index 3d7fdeb6..fe0e4bba 100644 --- a/Build.PL +++ b/Build.PL @@ -96,6 +96,7 @@ Module::Build->new( test_requires => { 'Test::More' => '1.302083', 'Env::Path' => '0', + 'Test::Compile' => '0', 'Test::File::ShareDir::Dist' => '0', }, script_files => [ diff --git a/xt/00-compile.t b/xt/00-compile.t new file mode 100644 index 00000000..307058af --- /dev/null +++ b/xt/00-compile.t @@ -0,0 +1,30 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +BEGIN { + use FindBin; + FindBin::again(); + + use Path::Class; + + # stuff useful locations into @INC and $PATH + unshift @INC, + dir($FindBin::RealBin)->parent->subdir('lib')->stringify, + dir($FindBin::RealBin, 'lib')->stringify; +} + +# for netdisco app config +use App::Netdisco; +use Test::Compile; + +my $test = Test::Compile->new(); + +my @plfiles = grep {$_ !~ m/(?:sshcollector|graph)/i} $test->all_pl_files(); +my @pmfiles = grep {$_ !~ m/(?:sshcollector|graph)/i} $test->all_pm_files(); + +$test->ok($test->pl_file_compiles($_), "$_ compiles") for @plfiles; +$test->ok($test->pm_file_compiles($_), "$_ compiles") for @pmfiles; + +$test->done_testing(); From 15c132a094215fe919e9d45ae3e7fea25e0dac34 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 11 Mar 2019 17:49:13 +0000 Subject: [PATCH 64/64] Revert "test compilation of all scripts and modules passes" This reverts commit fdafbb735e3beb018ccc80a4aeb0bf477ff3dc5e. --- Build.PL | 1 - xt/00-compile.t | 30 ------------------------------ 2 files changed, 31 deletions(-) delete mode 100644 xt/00-compile.t diff --git a/Build.PL b/Build.PL index fe0e4bba..3d7fdeb6 100644 --- a/Build.PL +++ b/Build.PL @@ -96,7 +96,6 @@ Module::Build->new( test_requires => { 'Test::More' => '1.302083', 'Env::Path' => '0', - 'Test::Compile' => '0', 'Test::File::ShareDir::Dist' => '0', }, script_files => [ diff --git a/xt/00-compile.t b/xt/00-compile.t deleted file mode 100644 index 307058af..00000000 --- a/xt/00-compile.t +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; - -BEGIN { - use FindBin; - FindBin::again(); - - use Path::Class; - - # stuff useful locations into @INC and $PATH - unshift @INC, - dir($FindBin::RealBin)->parent->subdir('lib')->stringify, - dir($FindBin::RealBin, 'lib')->stringify; -} - -# for netdisco app config -use App::Netdisco; -use Test::Compile; - -my $test = Test::Compile->new(); - -my @plfiles = grep {$_ !~ m/(?:sshcollector|graph)/i} $test->all_pl_files(); -my @pmfiles = grep {$_ !~ m/(?:sshcollector|graph)/i} $test->all_pm_files(); - -$test->ok($test->pl_file_compiles($_), "$_ compiles") for @plfiles; -$test->ok($test->pm_file_compiles($_), "$_ compiles") for @pmfiles; - -$test->done_testing();
VlanVLAN Device Description Model