Search in sources :

Example 1 with MultipartReplyPortDesc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc in project openflowplugin by opendaylight.

the class PortDescMultipartWriter method storeStatistics.

@Override
public void storeStatistics(final MultipartReplyPortDesc statistics, final boolean withParents) {
    statistics.getPorts().forEach(stat -> {
        final NodeConnectorId id = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(features.getDatapathId(), OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(features.getVersion()), stat.getPortNumber()), OpenflowVersion.get(features.getVersion()));
        writeToTransaction(getInstanceIdentifier().child(NodeConnector.class, new NodeConnectorKey(id)), new NodeConnectorBuilder().setId(id).addAugmentation(FlowCapableNodeConnector.class, new FlowCapableNodeConnectorBuilder(stat).build()).addAugmentation(FlowCapableNodeConnectorStatisticsData.class, new FlowCapableNodeConnectorStatisticsDataBuilder().build()).build(), withParents);
    });
}
Also used : FlowCapableNodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowCapableNodeConnectorStatisticsDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) NodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder) FlowCapableNodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)

Example 2 with MultipartReplyPortDesc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializePortDescBody.

private void serializePortDescBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
    MultipartReplyPortDescCase portCase = (MultipartReplyPortDescCase) body;
    MultipartReplyPortDesc portDesc = portCase.getMultipartReplyPortDesc();
    for (Ports port : portDesc.getPorts()) {
        // Assuming PortNo
        outBuffer.writeInt(port.getPortNo().intValue());
        // = PortId
        outBuffer.writeZero(PORT_DESC_PADDING_1);
        outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(port.getHwAddr()));
        outBuffer.writeZero(PORT_DESC_PADDING_2);
        writeName(port.getName(), outBuffer);
        writePortConfig(port.getConfig(), outBuffer);
        writePortState(port.getState(), outBuffer);
        writePortFeatures(port.getCurrentFeatures(), outBuffer);
        writePortFeatures(port.getAdvertisedFeatures(), outBuffer);
        writePortFeatures(port.getSupportedFeatures(), outBuffer);
        writePortFeatures(port.getPeerFeatures(), outBuffer);
        outBuffer.writeInt(port.getCurrSpeed().intValue());
        outBuffer.writeInt(port.getMaxSpeed().intValue());
    }
}
Also used : MultipartReplyPortDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MultipartReplyPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc)

Example 3 with MultipartReplyPortDesc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testPortDescSerialize.

@Test
public void testPortDescSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(13));
    MultipartReplyPortDescCaseBuilder portDescCase = new MultipartReplyPortDescCaseBuilder();
    MultipartReplyPortDescBuilder portDesc = new MultipartReplyPortDescBuilder();
    portDesc.setPorts(createPortList());
    portDescCase.setMultipartReplyPortDesc(portDesc.build());
    builder.setMultipartReplyBody(portDescCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTDESC.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyPortDescCase body = (MultipartReplyPortDescCase) message.getMultipartReplyBody();
    MultipartReplyPortDesc messageOutput = body.getMultipartReplyPortDesc();
    Ports port = messageOutput.getPorts().get(0);
    Assert.assertEquals("Wrong PortNo", port.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
    serializedBuffer.skipBytes(4);
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    serializedBuffer.skipBytes(2);
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", port.getConfig(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", port.getState(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", port.getCurrentFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", port.getAdvertisedFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", port.getSupportedFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", port.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong Current speed", port.getCurrSpeed().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong Max speed", port.getMaxSpeed().longValue(), serializedBuffer.readInt());
}
Also used : MultipartReplyPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder) MultipartReplyPortDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase) MultipartReplyPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MultipartReplyPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 4 with MultipartReplyPortDesc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc in project openflowplugin by opendaylight.

the class MultipartReplyPortDescTest method testMultipartReplyPortDesc.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyPortDesc() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0D 00 00 00 00 00 00 " + // first port desc
    "00 01 02 03 00 00 00 00 " + // portNo, padding
    "08 00 27 00 B0 EB 00 00 " + // mac address, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
    "00 00 00 65 " + // port config
    "00 00 00 07 " + // port state
    "00 00 00 81 " + // current features
    "00 00 FF FF " + // advertised features
    "00 00 C1 89 " + // supported features
    "00 00 C5 8D " + // peer features
    "00 00 00 81 " + // curr speed
    "00 00 00 80 " + // second port desc
    "00 00 00 01 00 00 00 00 " + // portNo, padding
    "08 00 27 00 B0 EB 00 00 " + // mac address, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
    "00 00 00 00 " + // port config
    "00 00 00 00 " + // port state
    "00 00 00 00 " + // current features
    "00 00 00 00 " + // advertised features
    "00 00 00 00 " + // supported features
    "00 00 00 00 " + // peer features
    "00 00 00 05 " + // curr speed
    "00 00 00 06");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
    Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size());
    Ports port = message.getPorts().get(0);
    Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue());
    Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
    Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
    Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig());
    Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState());
    Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures());
    Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures());
    Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures());
    Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, false, false, true, false, false, false, true, true, true), port.getPeerFeatures());
    Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue());
    Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue());
    port = message.getPorts().get(1);
    Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue());
    Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
    Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
    Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig());
    Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());
    Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());
    Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());
    Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());
    Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getPeerFeatures());
    Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue());
    Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue());
}
Also used : MultipartReplyPortDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) 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) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MultipartReplyPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig) Test(org.junit.Test)

Example 5 with MultipartReplyPortDesc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc in project openflowplugin by opendaylight.

the class MultipartReplyPortDescTest method testEmptyMultipartReplyPortDesc.

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

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)4 MultipartReplyPortDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc)4 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)2 HashMap (java.util.HashMap)1 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)1 FlowCapableNodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder)1 MultipartReplyPortDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDesc)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)1 NodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder)1 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)1 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)1 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)1 PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1