Search in sources :

Example 11 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translatePortStats.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStats translatePortStats(final MultipartReply msg, final OpenflowVersion ofVersion, final BigInteger datapathId) {
    MultipartReplyPortStatsBuilder message = new MultipartReplyPortStatsBuilder();
    MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) msg.getMultipartReplyBody();
    MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
    List<NodeConnectorStatisticsAndPortNumberMap> statsMap = new ArrayList<>();
    for (PortStats portStats : replyBody.getPortStats()) {
        NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
        statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portStats.getPortNo(), ofVersion));
        BytesBuilder bytesBuilder = new BytesBuilder();
        bytesBuilder.setReceived(portStats.getRxBytes());
        bytesBuilder.setTransmitted(portStats.getTxBytes());
        statsBuilder.setBytes(bytesBuilder.build());
        PacketsBuilder packetsBuilder = new PacketsBuilder();
        packetsBuilder.setReceived(portStats.getRxPackets());
        packetsBuilder.setTransmitted(portStats.getTxPackets());
        statsBuilder.setPackets(packetsBuilder.build());
        DurationBuilder durationBuilder = new DurationBuilder();
        if (portStats.getDurationSec() != null) {
            durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
        }
        if (portStats.getDurationNsec() != null) {
            durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
        }
        statsBuilder.setDuration(durationBuilder.build());
        statsBuilder.setCollisionCount(portStats.getCollisions());
        statsBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(statsBuilder.getNodeConnectorId()));
        statsBuilder.setReceiveCrcError(portStats.getRxCrcErr());
        statsBuilder.setReceiveDrops(portStats.getRxDropped());
        statsBuilder.setReceiveErrors(portStats.getRxErrors());
        statsBuilder.setReceiveFrameError(portStats.getRxFrameErr());
        statsBuilder.setReceiveOverRunError(portStats.getRxOverErr());
        statsBuilder.setTransmitDrops(portStats.getTxDropped());
        statsBuilder.setTransmitErrors(portStats.getTxErrors());
        statsMap.add(statsBuilder.build());
    }
    message.setNodeConnectorStatisticsAndPortNumberMap(statsMap);
    return message.build();
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) ArrayList(java.util.ArrayList) PacketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) NodeConnectorStatisticsAndPortNumberMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey) MultipartReplyPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder) NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) PortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) BytesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 12 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class InventoryDataServiceUtilTest method testNodeConnectorBuilderFromDatapathIdPortNo.

/**
 * Test method for {@link InventoryDataServiceUtil#nodeConnectorBuilderFromDatapathIdPortNo(BigInteger datapathId,
 * Long portNo, org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion ofVersion)}.
 */
@Test
public void testNodeConnectorBuilderFromDatapathIdPortNo() {
    NodeConnectorBuilder nodeConnectorBuilder = InventoryDataServiceUtil.nodeConnectorBuilderFromDatapathIdPortNo(PATH_ID, PORT_NO, OpenflowVersion.OF10);
    assertNotNull(nodeConnectorBuilder);
    nodeConnectorBuilder = InventoryDataServiceUtil.nodeConnectorBuilderFromDatapathIdPortNo(PATH_ID, PORT_NO, OpenflowVersion.OF13);
    assertNotNull(nodeConnectorBuilder);
    nodeConnectorBuilder = InventoryDataServiceUtil.nodeConnectorBuilderFromDatapathIdPortNo(PATH_ID, PORT_NO, OpenflowVersion.UNSUPPORTED);
    assertNotNull(nodeConnectorBuilder);
}
Also used : NodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder) Test(org.junit.Test)

Example 13 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class InventoryDataServiceUtilTest method testNodeConnectorRefFromDatapathIdPortno.

/**
 * Test method for {@link InventoryDataServiceUtil#nodeConnectorRefFromDatapathIdPortno(
 * BigInteger datapathId, Long portNo, OpenflowVersion ofVersion)}.
 */
@Test
public void testNodeConnectorRefFromDatapathIdPortno() {
    NodeConnectorRef nodeConnectorRef = InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(PATH_ID, PORT_NO, OpenflowVersion.OF10);
    assertNotNull(nodeConnectorRef);
    nodeConnectorRef = InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(PATH_ID, PORT_NO, OpenflowVersion.OF13);
    assertNotNull(nodeConnectorRef);
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) Test(org.junit.Test)

Example 14 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class InventoryDataServiceUtilTest method testDataPathIdFromNodeId.

/**
 * Test method for {@link InventoryDataServiceUtil#dataPathIdFromNodeId(NodeId)}.
 */
@Test
public void testDataPathIdFromNodeId() {
    String string = "openflow:";
    NodeId[] nodeIds = new NodeId[] { // 0x00000000 000004d2
    new NodeId(string + "1234"), // 0x8db2089e 01391a86
    new NodeId(string + "10210232779920710278"), // 0xffffffff ffffffff
    new NodeId(string + "18446744073709551615") };
    long[] expectedDPIDs = new long[] { 1234L, -8236511293788841338L, -1L };
    for (int i = 0; i < nodeIds.length; i++) {
        BigInteger datapathId = InventoryDataServiceUtil.dataPathIdFromNodeId(nodeIds[i]);
        Assert.assertEquals(expectedDPIDs[i], datapathId.longValue());
    }
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 15 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId 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)

Aggregations

BigInteger (java.math.BigInteger)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)7 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)6 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)6 ActionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)5 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)5 OvsdbBridgeAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation)5 List (java.util.List)4 DatapathId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4 ByteBuf (io.netty.buffer.ByteBuf)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)3 NodeConnectorUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder)3 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)3 OvsdbBridgeAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder)3 OvsdbBridgeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName)3 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)3