/** Initialize interface costs for all interfaces that belong to this process */ public void initInterfaceCosts(Configuration c) { _areas.values().stream() .flatMap(a -> a.getInterfaces().stream()) .map(interfaceName -> c.getAllInterfaces().get(interfaceName)) .filter(Interface::getActive) .forEach(i -> i.setOspfCost(computeInterfaceCost(i))); }
private void placeInterfaceIntoArea( Map<Long, org.batfish.datamodel.ospf.OspfArea.Builder> newAreas, String interfaceName, Interface iface, String vrfName) { Vrf vrf = _c.getVrfs().get(vrfName); org.batfish.datamodel.Interface newIface = vrf.getInterfaces().get(interfaceName); Ip ospfArea = iface.getOspfArea(); if (ospfArea == null) { return; } if (newIface.getAddress() == null) { _w.redFlag( String.format( "Cannot assign interface %s to area %s because it has no IP address.", interfaceName, ospfArea)); return; } long ospfAreaLong = ospfArea.asLong(); org.batfish.datamodel.ospf.OspfArea.Builder newArea = newAreas.get(ospfAreaLong); newArea.addInterface(interfaceName); newIface.setOspfEnabled(true); newIface.setOspfPassive(iface.getOspfPassive()); Integer ospfCost = iface.getOspfCost(); if (ospfCost == null && newIface.isLoopback(ConfigurationFormat.FLAT_JUNIPER)) { ospfCost = 0; } newIface.setOspfCost(ospfCost); }
iface.setOspfAreaName(_ospfArea.getAreaNumber()); iface.setOspfCost(_ospfCost); iface.setOspfEnabled(_ospfEnabled); iface.setOspfPassive(_ospfPassive); OspfProcess proc = _vrf.getOspfProcess(); if (proc != null && _active) { iface.setOspfCost(proc.computeInterfaceCost(iface));
newIface.setOspfCost(iface.getOspfCost()); newIface.setOspfDeadInterval(iface.getOspfDeadInterval()); newIface.setOspfHelloMultiplier(iface.getOspfHelloMultiplier());