Search in sources :

Example 11 with Flow

use of org.batfish.datamodel.Flow in project batfish by batfish.

the class AbstractNodJob method call.

@Override
public final NodJobResult call() {
    long startTime = System.currentTimeMillis();
    try (Context ctx = new Context()) {
        SmtInput smtInput = computeSmtInput(startTime, ctx);
        Map<OriginateVrf, Map<String, Long>> originateVrfConstraints = getOriginateVrfConstraints(ctx, smtInput);
        Set<Flow> flows = getFlows(originateVrfConstraints);
        return new NodJobResult(startTime, _logger.getHistory(), flows);
    } catch (Z3Exception e) {
        return new NodJobResult(startTime, _logger.getHistory(), new BatfishException("Error running NoD on concatenated data plane", e));
    }
}
Also used : Context(com.microsoft.z3.Context) BatfishException(org.batfish.common.BatfishException) OriginateVrf(org.batfish.z3.state.OriginateVrf) Z3Exception(com.microsoft.z3.Z3Exception) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Flow(org.batfish.datamodel.Flow)

Example 12 with Flow

use of org.batfish.datamodel.Flow in project batfish by batfish.

the class BdpDataPlanePluginTest method testApplySourceNatSingleAclMatch.

@Test
public void testApplySourceNatSingleAclMatch() {
    Flow flow = makeFlow();
    SourceNat nat = new SourceNat();
    nat.setAcl(makeAcl("accept", LineAction.ACCEPT));
    nat.setPoolIpFirst(new Ip("4.5.6.7"));
    Flow transformed = BdpEngine.applySourceNat(flow, singletonList(nat));
    assertThat(transformed.getSrcIp(), equalTo(new Ip("4.5.6.7")));
}
Also used : SourceNat(org.batfish.datamodel.SourceNat) Ip(org.batfish.datamodel.Ip) Flow(org.batfish.datamodel.Flow) Test(org.junit.Test)

Example 13 with Flow

use of org.batfish.datamodel.Flow in project batfish by batfish.

the class BdpDataPlanePluginTest method makeFlow.

private static Flow makeFlow() {
    Flow.Builder builder = new Flow.Builder();
    builder.setSrcIp(new Ip("1.2.3.4"));
    builder.setIngressNode("foo");
    builder.setTag("TEST");
    return builder.build();
}
Also used : Ip(org.batfish.datamodel.Ip) Flow(org.batfish.datamodel.Flow)

Example 14 with Flow

use of org.batfish.datamodel.Flow in project batfish by batfish.

the class BdpDataPlanePluginTest method testApplySourceNatLateMatchWins.

@Test
public void testApplySourceNatLateMatchWins() {
    Flow flow = makeFlow();
    SourceNat nat = new SourceNat();
    nat.setAcl(makeAcl("rejectAll", LineAction.REJECT));
    nat.setPoolIpFirst(new Ip("4.5.6.7"));
    SourceNat secondNat = new SourceNat();
    secondNat.setAcl(makeAcl("acceptAnyway", LineAction.ACCEPT));
    secondNat.setPoolIpFirst(new Ip("4.5.6.8"));
    Flow transformed = BdpEngine.applySourceNat(flow, Lists.newArrayList(nat, secondNat));
    assertThat(transformed.getSrcIp(), equalTo(new Ip("4.5.6.8")));
}
Also used : SourceNat(org.batfish.datamodel.SourceNat) Ip(org.batfish.datamodel.Ip) Flow(org.batfish.datamodel.Flow) Test(org.junit.Test)

Example 15 with Flow

use of org.batfish.datamodel.Flow in project batfish by batfish.

the class BdpDataPlanePluginTest method testApplySourceNatInvalidAclThrows.

@Test
public void testApplySourceNatInvalidAclThrows() {
    Flow flow = makeFlow();
    SourceNat nat = new SourceNat();
    nat.setAcl(makeAcl("matchAll", LineAction.ACCEPT));
    _thrown.expect(BatfishException.class);
    _thrown.expectMessage("missing NAT address or pool");
    BdpEngine.applySourceNat(flow, singletonList(nat));
}
Also used : SourceNat(org.batfish.datamodel.SourceNat) Flow(org.batfish.datamodel.Flow) Test(org.junit.Test)

Aggregations

Flow (org.batfish.datamodel.Flow)25 Ip (org.batfish.datamodel.Ip)16 FlowTrace (org.batfish.datamodel.FlowTrace)11 TreeSet (java.util.TreeSet)8 Edge (org.batfish.datamodel.Edge)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 BatfishException (org.batfish.common.BatfishException)7 SortedMap (java.util.SortedMap)6 BgpAdvertisement (org.batfish.datamodel.BgpAdvertisement)6 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)5 Prefix (org.batfish.datamodel.Prefix)5 SourceNat (org.batfish.datamodel.SourceNat)5 Test (org.junit.Test)5 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)4 BoolExpr (com.microsoft.z3.BoolExpr)4 GlobalTracer (io.opentracing.util.GlobalTracer)4 Collections (java.util.Collections)4 SortedSet (java.util.SortedSet)4