Search in sources :

Example 11 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class OpenflowUtilsTest method testPortFeatures.

/**
 * Tests {@link OpenflowUtils#createPortFeatures(long)}.
 */
@Test
public void testPortFeatures() {
    PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L);
    Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true, true, true, true, true, true), features);
    features = OpenflowUtils.createPortFeatures(0L);
    Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false, false, false, false, false, false, false), features);
}
Also used : PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) Test(org.junit.Test)

Example 12 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features 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 13 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class PortStatusMessageFactoryTest method testWithDifferentBitmaps.

/**
 * Testing {@link PortStatusMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithDifferentBitmaps() {
    ByteBuf bb = BufferHelper.buildBuffer(// reason, padding
    "01 00 00 00 00 00 00 00 " + // port no, padding
    "00 01 02 03 00 00 00 00 " + // mac address, padding
    "08 00 27 00 B0 EB 00 00 " + // port name, String "s1-eth1"
    "73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port config
    "00 00 00 24 " + // port state
    "00 00 00 02 " + // current + advertised features
    "00 00 00 81 00 00 00 A1 " + // supported + peer features
    "00 00 FF FF 00 00 00 00 " + // curr speed, max speed
    "00 00 00 81 00 00 00 80");
    PortStatusMessage message = BufferHelper.deserialize(statusFactory, bb);
    Assert.assertEquals("Wrong portConfig", new PortConfig(true, false, true, false), message.getConfig());
    Assert.assertEquals("Wrong portState", new PortState(true, false, false), message.getState());
    Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true), message.getSupportedFeatures());
    Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), message.getPeerFeatures());
}
Also used : PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) ByteBuf(io.netty.buffer.ByteBuf) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig) Test(org.junit.Test)

Example 14 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyTableFeatures() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0C 00 00 00 00 00 00 " + // first table feature
    "00 40 01 00 00 00 00 00 " + // length, tableId, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // 
    "00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
    "00 00 00 00 00 00 00 01 " + // metadata match
    "00 00 00 00 00 00 00 02 " + // metadata write
    "00 00 00 00 " + // config
    "00 00 00 2A " + // second table feature
    "00 40 02 00 00 00 00 00 " + // length, tableId, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + // name
    " 00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
    "00 00 00 00 00 00 00 03 " + // metadata write
    "00 00 00 00 00 00 00 04 " + // config
    "00 00 00 03 " + // max entries
    "00 00 00 2B");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
    Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size());
    TableFeatures feature = message.getTableFeatures().get(0);
    Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
    feature = message.getTableFeatures().get(1);
    Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 4 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue());
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) Test(org.junit.Test)

Example 15 with Features

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesTest method testEmptyMultipartReplyTableFeatures.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testEmptyMultipartReplyTableFeatures() {
    ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
    Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size());
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 ArrayList (java.util.ArrayList)9 ByteBuf (io.netty.buffer.ByteBuf)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)5 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)4 BigInteger (java.math.BigInteger)3 PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState)3 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)3 Before (org.junit.Before)2 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)2 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)2 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)2 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)2 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)2 MultipartReplyTableFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase)2