@Test public void testConvertBond_Pvid() { InterfacesInterface bondIface = new InterfacesInterface("bond"); bondIface.setBondSlaves(ImmutableSet.of("slave")); bondIface.createOrGetBridgeSettings().setPvid(5); Bond bond = convertBond(bondIface); assertThat(bond.getBridge().getPvid(), equalTo(5)); }
@VisibleForTesting static Bond convertBond(InterfacesInterface bondIface) { Bond bond = new Bond(bondIface.getName()); bond.setClagId(bondIface.getClagId()); bond.setSlaves(bondIface.getBondSlaves()); bond.setVrf(bondIface.getVrf()); InterfaceBridgeSettings bridgeSettings = bondIface.getBridgeSettings(); if (bridgeSettings != null) { InterfaceBridgeSettings bridge = bond.getBridge(); bridge.setVids(bridgeSettings.getVids()); Optional.ofNullable(bridgeSettings.getAccess()).ifPresent(bridge::setAccess); Optional.ofNullable(bridgeSettings.getPvid()).ifPresent(bridge::setPvid); } return bond; }
InterfaceConverter { @VisibleForTesting static Bond convertBond(InterfacesInterface bondIface) { Bond bond = new Bond(bondIface.getName()); bond.setClagId(bondIface.getClagId()); bond.setSlaves(bondIface.getBondSlaves()); bond.setVrf(bondIface.getVrf()); InterfaceBridgeSettings bridgeSettings = bondIface.getBridgeSettings(); if (bridgeSettings != null) { InterfaceBridgeSettings bridge = bond.getBridge(); bridge.setVids(bridgeSettings.getVids()); Optional.ofNullable(bridgeSettings.getAccess()).ifPresent(bridge::setAccess); Optional.ofNullable(bridgeSettings.getPvid()).ifPresent(bridge::setPvid); } return bond; } }
InterfaceConverter { @VisibleForTesting static Bond convertBond(InterfacesInterface bondIface) { Bond bond = new Bond(bondIface.getName()); bond.setClagId(bondIface.getClagId()); bond.setSlaves(bondIface.getBondSlaves()); bond.setVrf(bondIface.getVrf()); InterfaceBridgeSettings bridgeSettings = bondIface.getBridgeSettings(); if (bridgeSettings != null) { InterfaceBridgeSettings bridge = bond.getBridge(); bridge.setVids(bridgeSettings.getVids()); Optional.ofNullable(bridgeSettings.getAccess()).ifPresent(bridge::setAccess); Optional.ofNullable(bridgeSettings.getPvid()).ifPresent(bridge::setPvid); } return bond; } InterfaceConverter(CumulusInterfacesConfiguration interfaces, Warnings w); }
InterfaceConverter { @VisibleForTesting static Bond convertBond(InterfacesInterface bondIface) { Bond bond = new Bond(bondIface.getName()); bond.setClagId(bondIface.getClagId()); bond.setSlaves(bondIface.getBondSlaves()); bond.setVrf(bondIface.getVrf()); InterfaceBridgeSettings bridgeSettings = bondIface.getBridgeSettings(); if (bridgeSettings != null) { InterfaceBridgeSettings bridge = bond.getBridge(); bridge.setVids(bridgeSettings.getVids()); Optional.ofNullable(bridgeSettings.getAccess()).ifPresent(bridge::setAccess); Optional.ofNullable(bridgeSettings.getPvid()).ifPresent(bridge::setPvid); } return bond; } 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 static Bond convertBond(InterfacesInterface bondIface) { Bond bond = new Bond(bondIface.getName()); bond.setClagId(bondIface.getClagId()); bond.setSlaves(bondIface.getBondSlaves()); bond.setVrf(bondIface.getVrf()); InterfaceBridgeSettings bridgeSettings = bondIface.getBridgeSettings(); if (bridgeSettings != null) { InterfaceBridgeSettings bridge = bond.getBridge(); bridge.setVids(bridgeSettings.getVids()); Optional.ofNullable(bridgeSettings.getAccess()).ifPresent(bridge::setAccess); Optional.ofNullable(bridgeSettings.getPvid()).ifPresent(bridge::setPvid); } return bond; } 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; }