Search in sources :

Example 1 with OFBucket

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

the class OfGroupConverter method convertToGroupSpeakerData.

/**
 * Convert stats entry.
 */
public GroupSpeakerData convertToGroupSpeakerData(OFGroupDescStatsEntry entry) {
    GroupId groupId = new GroupId(entry.getGroup().getGroupNumber());
    GroupType type = fromOfGroupType(entry.getGroupType());
    List<Bucket> buckets = new ArrayList<>();
    List<OFBucket> ofBuckets = entry.getBuckets();
    for (OFBucket bucket : ofBuckets) {
        buckets.add(fromOfBucket(bucket));
    }
    return GroupSpeakerData.builder().groupId(groupId).type(type).buckets(buckets).build();
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) GroupType(org.openkilda.rulemanager.group.GroupType) OFGroupType(org.projectfloodlight.openflow.protocol.OFGroupType) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) ArrayList(java.util.ArrayList) GroupId(org.openkilda.model.GroupId)

Example 2 with OFBucket

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

the class SwitchManager method getInstallRoundTripLatencyGroupInstruction.

@VisibleForTesting
OFGroupAdd getInstallRoundTripLatencyGroupInstruction(IOFSwitch sw) {
    OFFactory ofFactory = sw.getOFFactory();
    List<OFBucket> bucketList = new ArrayList<>();
    bucketList.add(ofFactory.buildBucket().setActions(Lists.newArrayList(actionSetDstMac(sw, convertDpIdToMac(sw.getId())), actionSendToController(sw))).setWatchGroup(OFGroup.ANY).build());
    TransportPort udpPort = TransportPort.of(LATENCY_PACKET_UDP_PORT);
    List<OFAction> latencyActions = ImmutableList.of(ofFactory.actions().setField(ofFactory.oxms().udpDst(udpPort)), actionSetOutputPort(ofFactory, OFPort.IN_PORT));
    bucketList.add(ofFactory.buildBucket().setActions(latencyActions).setWatchGroup(OFGroup.ANY).build());
    return ofFactory.buildGroupAdd().setGroup(OFGroup.of(GroupId.ROUND_TRIP_LATENCY_GROUP_ID.intValue())).setGroupType(OFGroupType.ALL).setBuckets(bucketList).build();
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) ArrayList(java.util.ArrayList) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) TransportPort(org.projectfloodlight.openflow.types.TransportPort) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with OFBucket

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

the class AbstractGroupInstall method buildGroupOfBuckets.

protected List<OFBucket> buildGroupOfBuckets(OFFactory ofFactory) {
    List<OFAction> flowActions = buildFlowActions(ofFactory);
    flowActions.add(ofFactory.actions().buildOutput().setPort(OFPort.of(mirrorConfig.getFlowPort())).build());
    OFBucket flowBucket = ofFactory.buildBucket().setActions(flowActions).setWatchGroup(OFGroup.ANY).build();
    List<OFBucket> buckets = Lists.newArrayList(flowBucket);
    for (MirrorConfigData mirrorConfigData : mirrorConfig.getMirrorConfigDataSet()) {
        List<OFAction> mirrorActions = new ArrayList<>();
        int mirrorVlan = mirrorConfigData.getMirrorVlan();
        if (mirrorVlan > 0) {
            mirrorActions.addAll(OfAdapter.INSTANCE.makeVlanReplaceActions(ofFactory, Collections.emptyList(), Lists.newArrayList(mirrorVlan)));
        }
        mirrorActions.add(ofFactory.actions().buildOutput().setPort(OFPort.of(mirrorConfigData.getMirrorPort())).build());
        buckets.add(ofFactory.buildBucket().setActions(mirrorActions).setWatchGroup(OFGroup.ANY).build());
    }
    return buckets;
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) ArrayList(java.util.ArrayList)

Example 4 with OFBucket

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

the class GroupVerifyCommand method validateGroupConfig.

