Search in sources :

Example 11 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class RecordHandler method doDeleteSwitchRules.

private void doDeleteSwitchRules(final CommandMessage message) {
    SwitchRulesDeleteRequest request = (SwitchRulesDeleteRequest) message.getData();
    logger.info("Deleting rules from '{}' switch: action={}, criteria={}", request.getSwitchId(), request.getDeleteRulesAction(), request.getCriteria());
    final IKafkaProducerService producerService = getKafkaProducer();
    final String replyToTopic = context.getKafkaSwitchManagerTopic();
    DatapathId dpid = DatapathId.of(request.getSwitchId().toLong());
    DeleteRulesAction deleteAction = request.getDeleteRulesAction();
    DeleteRulesCriteria criteria = request.getCriteria();
    ISwitchManager switchManager = context.getSwitchManager();
    try {
        List<Long> removedRules = new ArrayList<>();
        if (deleteAction != null) {
            switch(deleteAction) {
                case REMOVE_DROP:
                    criteria = DeleteRulesCriteria.builder().cookie(DROP_RULE_COOKIE).build();
                    break;
                case REMOVE_BROADCAST:
                    criteria = DeleteRulesCriteria.builder().cookie(VERIFICATION_BROADCAST_RULE_COOKIE).build();
                    break;
                case REMOVE_UNICAST:
                    criteria = DeleteRulesCriteria.builder().cookie(VERIFICATION_UNICAST_RULE_COOKIE).build();
                    break;
                case REMOVE_VERIFICATION_LOOP:
                    criteria = DeleteRulesCriteria.builder().cookie(DROP_VERIFICATION_LOOP_RULE_COOKIE).build();
                    break;
                case REMOVE_BFD_CATCH:
                    criteria = DeleteRulesCriteria.builder().cookie(CATCH_BFD_RULE_COOKIE).build();
                    break;
                case REMOVE_ROUND_TRIP_LATENCY:
                    criteria = DeleteRulesCriteria.builder().cookie(ROUND_TRIP_LATENCY_RULE_COOKIE).build();
                    break;
                case REMOVE_UNICAST_VXLAN:
                    criteria = DeleteRulesCriteria.builder().cookie(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).build();
                    break;
                case REMOVE_MULTITABLE_PRE_INGRESS_PASS_THROUGH:
                    criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE).build();
                    break;
                case REMOVE_MULTITABLE_INGRESS_DROP:
                    criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_INGRESS_DROP_COOKIE).build();
                    break;
                case REMOVE_MULTITABLE_POST_INGRESS_DROP:
                    criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_POST_INGRESS_DROP_COOKIE).build();
                    break;
                case REMOVE_MULTITABLE_EGRESS_PASS_THROUGH:
                    criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE).build();
                    break;
                case REMOVE_MULTITABLE_TRANSIT_DROP:
                    criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_TRANSIT_DROP_COOKIE).build();
                    break;
                case REMOVE_LLDP_INPUT_PRE_DROP:
                    criteria = DeleteRulesCriteria.builder().cookie(LLDP_INPUT_PRE_DROP_COOKIE).build();
                    break;
                case REMOVE_LLDP_INGRESS:
                    criteria = DeleteRulesCriteria.builder().cookie(LLDP_INGRESS_COOKIE).build();
                    break;
                case REMOVE_LLDP_POST_INGRESS:
                    criteria = DeleteRulesCriteria.builder().cookie(LLDP_POST_INGRESS_COOKIE).build();
                    break;
                case REMOVE_LLDP_POST_INGRESS_VXLAN:
                    criteria = DeleteRulesCriteria.builder().cookie(LLDP_POST_INGRESS_VXLAN_COOKIE).build();
                    break;
                case REMOVE_LLDP_POST_INGRESS_ONE_SWITCH:
                    criteria = DeleteRulesCriteria.builder().cookie(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).build();
                    break;
                case REMOVE_LLDP_TRANSIT:
                    criteria = DeleteRulesCriteria.builder().cookie(LLDP_TRANSIT_COOKIE).build();
                    break;
                case REMOVE_ARP_INPUT_PRE_DROP:
                    criteria = DeleteRulesCriteria.builder().cookie(ARP_INPUT_PRE_DROP_COOKIE).build();
                    break;
                case REMOVE_ARP_INGRESS:
                    criteria = DeleteRulesCriteria.builder().cookie(ARP_INGRESS_COOKIE).build();
                    break;
                case REMOVE_ARP_POST_INGRESS:
                    criteria = DeleteRulesCriteria.builder().cookie(ARP_POST_INGRESS_COOKIE).build();
                    break;
                case REMOVE_ARP_POST_INGRESS_VXLAN:
                    criteria = DeleteRulesCriteria.builder().cookie(ARP_POST_INGRESS_VXLAN_COOKIE).build();
                    break;
                case REMOVE_ARP_POST_INGRESS_ONE_SWITCH:
                    criteria = DeleteRulesCriteria.builder().cookie(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).build();
                    break;
                case REMOVE_ARP_TRANSIT:
                    criteria = DeleteRulesCriteria.builder().cookie(ARP_TRANSIT_COOKIE).build();
                    break;
                case REMOVE_SERVER_42_FLOW_RTT_TURNING:
                case REMOVE_SERVER_42_TURNING:
                    criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_TURNING_COOKIE).build();
                    break;
                case REMOVE_SERVER_42_FLOW_RTT_VXLAN_TURNING:
                    criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE).build();
                    break;
                case REMOVE_SERVER_42_FLOW_RTT_OUTPUT_VLAN:
                case REMOVE_SERVER_42_OUTPUT_VLAN:
                    criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE).build();
                    break;
                case REMOVE_SERVER_42_FLOW_RTT_OUTPUT_VXLAN:
                case REMOVE_SERVER_42_OUTPUT_VXLAN:
                    criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE).build();
                    break;
                case REMOVE_SERVER_42_ISL_RTT_TURNING:
                    criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_ISL_RTT_TURNING_COOKIE).build();
                    break;
                case REMOVE_SERVER_42_ISL_RTT_OUTPUT:
                    criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_ISL_RTT_OUTPUT_COOKIE).build();
                    break;
                default:
                    logger.warn("Received unexpected delete switch rule action: {}", deleteAction);
            }
            // The cases when we delete all non-default rules.
            if (deleteAction.nonDefaultRulesToBeRemoved()) {
                removedRules.addAll(switchManager.deleteAllNonDefaultRules(dpid));
            }
            // The cases when we delete the default rules.
            if (deleteAction.defaultRulesToBeRemoved()) {
                removedRules.addAll(switchManager.deleteDefaultRules(dpid, request.getIslPorts(), request.getFlowPorts(), request.getFlowLldpPorts(), request.getFlowArpPorts(), request.getServer42FlowRttPorts(), request.isMultiTable(), request.isSwitchLldp(), request.isSwitchArp(), request.isServer42FlowRttFeatureToggle() && request.isServer42FlowRttSwitchProperty(), request.isServer42IslRttEnabled()));
            }
        }
        // The case when we either delete by criteria or a specific default rule.
        if (criteria != null) {
            removedRules.addAll(switchManager.deleteRulesByCriteria(dpid, false, null, criteria));
        }
        // The cases when we (re)install the default rules.
        if (deleteAction != null && deleteAction.defaultRulesToBeInstalled()) {
            switchManager.installDefaultRules(dpid);
            if (request.isMultiTable()) {
                processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_INGRESS_DROP_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_POST_INGRESS_DROP_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_EGRESS_PASS_THROUGH_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_TRANSIT_DROP_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_VXLAN_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_ONE_SWITCH_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_VXLAN_COOKIE);
                processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_ONE_SWITCH_COOKIE);
                for (int port : request.getIslPorts()) {
                    switchManager.installMultitableEndpointIslRules(dpid, port);
                }
                for (int port : request.getFlowPorts()) {
                    switchManager.installIntermediateIngressRule(dpid, port);
                }
                for (Integer port : request.getFlowLldpPorts()) {
                    switchManager.installLldpInputCustomerFlow(dpid, port);
                }
                for (Integer port : request.getFlowArpPorts()) {
                    switchManager.installArpInputCustomerFlow(dpid, port);
                }
                if (request.isSwitchLldp()) {
                    processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_INPUT_PRE_DROP_COOKIE);
                    processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_TRANSIT_COOKIE);
                    processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_INGRESS_COOKIE);
                }
                if (request.isSwitchArp()) {
                    processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_INPUT_PRE_DROP_COOKIE);
                    processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_TRANSIT_COOKIE);
                    processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_INGRESS_COOKIE);
                }
            }
            Integer server42Port = request.getServer42Port();
            Integer server42Vlan = request.getServer42Vlan();
            MacAddress server42MacAddress = request.getServer42MacAddress();
            if (request.isServer42FlowRttFeatureToggle()) {
                switchManager.installServer42FlowRttTurningFlow(dpid);
                switchManager.installServer42FlowRttVxlanTurningFlow(dpid);
                if (request.isServer42FlowRttSwitchProperty() && server42Port != null && server42Vlan != null && server42MacAddress != null) {
                    switchManager.installServer42FlowRttOutputVlanFlow(dpid, server42Port, server42Vlan, server42MacAddress);
                    switchManager.installServer42FlowRttOutputVxlanFlow(dpid, server42Port, server42Vlan, server42MacAddress);
                    for (Integer port : request.getServer42FlowRttPorts()) {
                        switchManager.installServer42FlowRttInputFlow(dpid, server42Port, port, server42MacAddress);
                    }
                }
            }
            if (request.isServer42IslRttEnabled()) {
                switchManager.installServer42IslRttTurningFlow(dpid);
                switchManager.installServer42IslRttOutputFlow(dpid, server42Port, server42Vlan, server42MacAddress);
                for (Integer port : request.getIslPorts()) {
                    switchManager.installServer42IslRttInputFlow(dpid, server42Port, port);
                }
            }
        }
        SwitchRulesResponse response = new SwitchRulesResponse(removedRules);
        InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), message.getCorrelationId());
        producerService.sendMessageAndTrack(replyToTopic, record.key(), infoMessage);
    } catch (SwitchNotFoundException e) {
        logger.error("Deleting switch rules was unsuccessful. Switch '{}' not found", request.getSwitchId());
        anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).withKey(record.key()).sendVia(producerService);
    } catch (SwitchOperationException e) {
        logger.error("Failed to delete switch '{}' rules.", request.getSwitchId(), e);
        anError(ErrorType.DELETION_FAILURE).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).withKey(record.key()).sendVia(producerService);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) ArrayList(java.util.ArrayList) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) DatapathId(org.projectfloodlight.openflow.types.DatapathId) MacAddress(org.openkilda.model.MacAddress) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) FlowEndpoint(org.openkilda.model.FlowEndpoint) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchRulesResponse(org.openkilda.messaging.info.switches.SwitchRulesResponse) DeleteRulesAction(org.openkilda.messaging.command.switches.DeleteRulesAction) SwitchRulesDeleteRequest(org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest)

