Search in sources :

Example 1 with GetFeaturesInput

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

the class MockPlugin method getSwitchFeatures.

protected void getSwitchFeatures() {
    GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
    featuresBuilder.setVersion((short) 4);
    featuresBuilder.setXid(3L);
    GetFeaturesInput featuresInput = featuresBuilder.build();
    try {
        LOGGER.debug("Requesting features ");
        RpcResult<GetFeaturesOutput> rpcResult = adapter.getFeatures(featuresInput).get(2500, TimeUnit.MILLISECONDS);
        if (rpcResult.isSuccessful()) {
            byte[] byteArray = rpcResult.getResult().getDatapathId().toByteArray();
            LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray));
        } else {
            RpcError rpcError = rpcResult.getErrors().iterator().next();
            LOGGER.warn("rpcResult failed", rpcError.getCause());
        }
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e);
    }
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) RpcError(org.opendaylight.yangtools.yang.common.RpcError) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with GetFeaturesInput

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

the class GetFeaturesInputMessageFactoryTest method testV13.

/**
 * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testV13() throws Exception {
    GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
    BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);
    GetFeaturesInput gfi = gfib.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    featuresFactory.serialize(gfi, out);
    BufferHelper.checkHeaderV13(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with GetFeaturesInput

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

the class OF10FeaturesRequestMessageFactory method deserialize.

@Override
public GetFeaturesInput deserialize(ByteBuf rawMessage) {
    GetFeaturesInputBuilder builder = new GetFeaturesInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    return builder.build();
}
Also used : GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder)

Example 4 with GetFeaturesInput

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

the class OF10FeaturesRequestMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer();
    GetFeaturesInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV10(deserializedMessage);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with GetFeaturesInput

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

the class GetFeaturesInputMessageFactoryTest method testV10.

/**
 * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testV10() throws Exception {
    GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
    BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);
    GetFeaturesInput gfi = gfib.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    featuresFactory.serialize(gfi, out);
    BufferHelper.checkHeaderV10(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
}
Also used : GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

GetFeaturesInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput)5 GetFeaturesInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1