Search in sources :

Example 96 with FlowSpeakerData

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

the class ConnectedDevicesRuleGeneratorTest method shouldBuildCorrectRuleWithMeterInBytesForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterInBytesForOf13() {
    expectedFeatures.remove(PKTPS_FLAG);
    sw = buildSwitch("OF_13", expectedFeatures);
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(2, commands.size());
    commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
    commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
    assertEquals(1, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertTrue(meterCommandData.getDependsOn().isEmpty());
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
    // Check meter command
    checkMeterInBytesCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 97 with FlowSpeakerData

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

the class MultiTableIngressRuleGeneratorTest method oneSwitchFlowFullPortRuleTest.

@Test
public void oneSwitchFlowFullPortRuleTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, 0, 0, OUTER_VLAN_ID_2, 0);
    MultiTableIngressRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(1);
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
    List<Action> expectedIngressActions = newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_2).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    RoutingMetadata metadata = RoutingMetadata.builder().oneSwitchFlowFlag(true).build(SWITCH_1.getFeatures());
    assertIngressCommand(ingressCommand, Priority.DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, null, mapMetadata(metadata));
    assertInputCustomerCommand(inputCustomerCommand, new PortColourCookie(MULTI_TABLE_INGRESS_RULES, PORT_NUMBER_1), Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()));
}
Also used : 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) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Flow(org.openkilda.model.Flow) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 98 with FlowSpeakerData

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

the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(4, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(3);
    assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
    Set<FieldMatch> expectedPreIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
    FlowSharedSegmentCookie preIngressCookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(PORT_NUMBER_1).vlanId(OUTER_VLAN_ID_1).build();
    RoutingMetadata preIngressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    assertPreIngressCommand(preIngressCommand, preIngressCookie, Priority.FLOW_PRIORITY, expectedPreIngressMatch, newArrayList(new PopVlanAction()), mapMetadata(preIngressMetadata));
    assertInputCustomerCommand(inputCustomerCommand, new PortColourCookie(MULTI_TABLE_INGRESS_RULES, PORT_NUMBER_1), Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()));
    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(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
    assertMeterCommand(meterCommand);
}
Also used : 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) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 99 with FlowSpeakerData

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

the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationFullPortTest.

@Test
public void buildCommandsVlanEncapsulationFullPortTest() {
    Flow flow = buildFlow(PATH, 0, 0);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(1);
    assertInputCommand(inputCustomerCommand);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
    List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
Also used : 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) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 100 with FlowSpeakerData

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

the class SingleTableIngressRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    List<SpeakerData> result = new ArrayList<>();
    FlowEndpoint ingressEndpoint = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowSpeakerData command = buildFlowIngressCommand(sw, ingressEndpoint);
    if (command == null) {
        return Collections.emptyList();
    }
    result.add(command);
    SpeakerData meterCommand = buildMeter(flowPath, config, flowPath.getMeterId(), sw);
    if (meterCommand != null) {
        addMeterToInstructions(flowPath.getMeterId(), sw, command.getInstructions());
        result.add(meterCommand);
        command.getDependsOn().add(meterCommand.getUuid());
    }
    return result;
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Aggregations

FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)106 SpeakerData (org.openkilda.rulemanager.SpeakerData)88 Test (org.junit.Test)83 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)58 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)55 Action (org.openkilda.rulemanager.action.Action)54 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)49 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)42 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)38 Flow (org.openkilda.model.Flow)35 Instructions (org.openkilda.rulemanager.Instructions)35 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)35 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)35 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)33 GroupAction (org.openkilda.rulemanager.action.GroupAction)23 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)22 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)18 Cookie (org.openkilda.model.cookie.Cookie)15 FlowPath (org.openkilda.model.FlowPath)14 Switch (org.openkilda.model.Switch)14