Search in sources :

Example 16 with SpeakerData

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

the class ArpRuleGenerator method buildCommands.

protected List<SpeakerData> buildCommands(Switch sw, Cookie cookie, OfTable table, int priority, Set<FieldMatch> match, Instructions instructions) {
    FlowSpeakerData flowCommand = FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(table).priority(priority).match(match).instructions(instructions).build();
    List<SpeakerData> result = Lists.newArrayList(flowCommand);
    MeterSpeakerData meterCommand = generateMeter(sw, cookie);
    if (meterCommand != null) {
        result.add(meterCommand);
        addMeterToInstructions(meterCommand.getMeterId(), sw, instructions);
        flowCommand.getDependsOn().add(meterCommand.getUuid());
    }
    return result;
}
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)

Example 17 with SpeakerData

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

the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanWithOuterVlanOverlappingTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanWithOuterVlanOverlappingTest() {
    Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_1, 0);
    Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(1);
    assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
    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) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) 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 18 with SpeakerData

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

the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVxlanEncapsulationSingleVlanTest.

@Test
public void buildCommandsVxlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(3, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
    assertInputCommand(inputCustomerCommand);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_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(buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_SINGLE_VLAN_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) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 19 with SpeakerData

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

the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(3, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
    assertInputCommand(inputCustomerCommand);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_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.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.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DOUBLE_VLAN_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) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 20 with SpeakerData

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

the class SingleTableIngressYRuleGeneratorTest method buildCommandsWithoutMeter.

@Test
public void buildCommandsWithoutMeter() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    SingleTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, false);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(1, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    assertEquals(newArrayList(SHARED_METER_UUID), new ArrayList<>(ingressCommand.getDependsOn()));
    Set<FieldMatch> expectedIngressMatch = 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());
    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.Y_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, SHARED_METER_ID);
}
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) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

SpeakerData (org.openkilda.rulemanager.SpeakerData)119 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)115 Test (org.junit.Test)96 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)71 Action (org.openkilda.rulemanager.action.Action)65 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)60 Flow (org.openkilda.model.Flow)54 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)52 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)49 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)48 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)47 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)38 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)30 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)30 Instructions (org.openkilda.rulemanager.Instructions)28 FlowPath (org.openkilda.model.FlowPath)27 GroupAction (org.openkilda.rulemanager.action.GroupAction)22 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)21 Switch (org.openkilda.model.Switch)19 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)19