From 4531c61246f349512f977d9f7822ab564ffb514a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 12 Jan 2014 21:51:41 +0000 Subject: [PATCH] move nodes to lag master port --- Netdisco/lib/App/Netdisco/Core/Discover.pm | 11 +++++++++++ Netdisco/lib/App/Netdisco/Core/Macsuck.pm | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index 38e8bb45..5efe62f1 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -786,6 +786,17 @@ sub store_neighbors { is_uplink => \"true", manual_topo => \"false", }); + + if (defined $portrow->slave_of and + my $master = schema('netdisco')->resultset('DevicePort') + ->single({ip => $device->ip, port => $portrow->slave_of})) { + + $master->update({ + remote_ip => $remote_ip, + is_uplink => \"true", + manual_topo => \"false", + }); + } } return @to_discover; diff --git a/Netdisco/lib/App/Netdisco/Core/Macsuck.pm b/Netdisco/lib/App/Netdisco/Core/Macsuck.pm index 1c082b7d..39b0c5e1 100644 --- a/Netdisco/lib/App/Netdisco/Core/Macsuck.pm +++ b/Netdisco/lib/App/Netdisco/Core/Macsuck.pm @@ -98,8 +98,10 @@ sub do_macsuck { debug sprintf ' [%s] macsuck - port %s vlan %s : %s nodes', $ip, $port, $vlan, scalar keys %{ $fwtable->{$vlan}->{$port} }; - # make sure this port is UP in netdisco - $device_ports->{$port}->update({up_admin => 'up', up => 'up'}); + # make sure this port is UP in netdisco (unless it's a lag master, + # because we can still see nodes without a functioning aggregate) + $device_ports->{$port}->update({up_admin => 'up', up => 'up'}) + if not $device_ports->{$port}->is_master; foreach my $mac (keys %{ $fwtable->{$vlan}->{$port} }) { @@ -324,14 +326,6 @@ sub _walk_fwtable { next; } - # TODO: add proper port channel support! - if ($port =~ m/port.channel/i) { - debug sprintf - ' [%s] macsuck %s - port %s is LAG member - skipping.', - $device->ip, $mac, $port; - next; - } - # this uses the cached $ports resultset to limit hits on the db my $device_port = $device_ports->{$port}; @@ -342,6 +336,13 @@ sub _walk_fwtable { next; } + # possibly move node to lag master + if (defined $device_port->slave_of + and exists $device_ports->{$device_port->slave_of}) { + $port = $device_port->slave_of; + $device_port = $device_ports->{$port}; + } + # check to see if the port is connected to another device # and if we have that device in the database. @@ -390,7 +391,6 @@ sub _walk_fwtable { } my $vlan = $fw_vlan->{$idx} || $comm_vlan || '0'; - ++$cache->{$vlan}->{$port}->{$mac}; }