move wap and phone detection into portproperties worker

This commit is contained in:
Oliver Gorwits
2018-03-01 04:56:07 +00:00
parent 94da566184
commit e1b9f2225e
2 changed files with 24 additions and 34 deletions

View File

@@ -7,6 +7,9 @@ use aliased 'App::Netdisco::Worker::Status';
use App::Netdisco::Transport::SNMP ();
use Dancer::Plugin::DBIC 'schema';
use Encode;
use App::Netdisco::Util::Device 'match_devicetype';
register_worker({ phase => 'main', driver => 'snmp' }, sub {
my ($job, $workerconf) = @_;
@@ -26,22 +29,30 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
$properties{ $port }->{error_disable_cause} = $err_cause->{$idx};
}
my $lldp_if = $snmp->lldp_if || {};
my $lldp_cap = $snmp->lldp_cap || {};
my $c_if = $snmp->c_if || {};
my $c_cap = $snmp->c_cap || {};
my $c_platform = $snmp->c_platform || {};
my $rem_media_cap = $snmp->lldp_media_cap || {};
my $rem_vendor = $snmp->lldp_rem_vendor || {};
my $rem_model = $snmp->lldp_rem_model || {};
my $rem_os_ver = $snmp->lldp_rem_sw_rev || {};
my $rem_serial = $snmp->lldp_rem_serial || {};
foreach my $idx (keys %$lldp_if) {
my $port = $interfaces->{ $lldp_if->{$idx} };
foreach my $idx (keys %$c_if) {
my $port = $interfaces->{ $c_if->{$idx} };
next unless $port;
my $remote_cap = $c_cap->{$idx} || [];
my $remote_type = Encode::decode('UTF-8', $c_platform->{$idx} || '');
$properties{ $port }->{remote_is_wap} = 'true'
if scalar grep {defined && m/^wlanAccessPoint$/} @{ $lldp_cap->{$idx} };
if scalar grep {match_devicetype($_, 'wap_capabilities')} @$remote_cap
or match_devicetype($remote_type, 'wap_platforms');
$properties{ $port }->{remote_is_phone} = 'true'
if scalar grep {defined && m/^telephone$/} @{ $lldp_cap->{$idx} };
if scalar grep {match_devicetype($_, 'phone_capabilities')} @$remote_cap
or match_devicetype($remote_type, 'phone_platforms');
next unless scalar grep {defined && m/^inventory$/} @{ $rem_media_cap->{$idx} };