Search in sources :

Example 11 with MeterId

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

the class FermaFlowMeterRepositoryTest method findUnassignedMeterAndCreate.

private long findUnassignedMeterAndCreate(String flowId, String pathId) {
    MeterId availableMeterId = flowMeterRepository.findFirstUnassignedMeter(theSwitch.getSwitchId(), MIN_METER_ID, MAX_METER_ID).get();
    FlowMeter flowMeterId = FlowMeter.builder().switchId(theSwitch.getSwitchId()).meterId(availableMeterId).pathId(new PathId(flowId + "_" + pathId)).flowId(flowId).build();
    flowMeterRepository.add(flowMeterId);
    return availableMeterId.getValue();
}
Also used : PathId(org.openkilda.model.PathId) FlowMeter(org.openkilda.model.FlowMeter) MeterId(org.openkilda.model.MeterId)

Example 12 with MeterId

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

the class FermaFlowMeterRepositoryTest method createFlowMeter.

private FlowMeter createFlowMeter(int meterId, PathId pathId) {
    FlowMeter flowMeter = FlowMeter.builder().switchId(theSwitch.getSwitchId()).meterId(new MeterId(meterId)).pathId(pathId).flowId(TEST_FLOW_ID).build();
    flowMeterRepository.add(flowMeter);
    return flowMeter;
}
Also used : FlowMeter(org.openkilda.model.FlowMeter) MeterId(org.openkilda.model.MeterId)

Example 13 with MeterId

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

the class FermaIslRepositoryTest method createFlowWithPath.

private Flow createFlowWithPath(int forwardBandwidth, int reverseBandwidth) {
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(switchA).destSwitch(switchB).status(FlowStatus.UP).build();
    FlowPath forwardPath = FlowPath.builder().srcSwitch(switchA).destSwitch(switchB).pathId(new PathId(TEST_FLOW_ID + "_forward_path")).cookie(new FlowSegmentCookie(1)).meterId(new MeterId(1)).status(FlowPathStatus.ACTIVE).bandwidth(forwardBandwidth).ignoreBandwidth(false).build();
    flow.setForwardPath(forwardPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).build();
    forwardPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reversePath = FlowPath.builder().srcSwitch(switchB).destSwitch(switchA).pathId(new PathId(TEST_FLOW_ID + "_reverse_path")).cookie(new FlowSegmentCookie(2)).meterId(new MeterId(2)).status(FlowPathStatus.ACTIVE).bandwidth(reverseBandwidth).ignoreBandwidth(false).build();
    flow.setReversePath(reversePath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reversePath.getPathId()).srcSwitch(switchB).srcPort(2).destSwitch(switchA).destPort(1).build();
    reversePath.setSegments(Collections.singletonList(reverseSegment));
    flowRepository.add(flow);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 14 with MeterId

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

the class FlowMeterModifyFsm method modifyMeters.

protected void modifyMeters(FlowMeterModifyState from, FlowMeterModifyState to, FlowMeterModifyEvent event, Object context) {
    log.info("Key: {}; Send commands to modify meters", key);
    SwitchId forwardSwitchId = flow.getForwardPath().getSrcSwitchId();
    SwitchId reverseSwitchId = flow.getReversePath().getSrcSwitchId();
    long bandwidth = flow.getForwardPath().getBandwidth();
    MeterId forwardMeterId = flow.getForwardPath().getMeterId();
    MeterId reverseMeterId = flow.getReversePath().getMeterId();
    if (forwardMeterId == null || reverseMeterId == null) {
        sendException(String.format("Flow '%s' is unmetered", flowId), "Modify meters in FlowMeterModifyFsm ", ErrorType.REQUEST_INVALID);
        return;
    }
    carrier.sendCommandToSpeakerWorker(key, new MeterModifyCommandRequest(forwardSwitchId, forwardMeterId.getValue(), bandwidth));
    carrier.sendCommandToSpeakerWorker(key, new MeterModifyCommandRequest(reverseSwitchId, reverseMeterId.getValue(), bandwidth));
}
Also used : MeterModifyCommandRequest(org.openkilda.messaging.command.flow.MeterModifyCommandRequest) SwitchId(org.openkilda.model.SwitchId) MeterId(org.openkilda.model.MeterId)

Example 15 with MeterId

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

the class RuleManagerHelperTest method buildFullFlowSpeakerCommandData.

private FlowSpeakerData buildFullFlowSpeakerCommandData(MeterId goToMeterId, UUID dependsOnUuid) {
    Set<FieldMatch> match = Arrays.stream(Field.values()).map(f -> FieldMatch.builder().field(f).value(f.ordinal()).mask(f.ordinal() + 1L).build()).collect(Collectors.toSet());
    Set<OfFlowFlag> flags = Sets.newHashSet(OfFlowFlag.values());
    List<Action> applyActions = new ArrayList<>(buildAllActions());
    applyActions.addAll(buildAllActions());
    Instructions instructions = Instructions.builder().goToMeter(goToMeterId).goToTable(OfTable.INPUT).writeMetadata(new OfMetadata(15, 0xff)).writeActions(new HashSet<>(buildAllActions())).applyActions(applyActions).build();
    return FlowSpeakerData.builder().uuid(UUID.randomUUID()).cookie(new Cookie(123)).priority(PRIORITY).table(OfTable.INPUT).match(match).instructions(instructions).flags(flags).switchId(SWITCH_ID).ofVersion(OfVersion.OF_13).dependsOn(dependsOnUuid == null ? newArrayList() : newArrayList(dependsOnUuid)).build();
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) Arrays(java.util.Arrays) MeterFlag(org.openkilda.rulemanager.MeterFlag) GroupType(org.openkilda.rulemanager.group.GroupType) OfMetadata(org.openkilda.rulemanager.OfMetadata) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) RuleManagerHelper.sortCommandsByDependencies(org.openkilda.rulemanager.utils.RuleManagerHelper.sortCommandsByDependencies) WatchGroup(org.openkilda.rulemanager.group.WatchGroup) Instructions(org.openkilda.rulemanager.Instructions) Set(java.util.Set) SpeakerData(org.openkilda.rulemanager.SpeakerData) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) MacAddress(org.openkilda.model.MacAddress) OfFlowFlag(org.openkilda.rulemanager.OfFlowFlag) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) RuleManagerHelper.checkCircularDependencies(org.openkilda.rulemanager.utils.RuleManagerHelper.checkCircularDependencies) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) IPv4Address(org.openkilda.model.IPv4Address) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Action(org.openkilda.rulemanager.action.Action) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) RuleManagerHelper.removeDuplicateCommands(org.openkilda.rulemanager.utils.RuleManagerHelper.removeDuplicateCommands) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) Cookie(org.openkilda.model.cookie.Cookie) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) ActionType(org.openkilda.rulemanager.action.ActionType) OpenFlowOxms(org.openkilda.rulemanager.action.noviflow.OpenFlowOxms) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) OfVersion(org.openkilda.rulemanager.OfVersion) WatchPort(org.openkilda.rulemanager.group.WatchPort) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterId(org.openkilda.model.MeterId) Bucket(org.openkilda.rulemanager.group.Bucket) SwitchId(org.openkilda.model.SwitchId) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) OfTable(org.openkilda.rulemanager.OfTable) GroupId(org.openkilda.model.GroupId) Assert.assertEquals(org.junit.Assert.assertEquals) Field(org.openkilda.rulemanager.Field) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OfMetadata(org.openkilda.rulemanager.OfMetadata) Cookie(org.openkilda.model.cookie.Cookie) MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) OfFlowFlag(org.openkilda.rulemanager.OfFlowFlag) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions)

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