private void validateGroupConfig(OFGroupDescStatsEntry group) {
    DatapathId datapathId = getSw().getId();
    OFFactory ofFactory = getSw().getOFFactory();
    List<OFBucket> expected = buildGroupOfBuckets(ofFactory);
    List<OFBucket> actual = group.getBuckets();
    if (!expected.equals(actual)) {
        throw maskCallbackException(new SwitchIncorrectMirrorGroupException(datapathId, mirrorConfig, fromStatsEntry(group)));
    }
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) SwitchIncorrectMirrorGroupException(org.openkilda.floodlight.error.SwitchIncorrectMirrorGroupException) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 5 with OFBucket

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

the class SwitchManagerTest method mockGetGroupsRequest.

private void mockGetGroupsRequest(List<Integer> groupIds) throws Exception {
    List<OFGroupDescStatsEntry> meterConfigs = new ArrayList<>(groupIds.size());
    for (Integer groupId : groupIds) {
        OFBucket firstBucket = mock(OFBucket.class);
        OFBucket secondBucket = mock(OFBucket.class);
        OFActionSetField setDestMacAction = ofFactory.actions().buildSetField().setField(ofFactory.oxms().buildEthDst().setValue(convertDpIdToMac(dpid)).build()).build();
        OFActionOutput sendToControllerAction = ofFactory.actions().output(OFPort.CONTROLLER, 0xFFFFFFFF);
        TransportPort udpPort = TransportPort.of(LATENCY_PACKET_UDP_PORT);
        OFActionSetField setUdpDstAction = ofFactory.actions().setField(ofFactory.oxms().udpDst(udpPort));
        OFActionOutput sendInPortAction = ofFactory.actions().output(OFPort.IN_PORT, 0xFFFFFFFF);
        expect(firstBucket.getActions()).andStubReturn(Lists.newArrayList(setDestMacAction, sendToControllerAction));
        expect(secondBucket.getActions()).andStubReturn(Lists.newArrayList(setUdpDstAction, sendInPortAction));
        OFGroupDescStatsEntry groupEntry = mock(OFGroupDescStatsEntry.class);
        expect(groupEntry.getGroup()).andStubReturn(OFGroup.of(groupId));
        expect(groupEntry.getBuckets()).andStubReturn(Lists.newArrayList(firstBucket, secondBucket));
        replay(firstBucket, secondBucket, groupEntry);
        meterConfigs.add(groupEntry);
    }
    OFGroupDescStatsReply statsReply = mock(OFGroupDescStatsReply.class);
    expect(statsReply.getEntries()).andStubReturn(meterConfigs);
    ListenableFuture<List<OFGroupDescStatsReply>> ofStatsFuture = mock(ListenableFuture.class);
    expect(ofStatsFuture.get(anyLong(), anyObject())).andStubReturn(Collections.singletonList(statsReply));
    expect(iofSwitch.writeStatsRequest(isA(OFGroupDescStatsRequest.class))).andStubReturn(ofStatsFuture);
    replay(statsReply, ofStatsFuture);
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) ArrayList(java.util.ArrayList) OFGroupDescStatsReply(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) TransportPort(org.projectfloodlight.openflow.types.TransportPort) OFGroupDescStatsRequest(org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest)

Aggregations

OFBucket (org.projectfloodlight.openflow.protocol.OFBucket)7 ArrayList (java.util.ArrayList)6 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)3 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)3 TransportPort (org.projectfloodlight.openflow.types.TransportPort)3 GroupId (org.openkilda.model.GroupId)2 Bucket (org.openkilda.rulemanager.group.Bucket)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Test (org.junit.Test)1 SwitchIncorrectMirrorGroupException (org.openkilda.floodlight.error.SwitchIncorrectMirrorGroupException)1 MirrorConfigData (org.openkilda.model.MirrorConfig.MirrorConfigData)1 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)1 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)1 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)1 GroupType (org.openkilda.rulemanager.group.GroupType)1 OFGroupAdd (org.projectfloodlight.openflow.protocol.OFGroupAdd)1