Search in sources :

Example 96 with FieldMatch

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

the class SingleTableIngressYRuleGeneratorTest method buildCommandsVlanEncapsulationSingleVlanTest.

@Test
public void buildCommandsVlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    SingleTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    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()));
    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);
    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) Flow(org.openkilda.model.Flow) 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 97 with FieldMatch

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

the class MultiTableIngressYRuleGeneratorTest method buildCommandsWithoutMeter.

@Test
public void buildCommandsWithoutMeter() {
    Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_2, 0);
    Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping, 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()));
    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.Y_FLOW_DOUBLE_VLAN_PRIORITY, expectedIngressMatch, expectedIngressActions, SHARED_METER_ID, null);
}
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) 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 98 with FieldMatch

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

the class MultiTableIngressYRuleGeneratorTest method buildMatchVlanEncapsulationDoubleVlanTest.

@Test
public void buildMatchVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    Set<FieldMatch> match = generator.buildIngressMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedMatch = 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(metadata.getValue()).mask(metadata.getMask()).build());
    assertEqualsMatch(expectedMatch, match);
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 99 with FieldMatch

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

the class SingleTableIngressRuleGeneratorTest method buildMatchVlanEncapsulationFullPortTest.

@Test
public void buildMatchVlanEncapsulationFullPortTest() {
    Flow flow = buildFlow(PATH, 0, 0);
    SingleTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    Set<FieldMatch> match = generator.buildMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
    assertEqualsMatch(expectedMatch, match);
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 100 with FieldMatch

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

the class Server42IslRttTurningRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    Set<FieldMatch> match = buildMatch(new MacAddress(config.getServer42IslRttMagicMacAddress()));
    List<Action> actions = new ArrayList<>();
    actions.add(SetFieldAction.builder().field(UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build());
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_ISL_RTT_TURNING_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_ISL_RTT_TURNING_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) MacAddress(org.openkilda.model.MacAddress) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Aggregations

FieldMatch (org.openkilda.rulemanager.match.FieldMatch)121 Test (org.junit.Test)61 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)55 Instructions (org.openkilda.rulemanager.Instructions)55 SpeakerData (org.openkilda.rulemanager.SpeakerData)50 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)50 Action (org.openkilda.rulemanager.action.Action)46 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)41 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)41 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)37 Flow (org.openkilda.model.Flow)31 Cookie (org.openkilda.model.cookie.Cookie)30 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)27 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)25 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)24 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)23 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)15 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)12 Switch (org.openkilda.model.Switch)12 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)12