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();
}
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);
}
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);
}
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());
}
}
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();
}
Aggregations