use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class OpenflowpluginStatsTestCommandProvider method _portStats.
public void _portStats(CommandInterpreter ci) {
int nodeConnectorCount = 0;
int nodeConnectorStatsCount = 0;
List<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.getKey();
InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getNodeConnector() != null) {
List<NodeConnector> ports = node.getNodeConnector();
for (NodeConnector nodeConnector2 : ports) {
nodeConnectorCount++;
NodeConnectorKey nodeConnectorKey = nodeConnector2.getKey();
InstanceIdentifier<NodeConnector> connectorRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey);
NodeConnector nodeConnector = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, connectorRef);
if (nodeConnector != null) {
FlowCapableNodeConnectorStatisticsData data = nodeConnector.getAugmentation(FlowCapableNodeConnectorStatisticsData.class);
if (null != data) {
nodeConnectorStatsCount++;
}
}
}
}
}
}
if (nodeConnectorCount == nodeConnectorStatsCount) {
LOG.debug("portStats - Success");
} else {
LOG.debug("portStats - Failed");
LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method testWithNoPortsSet.
/**
* Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithNoPortsSet() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 00 00 00 00 00");
GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(false, false, false, false, false, false, false, false), builtByFactory.getCapabilitiesV10());
Assert.assertEquals("Wrong actions", new ActionTypeV10(false, false, false, false, false, false, false, false, false, false, false, false, false), builtByFactory.getActionsV10());
Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method testWithTwoPortsSet.
/**
* Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithTwoPortsSet() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 8B 00 00 03 B5 " + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 01 " + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 " + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 " + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong ports size", 2, builtByFactory.getPhyPort().size());
PhyPort port = builtByFactory.getPhyPort().get(0);
Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue());
Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr());
Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName());
Assert.assertEquals("Wrong port - config", new PortConfigV10(false, false, false, false, false, false, false), port.getConfigV10());
Assert.assertEquals("Wrong port - state", new PortStateV10(false, true, false, true, true, true, false, true), port.getStateV10());
port = builtByFactory.getPhyPort().get(1);
Assert.assertEquals("Wrong port - state", new PortStateV10(false, false, false, false, false, false, true, false), port.getStateV10());
}
Aggregations