Search in sources :

Example 21 with SwitchOperationException

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

the class RecordHandler method dumpRuleMangerGroupsRequest.

private void dumpRuleMangerGroupsRequest(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
    try {
        logger.debug("Loading installed groups for switch {}", switchId);
        List<OFGroupDescStatsEntry> ofGroupDescStatsEntries = context.getSwitchManager().dumpGroups(DatapathId.of(switchId.toLong()));
        List<GroupSpeakerData> groups = ofGroupDescStatsEntries.stream().map(OfGroupConverter.INSTANCE::convertToGroupSpeakerData).collect(Collectors.toList());
        GroupDumpResponse response = GroupDumpResponse.builder().switchId(switchId).groupSpeakerData(groups).build();
        sender.accept(response);
    } catch (SwitchOperationException e) {
        logger.error("Dumping of groups on switch '{}' was unsuccessful: {}", switchId, e.getMessage());
        ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("The switch was not found when requesting a groups dump.").buildData();
        sender.accept(errorData);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) OfGroupConverter(org.openkilda.floodlight.converter.rulemanager.OfGroupConverter) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 22 with SwitchOperationException

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

the class RecordHandler method doInstallFlowForSwitchManager.

/**
 * Install of flow on the switch from SwitchManager topology.
 *
 * @param message with list of flows.
 */
private void doInstallFlowForSwitchManager(final CommandMessage message) {
    InstallFlowForSwitchManagerRequest request = (InstallFlowForSwitchManagerRequest) message.getData();
    String replyToTopic = context.getKafkaSwitchManagerTopic();
    FlowSegmentResponseFactory responseFactory = new FlowSegmentSyncResponseFactory(message.getCorrelationId(), replyToTopic);
    MessageContext messageContext = new MessageContext(message);
    Optional<FlowSegmentWrapperCommand> syncCommand = makeSyncCommand(request.getFlowCommand(), messageContext, responseFactory);
    if (syncCommand.isPresent()) {
        handleSpeakerCommand(syncCommand.get());
        return;
    }
    try {
        installFlow(request.getFlowCommand());
    } catch (SwitchOperationException e) {
        logger.error("Error during flow installation", e);
        ErrorData errorData = new ErrorData(ErrorType.INTERNAL_ERROR, "Error during flow installation", "Switch operation error");
        ErrorMessage error = new ErrorMessage(errorData, System.currentTimeMillis(), message.getCorrelationId());
        getKafkaProducer().sendMessageAndTrack(replyToTopic, message.getCorrelationId(), error);
    } catch (FlowCommandException e) {
        String errorMessage = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
        logger.error("Failed to handle message {}: {}", message, errorMessage);
        ErrorData errorData = new FlowCommandErrorData(e.getFlowId(), e.getCookie(), e.getTransactionId(), e.getErrorType(), errorMessage, e.getMessage());
        ErrorMessage error = new ErrorMessage(errorData, System.currentTimeMillis(), message.getCorrelationId());
        getKafkaProducer().sendMessageAndTrack(replyToTopic, message.getCorrelationId(), error);
    }
    InfoMessage response = new InfoMessage(new FlowInstallResponse(), System.currentTimeMillis(), message.getCorrelationId());
    getKafkaProducer().sendMessageAndTrack(replyToTopic, message.getCorrelationId(), response);
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) FlowSegmentWrapperCommand(org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) FlowInstallResponse(org.openkilda.messaging.info.flow.FlowInstallResponse) FlowSegmentResponseFactory(org.openkilda.floodlight.command.flow.FlowSegmentResponseFactory) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowCommandException(org.openkilda.floodlight.error.FlowCommandException) MessageContext(org.openkilda.messaging.MessageContext) FlowSegmentSyncResponseFactory(org.openkilda.floodlight.command.flow.FlowSegmentSyncResponseFactory) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 23 with SwitchOperationException

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

the class SwitchManager method updatePortStatus.

private void updatePortStatus(IOFSwitch sw, int portNumber, boolean isAdminDown) throws SwitchOperationException {
    Set<OFPortConfig> config = new HashSet<>(1);
    if (isAdminDown) {
        config.add(OFPortConfig.PORT_DOWN);
    }
    Set<OFPortConfig> portMask = ImmutableSet.of(OFPortConfig.PORT_DOWN);
    final OFFactory ofFactory = sw.getOFFactory();
    OFPortMod ofPortMod = ofFactory.buildPortMod().setPortNo(OFPort.of(portNumber)).setHwAddr(getPortHwAddress(sw, portNumber)).setConfig(config).setMask(portMask).build();
    if (!sw.write(ofPortMod)) {
        throw new SwitchOperationException(sw.getId(), format("Unable to update port configuration: %s", ofPortMod));
    }
    logger.debug("Successfully updated port status {}", ofPortMod);
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) OFPortMod(org.projectfloodlight.openflow.protocol.OFPortMod) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFPortConfig(org.projectfloodlight.openflow.protocol.OFPortConfig) HashSet(java.util.HashSet)

Example 24 with SwitchOperationException

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

the class SwitchManager method removeFlowByOfFlowDelete.

private List<Long> removeFlowByOfFlowDelete(DatapathId dpid, int tableId, OFFlowDelete dropFlowDelete) throws SwitchOperationException {
    List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid, tableId);
    IOFSwitch sw = lookupSwitch(dpid);
    pushFlow(sw, "--DeleteFlow--", dropFlowDelete);
    // Wait for OFFlowDelete to be processed.
    sendBarrierRequest(sw);
    List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid, tableId);
    Set<Long> cookiesAfter = flowStatsAfter.stream().map(entry -> entry.getCookie().getValue()).collect(toSet());
    return flowStatsBefore.stream().map(entry -> entry.getCookie().getValue()).filter(cookie -> !cookiesAfter.contains(cookie)).peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)).collect(toList());
}
Also used : OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) 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)

Example 25 with SwitchOperationException

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

the class SwitchManager method deleteRulesByCriteria.

@Override
public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException {
    List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid);
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    for (DeleteRulesCriteria criteriaEntry : criteria) {
        OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType);
        logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid);
        pushFlow(sw, "--DeleteFlow--", dropFlowDelete);
    }
    // Wait for OFFlowDelete to be processed.
    sendBarrierRequest(sw);
    List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid);
    Set<Long> cookiesAfter = flowStatsAfter.stream().map(entry -> entry.getCookie().getValue()).collect(Collectors.toSet());
    return flowStatsBefore.stream().map(entry -> entry.getCookie().getValue()).filter(cookie -> !cookiesAfter.contains(cookie)).peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)).collect(toList());
}
Also used : OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) 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) OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria)

Aggregations

SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)28 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)25 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)13 InfoMessage (org.openkilda.messaging.info.InfoMessage)13 DatapathId (org.projectfloodlight.openflow.types.DatapathId)13 ErrorData (org.openkilda.messaging.error.ErrorData)9 SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)8 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)8 SwitchId (org.openkilda.model.SwitchId)8 ArrayList (java.util.ArrayList)7 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)7 OFMeterConfig (org.projectfloodlight.openflow.protocol.OFMeterConfig)7 HashSet (java.util.HashSet)6 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)6 OFGroupDescStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 ImmutableList (com.google.common.collect.ImmutableList)5 List (java.util.List)5 Objects (java.util.Objects)5 String.format (java.lang.String.format)4