Example 12 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class RecordHandler method doModifyMeterRequest.

private void doModifyMeterRequest(CommandMessage message) {
    MeterModifyCommandRequest request = (MeterModifyCommandRequest) message.getData();
    final IKafkaProducerService producerService = getKafkaProducer();
    String replyToTopic = context.getKafkaNbWorkerTopic();
    SwitchId switchId = request.getSwitchId();
    DatapathId datapathId = DatapathId.of(switchId.toLong());
    long meterId = request.getMeterId();
    ISwitchManager switchManager = context.getSwitchManager();
    try {
        switchManager.modifyMeterForFlow(datapathId, meterId, request.getBandwidth());
        MeterEntry meterEntry = OfMeterConverter.toMeterEntry(switchManager.dumpMeterById(datapathId, meterId));
        SwitchMeterEntries response = SwitchMeterEntries.builder().switchId(switchId).meterEntries(ImmutableList.of(meterEntry)).build();
        InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
        producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), infoMessage);
    } catch (UnsupportedSwitchOperationException e) {
        String messageString = String.format("Not supported: %s", new SwitchId(e.getDpId().getLong()));
        logger.error(messageString, e);
        anError(ErrorType.PARAMETERS_INVALID).withMessage(e.getMessage()).withDescription(messageString).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    } catch (SwitchNotFoundException e) {
        logger.error("Update switch meters is unsuccessful. Switch {} not found", new SwitchId(e.getDpId().getLong()));
        anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(new SwitchId(e.getDpId().getLong()).toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    } catch (SwitchOperationException e) {
        String messageString = "Unable to update meter";
        logger.error(messageString, e);
        anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(messageString).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) SwitchId(org.openkilda.model.SwitchId) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) MeterEntry(org.openkilda.messaging.info.meter.MeterEntry) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) MeterModifyCommandRequest(org.openkilda.messaging.command.flow.MeterModifyCommandRequest)

