Search in sources :

Example 11 with MirrorConfig

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

the class RecordHandler method doInstallGroupRequest.

private void doInstallGroupRequest(CommandMessage message) {
    SwitchId switchId = ((InstallGroupRequest) message.getData()).getSwitchId();
    MirrorConfig mirrorConfig = ((InstallGroupRequest) message.getData()).getMirrorConfig();
    FlowTransitEncapsulation encapsulation = ((InstallGroupRequest) message.getData()).getEncapsulation();
    SwitchId egressSwitchId = ((InstallGroupRequest) message.getData()).getEgressSwitchId();
    FlowTransitData flowTransitData = null;
    if (encapsulation != null) {
        flowTransitData = FlowTransitData.builder().ingressSwitchId(switchId).egressSwitchId(egressSwitchId).encapsulation(encapsulation).build();
    }
    logger.debug("Install group '{}' for switch '{}'", mirrorConfig.getGroupId().intValue(), switchId);
    handleSpeakerCommand(new GroupInstallCommand(new MessageContext(message), switchId, mirrorConfig, flowTransitData));
    InstallGroupResponse response = new InstallGroupResponse(switchId, mirrorConfig.getGroupId().intValue());
    String correlationId = message.getCorrelationId();
    InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), correlationId);
    getKafkaProducer().sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), correlationId, infoMessage);
}
Also used : FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) InstallGroupRequest(org.openkilda.messaging.command.switches.InstallGroupRequest) MirrorConfig(org.openkilda.model.MirrorConfig) InfoMessage(org.openkilda.messaging.info.InfoMessage) InstallGroupResponse(org.openkilda.messaging.info.switches.InstallGroupResponse) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) GroupInstallCommand(org.openkilda.floodlight.command.group.GroupInstallCommand)

Example 12 with MirrorConfig

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

the class SwitchSyncFsm method finished.

protected void finished(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
    ValidateRulesResult validateRulesResult = validationResult.getValidateRulesResult();
    ValidateMetersResult validateMetersResult = validationResult.getValidateMetersResult();
    ValidateGroupsResult validateGroupsResult = validationResult.getValidateGroupsResult();
    ValidateLogicalPortsResult validateLogicalPortsResult = Optional.ofNullable(validationResult.getValidateLogicalPortsResult()).orElse(ValidateLogicalPortsResult.newEmpty());
    RulesSyncEntry rulesEntry = new RulesSyncEntry(new ArrayList<>(validateRulesResult.getMissingRules()), new ArrayList<>(validateRulesResult.getMisconfiguredRules()), new ArrayList<>(validateRulesResult.getProperRules()), new ArrayList<>(validateRulesResult.getExcessRules()), installedRulesCookies, request.isRemoveExcess() ? union(removedFlowRulesCookies, removedDefaultRulesCookies) : removedDefaultRulesCookies);
    MetersSyncEntry metersEntry = null;
    if (validationResult.isProcessMeters()) {
        metersEntry = new MetersSyncEntry(validateMetersResult.getMissingMeters(), validateMetersResult.getMisconfiguredMeters(), validateMetersResult.getProperMeters(), validateMetersResult.getExcessMeters(), validateMetersResult.getMissingMeters(), request.isRemoveExcess() ? validateMetersResult.getExcessMeters() : emptyList());
    }
    List<Integer> installedGroupsIds = missingGroups.stream().map(GroupInstallContext::getMirrorConfig).map(MirrorConfig::getGroupId).map(GroupId::intValue).collect(Collectors.toList());
    List<Integer> modifiedGroupsIds = misconfiguredGroups.stream().map(GroupInstallContext::getMirrorConfig).map(MirrorConfig::getGroupId).map(GroupId::intValue).collect(Collectors.toList());
    GroupSyncEntry groupEntry = GroupSyncEntry.builder().proper(validateGroupsResult.getProperGroups()).misconfigured(validateGroupsResult.getMisconfiguredGroups()).missing(validateGroupsResult.getMissingGroups()).excess(validateGroupsResult.getExcessGroups()).installed(mapToGroupEntryList(installedGroupsIds, validateGroupsResult.getMissingGroups())).modified(mapToGroupEntryList(modifiedGroupsIds, validateGroupsResult.getMisconfiguredGroups())).removed(mapToGroupEntryList(excessGroups, validateGroupsResult.getExcessGroups())).build();
    LogicalPortsSyncEntry logicalPortsEntry = LogicalPortsSyncEntry.builder().proper(validateLogicalPortsResult.getProperLogicalPorts()).misconfigured(validateLogicalPortsResult.getMisconfiguredLogicalPorts()).excess(validateLogicalPortsResult.getExcessLogicalPorts()).missing(validateLogicalPortsResult.getMissingLogicalPorts()).installed(validateLogicalPortsResult.getMissingLogicalPorts()).removed(validateLogicalPortsResult.getExcessLogicalPorts()).build();
    SwitchSyncResponse response = new SwitchSyncResponse(switchId, rulesEntry, metersEntry, groupEntry, logicalPortsEntry);
    InfoMessage message = new InfoMessage(response, System.currentTimeMillis(), key);
    carrier.cancelTimeoutCallback(key);
    carrier.response(key, message);
}
Also used : ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) MetersSyncEntry(org.openkilda.messaging.info.switches.MetersSyncEntry) RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidateGroupsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult) MirrorConfig(org.openkilda.model.MirrorConfig) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) GroupSyncEntry(org.openkilda.messaging.info.switches.GroupSyncEntry) LogicalPortsSyncEntry(org.openkilda.messaging.info.switches.LogicalPortsSyncEntry)

Aggregations

MirrorConfig (org.openkilda.model.MirrorConfig)12 ArrayList (java.util.ArrayList)7 MessageContext (org.openkilda.messaging.MessageContext)7 SwitchId (org.openkilda.model.SwitchId)7 Flow (org.openkilda.model.Flow)6 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)6 FlowTransitData (org.openkilda.floodlight.model.FlowTransitData)4 List (java.util.List)3 Optional (java.util.Optional)3 Set (java.util.Set)3 UUID (java.util.UUID)3 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)3 EgressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory)3 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)3 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)3 IngressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory)3 TransitFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory)3 FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)3 BaseFlow (org.openkilda.messaging.command.flow.BaseFlow)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3