@Test public void testGetInterfaceType() { CumulusInterfacesConfiguration interfaces = new CumulusInterfacesConfiguration(); interfaces.getInterfaces().putAll(INTERFACE_MAP); InterfaceConverter converter = new InterfaceConverter(interfaces, _w); assertThat(converter.getInterfaceType(PHYSICAL_IFACE), equalTo(PHYSICAL)); assertThat( converter.getInterfaceType(new InterfacesInterface(BOND_IFACE.getName() + ".1")), equalTo(BOND_SUBINTERFACE)); assertThat(converter.getInterfaceType(PHYSICAL_SUBIFACE), equalTo(PHYSICAL_SUBINTERFACE)); }
@VisibleForTesting CumulusInterfaceType getInterfaceType(InterfacesInterface iface) { String name = iface.getName(); if (InterfacesInterface.isPhysicalInterfaceType(name)) { return CumulusInterfaceType.PHYSICAL; } String superInterfaceName = getSuperInterfaceName(iface.getName()); if (superInterfaceName == null) { throw new BatfishException("cannot determine interface type for " + name); } InterfacesInterface superIface = _interfaces.getInterfaces().get(superInterfaceName); if (superIface == null) { throw new BatfishException("missing superinterface of subinterface " + name); } else if (superIface.getType() == BOND) { return BOND_SUBINTERFACE; } else if (superIface.getType() == INTERFACE && getInterfaceType(superIface) == PHYSICAL) { return PHYSICAL_SUBINTERFACE; } else { throw new BatfishException("invalid superinterface of subinterface " + name); } }
InterfaceConverter { @VisibleForTesting CumulusInterfaceType getInterfaceType(InterfacesInterface iface) { String name = iface.getName(); if (InterfacesInterface.isPhysicalInterfaceType(name)) { return CumulusInterfaceType.PHYSICAL; } String superInterfaceName = getSuperInterfaceName(iface.getName()); if (superInterfaceName == null) { throw new BatfishException("cannot determine interface type for " + name); } InterfacesInterface superIface = _interfaces.getInterfaces().get(superInterfaceName); if (superIface == null) { throw new BatfishException("missing superinterface of subinterface " + name); } else if (superIface.getType() == BOND) { return BOND_SUBINTERFACE; } else if (superIface.getType() == INTERFACE && getInterfaceType(superIface) == PHYSICAL) { return PHYSICAL_SUBINTERFACE; } else { throw new BatfishException("invalid superinterface of subinterface " + name); } } }
InterfaceConverter { @VisibleForTesting CumulusInterfaceType getInterfaceType(InterfacesInterface iface) { String name = iface.getName(); if (InterfacesInterface.isPhysicalInterfaceType(name)) { return CumulusInterfaceType.PHYSICAL; } String superInterfaceName = getSuperInterfaceName(iface.getName()); if (superInterfaceName == null) { throw new BatfishException("cannot determine interface type for " + name); } InterfacesInterface superIface = _interfaces.getInterfaces().get(superInterfaceName); if (superIface == null) { throw new BatfishException("missing superinterface of subinterface " + name); } else if (superIface.getType() == BOND) { return BOND_SUBINTERFACE; } else if (superIface.getType() == INTERFACE && getInterfaceType(superIface) == PHYSICAL) { return PHYSICAL_SUBINTERFACE; } else { throw new BatfishException("invalid superinterface of subinterface " + name); } } InterfaceConverter(CumulusInterfacesConfiguration interfaces, Warnings w); }
InterfaceConverter { @VisibleForTesting CumulusInterfaceType getInterfaceType(InterfacesInterface iface) { String name = iface.getName(); if (InterfacesInterface.isPhysicalInterfaceType(name)) { return CumulusInterfaceType.PHYSICAL; } String superInterfaceName = getSuperInterfaceName(iface.getName()); if (superInterfaceName == null) { throw new BatfishException("cannot determine interface type for " + name); } InterfacesInterface superIface = _interfaces.getInterfaces().get(superInterfaceName); if (superIface == null) { throw new BatfishException("missing superinterface of subinterface " + name); } else if (superIface.getType() == BOND) { return BOND_SUBINTERFACE; } else if (superIface.getType() == INTERFACE && getInterfaceType(superIface) == PHYSICAL) { return PHYSICAL_SUBINTERFACE; } else { throw new BatfishException("invalid superinterface of subinterface " + name); } } InterfaceConverter(CumulusInterfacesConfiguration interfaces, Warnings w); Map<String, Bond> convertBonds(); @Nullable Bridge convertBridge(); Map<String, org.batfish.representation.cumulus.Interface> convertInterfaces(); Map<String, Vlan> convertVlans(); Map<String, Vrf> convertVrfs(); Map<String, Vxlan> convertVxlans(); @VisibleForTesting @Nullable static String getSuperInterfaceName(String ifaceName); @VisibleForTesting @Nullable static Integer getEncapsulationVlan(InterfacesInterface iface); static boolean isBond(InterfacesInterface iface); static boolean isVlan(InterfacesInterface iface); static boolean isVxlan(InterfacesInterface iface); static boolean isVrf(InterfacesInterface iface); static boolean isInterface(InterfacesInterface iface); }
InterfaceConverter { @VisibleForTesting CumulusInterfaceType getInterfaceType(InterfacesInterface iface) { String name = iface.getName(); if (InterfacesInterface.isPhysicalInterfaceType(name)) { return CumulusInterfaceType.PHYSICAL; } String superInterfaceName = getSuperInterfaceName(iface.getName()); if (superInterfaceName == null) { throw new BatfishException("cannot determine interface type for " + name); } InterfacesInterface superIface = _interfaces.getInterfaces().get(superInterfaceName); if (superIface == null) { throw new BatfishException("missing superinterface of subinterface " + name); } else if (superIface.getType() == BOND) { return BOND_SUBINTERFACE; } else if (superIface.getType() == INTERFACE && getInterfaceType(superIface) == PHYSICAL) { return PHYSICAL_SUBINTERFACE; } else { throw new BatfishException("invalid superinterface of subinterface " + name); } } InterfaceConverter(CumulusInterfacesConfiguration interfaces, Warnings w); Map<String, Bond> convertBonds(); @Nullable Bridge convertBridge(); Map<String, org.batfish.representation.cumulus.Interface> convertInterfaces(); Map<String, Vlan> convertVlans(); Map<String, Vrf> convertVrfs(); Map<String, Vxlan> convertVxlans(); @VisibleForTesting @Nullable static String getSuperInterfaceName(String ifaceName); @VisibleForTesting @Nullable static Integer getEncapsulationVlan(InterfacesInterface iface); static boolean isBond(InterfacesInterface iface); static boolean isVlan(InterfacesInterface iface); static boolean isVxlan(InterfacesInterface iface); static boolean isVrf(InterfacesInterface iface); static boolean isInterface(InterfacesInterface iface); @VisibleForTesting static final String BRIDGE_NAME; static final Set<String> DEFAULT_BRIDGE_PORTS; static final int DEFAULT_BRIDGE_PVID; }