Example 13 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class RecordHandler method doModifyDefaultMeterForSwitchManager.

private void doModifyDefaultMeterForSwitchManager(CommandMessage message) {
    ModifyDefaultMeterForSwitchManagerRequest request = (ModifyDefaultMeterForSwitchManagerRequest) message.getData();
    IKafkaProducerService producerService = getKafkaProducer();
    String replyToTopic = context.getKafkaSwitchManagerTopic();
    long meterId = request.getMeterId();
    SwitchId switchId = request.getSwitchId();
    DatapathId dpid = DatapathId.of(switchId.toLong());
    try {
        context.getSwitchManager().modifyDefaultMeter(dpid, request.getMeterId());
        InfoMessage response = new InfoMessage(new ModifyMeterResponse(switchId, request.getMeterId()), System.currentTimeMillis(), message.getCorrelationId());
        producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), response);
    } catch (UnsupportedSwitchOperationException e) {
        logger.warn(format("Skip meter %d modification on switch %s because switch doesn't support meters", meterId, switchId), e);
    } catch (InvalidMeterIdException | OfInstallException | SwitchNotFoundException e) {
        logger.error("Failed to modify meter {} for switch: '{}'", request.getSwitchId(), meterId, e);
        ErrorType errorType;
        if (e instanceof InvalidMeterIdException) {
            errorType = ErrorType.DATA_INVALID;
        } else if (e instanceof SwitchNotFoundException) {
            errorType = ErrorType.NOT_FOUND;
        } else {
            errorType = ErrorType.INTERNAL_ERROR;
        }
        anError(errorType).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    }
}
Also used : ModifyMeterResponse(org.openkilda.messaging.info.switches.ModifyMeterResponse) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException) SwitchId(org.openkilda.model.SwitchId) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ErrorType(org.openkilda.messaging.error.ErrorType) ModifyDefaultMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) OfInstallException(org.openkilda.floodlight.error.OfInstallException)

