private void postProcessAggregatedInterfacesHelper(Map<String, Interface> interfaces) { /* Populate aggregated interfaces with members referring to them. */ interfaces.forEach( (ifaceName, iface) -> populateChannelGroupMembers(interfaces, ifaceName, iface)); /* Compute bandwidth for aggregated interfaces. */ interfaces.values().forEach(iface -> computeAggregatedInterfaceBandwidth(iface, interfaces)); /* * For aggregated logical interfaces, inherit a subset of properties * from the parent aggregated interfaces */ interfaces.values().stream() .filter(iface -> iface.getInterfaceType() == InterfaceType.AGGREGATED) .filter(iface -> !iface.getDependencies().isEmpty()) .forEach( iface -> iface.setBandwidth( iface.getDependencies().stream() .map(dependency -> interfaces.get(dependency.getInterfaceName())) .filter(Objects::nonNull) .map(Interface::getBandwidth) .filter(Objects::nonNull) .mapToDouble(Double::doubleValue) .sum())); }
private static void computeAggregatedInterfaceBandwidth( Interface iface, Map<String, Interface> interfaces) { if (iface.getInterfaceType() == InterfaceType.AGGREGATED) { /* Bandwidth should be sum of bandwidth of channel-group members. */ iface.setBandwidth( iface.getChannelGroupMembers().stream() .mapToDouble(ifaceName -> interfaces.get(ifaceName).getBandwidth()) .sum()); } else if (iface.getInterfaceType() == InterfaceType.AGGREGATE_CHILD) { /* Bandwidth for aggregate child interfaces (e.g. units) should be inherited from the parent. */ iface.getDependencies().stream() .filter(d -> d.getType() == DependencyType.BIND) .findFirst() .map(Dependency::getInterfaceName) .map(interfaces::get) .map(Interface::getBandwidth) .ifPresent(iface::setBandwidth); } }
private void addNullRouteEdges() { for (Entry<String, List<StaticRoute>> entry : _nullStaticRoutes.entrySet()) { String router = entry.getKey(); List<StaticRoute> srs = entry.getValue(); for (StaticRoute sr : srs) { String name = sr.getNextHopInterface(); // Create null route interface Interface iface = new Interface(name); iface.setActive(true); iface.setAddress( new InterfaceAddress(sr.getNetwork().getStartIp(), sr.getNextHopIp().numSubnetBits())); iface.setBandwidth(0.); // Add static route to all static routes list Map<String, List<StaticRoute>> map = _staticRoutes.get(router); List<StaticRoute> routes = map.computeIfAbsent(name, k -> new ArrayList<>()); routes.add(sr); // Create and add graph edge for null route GraphEdge ge = new GraphEdge(iface, null, router, null, false, true); _allRealEdges.add(ge); _allEdges.add(ge); List<GraphEdge> edges = _edgeMap.computeIfAbsent(router, k -> new ArrayList<>()); edges.add(ge); } } }
private Interface createIbgpInterface(BgpActivePeerConfig n, String peer) { Interface iface = new Interface("iBGP-" + peer); iface.setActive(true); // TODO is this valid. iface.setAddress(new InterfaceAddress(n.getPeerAddress(), Prefix.MAX_PREFIX_LENGTH)); iface.setBandwidth(0.); return iface; }
private org.batfish.datamodel.Interface toInterface(Interface iface) { String name = iface.getName(); org.batfish.datamodel.Interface newIface = new org.batfish.datamodel.Interface(name, _c); newIface.setDeclaredNames(ImmutableSortedSet.of(name)); newIface.setActive(true); // TODO: may have to change newIface.setBandwidth(iface.getBandwidth()); newIface.setDescription(iface.getDescription()); InterfaceAddress address = iface.getAddress(); if (address != null) { newIface.setAddress(iface.getAddress()); } newIface.getAllAddresses().addAll(iface.getAllAddresses()); for (InterfaceAddress p : newIface.getAllAddresses()) { _ipToInterfaceMap.put(p.getIp(), newIface); } return newIface; }
for (Vrf vrf : cfgNode.getVrfs().values()) { for (Interface iface : vrf.getInterfaces().values()) { iface.setBandwidth(1E12d);
newIface.setBandwidth(iface.getBandwidth());
/** * Convert a non-unit interface to the VI {@link org.batfish.datamodel.Interface}. * * <p>Note that bulk of the configuration is stored at the logical interface level, see {@link * #toInterface(Interface)} for those conversions. Here we convert aggregation and bandwidth * settings; track VRF membership. */ private org.batfish.datamodel.Interface toInterfaceNonUnit(Interface iface) { String name = iface.getName(); org.batfish.datamodel.Interface newIface = new org.batfish.datamodel.Interface(name, _c); newIface.setDeclaredNames(ImmutableSortedSet.of(name)); newIface.setDescription(iface.getDescription()); // 802.3ad link aggregation if (iface.get8023adInterface() != null) { newIface.setChannelGroup(iface.get8023adInterface()); } // Redundant ethernet if (iface.getRedundantParentInterface() != null) { newIface.setChannelGroup(iface.getRedundantParentInterface()); } newIface.setBandwidth(iface.getBandwidth()); newIface.setVrf(_c.getVrfs().get(iface.getRoutingInstance())); return newIface; }
iface.setBandwidth(_bandwidth); iface.setBlacklisted(_blacklisted); iface.setDeclaredNames(_declaredNames);
newIface.setVrf(c.getVrfs().get(vrfName)); if (iface.getBandwidth() == null) { newIface.setBandwidth( Interface.getDefaultBandwidth(iface.getName(), c.getConfigurationFormat())); } else { newIface.setBandwidth(iface.getBandwidth());