@VisibleForTesting
static void tryAddInterfaceToVlans(
SpecifierContext ctxt,
InterfaceSpecifier interfacesSpecifier,
boolean excludeShutInterfaces,
IntegerSpace vlans,
Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces,
String node,
Interface iface) {
if (!interfacesSpecifier.resolve(ImmutableSet.of(node), ctxt).contains(iface)
|| (excludeShutInterfaces && !iface.getActive())
|| (iface.getInterfaceType() != InterfaceType.VLAN
&& !Boolean.TRUE.equals(iface.getSwitchport()))) {
return;
}
if (iface.getInterfaceType() == InterfaceType.VLAN) {
tryAddInterfaceToVlan(switchedVlanInterfaces, node, iface, iface.getVlan(), vlans);
} else if (iface.getSwitchportMode() == SwitchportMode.ACCESS) {
tryAddInterfaceToVlan(switchedVlanInterfaces, node, iface, iface.getAccessVlan(), vlans);
} else if (iface.getSwitchportMode() == SwitchportMode.TRUNK) {
iface.getAllowedVlans().stream()
.forEach(
allowedVlan ->
tryAddInterfaceToVlan(switchedVlanInterfaces, node, iface, allowedVlan, vlans));
}
}