move nodes to lag master port

This commit is contained in:
Oliver Gorwits
2014-01-12 21:51:41 +00:00
parent ffc6b9c315
commit 4531c61246
2 changed files with 22 additions and 11 deletions

View File

@@ -786,6 +786,17 @@ sub store_neighbors {
is_uplink => \"true", is_uplink => \"true",
manual_topo => \"false", 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; return @to_discover;

View File

@@ -98,8 +98,10 @@ sub do_macsuck {
debug sprintf ' [%s] macsuck - port %s vlan %s : %s nodes', debug sprintf ' [%s] macsuck - port %s vlan %s : %s nodes',
$ip, $port, $vlan, scalar keys %{ $fwtable->{$vlan}->{$port} }; $ip, $port, $vlan, scalar keys %{ $fwtable->{$vlan}->{$port} };
# make sure this port is UP in netdisco # make sure this port is UP in netdisco (unless it's a lag master,
$device_ports->{$port}->update({up_admin => 'up', up => 'up'}); # 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} }) { foreach my $mac (keys %{ $fwtable->{$vlan}->{$port} }) {
@@ -324,14 +326,6 @@ sub _walk_fwtable {
next; 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 # this uses the cached $ports resultset to limit hits on the db
my $device_port = $device_ports->{$port}; my $device_port = $device_ports->{$port};
@@ -342,6 +336,13 @@ sub _walk_fwtable {
next; 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 # check to see if the port is connected to another device
# and if we have that device in the database. # and if we have that device in the database.
@@ -390,7 +391,6 @@ sub _walk_fwtable {
} }
my $vlan = $fw_vlan->{$idx} || $comm_vlan || '0'; my $vlan = $fw_vlan->{$idx} || $comm_vlan || '0';
++$cache->{$vlan}->{$port}->{$mac}; ++$cache->{$vlan}->{$port}->{$mac};
} }