From ec31a75dd4984f0dc5fc84f4570b16024bf5ad58 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Mon, 16 Dec 2013 09:26:27 -0500 Subject: [PATCH] Require SNMP::Info 3.10+, use new c_cap method to tag device remote_type as 'IP Phone:' or 'AP:' when those capabilities are advertised by LLDP or CDP --- Netdisco/Changes | 8 ++++++++ Netdisco/Makefile.PL | 2 +- Netdisco/lib/App/Netdisco/Core/Discover.pm | 21 +++++++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 723ccdfb..cd5b6da8 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,3 +1,11 @@ +2.030000 - + + [ENHANCEMENTS] + + * Require SNMP::Info 3.10+, use new c_cap method to tag device remote_type + as 'IP Phone:' or 'AP:' when those capabilities are advertised by LLDP + or CDP + 2.020002 - 2013-12-11 [NEW FEATURES] diff --git a/Netdisco/Makefile.PL b/Netdisco/Makefile.PL index 36ec9f23..35456e8d 100644 --- a/Netdisco/Makefile.PL +++ b/Netdisco/Makefile.PL @@ -35,7 +35,7 @@ requires 'Plack::Middleware::Expires' => 0.03; requires 'Role::Tiny' => 1.002005; requires 'Socket6' => 0.23; requires 'Starman' => 0.4008; -requires 'SNMP::Info' => 3.08; +requires 'SNMP::Info' => 3.10; requires 'SQL::Translator' => 0.11016; requires 'Template' => 2.24; requires 'Template::Plugin::CSV' => 0.04; diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index 7a9a8194..17ee8f10 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -617,7 +617,7 @@ sub store_neighbors { my ($device, $snmp) = @_; my @to_discover = (); - # first allow any manually configred topology to be set + # first allow any manually configured topology to be set _set_manual_topology($device, $snmp); my $c_ip = $snmp->c_ip; @@ -631,6 +631,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; foreach my $entry (keys %$c_ip) { my $port = $interfaces->{ $c_if->{$entry} }; @@ -645,6 +646,7 @@ sub store_neighbors { my $remote_port = undef; my $remote_type = $c_platform->{$entry}; my $remote_id = Encode::decode('UTF-8', $c_id->{$entry}); + my $remote_cap = $c_cap->{$entry} || []; next unless $remote_ip; @@ -684,13 +686,20 @@ sub store_neighbors { } } - # IP Phone detection type fixup - if (defined $remote_type and $remote_type =~ m/(mitel.5\d{3})/i) { - $remote_type = 'IP Phone - '. $remote_type + # IP Phone and WAP detection type fixup + if (defined $remote_type) { + my $phone_flag = grep {/phone/i} @$remote_cap; + my $ap_flag = grep {/wlanAccessPoint/} @$remote_cap; + if ($phone_flag or $remote_type =~ m/(mitel.5\d{3})/i) { + $remote_type = 'IP Phone: '. $remote_type if $remote_type !~ /ip phone/i; - } - else { + } + elsif ($ap_flag) { + $remote_type = 'AP: '. $remote_type; + } + else { $remote_type ||= ''; + } } # hack for devices seeing multiple neighbors on the port