Search in sources :

Example 6 with OFBucket

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

the class OfGroupConverterTest method testConvertInstallGroupCommand.

@Test
public void testConvertInstallGroupCommand() {
    List<Bucket> buckets = new ArrayList<>();
    buckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
    buckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
    GroupSpeakerData groupSpeakerData = GroupSpeakerData.builder().groupId(new GroupId(GROUP_ID)).type(GroupType.ALL).buckets(buckets).build();
    OFFactoryVer13 factory = new OFFactoryVer13();
    OFGroupAdd ofGroupAdd = OfGroupConverter.INSTANCE.convertInstallGroupCommand(groupSpeakerData, factory);
    assertEquals(OFGroup.of(GROUP_ID), ofGroupAdd.getGroup());
    assertEquals(OFGroupType.ALL, ofGroupAdd.getGroupType());
    assertEquals(2, ofGroupAdd.getBuckets().size());
    List<OFBucket> expectedBuckets = new ArrayList<>();
    expectedBuckets.add(factory.buildBucket().setWatchPort(OFPort.ANY).setWatchGroup(OFGroup.ALL).setActions(getActions(factory, 2)).build());
    expectedBuckets.add(factory.buildBucket().setWatchPort(OFPort.ANY).setWatchGroup(OFGroup.ALL).setActions(getActions(factory, 1)).build());
    assertEquals(expectedBuckets, ofGroupAdd.getBuckets());
}
Also used : OFGroupAdd(org.projectfloodlight.openflow.protocol.OFGroupAdd) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) GroupId(org.openkilda.model.GroupId) Test(org.junit.Test)

Example 7 with OFBucket

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

the class VerificationFlowGenerator method getInstallRoundTripLatencyGroupInstruction.

private static OFGroupAdd getInstallRoundTripLatencyGroupInstruction(IOFSwitch sw) {
    OFFactory ofFactory = sw.getOFFactory();
    List<OFBucket> bucketList = new ArrayList<>();
    bucketList.add(ofFactory.buildBucket().setActions(Lists.newArrayList(actionSetDstMac(sw.getOFFactory(), convertDpIdToMac(sw.getId())), actionSendToController(sw.getOFFactory()))).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));
    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)

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