Search in sources :

Example 56 with Interface

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());
}
Also used : Configuration(org.batfish.datamodel.Configuration) Batfish(org.batfish.main.Batfish) Interface(org.batfish.datamodel.Interface) ConfigurationMatchers.hasInterface(org.batfish.datamodel.matchers.ConfigurationMatchers.hasInterface) Test(org.junit.Test)

Example 57 with Interface

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"));
}
Also used : Configuration(org.batfish.datamodel.Configuration) Batfish(org.batfish.main.Batfish) Interface(org.batfish.datamodel.Interface) ConfigurationMatchers.hasInterface(org.batfish.datamodel.matchers.ConfigurationMatchers.hasInterface) Test(org.junit.Test)

Example 58 with Interface

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)));
}
Also used : HostInterface(org.batfish.representation.host.HostInterface) Warnings(org.batfish.common.Warnings) HostInterface(org.batfish.representation.host.HostInterface) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Example 59 with Interface

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()))));
}
Also used : IpWildcard(org.batfish.datamodel.IpWildcard) SourceNat(org.batfish.datamodel.SourceNat) Configuration(org.batfish.datamodel.Configuration) Ip(org.batfish.datamodel.Ip) IpAccessListLine(org.batfish.datamodel.IpAccessListLine) IpAccessList(org.batfish.datamodel.IpAccessList) HeaderSpaceMatchExpr(org.batfish.z3.expr.HeaderSpaceMatchExpr) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) SynthesizerInputMatchers.hasArpTrueEdge(org.batfish.z3.matchers.SynthesizerInputMatchers.hasArpTrueEdge) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Example 60 with Interface

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()))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) Vrf(org.batfish.datamodel.Vrf) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Aggregations

Interface (org.batfish.datamodel.Interface)68 Configuration (org.batfish.datamodel.Configuration)42 Ip (org.batfish.datamodel.Ip)26 Edge (org.batfish.datamodel.Edge)21 Prefix (org.batfish.datamodel.Prefix)20 Test (org.junit.Test)19 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)18 Vrf (org.batfish.datamodel.Vrf)18 HashMap (java.util.HashMap)17 IpAccessList (org.batfish.datamodel.IpAccessList)16 Topology (org.batfish.datamodel.Topology)14 ArrayList (java.util.ArrayList)13 List (java.util.List)13 StaticRoute (org.batfish.datamodel.StaticRoute)13 HashSet (java.util.HashSet)12 Set (java.util.Set)12 BatfishException (org.batfish.common.BatfishException)12 Map (java.util.Map)11 TreeSet (java.util.TreeSet)10 SortedSet (java.util.SortedSet)9