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 01/26] 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 02/26] #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 03/26] #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 04/26] #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 05/26] #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 06/26] #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 07/26] #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 08/26] 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 09/26] 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 10/26] #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 11/26] #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 12/26] #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 13/26] #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 14/26] 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 15/26] 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 16/26] #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 17/26] 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 18/26] 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 19/26] 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 20/26] #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 21/26] 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 22/26] 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 23/26] #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 24/26] 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 25/26] #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 26/26] 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