/** * 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; }
@Test public void testToLogicalNodeMissingAggregate() { String c1Name = "c1"; String iName = "i1"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(iName).build().setChannelGroup("missing"); NetworkConfigurations networkConfigurations = NetworkConfigurations.of(ImmutableSortedMap.of(c1Name, c1)); Layer1Node node = new Layer1Node(c1Name, iName); // If node is member of a missing aggregate, the result should be null assertThat(node.toLogicalNode(networkConfigurations), nullValue()); }
@Test public void testToLogicalNodeInactiveAggregate() { String c1Name = "c1"; String iName = "i1"; String aName = "a1"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(iName).build().setChannelGroup(aName); _ib.setName(aName).setActive(false).build(); NetworkConfigurations networkConfigurations = NetworkConfigurations.of(ImmutableSortedMap.of(c1Name, c1)); Layer1Node node = new Layer1Node(c1Name, iName); // If node is member of a disabled aggregate, the result should be null assertThat(node.toLogicalNode(networkConfigurations), nullValue()); }
@Test public void testToLogicalNodeAggregate() { String c1Name = "c1"; String iName = "i1"; String aName = "a1"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(iName).build().setChannelGroup(aName); _ib.setName(aName).build(); NetworkConfigurations networkConfigurations = NetworkConfigurations.of(ImmutableSortedMap.of(c1Name, c1)); Layer1Node node = new Layer1Node(c1Name, iName); // If node is member of an aggregate, the resulting logical node should be for the aggregate // interface. assertThat(node.toLogicalNode(networkConfigurations), equalTo(new Layer1Node(c1Name, aName))); }
newIface.setDescription(iface.getDescription()); newIface.setActive(iface.getActive()); newIface.setChannelGroup(iface.getChannelGroup()); newIface.setCryptoMap(iface.getCryptoMap()); newIface.setHsrpGroups(
@Test public void testToLogicalEdgeNode1Absent() { String c1Name = "c1"; String c2Name = "c2"; String iName = "i1"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(iName).build().setChannelGroup("missing"); Configuration c2 = _cb.setHostname(c2Name).build(); Vrf v2 = _vb.setOwner(c2).build(); _ib.setOwner(c2).setVrf(v2); _ib.setName(iName).build(); NetworkConfigurations networkConfigurations = NetworkConfigurations.of(ImmutableSortedMap.of(c1Name, c1, c2Name, c2)); Layer1Edge edge = new Layer1Edge(new Layer1Node(c1Name, iName), new Layer1Node(c2Name, iName)); // If node1 of a layer-1 physical edge cannot be mapped to a layer-1 logical node, a null edge // should be returned. assertThat(edge.toLogicalEdge(networkConfigurations), nullValue()); }
@Test public void testToLogicalEdgeNode2Absent() { String c1Name = "c1"; String c2Name = "c2"; String iName = "i1"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(iName).build(); Configuration c2 = _cb.setHostname(c2Name).build(); Vrf v2 = _vb.setOwner(c2).build(); _ib.setOwner(c2).setVrf(v2); // force node2 to map to null _ib.setName(iName).build().setChannelGroup("missing"); NetworkConfigurations networkConfigurations = NetworkConfigurations.of(ImmutableSortedMap.of(c1Name, c1, c2Name, c2)); Layer1Edge edge = new Layer1Edge(new Layer1Node(c1Name, iName), new Layer1Node(c2Name, iName)); // If node2 of a layer-1 physical edge cannot be mapped to a layer-1 logical node, a null edge // should be returned. assertThat(edge.toLogicalEdge(networkConfigurations), nullValue()); }
Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(c1i1aName).build().setChannelGroup(c1a1Name); _ib.setName(c1i1bName).build().setChannelGroup(c1a1Name); _ib.setName(c1a1Name).build(); _ib.setOwner(c2).setVrf(v2); _ib.setName(c2a1Name).build(); _ib.setName(c2i1aName).build().setChannelGroup(c2a1Name); _ib.setName(c2i1bName).build().setChannelGroup(c2a1Name);
Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(c1i1aName).build().setChannelGroup(c1a1Name); _ib.setName(c1i1bName).build().setChannelGroup(c1a1Name); _ib.setName(c1a1Name).build(); _ib.setOwner(c2).setVrf(v2); _ib.setName(c2a1Name).build(); _ib.setName(c2i1aName).build().setChannelGroup(c2a1Name); _ib.setName(c2i1bName).build().setChannelGroup(c2a1Name);