Search in sources :

Example 31 with GroupSpeakerData

use of org.openkilda.rulemanager.GroupSpeakerData in project open-kilda by telstra.

the class SwitchValidateFsm method validateEnter.

protected void validateEnter(SwitchValidateState from, SwitchValidateState to, SwitchValidateEvent event, SwitchValidateContext context) {
    SwitchId switchId = getSwitchId();
    Set<PathId> flowPathIds = flowPathRepository.findBySegmentSwitch(switchId).stream().map(FlowPath::getPathId).collect(Collectors.toSet());
    flowPathIds.addAll(flowPathRepository.findByEndpointSwitch(switchId).stream().map(FlowPath::getPathId).collect(Collectors.toSet()));
    PersistenceDataAdapter dataAdapter = PersistenceDataAdapter.builder().persistenceManager(persistenceManager).switchIds(Collections.singleton(switchId)).pathIds(flowPathIds).keepMultitableForFlow(true).build();
    List<SpeakerData> expectedEntities = ruleManager.buildRulesForSwitch(switchId, dataAdapter);
    List<FlowSpeakerData> expectedRules = filterSpeakerData(expectedEntities, FlowSpeakerData.class);
    List<MeterSpeakerData> expectedMeters = filterSpeakerData(expectedEntities, MeterSpeakerData.class);
    List<GroupSpeakerData> expectedGroups = filterSpeakerData(expectedEntities, GroupSpeakerData.class);
    validateRules(expectedRules);
    validateMeters(expectedMeters);
    validateGroups(expectedGroups);
    validateLogicalPorts();
}
Also used : PersistenceDataAdapter(org.openkilda.rulemanager.adapter.PersistenceDataAdapter) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) SwitchId(org.openkilda.model.SwitchId) PathId(org.openkilda.model.PathId) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowPath(org.openkilda.model.FlowPath) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData)

Example 32 with GroupSpeakerData

use of org.openkilda.rulemanager.GroupSpeakerData 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)

Aggregations

GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)32 Test (org.junit.Test)28 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)25 SpeakerData (org.openkilda.rulemanager.SpeakerData)24 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)23 Action (org.openkilda.rulemanager.action.Action)20 GroupAction (org.openkilda.rulemanager.action.GroupAction)20 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)20 Flow (org.openkilda.model.Flow)17 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)17 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)17 FlowPath (org.openkilda.model.FlowPath)14 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)13 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)9 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)8 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)6 ArrayList (java.util.ArrayList)5 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)4 GroupId (org.openkilda.model.GroupId)3 Instructions (org.openkilda.rulemanager.Instructions)3