Search in sources :

Example 1 with ValidateGroupsResult

use of org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult in project open-kilda by telstra.

the class SwitchValidateFsm method validateGroups.

protected void validateGroups(List<GroupSpeakerData> expectedGroups) {
    log.info("Validate groups (switch={}, key={})", getSwitchId(), key);
    ValidateGroupsResult results = validationService.validateGroups(getSwitchId(), validationContext.getActualGroupEntries(), expectedGroups);
    validationContext = validationContext.toBuilder().validateGroupsResult(results).build();
}
Also used : ValidateGroupsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult)

Example 2 with ValidateGroupsResult

use of org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult in project open-kilda by telstra.

the class SwitchSyncServiceImplTest method handleSyncWhenNotProcessMeters.

@Test
public void handleSyncWhenNotProcessMeters() {
    request = SwitchValidateRequest.builder().switchId(SWITCH_ID).performSync(true).removeExcess(true).build();
    ValidationResult tempResult = makeValidationResult();
    service.handleSwitchSync(KEY, request, new ValidationResult(tempResult.getFlowEntries(), false, tempResult.getValidateRulesResult(), null, new ValidateGroupsResult(emptyList(), emptyList(), emptyList(), emptyList()), new ValidateLogicalPortsResult(emptyList(), emptyList(), emptyList(), emptyList())));
    verify(commandBuilder).buildCommandsToSyncMissingRules(eq(SWITCH_ID), eq(missingRules));
    verify(carrier).sendCommandToSpeaker(eq(KEY), any(CommandData.class));
    service.handleInstallRulesResponse(KEY);
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
    verify(carrier).response(eq(KEY), responseCaptor.capture());
    assertNull(((SwitchSyncResponse) responseCaptor.getValue().getData()).getMeters());
    verifyNoMoreInteractions(commandBuilder);
    verifyNoMoreInteractions(carrier);
}
Also used : ValidateGroupsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult) InfoMessage(org.openkilda.messaging.info.InfoMessage) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) CommandData(org.openkilda.messaging.command.CommandData) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) Test(org.junit.Test)

Example 3 with ValidateGroupsResult

use of org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult 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

ValidateGroupsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult)3 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 ValidateLogicalPortsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult)2 Test (org.junit.Test)1 CommandData (org.openkilda.messaging.command.CommandData)1 GroupSyncEntry (org.openkilda.messaging.info.switches.GroupSyncEntry)1 LogicalPortsSyncEntry (org.openkilda.messaging.info.switches.LogicalPortsSyncEntry)1 MetersSyncEntry (org.openkilda.messaging.info.switches.MetersSyncEntry)1 RulesSyncEntry (org.openkilda.messaging.info.switches.RulesSyncEntry)1 SwitchSyncResponse (org.openkilda.messaging.info.switches.SwitchSyncResponse)1 MirrorConfig (org.openkilda.model.MirrorConfig)1 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)1 ValidateRulesResult (org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult)1 ValidationResult (org.openkilda.wfm.topology.switchmanager.model.ValidationResult)1