Search in sources :

Example 36 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class EgressRuleGeneratorTest method buildVlanMultiTableFullPortEgressRuleTest.

@Test
public void buildVlanMultiTableFullPortEgressRuleTest() {
    FlowPath path = buildPath(true);
    Flow flow = buildFlow(path, 0, 0);
    EgressRuleGenerator generator = buildGenerator(path, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVlanAction(), new PortOutAction(new PortNumber(PORT_NUMBER_4)));
    assertEgressCommands(commands, OfTable.EGRESS, VLAN_ENCAPSULATION, expectedApplyActions);
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowPath(org.openkilda.model.FlowPath) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) Test(org.junit.Test)

Example 37 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class EgressRuleGeneratorTest method buildVlanMultiTableOuterInnerVlanEgressRuleTest.

@Test
public void buildVlanMultiTableOuterInnerVlanEgressRuleTest() {
    FlowPath path = buildPath(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, INNER_VLAN_ID);
    EgressRuleGenerator generator = buildGenerator(path, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_4)));
    assertEgressCommands(commands, OfTable.EGRESS, VLAN_ENCAPSULATION, expectedApplyActions);
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) FlowPath(org.openkilda.model.FlowPath) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 38 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class EgressRuleGeneratorTest method buildVxlanSingleTableFullPortEgressRuleTest.

@Test
public void buildVxlanSingleTableFullPortEgressRuleTest() {
    FlowPath path = buildPath(false);
    Flow flow = buildFlow(path, 0, 0);
    EgressRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PortOutAction(new PortNumber(PORT_NUMBER_4)));
    assertEgressCommands(commands, OfTable.INPUT, VXLAN_ENCAPSULATION, expectedApplyActions);
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) FlowPath(org.openkilda.model.FlowPath) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 39 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class TransitYRuleGeneratorTest method assertTransitCommands.

private void assertTransitCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
    assertEquals(2, commands.size());
    MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertEquals(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.Y_FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).goToMeter(SHARED_METER_ID).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), flowCommandData.getFlags());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 40 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class IngressMirrorRuleGeneratorTest method buildSingleTableCommandsOneSwitchFullPortTest.

@Test
public void buildSingleTableCommandsOneSwitchFullPortTest() {
    Flow flow = buildFlow(SINGLE_TABLE_ONE_SWITCH_PATH, 0, 0, 0, 0);
    IngressMirrorRuleGenerator generator = buildGenerator(SINGLE_TABLE_ONE_SWITCH_PATH, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
    List<Action> expectedIngressActions = newArrayList(new GroupAction(GROUP_ID));
    assertIngressCommand(ingressCommand, Priority.MIRROR_DEFAULT_FLOW_PRIORITY, INPUT, expectedIngressMatch, expectedIngressActions, null, groupCommand.getUuid());
    Set<Action> expectedFlowBucketActions = newHashSet(new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertGroupCommand(groupCommand, expectedFlowBucketActions);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) GroupAction(org.openkilda.rulemanager.action.GroupAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Aggregations

PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)76 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)76 Action (org.openkilda.rulemanager.action.Action)58 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)52 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)52 SpeakerData (org.openkilda.rulemanager.SpeakerData)49 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)47 Test (org.junit.Test)46 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)41 Flow (org.openkilda.model.Flow)40 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)37 Instructions (org.openkilda.rulemanager.Instructions)24 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)23 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)21 ArrayList (java.util.ArrayList)19 Cookie (org.openkilda.model.cookie.Cookie)15 FlowPath (org.openkilda.model.FlowPath)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)14 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)13 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)8