Handle management IP of one device being in use on another device

This commit is contained in:
Oliver Gorwits
2014-08-06 21:56:00 +01:00
parent 5d23338cbd
commit 5549e5239a
3 changed files with 8 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
* Show netdisco-do docs on options error * Show netdisco-do docs on options error
* Do not leak SNMP community string into debug output (unless SHOW_COMMUNITY=1) * Do not leak SNMP community string into debug output (unless SHOW_COMMUNITY=1)
* Process tree updated to show daemon worker status/activity * Process tree updated to show daemon worker status/activity
* Handle management IP of one device being in use on another device
[BUG FIXES] [BUG FIXES]

View File

@@ -49,8 +49,12 @@ sub get_device {
# naive check for existing DBIC object # naive check for existing DBIC object
return $ip if ref $ip; return $ip if ref $ip;
my $alias = schema('netdisco')->resultset('DeviceIp') # in case the management IP of one device is in use on another device,
->search({alias => $ip})->first; # 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; $ip = $alias->ip if defined $alias;
return schema('netdisco')->resultset('Device')->with_times return schema('netdisco')->resultset('Device')->with_times

View File

@@ -14,7 +14,7 @@ register_search_tab(
# device with various properties or a default match-all # device with various properties or a default match-all
get '/ajax/content/search/device' => require_login sub { get '/ajax/content/search/device' => require_login sub {
my $has_opt = List::MoreUtils::any { param($_) } 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; my $rs;
if ($has_opt) { if ($has_opt) {