@Test public void testConvertInterface() { InterfaceConverter converter = new InterfaceConverter(new CumulusInterfacesConfiguration(), _w); org.batfish.representation.cumulus.Interface vsIface = converter.convertInterface(PHYSICAL_IFACE); assertThat(vsIface.getName(), equalTo(PHYSICAL_IFACE.getName())); assertThat(vsIface.getType(), equalTo(PHYSICAL)); assertNull(vsIface.getSuperInterfaceName()); assertThat(vsIface.getEncapsulationVlan(), equalTo(null)); assertThat(vsIface.getAlias(), equalTo(PHYSICAL_IFACE.getDescription())); assertNull(vsIface.getBridge().getAccess()); assertTrue(vsIface.getBridge().getVids().isEmpty()); assertNull(vsIface.getBridge().getPvid()); assertThat(vsIface.getClag(), equalTo(PHYSICAL_IFACE.getClagSettings())); assertTrue(vsIface.getIpAddresses().isEmpty()); assertThat(vsIface.getSpeed(), equalTo(PHYSICAL_IFACE.getLinkSpeed())); assertThat(vsIface.getVrf(), equalTo(PHYSICAL_IFACE.getVrf())); assertThat(vsIface.getPostUpIpRoutes(), equalTo(PHYSICAL_IFACE.getPostUpIpRoutes())); }
@VisibleForTesting org.batfish.representation.cumulus.Interface convertInterface(InterfacesInterface iface) { checkArgument(isInterface(iface), "input is not an interface"); checkArgument(!iface.getName().equals(BRIDGE_NAME), "interface bridge is handled separately"); String name = iface.getName(); org.batfish.representation.cumulus.Interface vsIface = new org.batfish.representation.cumulus.Interface( name, getInterfaceType(iface), getSuperInterfaceName(iface.getName()), getEncapsulationVlan(iface)); vsIface.setAlias(iface.getDescription()); vsIface.setBridgeSettings(iface.getBridgeSettings()); vsIface.setClagSettings(iface.getClagSettings()); vsIface.getIpAddresses().addAll(firstNonNull(iface.getAddresses(), ImmutableList.of())); vsIface.setSpeed(iface.getLinkSpeed()); vsIface.setVrf(iface.getVrf()); iface.getPostUpIpRoutes().forEach(vsIface::addPostUpIpRoute); return vsIface; }
InterfaceConverter { @VisibleForTesting org.batfish.representation.cumulus.Interface convertInterface(InterfacesInterface iface) { checkArgument(isInterface(iface), "input is not an interface"); checkArgument(!iface.getName().equals(BRIDGE_NAME), "interface bridge is handled separately"); String name = iface.getName(); org.batfish.representation.cumulus.Interface vsIface = new org.batfish.representation.cumulus.Interface( name, getInterfaceType(iface), getSuperInterfaceName(iface.getName()), getEncapsulationVlan(iface)); vsIface.setAlias(iface.getDescription()); vsIface.setBridgeSettings(iface.getBridgeSettings()); vsIface.setClagSettings(iface.getClagSettings()); vsIface.getIpAddresses().addAll(firstNonNull(iface.getAddresses(), ImmutableList.of())); vsIface.setSpeed(iface.getLinkSpeed()); vsIface.setVrf(iface.getVrf()); iface.getPostUpIpRoutes().forEach(vsIface::addPostUpIpRoute); return vsIface; } }
InterfaceConverter { @VisibleForTesting org.batfish.representation.cumulus.Interface convertInterface(InterfacesInterface iface) { checkArgument(isInterface(iface), "input is not an interface"); checkArgument(!iface.getName().equals(BRIDGE_NAME), "interface bridge is handled separately"); String name = iface.getName(); org.batfish.representation.cumulus.Interface vsIface = new org.batfish.representation.cumulus.Interface( name, getInterfaceType(iface), getSuperInterfaceName(iface.getName()), getEncapsulationVlan(iface)); vsIface.setAlias(iface.getDescription()); vsIface.setBridgeSettings(iface.getBridgeSettings()); vsIface.setClagSettings(iface.getClagSettings()); vsIface.getIpAddresses().addAll(firstNonNull(iface.getAddresses(), ImmutableList.of())); vsIface.setSpeed(iface.getLinkSpeed()); vsIface.setVrf(iface.getVrf()); iface.getPostUpIpRoutes().forEach(vsIface::addPostUpIpRoute); return vsIface; } InterfaceConverter(CumulusInterfacesConfiguration interfaces, Warnings w); }
InterfaceConverter { @VisibleForTesting org.batfish.representation.cumulus.Interface convertInterface(InterfacesInterface iface) { checkArgument(isInterface(iface), "input is not an interface"); checkArgument(!iface.getName().equals(BRIDGE_NAME), "interface bridge is handled separately"); String name = iface.getName(); org.batfish.representation.cumulus.Interface vsIface = new org.batfish.representation.cumulus.Interface( name, getInterfaceType(iface), getSuperInterfaceName(iface.getName()), getEncapsulationVlan(iface)); vsIface.setAlias(iface.getDescription()); vsIface.setBridgeSettings(iface.getBridgeSettings()); vsIface.setClagSettings(iface.getClagSettings()); vsIface.getIpAddresses().addAll(firstNonNull(iface.getAddresses(), ImmutableList.of())); vsIface.setSpeed(iface.getLinkSpeed()); vsIface.setVrf(iface.getVrf()); iface.getPostUpIpRoutes().forEach(vsIface::addPostUpIpRoute); return vsIface; } 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 org.batfish.representation.cumulus.Interface convertInterface(InterfacesInterface iface) { checkArgument(isInterface(iface), "input is not an interface"); checkArgument(!iface.getName().equals(BRIDGE_NAME), "interface bridge is handled separately"); String name = iface.getName(); org.batfish.representation.cumulus.Interface vsIface = new org.batfish.representation.cumulus.Interface( name, getInterfaceType(iface), getSuperInterfaceName(iface.getName()), getEncapsulationVlan(iface)); vsIface.setAlias(iface.getDescription()); vsIface.setBridgeSettings(iface.getBridgeSettings()); vsIface.setClagSettings(iface.getClagSettings()); vsIface.getIpAddresses().addAll(firstNonNull(iface.getAddresses(), ImmutableList.of())); vsIface.setSpeed(iface.getLinkSpeed()); vsIface.setVrf(iface.getVrf()); iface.getPostUpIpRoutes().forEach(vsIface::addPostUpIpRoute); return vsIface; } 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; }