Search in sources :

Example 31 with MeterId

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

the class RecordHandler method doModifyFlowMeterForSwitchManager.

private void doModifyFlowMeterForSwitchManager(CommandMessage message) {
    ModifyFlowMeterForSwitchManagerRequest request = (ModifyFlowMeterForSwitchManagerRequest) message.getData();
    IKafkaProducerService producerService = getKafkaProducer();
    long meterId = request.getMeterId();
    SwitchId switchId = request.getSwitchId();
    MeterConfig meterConfig = new MeterConfig(new MeterId(request.getMeterId()), request.getRate());
    logger.info("Modifying flow meter {} on Switch {}", meterId, switchId);
    handleSpeakerCommand(new MeterModifyCommand(new MessageContext(message), switchId, meterConfig));
    InfoMessage response = new InfoMessage(new ModifyMeterResponse(switchId, request.getMeterId()), System.currentTimeMillis(), message.getCorrelationId());
    producerService.sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), message.getCorrelationId(), response);
}
Also used : MeterModifyCommand(org.openkilda.floodlight.command.meter.MeterModifyCommand) ModifyMeterResponse(org.openkilda.messaging.info.switches.ModifyMeterResponse) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterConfig(org.openkilda.model.MeterConfig) ModifyFlowMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyFlowMeterForSwitchManagerRequest) MeterId(org.openkilda.model.MeterId)

Example 32 with MeterId

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

the class MeterSchemaMapper method map.

/**
 * Produce {@code MeterSchema} from {@code OFMeterConfig}.
 */
public MeterSchema map(DatapathId datapathId, OFMeterConfig meterConfig, boolean isInaccurate) {
    MeterSchema.MeterSchemaBuilder schema = MeterSchema.builder().switchId(new SwitchId(datapathId.getLong())).meterId(new MeterId(meterConfig.getMeterId()));
    fillFlags(schema, meterConfig.getFlags());
    fillBands(schema, meterConfig.getEntries(), isInaccurate);
    return schema.build();
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) SwitchId(org.openkilda.model.SwitchId) MeterId(org.openkilda.model.MeterId)

Example 33 with MeterId

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

the class OfInstructionsConverter method convertToRuleManagerAction.

/**
 * Converts action.
 */
