use of org.batfish.datamodel.Interface in project batfish by batfish.
the class CiscoGrammarTest method testOspfPointToPoint.
@Test
public void testOspfPointToPoint() throws IOException {
String testrigName = "ospf-point-to-point";
String iosOspfPointToPoint = "ios-ospf-point-to-point";
List<String> configurationNames = ImmutableList.of(iosOspfPointToPoint);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Configuration iosMaxMetric = configurations.get(iosOspfPointToPoint);
Interface e0Sub0 = iosMaxMetric.getInterfaces().get("Ethernet0/0");
Interface e0Sub1 = iosMaxMetric.getInterfaces().get("Ethernet0/1");
assertTrue(e0Sub0.getOspfPointToPoint());
assertFalse(e0Sub1.getOspfPointToPoint());
}
use of org.batfish.datamodel.Interface in project batfish by batfish.
the class CiscoGrammarTest method testInterfaceNames.
@Test
public void testInterfaceNames() throws IOException {
String testrigName = "interface-names";
String iosHostname = "ios";
String i1Name = "Ethernet0/0";
List<String> configurationNames = ImmutableList.of(iosHostname);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Interface i1 = configurations.get(iosHostname).getInterfaces().get(i1Name);
assertThat(i1, hasDeclaredNames("Ethernet0/0", "e0/0", "Eth0/0", "ether0/0-1"));
}
use of org.batfish.datamodel.Interface in project batfish by batfish.
the class HostInterfaceTest method testToInterface.
@Test
public void testToInterface() {
String name = "eth0";
HostInterface hi = new HostInterface(name);
hi.setCanonicalName(name);
Interface i = hi.toInterface(_c, new Warnings());
/* Check defaults */
assertThat(i, isProxyArp(equalTo(false)));
}
use of org.batfish.datamodel.Interface in project batfish by batfish.
the class SynthesizerInputImplTest method testComputeAclConditions.
@Test
public void testComputeAclConditions() {
Configuration c = _cb.build();
IpAccessList aclWithoutLines = _aclb.setOwner(c).build();
_acllb.setAction(LineAction.ACCEPT);
IpAccessList aclWithLines = _aclb.setLines(ImmutableList.<IpAccessListLine>of(_acllb.setDstIps(ImmutableSet.of(new IpWildcard(new Ip("1.2.3.4")))).build(), _acllb.setDstIps(ImmutableSet.of(new IpWildcard(new Ip("5.6.7.8")))).build())).build();
SynthesizerInput input = _inputBuilder.setConfigurations(ImmutableMap.of(c.getName(), c)).build();
assertThat(input, hasAclConditions(equalTo(ImmutableMap.of(c.getName(), ImmutableMap.of(aclWithoutLines.getName(), ImmutableList.of(), aclWithLines.getName(), ImmutableList.of(new HeaderSpaceMatchExpr(aclWithLines.getLines().get(0)), new HeaderSpaceMatchExpr(aclWithLines.getLines().get(1))))))));
Configuration srcNode = _cb.build();
Configuration nextHop = _cb.build();
Vrf srcVrf = _vb.setOwner(srcNode).build();
Vrf nextHopVrf = _vb.setOwner(nextHop).build();
Ip ip11 = new Ip("1.0.0.0");
Ip ip12 = new Ip("1.0.0.10");
Ip ip21 = new Ip("2.0.0.0");
Ip ip22 = new Ip("2.0.0.10");
IpAccessList sourceNat1Acl = _aclb.setLines(ImmutableList.of()).setOwner(srcNode).build();
IpAccessList sourceNat2Acl = _aclb.build();
SourceNat sourceNat1 = _snb.setPoolIpFirst(ip11).setPoolIpLast(ip12).setAcl(sourceNat1Acl).build();
SourceNat sourceNat2 = _snb.setPoolIpFirst(ip21).setPoolIpLast(ip22).setAcl(sourceNat2Acl).build();
Interface srcInterfaceZeroSourceNats = _ib.setOwner(srcNode).setVrf(srcVrf).setSourceNats(ImmutableList.of()).build();
Interface srcInterfaceOneSourceNat = _ib.setSourceNats(ImmutableList.of(sourceNat1)).build();
Interface srcInterfaceTwoSourceNats = _ib.setSourceNats(ImmutableList.of(sourceNat1, sourceNat2)).build();
Interface nextHopInterface = _ib.setOwner(nextHop).setVrf(nextHopVrf).setSourceNats(ImmutableList.of()).build();
Edge forwardEdge1 = new Edge(srcInterfaceZeroSourceNats, nextHopInterface);
Edge forwardEdge2 = new Edge(srcInterfaceOneSourceNat, nextHopInterface);
Edge forwardEdge3 = new Edge(srcInterfaceTwoSourceNats, nextHopInterface);
Edge backEdge1 = new Edge(nextHopInterface, srcInterfaceZeroSourceNats);
Edge backEdge2 = new Edge(nextHopInterface, srcInterfaceOneSourceNat);
Edge backEdge3 = new Edge(nextHopInterface, srcInterfaceTwoSourceNats);
SynthesizerInput inputWithDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(srcNode.getName(), srcNode, nextHop.getName(), nextHop)).setForwardingAnalysis(MockForwardingAnalysis.builder().build()).setTopology(new Topology(ImmutableSortedSet.of(forwardEdge1, forwardEdge2, forwardEdge3, backEdge1, backEdge2, backEdge3))).build();
assertThat(inputWithDataPlane, hasAclConditions(equalTo(ImmutableMap.of(srcNode.getName(), ImmutableMap.of(sourceNat1Acl.getName(), ImmutableList.of(), sourceNat2Acl.getName(), ImmutableList.of()), nextHop.getName(), ImmutableMap.of()))));
}
use of org.batfish.datamodel.Interface in project batfish by batfish.
the class SynthesizerInputImplTest method testComputeEnabledInterfaces.
@Test
public void testComputeEnabledInterfaces() {
Configuration cEnabled = _cb.build();
Configuration cDisabled = _cb.build();
Vrf vEnabled = _vb.setOwner(cEnabled).build();
Vrf vDisabledViaVrf = _vb.build();
Vrf vDisabledViaNode = _vb.setOwner(cDisabled).build();
Interface iEnabled = _ib.setOwner(cEnabled).setVrf(vEnabled).build();
Interface iDisabledViaInactive = _ib.setActive(false).build();
Interface iDisabledViaBlacklisted = _ib.setActive(true).setBlacklisted(true).build();
Interface iDisabledViaInterface = _ib.setBlacklisted(false).build();
Interface iDisabledViaVrf = _ib.setVrf(vDisabledViaVrf).build();
// interface disabled via disabledNodes
_ib.setOwner(cDisabled).setVrf(vDisabledViaNode).build();
SynthesizerInput input = _inputBuilder.setConfigurations(ImmutableMap.of(cEnabled.getName(), cEnabled, cDisabled.getName(), cDisabled)).setDisabledNodes(ImmutableSet.of(cDisabled.getName())).setDisabledVrfs(ImmutableMap.of(cEnabled.getName(), ImmutableSet.of(vDisabledViaVrf.getName()))).setDisabledInterfaces(ImmutableMap.of(cEnabled.getName(), ImmutableSet.of(iDisabledViaInterface.getName()))).build();
assertThat(input, hasEnabledInterfaces(hasEntry(equalTo(cEnabled.getName()), hasItem(iEnabled.getName()))));
assertThat(input, hasEnabledInterfaces(hasEntry(equalTo(cEnabled.getName()), not(hasItem(iDisabledViaInactive.getName())))));
assertThat(input, hasEnabledInterfaces(hasEntry(equalTo(cEnabled.getName()), not(hasItem(iDisabledViaBlacklisted.getName())))));
assertThat(input, hasEnabledInterfaces(hasEntry(equalTo(cEnabled.getName()), not(hasItem(iDisabledViaInterface.getName())))));
assertThat(input, hasEnabledInterfaces(hasEntry(equalTo(cEnabled.getName()), not(hasItem(iDisabledViaVrf.getName())))));
assertThat(input, hasEnabledInterfaces(not(hasKey(cDisabled.getName()))));
}
Aggregations