Revert "save a device_port lookup"

This reverts commit d19b2fac93.
This commit is contained in:
Oliver Gorwits
2018-04-10 20:58:07 +01:00
parent 67ee1808b6
commit 08a5652ae0

View File

@@ -238,6 +238,7 @@ sub store_neighbors {
# OK, remote IP seems sane # OK, remote IP seems sane
$remote_ip = $r_netaddr->addr; $remote_ip = $r_netaddr->addr;
my $peer_device = get_device($remote_ip);
# what we came here to do.... discover the neighbor # what we came here to do.... discover the neighbor
debug sprintf ' [%s] neigh - %s with ID [%s] on %s', debug sprintf ' [%s] neigh - %s with ID [%s] on %s',
@@ -245,9 +246,6 @@ sub store_neighbors {
push @to_discover, [$remote_ip, $remote_type, $remote_id]; push @to_discover, [$remote_ip, $remote_type, $remote_id];
$remote_port = $c_port->{$entry}; $remote_port = $c_port->{$entry};
my $peer_device = get_device($remote_ip);
my $peer_port = undef;
if (defined $remote_port) { if (defined $remote_port) {
# clean weird characters # clean weird characters
$remote_port =~ s/[^\d\s\/\.,()\w:-]+//gi; $remote_port =~ s/[^\d\s\/\.,()\w:-]+//gi;
@@ -255,7 +253,7 @@ sub store_neighbors {
# attempt to resolve port name when it is given wrong # attempt to resolve port name when it is given wrong
# https://github.com/netdisco/netdisco/issues/380 # https://github.com/netdisco/netdisco/issues/380
if ($peer_device and $peer_device->in_storage) { if ($peer_device and $peer_device->in_storage) {
$peer_port = schema('netdisco')->resultset('DevicePort')->search({ my $peer_port = schema('netdisco')->resultset('DevicePort')->search({
ip => $peer_device->ip, ip => $peer_device->ip,
port => [ port => [
{'=', $remote_port}, {'=', $remote_port},
@@ -293,6 +291,11 @@ sub store_neighbors {
port => $portrow->slave_of port => $portrow->slave_of
}); });
my $peer_port = schema('netdisco')->resultset('DevicePort')->single({
ip => $peer_device->ip,
port => $portrow->remote_port,
});
if ($master and not ($portrow->is_master or defined $master->slave_of)) { if ($master and not ($portrow->is_master or defined $master->slave_of)) {
$master->update({ $master->update({
remote_ip => ($peer_device->ip || $remote_ip), remote_ip => ($peer_device->ip || $remote_ip),