Example 14 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class SwitchManager method buildExpectedServer42IslRttFlows.

@Override
public List<OFFlowMod> buildExpectedServer42IslRttFlows(DatapathId dpid, boolean server42IslRtt, Integer server42Port, Integer server42Vlan, org.openkilda.model.MacAddress server42MacAddress, Collection<Integer> islPorts) throws SwitchNotFoundException {
    List<SwitchFlowGenerator> generators = new ArrayList<>();
    if (server42IslRtt) {
        generators.add(switchFlowFactory.getServer42IslRttTurningFlowGenerator());
        generators.add(switchFlowFactory.getServer42IslRttOutputFlowGenerator(server42Port, server42Vlan, server42MacAddress));
        for (Integer islPort : islPorts) {
            generators.add(switchFlowFactory.getServer42IslRttInputFlowGenerator(server42Port, islPort));
        }
    }
    IOFSwitch sw = lookupSwitch(dpid);
    return generators.stream().map(g -> g.generateFlow(sw)).map(SwitchFlowTuple::getFlow).filter(Objects::nonNull).collect(toList());
}
Also used : TableId(org.projectfloodlight.openflow.types.TableId) U64(org.projectfloodlight.openflow.types.U64) Arrays(java.util.Arrays) DEFAULT_METERS(org.openkilda.model.MeterId.DEFAULT_METERS) OFPortMod(org.projectfloodlight.openflow.protocol.OFPortMod) MeteredFlowGenerator(org.openkilda.floodlight.switchmanager.factory.generator.MeteredFlowGenerator) DROP_VERIFICATION_LOOP_RULE_COOKIE(org.openkilda.model.cookie.Cookie.DROP_VERIFICATION_LOOP_RULE_COOKIE) OFFlowStatsRequest(org.projectfloodlight.openflow.protocol.OFFlowStatsRequest) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) VERIFICATION_UNICAST_VXLAN_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_UNICAST_VXLAN_RULE_COOKIE) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) Collections.singletonList(java.util.Collections.singletonList) InetAddress(java.net.InetAddress) MULTITABLE_POST_INGRESS_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_POST_INGRESS_DROP_COOKIE) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Future(java.util.concurrent.Future) SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) OFGroupDescStatsRequest(org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest) OFMeterModCommand(org.projectfloodlight.openflow.protocol.OFMeterModCommand) Match(org.projectfloodlight.openflow.protocol.match.Match) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFGroupType(org.projectfloodlight.openflow.protocol.OFGroupType) OFBarrierReply(org.projectfloodlight.openflow.protocol.OFBarrierReply) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) OFGroupAdd(org.projectfloodlight.openflow.protocol.OFGroupAdd) OFMeterConfigStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException) MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE) Set(java.util.Set) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) RuleType(org.openkilda.messaging.command.flow.RuleType) IRestApiService(net.floodlightcontroller.restserver.IRestApiService) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) ROUND_TRIP_LATENCY_RULE_COOKIE(org.openkilda.model.cookie.Cookie.ROUND_TRIP_LATENCY_RULE_COOKIE) CorrelationContext(org.openkilda.floodlight.utils.CorrelationContext) Stream(java.util.stream.Stream) LLDP_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_INGRESS_COOKIE) Meter(org.openkilda.model.Meter) OF_12(org.projectfloodlight.openflow.protocol.OFVersion.OF_12) OF_13(org.projectfloodlight.openflow.protocol.OFVersion.OF_13) SwitchFlowUtils.isOvs(org.openkilda.floodlight.switchmanager.SwitchFlowUtils.isOvs) OFBufferId(org.projectfloodlight.openflow.types.OFBufferId) OFOxms(org.projectfloodlight.openflow.protocol.oxm.OFOxms) LLDP_POST_INGRESS_ONE_SWITCH_METER_ID(org.openkilda.model.MeterId.LLDP_POST_INGRESS_ONE_SWITCH_METER_ID) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) LLDP_POST_INGRESS_VXLAN_METER_ID(org.openkilda.model.MeterId.LLDP_POST_INGRESS_VXLAN_METER_ID) CollectionUtils(org.apache.commons.collections4.CollectionUtils) VERIFICATION_UNICAST_VXLAN_METER_ID(org.openkilda.model.MeterId.VERIFICATION_UNICAST_VXLAN_METER_ID) ArrayList(java.util.ArrayList) EthType(org.projectfloodlight.openflow.types.EthType) Lists(com.google.common.collect.Lists) OFMeterFlags(org.projectfloodlight.openflow.protocol.OFMeterFlags) OFActionType(org.projectfloodlight.openflow.protocol.OFActionType) OFFlowStatsReply(org.projectfloodlight.openflow.protocol.OFFlowStatsReply) MacAddress(org.projectfloodlight.openflow.types.MacAddress) Cookie.isDefaultRule(org.openkilda.model.cookie.Cookie.isDefaultRule) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) LLDP_TRANSIT_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_TRANSIT_COOKIE) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Builder(org.projectfloodlight.openflow.protocol.match.Match.Builder) ErrorType(org.openkilda.messaging.error.ErrorType) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) SERVER_42_ISL_RTT_OUTPUT_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_OUTPUT_COOKIE) ARP_INPUT_PRE_DROP_METER_ID(org.openkilda.model.MeterId.ARP_INPUT_PRE_DROP_METER_ID) DROP_RULE_COOKIE(org.openkilda.model.cookie.Cookie.DROP_RULE_COOKIE) ARP_POST_INGRESS_VXLAN_METER_ID(org.openkilda.model.MeterId.ARP_POST_INGRESS_VXLAN_METER_ID) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) OFActions(org.projectfloodlight.openflow.protocol.action.OFActions) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) ExecutionException(java.util.concurrent.ExecutionException) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) NewCorrelationContextRequired(org.openkilda.floodlight.utils.NewCorrelationContextRequired) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop) VERIFICATION_UNICAST_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_UNICAST_RULE_COOKIE) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) IFloodlightService(net.floodlightcontroller.core.module.IFloodlightService) ARP_POST_INGRESS_METER_ID(org.openkilda.model.MeterId.ARP_POST_INGRESS_METER_ID) IpProtocol(org.projectfloodlight.openflow.types.IpProtocol) OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) ARP_POST_INGRESS_ONE_SWITCH_METER_ID(org.openkilda.model.MeterId.ARP_POST_INGRESS_ONE_SWITCH_METER_ID) DatapathId(org.projectfloodlight.openflow.types.DatapathId) VERIFICATION_BROADCAST_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_BROADCAST_RULE_COOKIE) VERIFICATION_BROADCAST_METER_ID(org.openkilda.model.MeterId.VERIFICATION_BROADCAST_METER_ID) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) OfPortDescConverter(org.openkilda.floodlight.converter.OfPortDescConverter) ARP_POST_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_COOKIE) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) KildaCore(org.openkilda.floodlight.KildaCore) SwitchFeature(org.openkilda.model.SwitchFeature) LLDP_POST_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_COOKIE) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) ARP_INPUT_PRE_DROP_COOKIE(org.openkilda.model.cookie.Cookie.ARP_INPUT_PRE_DROP_COOKIE) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) ARP_TRANSIT_METER_ID(org.openkilda.model.MeterId.ARP_TRANSIT_METER_ID) SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) FlowModUtils(net.floodlightcontroller.util.FlowModUtils) TransportPort(org.projectfloodlight.openflow.types.TransportPort) ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) LLDP_TRANSIT_METER_ID(org.openkilda.model.MeterId.LLDP_TRANSIT_METER_ID) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Collectors.toSet(java.util.stream.Collectors.toSet) LLDP_POST_INGRESS_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_VXLAN_COOKIE) OFGroupDelete(org.projectfloodlight.openflow.protocol.OFGroupDelete) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) ImmutableSet(com.google.common.collect.ImmutableSet) OFPortConfig(org.projectfloodlight.openflow.protocol.OFPortConfig) ImmutableMap(com.google.common.collect.ImmutableMap) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) LLDP_POST_INGRESS_METER_ID(org.openkilda.model.MeterId.LLDP_POST_INGRESS_METER_ID) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) NOVIFLOW_PUSH_POP_VXLAN(org.openkilda.model.SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) VERIFICATION_UNICAST_METER_ID(org.openkilda.model.MeterId.VERIFICATION_UNICAST_METER_ID) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) IOFMessageListener(net.floodlightcontroller.core.IOFMessageListener) Objects(java.util.Objects) OFPort(org.projectfloodlight.openflow.types.OFPort) MULTITABLE_EGRESS_PASS_THROUGH_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_EGRESS_PASS_THROUGH_COOKIE) List(java.util.List) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) SwitchFlowTuple(org.openkilda.floodlight.switchmanager.factory.SwitchFlowTuple) OFMetadata(org.projectfloodlight.openflow.types.OFMetadata) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) Optional(java.util.Optional) ARP_POST_INGRESS_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_VXLAN_COOKIE) OFType(org.projectfloodlight.openflow.protocol.OFType) ARP_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.ARP_INGRESS_COOKIE) OFGroup(org.projectfloodlight.openflow.types.OFGroup) MULTITABLE_TRANSIT_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_TRANSIT_DROP_COOKIE) SERVER_42_FLOW_RTT_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_TURNING_COOKIE) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SwitchFlowGenerator(org.openkilda.floodlight.switchmanager.factory.generator.SwitchFlowGenerator) HashMap(java.util.HashMap) KILDA_OVS_PUSH_POP_MATCH_VXLAN(org.openkilda.model.SwitchFeature.KILDA_OVS_PUSH_POP_MATCH_VXLAN) ARP_POST_INGRESS_ONE_SWITCH_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_ONE_SWITCH_COOKIE) CATCH_BFD_RULE_COOKIE(org.openkilda.model.cookie.Cookie.CATCH_BFD_RULE_COOKIE) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) MULTITABLE_INGRESS_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_INGRESS_DROP_COOKIE) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) Cookie(org.openkilda.model.cookie.Cookie) OFErrorMsg(org.projectfloodlight.openflow.protocol.OFErrorMsg) OFBarrierRequest(org.projectfloodlight.openflow.protocol.OFBarrierRequest) SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) Logger(org.slf4j.Logger) POST_INGRESS(org.openkilda.messaging.command.flow.RuleType.POST_INGRESS) ARP_INGRESS_METER_ID(org.openkilda.model.MeterId.ARP_INGRESS_METER_ID) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) ARP_TRANSIT_COOKIE(org.openkilda.model.cookie.Cookie.ARP_TRANSIT_COOKIE) LLDP_INPUT_PRE_DROP_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_INPUT_PRE_DROP_COOKIE) SwitchManagerWebRoutable(org.openkilda.floodlight.switchmanager.web.SwitchManagerWebRoutable) IPv4Address(org.projectfloodlight.openflow.types.IPv4Address) SwitchFlowUtils.convertDpIdToMac(org.openkilda.floodlight.switchmanager.SwitchFlowUtils.convertDpIdToMac) MeterId.createMeterIdForDefaultRule(org.openkilda.model.MeterId.createMeterIdForDefaultRule) FloodlightModuleException(net.floodlightcontroller.core.module.FloodlightModuleException) IFloodlightModule(net.floodlightcontroller.core.module.IFloodlightModule) MeterId(org.openkilda.model.MeterId) TimeUnit(java.util.concurrent.TimeUnit) OFGroupDescStatsReply(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply) Collectors.toList(java.util.stream.Collectors.toList) SERVER_42_ISL_RTT_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_TURNING_COOKIE) LLDP_INPUT_PRE_DROP_METER_ID(org.openkilda.model.MeterId.LLDP_INPUT_PRE_DROP_METER_ID) OfInstallException(org.openkilda.floodlight.error.OfInstallException) SwitchId(org.openkilda.model.SwitchId) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Destination(org.openkilda.messaging.Destination) MatchField(org.projectfloodlight.openflow.protocol.match.MatchField) LLDP_INGRESS_METER_ID(org.openkilda.model.MeterId.LLDP_INGRESS_METER_ID) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LATENCY_PACKET_UDP_PORT(org.openkilda.floodlight.pathverification.PathVerificationService.LATENCY_PACKET_UDP_PORT) ErrorData(org.openkilda.messaging.error.ErrorData) GroupId(org.openkilda.model.GroupId) Collections(java.util.Collections) LLDP_POST_INGRESS_ONE_SWITCH_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_ONE_SWITCH_COOKIE) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) SwitchFlowGenerator(org.openkilda.floodlight.switchmanager.factory.generator.SwitchFlowGenerator) SwitchFlowTuple(org.openkilda.floodlight.switchmanager.factory.SwitchFlowTuple) ArrayList(java.util.ArrayList)

