From f7f2d2088bac3da0894875b11370601ce46660f6 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Dec 2019 09:07:12 +0000 Subject: [PATCH] #81 avoid DEPRECATED single warning from DBIC --- lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Neighbors.pm index 34d75c9d..83adfe58 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 { } if (ref $c_ip->{$entry}) { - error sprintf ' [%s] neigh - Error! port %s has multiple neighbors - skipping', + debug sprintf ' [%s] neigh - port %s has multiple neighbors - skipping', $device->ip, $port; next; } @@ -189,10 +189,18 @@ sub store_neighbors { if ($remote_id) { my $devices = schema('netdisco')->resultset('Device'); - my $neigh = $devices->single({name => $remote_id}); + debug sprintf ' [%s] neigh - bad address %s on port %s, searching for %s instead', $device->ip, $remote_ip, $port, $remote_id; + my $neigh_rs = $devices->search_rs({name => $remote_id}); + my $neigh = ($neigh_rs->count == 1 ? $neigh_rs->first : undef); + + if (!defined $neigh and $neigh_rs->count) { + debug sprintf ' [%s] neigh - multiple devices claim to be %s (port %s) - skipping', + $device->ip, $remote_id, $port; + next; + } if (!defined $neigh) { my $mac = NetAddr::MAC->new(mac => $remote_id);