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
* 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]

View File

@@ -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