Search in sources :

Example 26 with MeterId

use of org.openkilda.model.MeterId in project open-kilda by telstra.

the class UnicastVerificationVxlanRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    // should be replaced with fair feature detection based on ActionId's during handshake
    if (!(sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN) || sw.getFeatures().contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN))) {
        return Collections.emptyList();
    }
    Cookie cookie = new Cookie(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE);
    FlowSpeakerData flowCommand = buildUnicastVerificationRuleVxlan(sw, cookie);
    List<SpeakerData> result = new ArrayList<>();
    result.add(flowCommand);
    MeterId meterId = createMeterIdForDefaultRule(cookie.getValue());
    long meterRate = config.getUnicastRateLimit();
    MeterSpeakerData meterCommand = generateMeterCommandForServiceRule(sw, meterId, meterRate, config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
    if (meterCommand != null) {
        addMeterToInstructions(meterId, sw, flowCommand.getInstructions());
        flowCommand.getDependsOn().add(meterCommand.getUuid());
        result.add(meterCommand);
    }
    return result;
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) ArrayList(java.util.ArrayList) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterId(org.openkilda.model.MeterId)

Example 27 with MeterId

use of org.openkilda.model.MeterId in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldBuildFlowPathFor3SwitchPath.

@Test
public void shouldBuildFlowPathFor3SwitchPath() {
    SwitchId switchId1 = new SwitchId(1);
    SwitchId switchId2 = new SwitchId(2);
    SwitchId switchId3 = new SwitchId(3);
    Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(asList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId3).destPort(2).build(), Segment.builder().srcSwitchId(switchId3).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId1).build()).destSwitch(Switch.builder().switchId(switchId2).build()).build();
    PathId pathId = new PathId("test_path_id");
    MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
    PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
    FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
    FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
    assertEquals(switchId1, flowPath.getSrcSwitchId());
    assertEquals(switchId2, flowPath.getDestSwitchId());
    assertEquals(pathId, flowPath.getPathId());
    assertEquals(meterId, flowPath.getMeterId());
    assertEquals(cookie, flowPath.getCookie());
    assertThat(flowPath.getSegments(), hasSize(2));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathResources(org.openkilda.wfm.share.flow.resources.FlowResources.PathResources) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 28 with MeterId

use of org.openkilda.model.MeterId in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldBuildFlowPathFor1SwitchPath.

@Test
public void shouldBuildFlowPathFor1SwitchPath() {
    SwitchId switchId = new SwitchId(1);
    Path path = Path.builder().srcSwitchId(switchId).destSwitchId(switchId).segments(Collections.emptyList()).build();
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId).build()).destSwitch(Switch.builder().switchId(switchId).build()).build();
    PathId pathId = new PathId("test_path_id");
    MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
    PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
    FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
    FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
    assertEquals(pathId, flowPath.getPathId());
    assertEquals(meterId, flowPath.getMeterId());
    assertEquals(cookie, flowPath.getCookie());
    assertThat(flowPath.getSegments(), empty());
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathResources(org.openkilda.wfm.share.flow.resources.FlowResources.PathResources) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 29 with MeterId

use of org.openkilda.model.MeterId in project open-kilda by telstra.

the class IngressInstallFlowModFactory method makeForwardMessageInstructions.

protected List<OFInstruction> makeForwardMessageInstructions(EffectiveIds effectiveIds, List<Integer> vlanStack) {
    List<OFAction> applyActions = new ArrayList<>();
    List<OFInstruction> instructions = new ArrayList<>();
    MeterId effectiveMeterId = effectiveIds.getMeterId();
    if (effectiveMeterId != null) {
        OfAdapter.INSTANCE.makeMeterCall(of, effectiveMeterId, applyActions, instructions);
    }
    GroupId effectiveGroupId = effectiveIds.getGroupId();
    boolean groupIsPresent = effectiveGroupId != null;
    applyActions.addAll(makeTransformActions(vlanStack, groupIsPresent));
    if (groupIsPresent) {
        applyActions.add(makeGroupAction(effectiveGroupId));
    } else {
        applyActions.add(makeOutputAction());
    }
    instructions.add(of.instructions().applyActions(applyActions));
    if (command.getMetadata().isMultiTable() && effectiveGroupId == null) {
        instructions.add(of.instructions().gotoTable(TableId.of(SwitchManager.POST_INGRESS_TABLE_ID)));
        instructions.addAll(makeMetadataInstructions());
    }
    return instructions;
}
Also used : OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) MeterId(org.openkilda.model.MeterId) GroupId(org.openkilda.model.GroupId)

Example 30 with MeterId

use of org.openkilda.model.MeterId in project open-kilda by telstra.

the class IngressFlowSegmentBase method planOfFlowsInstall.

private CompletableFuture<FlowSegmentReport> planOfFlowsInstall(EffectiveIds effectiveIds) {
    MeterId effectiveMeterId = effectiveIds.getMeterId();
    MeterConfig meterConfig = getMeterConfig();
    if (effectiveMeterId == null && rulesContext != null && !rulesContext.isUpdateMeter() && meterConfig != null) {
        effectiveIds.setMeterId(meterConfig.getId());
    }
    List<OFFlowMod> ofMessages = makeFlowModMessages(effectiveIds);
    List<CompletableFuture<Optional<OFMessage>>> writeResults = new ArrayList<>(ofMessages.size());
    try (Session session = getSessionService().open(messageContext, getSw())) {
        for (OFFlowMod message : ofMessages) {
            writeResults.add(session.write(message));
        }
    }
    return CompletableFuture.allOf(writeResults.toArray(new CompletableFuture[0])).thenApply(ignore -> makeSuccessReport());
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) ArrayList(java.util.ArrayList) MeterConfig(org.openkilda.model.MeterConfig) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) MeterId(org.openkilda.model.MeterId) Session(org.openkilda.floodlight.service.session.Session)

Aggregations

MeterId (org.openkilda.model.MeterId)62 PathId (org.openkilda.model.PathId)20 Flow (org.openkilda.model.Flow)19 FlowPath (org.openkilda.model.FlowPath)18 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)18 Test (org.junit.Test)17 SwitchId (org.openkilda.model.SwitchId)16 Switch (org.openkilda.model.Switch)11 ArrayList (java.util.ArrayList)10 PathSegment (org.openkilda.model.PathSegment)9 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)7 List (java.util.List)6 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)6 FlowMeter (org.openkilda.model.FlowMeter)5 MeterConfig (org.openkilda.model.MeterConfig)5 YFlow (org.openkilda.model.YFlow)5 Instructions (org.openkilda.rulemanager.Instructions)5 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)5 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)5 MessageContext (org.openkilda.messaging.MessageContext)4