save a device_port lookup
This commit is contained in:
@@ -238,7 +238,6 @@ 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',
|
||||||
@@ -246,6 +245,9 @@ 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;
|
||||||
@@ -253,7 +255,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) {
|
||||||
my $peer_port = schema('netdisco')->resultset('DevicePort')->search({
|
$peer_port = schema('netdisco')->resultset('DevicePort')->search({
|
||||||
ip => $peer_device->ip,
|
ip => $peer_device->ip,
|
||||||
port => [
|
port => [
|
||||||
{'=', $remote_port},
|
{'=', $remote_port},
|
||||||
@@ -291,11 +293,6 @@ 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),
|
||||||
|
|||||||
Reference in New Issue
Block a user