diff --git a/Netdisco/Changes b/Netdisco/Changes index 44cfaa53..2ed90e94 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -15,6 +15,7 @@ * Show netdisco-do docs on options error * Do not leak SNMP community string into debug output (unless SHOW_COMMUNITY=1) * Process tree updated to show daemon worker status/activity + * Handle management IP of one device being in use on another device [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Util/Device.pm b/Netdisco/lib/App/Netdisco/Util/Device.pm index a82b4020..6076c529 100644 --- a/Netdisco/lib/App/Netdisco/Util/Device.pm +++ b/Netdisco/lib/App/Netdisco/Util/Device.pm @@ -49,8 +49,12 @@ sub get_device { # naive check for existing DBIC object return $ip if ref $ip; - my $alias = schema('netdisco')->resultset('DeviceIp') - ->search({alias => $ip})->first; + # in case the management IP of one device is in use on another device, + # we first try to get an exact match for the IP as mgmt interface. + my $alias = + schema('netdisco')->resultset('DeviceIp')->find($ip, $ip) + || + schema('netdisco')->resultset('DeviceIp')->search({alias => $ip})->first; $ip = $alias->ip if defined $alias; return schema('netdisco')->resultset('Device')->with_times diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm index 49197b18..ec78f7ea 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Device.pm @@ -14,7 +14,7 @@ register_search_tab( # device with various properties or a default match-all get '/ajax/content/search/device' => require_login sub { my $has_opt = List::MoreUtils::any { param($_) } - qw/name location dns ip description model os_ver vendor layers/; + qw/name location dns ip description model os_ver vendor layers/; my $rs; if ($has_opt) {