Example 15 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class SwitchManager method dumpFlowTable.

private List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid, final int tableId) throws SwitchNotFoundException {
    List<OFFlowStatsEntry> entries = new ArrayList<>();
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest().setOutGroup(OFGroup.ANY).setCookieMask(U64.ZERO).setTableId(TableId.of(tableId)).build();
    try {
        Future<List<OFFlowStatsReply>> future = sw.writeStatsRequest(flowRequest);
        List<OFFlowStatsReply> values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            entries = values.stream().map(OFFlowStatsReply::getEntries).flatMap(List::stream).collect(toList());
        }
    } catch (ExecutionException | TimeoutException e) {
        logger.error("Could not get flow stats for {}.", dpid, e);
        throw new SwitchNotFoundException(dpid);
    } catch (InterruptedException e) {
        logger.error("Could not get flow stats for {}.", dpid, e);
        Thread.currentThread().interrupt();
        throw new SwitchNotFoundException(dpid);
    }
    return entries;
}
Also used : OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) ArrayList(java.util.ArrayList) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) OFFlowStatsRequest(org.projectfloodlight.openflow.protocol.OFFlowStatsRequest) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) OFFlowStatsReply(org.projectfloodlight.openflow.protocol.OFFlowStatsReply) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)15 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)9 DatapathId (org.projectfloodlight.openflow.types.DatapathId)9 ArrayList (java.util.ArrayList)8 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)8 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)8 ImmutableList (com.google.common.collect.ImmutableList)7 List (java.util.List)7 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)7 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)6 OFFlowStatsEntry (org.projectfloodlight.openflow.protocol.OFFlowStatsEntry)6 Arrays.asList (java.util.Arrays.asList)5 Collections.emptyList (java.util.Collections.emptyList)5 Collections.singletonList (java.util.Collections.singletonList)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 Collectors.toList (java.util.stream.Collectors.toList)5 InvalidMeterIdException (org.openkilda.floodlight.error.InvalidMeterIdException)5 OfInstallException (org.openkilda.floodlight.error.OfInstallException)5 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)5