fix copy of remote master to local master remote_port

This commit is contained in:
Oliver Gorwits
2014-01-13 13:35:16 +00:00
parent 86a9854f39
commit 5b2a0a0a4b
2 changed files with 22 additions and 32 deletions

View File

@@ -710,6 +710,7 @@ sub store_neighbors {
if (defined $remote_type) {
my $phone_flag = grep {/phone/i} @$remote_cap;
my $ap_flag = grep {/wlanAccessPoint/} @$remote_cap;
if ($phone_flag or $remote_type =~ m/(mitel.5\d{3})/i) {
$remote_type = 'IP Phone: '. $remote_type
if $remote_type !~ /ip phone/i;
@@ -791,10 +792,15 @@ sub store_neighbors {
my $master = schema('netdisco')->resultset('DevicePort')
->single({ip => $device->ip, port => $portrow->slave_of})) {
# TODO needs refactoring - this is quite expensive
my $peer = schema('netdisco')->resultset('DevicePort')->find({
ip => $portrow->neighbor->ip,
port => $portrow->remote_port,
}) if $portrow->neighbor;
$master->update({
remote_ip => $remote_ip,
remote_port =>
($portrow->neighbor_port ? $portrow->neighbor_port->slave_of : undef),
remote_ip => ($peer ? $peer->ip : $remote_ip),
remote_port => ($peer ? $peer->slave_of : undef ),
is_uplink => \"true",
manual_topo => \"false",
});

View File

@@ -199,22 +199,6 @@ __PACKAGE__->belongs_to(
}
);
=head2 neighbor_port
Returns another row from the C<device_port> table if this port has valid
C<remote_ip> and C<remote_port>.
=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
@@ -267,7 +251,7 @@ __PACKAGE__->belongs_to( oui => 'App::Netdisco::DB::Result::Oui',
=head1 ADDITIONAL METHODS
=head2
=head2 neighbor
Returns the Device entry for the neighbour Device on the given port.