Search in sources :

Example 6 with OFGroupDescStatsEntry

use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry in project open-kilda by telstra.

the class OfGroupConverterTest method testConvertToGroupSpeakerData.

@Test
public void testConvertToGroupSpeakerData() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    Builder builder = factory.buildGroupDescStatsReply();
    List<OFGroupDescStatsEntry> entries = new ArrayList<>();
    entries.add(getOfGroupEntry(factory));
    builder.setEntries(entries);
    List<GroupSpeakerData> groupSpeakerDataList = OfGroupConverter.INSTANCE.convertToGroupSpeakerData(builder.build());
    assertEquals(1, groupSpeakerDataList.size());
    GroupSpeakerData groupSpeakerData = groupSpeakerDataList.get(0);
    assertEquals(new GroupId(GROUP_ID), groupSpeakerData.getGroupId());
    assertEquals(GroupType.ALL, groupSpeakerData.getType());
    List<Bucket> buckets = groupSpeakerData.getBuckets();
    Set<Bucket> expectedBuckets = new HashSet<>();
    expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
    expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
    assertEquals(expectedBuckets, new HashSet<>(buckets));
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Builder(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply.Builder) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) GroupId(org.openkilda.model.GroupId) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with OFGroupDescStatsEntry

use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry 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

OFGroupDescStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry)7 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)3 GroupEntry (org.openkilda.messaging.info.rule.GroupEntry)3 OFBucket (org.projectfloodlight.openflow.protocol.OFBucket)3 OFGroupDescStatsReply (org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 Test (org.junit.Test)2 OfFlowStatsMapper (org.openkilda.floodlight.converter.OfFlowStatsMapper)2 SwitchMissingGroupException (org.openkilda.floodlight.error.SwitchMissingGroupException)2 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 FlowCommandErrorData (org.openkilda.messaging.error.rule.FlowCommandErrorData)2 GroupBucket (org.openkilda.messaging.info.rule.GroupBucket)2 GroupId (org.openkilda.model.GroupId)2 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)2 OFGroupDescStatsRequest (org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest)2 ImmutableList (com.google.common.collect.ImmutableList)1