From 6620a03686c9d80bb7407e2a79bab5605c23c194 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 13 Jan 2014 08:56:13 +0000 Subject: [PATCH] also store master neighbor port --- Netdisco/lib/App/Netdisco/Core/Discover.pm | 2 ++ .../lib/App/Netdisco/DB/Result/DevicePort.pm | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index 5efe62f1..4f6059b7 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -793,6 +793,8 @@ sub store_neighbors { $master->update({ remote_ip => $remote_ip, + remote_port => + ($portrow->neighbor_port ? $portrow->neighbor_port->slave_of : undef), is_uplink => \"true", manual_topo => \"false", }); diff --git a/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm b/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm index b4e8b265..988f41c0 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -199,6 +199,22 @@ __PACKAGE__->belongs_to( } ); +=head2 neighbor_port + +Returns another row from the C table if this port has valid +C and C. + +=cut + +__PACKAGE__->belongs_to( + neighbor_port => 'App::Netdisco::DB::Result::DevicePort', { + 'foreign.ip' => 'self.remote_ip', + 'foreign.port' => 'self.remote_port', + }, { + join_type => 'LEFT', + } +); + =head2 neighbor_alias When a device port has an attached neighbor device, this relationship will