@Test public void testAddOspfInterfaces_HasCost() { CumulusNcluConfiguration config = new CumulusNcluConfiguration(); config.setOspfProcess(new OspfProcess()); Interface vsIface = new Interface("iface", CumulusInterfaceType.PHYSICAL, null, null); config.getInterfaces().put("iface", vsIface); vsIface.getOrCreateOspf().setOspfArea(0L); vsIface.getOrCreateOspf().setCost(100); Vrf vrf = new Vrf(DEFAULT_VRF_NAME); org.batfish.datamodel.Interface viIface = org.batfish.datamodel.Interface.builder().setName("iface").setVrf(vrf).build(); Map<String, org.batfish.datamodel.Interface> ifaceMap = ImmutableMap.of(viIface.getName(), viIface); addOspfInterfaces(config, ifaceMap, "1", new Warnings()); assertThat(viIface.getOspfCost(), equalTo(100)); }
@VisibleForTesting static void addOspfInterfaces( CumulusNodeConfiguration vsConfig, Map<String, org.batfish.datamodel.Interface> viIfaces, String processId, Warnings w) { viIfaces.forEach( (ifaceName, iface) -> { Optional<OspfInterface> ospfOpt = vsConfig.getOspfInterface(ifaceName); if (!ospfOpt.isPresent() || ospfOpt.get().getOspfArea() == null) { return; } OspfInterface ospfInterface = ospfOpt.get(); iface.setOspfSettings( OspfInterfaceSettings.builder() .setPassive( Optional.ofNullable(ospfInterface.getPassive()) .orElse(vsConfig.getOspfProcess().getDefaultPassiveInterface())) .setAreaName(ospfInterface.getOspfArea()) .setNetworkType(toOspfNetworkType(ospfInterface.getNetwork(), w)) .setDeadInterval( Optional.ofNullable(ospfInterface.getDeadInterval()) .orElse(DEFAULT_OSPF_DEAD_INTERVAL)) .setHelloInterval( Optional.ofNullable(ospfInterface.getHelloInterval()) .orElse(DEFAULT_OSPF_HELLO_INTERVAL)) .setProcess(processId) .setCost(ospfInterface.getCost()) .build()); }); }
CumulusConversions { @VisibleForTesting static void addOspfInterfaces( CumulusNodeConfiguration vsConfig, Map<String, org.batfish.datamodel.Interface> viIfaces, String processId, Warnings w) { viIfaces.forEach( (ifaceName, iface) -> { Optional<OspfInterface> ospfOpt = vsConfig.getOspfInterface(ifaceName); if (!ospfOpt.isPresent() || ospfOpt.get().getOspfArea() == null) { return; } OspfInterface ospfInterface = ospfOpt.get(); iface.setOspfSettings( OspfInterfaceSettings.builder() .setPassive( Optional.ofNullable(ospfInterface.getPassive()) .orElse(vsConfig.getOspfProcess().getDefaultPassiveInterface())) .setAreaName(ospfInterface.getOspfArea()) .setNetworkType(toOspfNetworkType(ospfInterface.getNetwork(), w)) .setDeadInterval( Optional.ofNullable(ospfInterface.getDeadInterval()) .orElse(DEFAULT_OSPF_DEAD_INTERVAL)) .setHelloInterval( Optional.ofNullable(ospfInterface.getHelloInterval()) .orElse(DEFAULT_OSPF_HELLO_INTERVAL)) .setProcess(processId) .setCost(ospfInterface.getCost()) .build()); }); } }
CumulusConversions { @VisibleForTesting static void addOspfInterfaces( CumulusNodeConfiguration vsConfig, Map<String, org.batfish.datamodel.Interface> viIfaces, String processId, Warnings w) { viIfaces.forEach( (ifaceName, iface) -> { Optional<OspfInterface> ospfOpt = vsConfig.getOspfInterface(ifaceName); if (!ospfOpt.isPresent() || ospfOpt.get().getOspfArea() == null) { return; } OspfInterface ospfInterface = ospfOpt.get(); iface.setOspfSettings( OspfInterfaceSettings.builder() .setPassive( Optional.ofNullable(ospfInterface.getPassive()) .orElse(vsConfig.getOspfProcess().getDefaultPassiveInterface())) .setAreaName(ospfInterface.getOspfArea()) .setNetworkType(toOspfNetworkType(ospfInterface.getNetwork(), w)) .setDeadInterval( Optional.ofNullable(ospfInterface.getDeadInterval()) .orElse(DEFAULT_OSPF_DEAD_INTERVAL)) .setHelloInterval( Optional.ofNullable(ospfInterface.getHelloInterval()) .orElse(DEFAULT_OSPF_HELLO_INTERVAL)) .setProcess(processId) .setCost(ospfInterface.getCost()) .build()); }); }  }
CumulusConversions { @VisibleForTesting static void addOspfInterfaces( CumulusNodeConfiguration vsConfig, Map<String, org.batfish.datamodel.Interface> viIfaces, String processId, Warnings w) { viIfaces.forEach( (ifaceName, iface) -> { Optional<OspfInterface> ospfOpt = vsConfig.getOspfInterface(ifaceName); if (!ospfOpt.isPresent() || ospfOpt.get().getOspfArea() == null) { return; } OspfInterface ospfInterface = ospfOpt.get(); iface.setOspfSettings( OspfInterfaceSettings.builder() .setPassive( Optional.ofNullable(ospfInterface.getPassive()) .orElse(vsConfig.getOspfProcess().getDefaultPassiveInterface())) .setAreaName(ospfInterface.getOspfArea()) .setNetworkType(toOspfNetworkType(ospfInterface.getNetwork(), w)) .setDeadInterval( Optional.ofNullable(ospfInterface.getDeadInterval()) .orElse(DEFAULT_OSPF_DEAD_INTERVAL)) .setHelloInterval( Optional.ofNullable(ospfInterface.getHelloInterval()) .orElse(DEFAULT_OSPF_HELLO_INTERVAL)) .setProcess(processId) .setCost(ospfInterface.getCost()) .build()); }); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); }
CumulusConversions { @VisibleForTesting static void addOspfInterfaces( CumulusNodeConfiguration vsConfig, Map<String, org.batfish.datamodel.Interface> viIfaces, String processId, Warnings w) { viIfaces.forEach( (ifaceName, iface) -> { Optional<OspfInterface> ospfOpt = vsConfig.getOspfInterface(ifaceName); if (!ospfOpt.isPresent() || ospfOpt.get().getOspfArea() == null) { return; } OspfInterface ospfInterface = ospfOpt.get(); iface.setOspfSettings( OspfInterfaceSettings.builder() .setPassive( Optional.ofNullable(ospfInterface.getPassive()) .orElse(vsConfig.getOspfProcess().getDefaultPassiveInterface())) .setAreaName(ospfInterface.getOspfArea()) .setNetworkType(toOspfNetworkType(ospfInterface.getNetwork(), w)) .setDeadInterval( Optional.ofNullable(ospfInterface.getDeadInterval()) .orElse(DEFAULT_OSPF_DEAD_INTERVAL)) .setHelloInterval( Optional.ofNullable(ospfInterface.getHelloInterval()) .orElse(DEFAULT_OSPF_HELLO_INTERVAL)) .setProcess(processId) .setCost(ospfInterface.getCost()) .build()); }); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); static final int DEFAULT_STATIC_ROUTE_ADMINISTRATIVE_DISTANCE; static final int DEFAULT_STATIC_ROUTE_METRIC; static final Ip CLAG_LINK_LOCAL_IP; static final long DEFAULT_MAX_MED; static final double SPEED_CONVERSION_FACTOR; static final double DEFAULT_LOOPBACK_BANDWIDTH; static final double DEFAULT_PORT_BANDWIDTH; }