Search in sources :

Example 16 with OFFactoryVer13

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

the class PingRequestCommandAbstractTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    moduleContext.addService(IOFSwitchService.class, switchService);
    final DatapathId dpIdAlpha = DatapathId.of(0x0000fffe00000001L);
    final DatapathId dpIdBeta = DatapathId.of(0x0000fffe00000002L);
    final DatapathId dpIdGamma = DatapathId.of(0x0000fffe00000003L);
    final DatapathId dpIdDelta = DatapathId.of(0x0000fffe00000004L);
    OFFactory ofFactory = new OFFactoryVer13();
    expect(switchAlpha.getId()).andReturn(dpIdAlpha).anyTimes();
    expect(switchBeta.getId()).andReturn(dpIdBeta).anyTimes();
    expect(switchMissing.getId()).andReturn(dpIdGamma).anyTimes();
    expect(switchNotCapable.getId()).andReturn(dpIdDelta).anyTimes();
    expect(switchAlpha.getOFFactory()).andReturn(ofFactory).anyTimes();
    expect(switchBeta.getOFFactory()).andReturn(ofFactory).anyTimes();
    expect(switchNotCapable.getOFFactory()).andReturn(new OFFactoryVer12()).anyTimes();
    expect(switchService.getActiveSwitch(dpIdAlpha)).andReturn(switchAlpha).anyTimes();
    expect(switchService.getActiveSwitch(dpIdBeta)).andReturn(switchBeta).anyTimes();
    expect(switchService.getActiveSwitch(dpIdGamma)).andReturn(null).anyTimes();
    expect(switchService.getActiveSwitch(dpIdDelta)).andReturn(switchNotCapable).anyTimes();
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactoryVer12(org.projectfloodlight.openflow.protocol.ver12.OFFactoryVer12) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) DatapathId(org.projectfloodlight.openflow.types.DatapathId) Before(org.junit.Before)

Example 17 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 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 18 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 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 19 with OFFactoryVer13

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

the class BfdFeatureTest method createSwitchWithDescription.

private static IOFSwitch createSwitchWithDescription(SwitchDescription description) {
    OFFactory factory = new OFFactoryVer13();
    DatapathId dpid = DatapathId.of("1");
    OFConnection connection = new OFConnection(dpid, factory, new LocalChannel(), OFAuxId.MAIN, new MockDebugCounterService(), new HashedWheelTimer());
    OFSwitch sw = new OFSwitch(connection, factory, new OFSwitchManager(), dpid);
    sw.setSwitchProperties(description);
    return sw;
}
Also used : OFSwitchManager(net.floodlightcontroller.core.internal.OFSwitchManager) OFConnection(net.floodlightcontroller.core.internal.OFConnection) MockDebugCounterService(net.floodlightcontroller.debugcounter.MockDebugCounterService) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) LocalChannel(io.netty.channel.local.LocalChannel) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) DatapathId(org.projectfloodlight.openflow.types.DatapathId) HashedWheelTimer(io.netty.util.HashedWheelTimer) OFSwitch(net.floodlightcontroller.core.internal.OFSwitch) IOFSwitch(net.floodlightcontroller.core.IOFSwitch)

Example 20 with OFFactoryVer13

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

the class PingResponseCommandTest method success.

@Test
public void success() throws Exception {
    final PingService realPingService = new PingService();
    moduleContext.addService(PingService.class, realPingService);
    final ISwitchManager realSwitchManager = new SwitchManager();
    moduleContext.addService(ISwitchManager.class, realSwitchManager);
    InputService inputService = createMock(InputService.class);
    moduleContext.addService(InputService.class, inputService);
    inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
    replayAll();
    final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
    final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
    final PingData payload = PingData.of(ping);
    moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
    realPingService.setup(moduleContext);
    byte[] signedPayload = realPingService.getSignature().sign(payload);
    byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
    OFFactory ofFactory = new OFFactoryVer13();
    OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
    FloodlightContext metadata = new FloodlightContext();
    IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
    Assert.assertTrue(decodedEthernet instanceof Ethernet);
    IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
    OfInput input = new OfInput(iofSwitch, message, metadata);
    final PingResponseCommand command = makeCommand(input);
    command.call();
    final List<Message> replies = kafkaMessageCatcher.getValues();
    Assert.assertEquals(1, replies.size());
    InfoMessage response = (InfoMessage) replies.get(0);
    PingResponse pingResponse = (PingResponse) response.getData();
    Assert.assertNull(pingResponse.getError());
    Assert.assertNotNull(pingResponse.getMeters());
    Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchId(org.openkilda.model.SwitchId) PingResponse(org.openkilda.messaging.floodlight.response.PingResponse) SwitchManager(org.openkilda.floodlight.switchmanager.SwitchManager) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) PingData(org.openkilda.floodlight.model.PingData) InputService(org.openkilda.floodlight.service.of.InputService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) InfoMessage(org.openkilda.messaging.info.InfoMessage) PingService(org.openkilda.floodlight.service.ping.PingService) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Test(org.junit.Test)

Aggregations

OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)22 Test (org.junit.Test)16 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 Match (org.projectfloodlight.openflow.protocol.match.Match)5 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)5 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)4 OFSwitch (net.floodlightcontroller.core.internal.OFSwitch)4 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)4 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4 OFConnection (net.floodlightcontroller.core.internal.OFConnection)3 GroupId (org.openkilda.model.GroupId)3 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)3 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)3 U64 (org.projectfloodlight.openflow.types.U64)3 InetSocketAddress (java.net.InetSocketAddress)2 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)2 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)2