public Action convertToRuleManagerAction(OFAction action) {
    switch(action.getType()) {
        case PUSH_VLAN:
            return new PushVlanAction();
        case POP_VLAN:
            return new PopVlanAction();
        case METER:
            OFActionMeter meterAction = (OFActionMeter) action;
            MeterId meterId = new MeterId(meterAction.getMeterId());
            return new MeterAction(meterId);
        case GROUP:
            OFActionGroup groupAction = (OFActionGroup) action;
            GroupId groupId = new GroupId(groupAction.getGroup().getGroupNumber());
            return new GroupAction(groupId);
        case OUTPUT:
            OFActionOutput outputAction = (OFActionOutput) action;
            PortNumber portNumber = convertPort(outputAction.getPort());
            return new PortOutAction(portNumber);
        case EXPERIMENTER:
            if (action instanceof OFActionNoviflowPushVxlanTunnel) {
                OFActionNoviflowPushVxlanTunnel pushNoviVxlan = (OFActionNoviflowPushVxlanTunnel) action;
                return PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_NOVIFLOW).vni((int) pushNoviVxlan.getVni()).srcMacAddress(convertMac(pushNoviVxlan.getEthSrc())).dstMacAddress(convertMac(pushNoviVxlan.getEthDst())).srcIpv4Address(convertIPv4Address(pushNoviVxlan.getIpv4Src())).dstIpv4Address(convertIPv4Address(pushNoviVxlan.getIpv4Dst())).udpSrc(pushNoviVxlan.getUdpSrc()).build();
            } else if (action instanceof OFActionKildaPushVxlanField) {
                OFActionKildaPushVxlanField pushKildaVxlan = (OFActionKildaPushVxlanField) action;
                return PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_OVS).vni((int) pushKildaVxlan.getVni()).srcMacAddress(convertMac(pushKildaVxlan.getEthSrc())).dstMacAddress(convertMac(pushKildaVxlan.getEthDst())).srcIpv4Address(convertIPv4Address(pushKildaVxlan.getIpv4Src())).dstIpv4Address(convertIPv4Address(pushKildaVxlan.getIpv4Dst())).udpSrc(pushKildaVxlan.getUdpSrc()).build();
            } else if (action instanceof OFActionNoviflowCopyField) {
                OFActionNoviflowCopyField copyField = (OFActionNoviflowCopyField) action;
                return CopyFieldAction.builder().numberOfBits(copyField.getNBits()).srcOffset(copyField.getSrcOffset()).dstOffset(copyField.getDstOffset()).oxmSrcHeader(convertOxmHeader(copyField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(copyField.getOxmDstHeader())).build();
            } else if (action instanceof OFActionNoviflowSwapField) {
                OFActionNoviflowSwapField swapField = (OFActionNoviflowSwapField) action;
                return SwapFieldAction.builder().type(ActionType.NOVI_SWAP_FIELD).numberOfBits(swapField.getNBits()).srcOffset(swapField.getSrcOffset()).dstOffset(swapField.getDstOffset()).oxmSrcHeader(convertOxmHeader(swapField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(swapField.getOxmDstHeader())).build();
            } else if (action instanceof OFActionKildaSwapField) {
                OFActionKildaSwapField swapField = (OFActionKildaSwapField) action;
                return SwapFieldAction.builder().type(ActionType.KILDA_SWAP_FIELD).numberOfBits(swapField.getNBits()).srcOffset(swapField.getSrcOffset()).dstOffset(swapField.getDstOffset()).oxmSrcHeader(convertOxmHeader(swapField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(swapField.getOxmDstHeader())).build();
            } else if (action instanceof OFActionNoviflowPopVxlanTunnel) {
                return new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW);
            } else if (action instanceof OFActionKildaPopVxlanField) {
                return new PopVxlanAction(ActionType.POP_VXLAN_OVS);
            } else {
                throw new IllegalStateException(format("Unknown experimenter action %s", action.getType()));
            }
        case SET_FIELD:
            OFActionSetField setFieldAction = (OFActionSetField) action;
            return convertOxm(setFieldAction.getField());
        case SET_VLAN_VID:
            OFActionSetVlanVid setVlanVid = (OFActionSetVlanVid) action;
            return SetFieldAction.builder().field(Field.VLAN_VID).value(setVlanVid.getVlanVid().getVlan()).build();
        default:
            throw new IllegalStateException(format("Unknown action type %s", action.getType()));
    }
}
Also used : OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFActionNoviflowPushVxlanTunnel(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowPushVxlanTunnel) OFActionNoviflowPopVxlanTunnel(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowPopVxlanTunnel) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) MeterAction(org.openkilda.rulemanager.action.MeterAction) OFActionNoviflowCopyField(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowCopyField) OFActionGroup(org.projectfloodlight.openflow.protocol.action.OFActionGroup) OFActionNoviflowSwapField(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowSwapField) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterId(org.openkilda.model.MeterId) GroupId(org.openkilda.model.GroupId) GroupAction(org.openkilda.rulemanager.action.GroupAction) OFActionMeter(org.projectfloodlight.openflow.protocol.action.OFActionMeter) OFActionSetVlanVid(org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid) OFActionKildaPushVxlanField(org.projectfloodlight.openflow.protocol.action.OFActionKildaPushVxlanField) OFActionKildaPopVxlanField(org.projectfloodlight.openflow.protocol.action.OFActionKildaPopVxlanField) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) OFActionKildaSwapField(org.projectfloodlight.openflow.protocol.action.OFActionKildaSwapField)

Example 34 with MeterId

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

the class OfMeterConverter method convertToMeterSpeakerData.

/**
 * Convert meter config.
 */
public MeterSpeakerData convertToMeterSpeakerData(OFMeterConfig meterConfig, boolean inaccurate) {
    MeterId meterId = new MeterId(meterConfig.getMeterId());
    long rate = 0;
    long burst = 0;
    for (OFMeterBand band : meterConfig.getEntries()) {
        if (band instanceof OFMeterBandDrop) {
            rate = ((OFMeterBandDrop) band).getRate();
            burst = ((OFMeterBandDrop) band).getBurstSize();
        }
    }
    return MeterSpeakerData.builder().meterId(meterId).burst(burst).rate(rate).flags(fromOfMeterFlags(meterConfig.getFlags())).inaccurate(inaccurate).build();
}
Also used : OFMeterBand(org.projectfloodlight.openflow.protocol.meterband.OFMeterBand) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop) MeterId(org.openkilda.model.MeterId)

Example 35 with MeterId

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

the class MeterSchemaMapper method map.

/**
 * Produce {@code MeterSchema} from {@code OFMeterMod}.
 */
public MeterSchema map(DatapathId datapathId, OFMeterMod meterMod) {
    MeterSchema.MeterSchemaBuilder schema = MeterSchema.builder().switchId(new SwitchId(datapathId.getLong())).meterId(new MeterId(meterMod.getMeterId()));
    fillFlags(schema, meterMod.getFlags());
    fillBands(schema, OfAdapter.INSTANCE.getMeterBands(meterMod));
    return schema.build();
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) SwitchId(org.openkilda.model.SwitchId) 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