Search in sources :

Example 66 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class IngressMirrorRuleGeneratorTest method buildCommandsVxlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVxlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(MULTI_TABLE_PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    IngressMirrorRuleGenerator generator = buildGenerator(MULTI_TABLE_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);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
    List<Action> expectedIngressActions = newArrayList(new PopVlanAction(), new GroupAction(GROUP_ID));
    assertIngressCommand(ingressCommand, Priority.MIRROR_DOUBLE_VLAN_FLOW_PRIORITY, INGRESS, expectedIngressMatch, expectedIngressActions, METER_ID, groupCommand.getUuid());
    Set<Action> expectedFlowBucketActions = newHashSet(buildPushVxlan(), 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) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) 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)

Example 67 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class UniCastDiscoveryRuleGeneratorTest method checkPortOutAction.

private void checkPortOutAction(Action action) {
    assertTrue(action instanceof PortOutAction);
    PortOutAction portOutAction = (PortOutAction) action;
    assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction)

Example 68 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class ArpPostIngressVxlanRuleGeneratorTest method checkInstructions.

@Override
protected void checkInstructions(Instructions instructions, MeterId meterId) {
    assertEquals(2, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof PopVxlanAction);
    PopVxlanAction popVxlanAction = (PopVxlanAction) first;
    assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
    Action second = instructions.getApplyActions().get(1);
    assertTrue(second instanceof PortOutAction);
    PortOutAction portOutAction = (PortOutAction) second;
    assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
    assertNull(instructions.getWriteActions());
    assertEquals(instructions.getGoToMeter(), meterId);
    assertNull(instructions.getGoToTable());
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction)

Example 69 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class Server42FlowRttTurningRuleGeneratorTest method testOutputRule.

private void testOutputRule(Switch sw, ActionType expectedSwapFieldType) {
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(new Cookie(SERVER_42_FLOW_RTT_TURNING_COOKIE), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(SERVER_42_FLOW_RTT_TURNING_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build());
    assertEquals(expectedMatch, flowCommandData.getMatch());
    List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build(), SwapFieldAction.builder().type(expectedSwapFieldType).numberOfBits(MAC_ADDRESS_SIZE_IN_BITS).srcOffset(0).dstOffset(0).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) 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) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Example 70 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class Server42IslRttInputRuleGeneratorTest method server42IslRttInputRuleGeneratorTest.

@Test
public void server42IslRttInputRuleGeneratorTest() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(new PortColourCookie(CookieType.SERVER_42_ISL_RTT_INPUT, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(SERVER_42_ISL_RTT_INPUT_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(Utils.SERVER_42_PORT).build(), FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(OFFSET + ISL_PORT).build());
    assertEquals(expectedMatch, flowCommandData.getMatch());
    List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.ETH_DST).value(MAC_ADDRESS.toLong()).build(), new PortOutAction(new PortNumber(ISL_PORT)));
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Test(org.junit.Test)

Aggregations

PortOutAction (org.openkilda.rulemanager.action.PortOutAction)102 Action (org.openkilda.rulemanager.action.Action)80 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)76 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)60 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)59 SpeakerData (org.openkilda.rulemanager.SpeakerData)56 Test (org.junit.Test)53 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)48 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)45 Flow (org.openkilda.model.Flow)40 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)40 Instructions (org.openkilda.rulemanager.Instructions)33 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)30 ArrayList (java.util.ArrayList)27 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)26 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)18 Cookie (org.openkilda.model.cookie.Cookie)17 MeterAction (org.openkilda.rulemanager.action.MeterAction)15 FlowPath (org.openkilda.model.FlowPath)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)14