diff --git a/lib/App/Netdisco/Util/PortMAC.pm b/lib/App/Netdisco/Util/PortMAC.pm index 348ffad2..320d2b82 100644 --- a/lib/App/Netdisco/Util/PortMAC.pm +++ b/lib/App/Netdisco/Util/PortMAC.pm @@ -29,13 +29,15 @@ addresses supplied as array reference =cut sub get_port_macs { - my ($fw_mac_list) = @_; + my ($fw_mac_list) = $_[0]; my $port_macs = {}; - return {} unless defined $fw_mac_list and ref [] eq ref $fw_mac_list; + return {} unless ref [] eq ref $fw_mac_list and @{$fw_mac_list} >= 1; + + my $bindarray = [ { sqlt_datatype => "array" }, $fw_mac_list ]; my $macs = schema('netdisco')->resultset('Virtual::PortMacs')->search({}, - { bind => [$fw_mac_list], select => [ 'mac', 'ip' ], group_by => [ 'mac', 'ip' ] } ); + { bind => [$bindarray], select => [ 'mac', 'ip' ], group_by => [ 'mac', 'ip' ] } ); my $cursor = $macs->cursor; while ( my @vals = $cursor->next ) { $port_macs->{ $vals[0] } = $vals[1]; diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm index 43568193..d1c1a9f9 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm @@ -278,7 +278,8 @@ sub walk_fwtable { ? {} : $snmp->qb_fw_vlan; my $bp_index = $snmp->bp_index || {}; - my $port_macs = get_port_macs( values %$fw_mac ); + my @fw_mac_list = values %$fw_mac; + my $port_macs = get_port_macs(\@fw_mac_list); # to map forwarding table port to device port we have # fw_port -> bp_index -> interfaces