Search in sources :

Example 1 with MeterId

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

the class OfInstructionsConverterTest method convertToRuleManagerInstructionsTest.

@Test
public void convertToRuleManagerInstructionsTest() {
    OFFactory factory = new OFFactoryVer13();
    List<OFInstruction> instructions = new ArrayList<>();
    instructions.add(factory.instructions().gotoTable(TableId.of(1)));
    instructions.add(factory.instructions().meter(2));
    instructions.add(factory.instructions().writeMetadata(U64.of(123), U64.of(234)));
    List<OFAction> actions = buildActions(factory);
    instructions.add(factory.instructions().applyActions(actions));
    Instructions actual = OfInstructionsConverter.INSTANCE.convertToRuleManagerInstructions(instructions);
    assertEquals(OfTable.PRE_INGRESS, actual.getGoToTable());
    assertEquals(new MeterId(2), actual.getGoToMeter());
    assertEquals(new OfMetadata(123, 234), actual.getWriteMetadata());
    assertEquals(12, actual.getApplyActions().size());
    List<Action> expectedActions = buildActions();
    assertTrue(actual.getApplyActions().containsAll(expectedActions));
}
Also used : OfMetadata(org.openkilda.rulemanager.OfMetadata) 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) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) ArrayList(java.util.ArrayList) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) Instructions(org.openkilda.rulemanager.Instructions) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 2 with MeterId

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

the class MeterVerifyCommandTest method shouldVerifyInaccurateMeterBurst.

@Test
public void shouldVerifyInaccurateMeterBurst() throws Exception {
    MeterConfig validConfig = new MeterConfig(new MeterId(1), (long) (100 / 1.05));
    MeterVerifyCommand command1 = new MeterVerifyCommand(new MessageContext(), mapSwitchId(dpId), validConfig);
    switchFeaturesSetup(sw, SwitchFeature.METERS, SwitchFeature.INACCURATE_METER);
    SettableFuture<List<OFMeterConfigStatsReply>> statsReplyProxy = setupMeterConfigStatsReply();
    // for command2
    setupMeterConfigStatsReply();
    replayAll();
    CompletableFuture<MeterVerifyReport> result = command1.execute(commandProcessor);
    // make one more command with altered config, to produce meter config flags/bands
    MeterConfig invalidConfig = new MeterConfig(validConfig.getId(), validConfig.getBandwidth() + 1);
    MeterVerifyCommand command2 = new MeterVerifyCommand(command1.getMessageContext(), command1.getSwitchId(), invalidConfig);
    // must be executed, for let .setup() method to initialize all dependencies
    command2.execute(commandProcessor);
    OFMeterConfig reply = sw.getOFFactory().buildMeterConfig().setMeterId(validConfig.getId().getValue()).setFlags(command2.makeMeterFlags()).setEntries(command2.makeMeterBands()).build();
    statsReplyProxy.set(wrapMeterStatsReply(reply));
    verifySuccessCompletion(result);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) MessageContext(org.openkilda.messaging.MessageContext) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterConfig(org.openkilda.model.MeterConfig) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test) AbstractSpeakerCommandTest(org.openkilda.floodlight.command.AbstractSpeakerCommandTest)

Example 3 with MeterId

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

the class OneSwitchFlowCommandJsonTest method makeRequest.

@Override
protected OneSwitchFlowRequest makeRequest() {
    SwitchId swId = new SwitchId(1);
    OneSwitchFlowRequestFactory factory = new OneSwitchFlowRequestFactory(new MessageContext(), new FlowSegmentMetadata("single-switch-flow-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new MeterConfig(new MeterId(6), 7000), new FlowEndpoint(swId, 8, 9), RulesContext.builder().build(), MirrorConfig.builder().build());
    return makeRequest(factory);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowEndpoint(org.openkilda.model.FlowEndpoint) OneSwitchFlowRequestFactory(org.openkilda.floodlight.api.request.factory.OneSwitchFlowRequestFactory) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) MeterConfig(org.openkilda.model.MeterConfig) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) MeterId(org.openkilda.model.MeterId)

Example 4 with MeterId

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

the class AllocateYFlowResourcesAction method allocateMeter.

@SneakyThrows
protected MeterId allocateMeter(String yFlowId, SwitchId switchId) throws ResourceAllocationException {
    MeterId meterId = transactionManager.doInTransaction(resourceAllocationRetryPolicy, () -> resourcesManager.allocateMeter(yFlowId, switchId));
    log.debug("Meter {} has been allocated for y-flow {}", meterId, yFlowId);
    return meterId;
}
Also used : MeterId(org.openkilda.model.MeterId) SneakyThrows(lombok.SneakyThrows)

Example 5 with MeterId

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

the class AllocateYFlowResourcesAction method allocateMeterAsEndpointResources.

private EndpointResources allocateMeterAsEndpointResources(String yFlowId, SwitchId switchId, long bandwidth) throws ResourceAllocationException {
    MeterId meterId = null;
    if (bandwidth > 0L) {
        log.debug("Allocating resources for y-flow {}", yFlowId);
        meterId = allocateMeter(yFlowId, switchId);
    } else {
        log.debug("Meter is not required for y-flow {}", yFlowId);
    }
    return EndpointResources.builder().endpoint(switchId).meterId(meterId).build();
}
Also used : MeterId(org.openkilda.model.MeterId)

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