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();
}
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();
}
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;
}
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)));
}
}
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);
}
Aggregations