Skip to content

Commit

Permalink
L3AdjacencyComputer: warn if some but not all L2 interfaces are menti…
Browse files Browse the repository at this point in the history
…oned in L1 (#7992)
  • Loading branch information
dhalperi committed Feb 2, 2022
1 parent 14854dd commit 4ba453e
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import java.util.EnumSet;
import java.util.HashSet;
Expand Down Expand Up @@ -391,6 +393,35 @@ static Map<String, EthernetHub> computeEthernetHubs(
ret.put(hub.getId(), hub);
});
}

// Log if at least one L2 interface is mentioned in L1 and at least one L2 interface is attached
// to global hub.
Set<NodeInterfacePair> l2AttachedToGlobalHub =
interfacesAttachedToGlobalHub.stream()
.filter(
nip ->
Optional.ofNullable(configs.get(nip.getHostname()))
.map(c -> c.getAllInterfaces().get(nip.getInterface()))
.map(Interface::getSwitchport)
.orElse(false))
.collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural()));
Set<NodeInterfacePair> l2MentionedInL1 =
physicalInterfacesMentionedInL1.stream()
.filter(
nip ->
Optional.ofNullable(configs.get(nip.getHostname()))
.map(c -> c.getAllInterfaces().get(nip.getInterface()))
.map(Interface::getSwitchport)
.orElse(false))
.collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural()));
if (!l2AttachedToGlobalHub.isEmpty() && !l2MentionedInL1.isEmpty()) {
LOGGER.warn(
"Surprised that some L2 interfaces are mentioned in L1 ({}) but not all ({}): {} are not",
l2MentionedInL1.size(),
l2AttachedToGlobalHub.size(),
l2AttachedToGlobalHub);
}

return ret.build();
}

Expand Down

0 comments on commit 4ba453e

Please sign in to comment.