Search in sources :

Example 1 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class BuildSwitchCapabilitiesOF13 method build.

@Override
public SwitchFeatures build(GetFeaturesOutput features) {
    SwitchFeaturesBuilder builderSwFeatures = new SwitchFeaturesBuilder();
    builderSwFeatures.setMaxBuffers(features.getBuffers());
    builderSwFeatures.setMaxTables(features.getTables());
    List<Class<? extends FeatureCapability>> capabilities = new ArrayList<>();
    if (features.getCapabilities().isOFPCFLOWSTATS()) {
        capabilities.add(FlowFeatureCapabilityFlowStats.class);
    }
    if (features.getCapabilities().isOFPCGROUPSTATS()) {
        capabilities.add(FlowFeatureCapabilityGroupStats.class);
    }
    if (features.getCapabilities().isOFPCIPREASM()) {
        capabilities.add(FlowFeatureCapabilityIpReasm.class);
    }
    if (features.getCapabilities().isOFPCPORTBLOCKED()) {
        capabilities.add(FlowFeatureCapabilityPortBlocked.class);
    }
    if (features.getCapabilities().isOFPCPORTSTATS()) {
        capabilities.add(FlowFeatureCapabilityPortStats.class);
    }
    if (features.getCapabilities().isOFPCQUEUESTATS()) {
        capabilities.add(FlowFeatureCapabilityQueueStats.class);
    }
    if (features.getCapabilities().isOFPCTABLESTATS()) {
        capabilities.add(FlowFeatureCapabilityTableStats.class);
    }
    builderSwFeatures.setCapabilities(capabilities);
    return builderSwFeatures.build();
}
Also used : FeatureCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability) ArrayList(java.util.ArrayList) SwitchFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeaturesBuilder)

Example 2 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactory method deserialize.

@Override
public GetFeaturesOutput deserialize(final ByteBuf rawMessage) {
    GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(datapathId);
    builder.setDatapathId(new BigInteger(1, datapathId));
    builder.setBuffers(rawMessage.readUnsignedInt());
    builder.setTables(rawMessage.readUnsignedByte());
    rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
    builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));
    builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));
    List<PhyPort> ports = new ArrayList<>();
    while (rawMessage.readableBytes() > 0) {
        ports.add(deserializePort(rawMessage));
    }
    builder.setPhyPort(ports);
    return builder.build();
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PhyPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)

Example 3 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class DeviceContextImplTest method testPortStatusMessage.

@Test
public void testPortStatusMessage() throws Exception {
    final PortStatusMessage mockedPortStatusMessage = mock(PortStatusMessage.class);
    final Class dummyClass = Class.class;
    when(mockedPortStatusMessage.getImplementedInterface()).thenReturn(dummyClass);
    final GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class);
    when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
    when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD);
    when(mockedPortStatusMessage.getPortNo()).thenReturn(42L);
    deviceContextSpy.processPortStatusMessage(mockedPortStatusMessage);
    verify(messageSpy).spyMessage(any(), any());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) Test(org.junit.Test)

Example 4 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class ConnectionManagerImplTest method testOnSwitchConnected1.

/**
 * Test method for
 * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
 * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
 * invoking onConnectionReady first, scenario:
 * <ol>
 * <li>send hello to device (rpc with void output)</li>
 * <li>receive hello from device (notification)</li>
 * <li>send getFeature to device (rpc with getFeatureOutput)</li>
 * <li>wait for rpc to finish with getFeatureOutput</li>
 * </ol>
 *
 * @throws InterruptedException - interrupted exception
 */
@Test
public void testOnSwitchConnected1() throws Exception {
    connectionManagerImpl.onSwitchConnected(connection);
    Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
    Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
    // prepare void reply (hello rpc output)
    final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
    Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
    // prepare getFeature reply (getFeture rpc output)
    final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
    Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
    // fire handshake
    connectionReadyListenerAC.getValue().onConnectionReady();
    // deliver hello send output (void)
    Thread.sleep(100L);
    final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
    voidResponseFx.set(helloResponse);
    // send hello reply
    final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
    ofpListenerAC.getValue().onHelloMessage(hello);
    // deliver getFeature output
    Thread.sleep(100L);
    final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
    final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
    featureResponseFx.set(rpcFeaturesOutput);
    Mockito.verify(deviceConnectedHandler, Mockito.timeout(500)).deviceConnected(Matchers.any(ConnectionContext.class));
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Test(org.junit.Test)

Example 5 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class ConnectionManagerImplTest method testOnSwitchConnected2.

/**
 * Test method for
 * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
 * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
 * invoking onHelloMessage, scenario:
 * <ol>
 * <li>receive hello from device (notification)</li>
 * <li>send hello to device (rpc with void output)</li>
 * <li>send getFeature to device (rpc with getFeatureOutput)</li>
 * <li>wait for rpc to finish with getFeatureOutput</li>
 * </ol>
 *
 * @throws InterruptedException - interrupted exception
 */
@Test
public void testOnSwitchConnected2() throws Exception {
    connectionManagerImpl.onSwitchConnected(connection);
    Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
    Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
    // prepare void reply (hello rpc output)
    final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
    Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
    // prepare getFeature reply (getFeture rpc output)
    final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
    Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
    // fire handshake - send hello reply
    final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
    ofpListenerAC.getValue().onHelloMessage(hello);
    // notify about connection ready
    connectionReadyListenerAC.getValue().onConnectionReady();
    // deliver hello send output (void)
    Thread.sleep(100L);
    final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
    voidResponseFx.set(helloResponse);
    // deliver getFeature output
    Thread.sleep(100L);
    final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
    final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
    featureResponseFx.set(rpcFeaturesOutput);
    Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(Matchers.any(ConnectionContext.class));
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Test(org.junit.Test)

Aggregations

GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)12 Test (org.junit.Test)10 ByteBuf (io.netty.buffer.ByteBuf)7 GetFeaturesOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder)6 PhyPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)5 ArrayList (java.util.ArrayList)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 ActionTypeV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10)3 Capabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities)3 CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)3 GetFeaturesInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 BigInteger (java.math.BigInteger)2 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)2 FeatureCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability)2 SwitchFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeaturesBuilder)2 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)2 PortStateV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10)2 GetFeaturesInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder)2 HelloInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput)2