Search in sources :

Example 56 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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 57 with PortNumber

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

the class FlowLoopIngressRuleGeneratorTest method buildSingleTableSingleVlanRuleTest.

@Test
public void buildSingleTableSingleVlanRuleTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_1, 0, OUTER_VLAN_2, 0);
    List<SpeakerData> commands = buildGenerator(flow, false).generateCommands(SWITCH_1);
    assertIngressCommands(commands, OfTable.INPUT, Priority.LOOP_FLOW_PRIORITY, newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_1).build()), newArrayList(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT))));
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) 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 58 with PortNumber

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

the class FlowLoopIngressRuleGeneratorTest method buildMultiTableDefaultFlowRuleTest.

@Test
public void buildMultiTableDefaultFlowRuleTest() {
    Flow flow = buildFlow(PATH, 0, 0, OUTER_VLAN_2, INNER_VLAN_2);
    List<SpeakerData> commands = buildGenerator(flow, true).generateCommands(SWITCH_1);
    assertIngressCommands(commands, OfTable.INGRESS, Priority.LOOP_DEFAULT_FLOW_PRIORITY, newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()), newArrayList(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT))));
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) 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 59 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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 60 with PortNumber

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

the class EgressMirrorRuleGeneratorTest method assertGroupCommand.

private void assertGroupCommand(GroupSpeakerData command) {
    assertEquals(GROUP_ID, command.getGroupId());
    assertEquals(SWITCH_2.getSwitchId(), command.getSwitchId());
    assertEquals(SWITCH_2.getOfVersion(), command.getOfVersion().toString());
    assertEquals(GroupType.ALL, command.getType());
    assertTrue(command.getDependsOn().isEmpty());
    assertEquals(2, command.getBuckets().size());
    Bucket flowBucket = command.getBuckets().get(0);
    assertBucketCommon(flowBucket);
    assertEquals(newHashSet(new PortOutAction(new PortNumber(PORT_NUMBER_4))), flowBucket.getWriteActions());
    Bucket mirrorBucket = command.getBuckets().get(1);
    assertBucketCommon(mirrorBucket);
    assertEquals(newHashSet(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(MIRROR_VLAN).build(), new PortOutAction(new PortNumber(MIRROR_PORT))), mirrorBucket.getWriteActions());
}
Also used : Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

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