Search in sources :

Example 1 with Originate

use of org.batfish.z3.state.Originate in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitPostIn.

@Test
public void testVisitPostIn() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).setEnabledInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1, INTERFACE2), NODE2, ImmutableSet.of(INTERFACE1, INTERFACE2))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PostIn.State.INSTANCE)));
    // CopyOriginate
    assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE1), new PostIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE2), new PostIn(NODE2))));
    // ProjectPostInInterface
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE1), new PostIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE2), new PostIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE1), new PostIn(NODE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE2), new PostIn(NODE2))));
}
Also used : PostIn(org.batfish.z3.state.PostIn) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) PostInInterface(org.batfish.z3.state.PostInInterface) Originate(org.batfish.z3.state.Originate) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 2 with Originate

use of org.batfish.z3.state.Originate in project batfish by batfish.

the class DefaultTransitionGenerator method visitPostIn.

@Override
public void visitPostIn(PostIn.State postIn) {
    // CopyOriginate
    _input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new Originate(hostname), new PostIn(hostname))).forEach(_rules::add);
    // ProjectPostInInterface
    _input.getEnabledInterfaces().entrySet().stream().flatMap(enabledInterfacesByHostnameEntry -> {
        String hostname = enabledInterfacesByHostnameEntry.getKey();
        return enabledInterfacesByHostnameEntry.getValue().stream().map(ifaceName -> new BasicRuleStatement(new PostInInterface(hostname, ifaceName), new PostIn(hostname)));
    }).forEach(_rules::add);
}
Also used : DropAclIn(org.batfish.z3.state.DropAclIn) NodeDropAclOut(org.batfish.z3.state.NodeDropAclOut) AclLineMatch(org.batfish.z3.state.AclLineMatch) Drop(org.batfish.z3.state.Drop) NodeDropAcl(org.batfish.z3.state.NodeDropAcl) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NumberedQuery(org.batfish.z3.state.NumberedQuery) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PostIn(org.batfish.z3.state.PostIn) AclLineNoMatch(org.batfish.z3.state.AclLineNoMatch) HeaderSpaceMatchExpr(org.batfish.z3.expr.HeaderSpaceMatchExpr) State(org.batfish.z3.expr.StateExpr.State) Originate(org.batfish.z3.state.Originate) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) Query(org.batfish.z3.state.Query) PostOutEdge(org.batfish.z3.state.PostOutEdge) List(java.util.List) PreOutEdgePostNat(org.batfish.z3.state.PreOutEdgePostNat) OriginateVrf(org.batfish.z3.state.OriginateVrf) PreOutEdge(org.batfish.z3.state.PreOutEdge) Entry(java.util.Map.Entry) NodeDrop(org.batfish.z3.state.NodeDrop) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) IpWildcard(org.batfish.datamodel.IpWildcard) TransformationHeaderField(org.batfish.z3.TransformationHeaderField) TrueExpr(org.batfish.z3.expr.TrueExpr) DropAcl(org.batfish.z3.state.DropAcl) DropNullRoute(org.batfish.z3.state.DropNullRoute) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) NodeAccept(org.batfish.z3.state.NodeAccept) ImmutableList(com.google.common.collect.ImmutableList) StateExpr(org.batfish.z3.expr.StateExpr) LineAction(org.batfish.datamodel.LineAction) RuleStatement(org.batfish.z3.expr.RuleStatement) DropAclOut(org.batfish.z3.state.DropAclOut) Debug(org.batfish.z3.state.Debug) DropNoRoute(org.batfish.z3.state.DropNoRoute) BooleanExpr(org.batfish.z3.expr.BooleanExpr) Accept(org.batfish.z3.state.Accept) NodeDropAclIn(org.batfish.z3.state.NodeDropAclIn) PreOut(org.batfish.z3.state.PreOut) AclDeny(org.batfish.z3.state.AclDeny) NotExpr(org.batfish.z3.expr.NotExpr) AclPermit(org.batfish.z3.state.AclPermit) VarIntExpr(org.batfish.z3.expr.VarIntExpr) PreInInterface(org.batfish.z3.state.PreInInterface) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NeighborUnreachable(org.batfish.z3.state.NeighborUnreachable) EqExpr(org.batfish.z3.expr.EqExpr) PostInInterface(org.batfish.z3.state.PostInInterface) PostIn(org.batfish.z3.state.PostIn) PostInInterface(org.batfish.z3.state.PostInInterface) Originate(org.batfish.z3.state.Originate) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement)

Example 3 with Originate

use of org.batfish.z3.state.Originate in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitOriginate.

@Test
public void testVisitOriginate() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledVrfs(ImmutableMap.of(NODE1, ImmutableSet.of(VRF1, VRF2), NODE2, ImmutableSet.of(VRF1, VRF2))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(Originate.State.INSTANCE)));
    // ProjectOriginateVrf
    assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE1, VRF1), new Originate(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE1, VRF2), new Originate(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE2, VRF1), new Originate(NODE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE2, VRF2), new Originate(NODE2))));
}
Also used : MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) OriginateVrf(org.batfish.z3.state.OriginateVrf) Originate(org.batfish.z3.state.Originate) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Aggregations

SynthesizerInput (org.batfish.z3.SynthesizerInput)3 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)3 RuleStatement (org.batfish.z3.expr.RuleStatement)3 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)3 Originate (org.batfish.z3.state.Originate)3 MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)2 PostIn (org.batfish.z3.state.PostIn)2 PostInInterface (org.batfish.z3.state.PostInInterface)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IpWildcard (org.batfish.datamodel.IpWildcard)1 LineAction (org.batfish.datamodel.LineAction)1 TransformationHeaderField (org.batfish.z3.TransformationHeaderField)1 BooleanExpr (org.batfish.z3.expr.BooleanExpr)1