Search in sources :

Example 16 with PortNumber

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

the class TransitRuleGeneratorTest method assertTransitCommands.

private void assertTransitCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertTrue(flowCommandData.getFlags().isEmpty());
}
Also used : 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)

Example 17 with PortNumber

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

the class FlowLoopIngressRuleGeneratorTest method buildMultiTableSingleVlanRuleTest.

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

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

the class Utils method buildMirrorBuckets.

/**
 * Builds group buckets for flow mirror points (only for sink endpoints. Flow bucket must be build separately).
 */
public static List<Bucket> buildMirrorBuckets(FlowMirrorPoints flowMirrorPoints) {
    List<Bucket> buckets = new ArrayList<>();
    Set<MirrorConfigData> mirrorConfigDataSet = flowMirrorPoints.getMirrorPaths().stream().map(mirrorPath -> new MirrorConfigData(mirrorPath.getEgressPort(), mirrorPath.getEgressOuterVlan())).collect(Collectors.toSet());
    for (MirrorConfigData mirrorConfig : mirrorConfigDataSet) {
        Set<Action> actions = new HashSet<>(makeVlanReplaceActions(new ArrayList<>(), makeVlanStack(mirrorConfig.getMirrorVlan())));
        actions.add(new PortOutAction(new PortNumber(mirrorConfig.getMirrorPort())));
        buckets.add(Bucket.builder().writeActions(actions).watchGroup(WatchGroup.ANY).watchPort(WatchPort.ANY).build());
    }
    return buckets;
}
Also used : VXLAN_SRC_IPV4_ADDRESS(org.openkilda.rulemanager.Constants.VXLAN_SRC_IPV4_ADDRESS) FlowPath(org.openkilda.model.FlowPath) SwitchFeature(org.openkilda.model.SwitchFeature) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Action(org.openkilda.rulemanager.action.Action) SpecialPortType(org.openkilda.rulemanager.ProtoConstants.PortNumber.SpecialPortType) KILDA_OVS_PUSH_POP_MATCH_VXLAN(org.openkilda.model.SwitchFeature.KILDA_OVS_PUSH_POP_MATCH_VXLAN) OfMetadata(org.openkilda.rulemanager.OfMetadata) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) VXLAN_DST_IPV4_ADDRESS(org.openkilda.rulemanager.Constants.VXLAN_DST_IPV4_ADDRESS) Flow(org.openkilda.model.Flow) FlowEndpoint.makeVlanStack(org.openkilda.model.FlowEndpoint.makeVlanStack) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) ActionType(org.openkilda.rulemanager.action.ActionType) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) WatchGroup(org.openkilda.rulemanager.group.WatchGroup) FlowEndpoint(org.openkilda.model.FlowEndpoint) Iterator(java.util.Iterator) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) WatchPort(org.openkilda.rulemanager.group.WatchPort) Set(java.util.Set) SpeakerData(org.openkilda.rulemanager.SpeakerData) NOVIFLOW_PUSH_POP_VXLAN(org.openkilda.model.SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Bucket(org.openkilda.rulemanager.group.Bucket) MacAddress(org.openkilda.model.MacAddress) List(java.util.List) FlowEndpoint.isVlanIdSet(org.openkilda.model.FlowEndpoint.isVlanIdSet) SwitchId(org.openkilda.model.SwitchId) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) Optional(java.util.Optional) Field(org.openkilda.rulemanager.Field) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) 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) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) HashSet(java.util.HashSet) Sets.newHashSet(com.google.common.collect.Sets.newHashSet)

Example 19 with PortNumber

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

the class SingleTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationSingleVlanTest.

@Test
public void buildCommandsVlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    SingleTableIngressRuleGenerator 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.FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, 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 20 with PortNumber

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

the class SingleTableIngressRuleGeneratorTest method oneSwitchFlowFullPortRuleTest.

@Test
public void oneSwitchFlowFullPortRuleTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, 0, OUTER_VLAN_ID_2);
    SingleTableIngressRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(1, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    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)));
    assertIngressCommand(ingressCommand, Priority.DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, 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) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) 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) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

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