use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.
the class NodeConnectorDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyPortStatsCase nodeConnectorCase = mock(MultipartReplyPortStatsCase.class);
final MultipartReplyPortStats nodeConnector = mock(MultipartReplyPortStats.class);
final PortStats nodeConnectorStat = mock(PortStats.class);
final List<PortStats> nodeConnectorStats = Collections.singletonList(nodeConnectorStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(nodeConnector.getPortStats()).thenReturn(nodeConnectorStats);
when(nodeConnectorCase.getMultipartReplyPortStats()).thenReturn(nodeConnector);
when(reply.getMultipartReplyBody()).thenReturn(nodeConnectorCase);
when(nodeConnectorStat.getPortNo()).thenReturn(PORT_NO);
when(nodeConnectorStat.getTxBytes()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getCollisions()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxBytes()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxCrcErr()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxDropped()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxErrors()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxFrameErr()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxOverErr()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxPackets()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getTxDropped()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getTxErrors()).thenReturn(BigInteger.ONE);
final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
final NodeConnectorStatisticsAndPortNumberMap stats = output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.
the class NodeConnectorRefToPortTranslator method fromNodeConnectorRef.
/**
* Gets port number from {@link NodeConnectorRef}.
* @param nodeConnectorRef Node connector reference
* @param version Openflow version
* @return port number
*/
@SuppressWarnings("unchecked")
@Nullable
public static Long fromNodeConnectorRef(@Nonnull NodeConnectorRef nodeConnectorRef, short version) {
Preconditions.checkNotNull(nodeConnectorRef);
Long port = null;
final InstanceIdentifier<?> value = nodeConnectorRef.getValue();
if (value instanceof KeyedInstanceIdentifier) {
KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> identifier = (KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey>) value;
OpenflowVersion ofVersion = OpenflowVersion.get(version);
String nodeConnectorId = identifier.getKey().getId().getValue();
port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, nodeConnectorId);
}
return port;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector 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.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.
the class PortUpdateTranslatorTest method testTranslate_10.
@Test
public void testTranslate_10() throws Exception {
Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures portFeatures = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures(null, null, null, false, false, true, null, null, null, false, false, null, null, null, null, null);
final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceInfo, null);
commonCheck(nodeConnector);
Assert.assertEquals(portConfig, nodeConnector.getConfiguration());
Assert.assertEquals(portFeatures, nodeConnector.getCurrentFeature());
Assert.assertEquals(portFeatures, nodeConnector.getAdvertisedFeatures());
Assert.assertEquals(portFeatures, nodeConnector.getPeerFeatures());
Assert.assertEquals(portFeatures, nodeConnector.getSupported());
Assert.assertEquals(portStateBld.build(), nodeConnector.getState());
Assert.assertNull(nodeConnector.getQueue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project genius by opendaylight.
the class MDSALUtil method getMacAddressForNodeConnector.
// "Consider returning a zero length array rather than null" - too late to change behavior plus it's deprecated.
@Deprecated
@SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS")
public static byte[] getMacAddressForNodeConnector(DataBroker broker, InstanceIdentifier<NodeConnector> nodeConnectorId) throws ReadFailedException {
Optional<NodeConnector> optNc = SingleTransactionDataBroker.syncReadOptional(broker, LogicalDatastoreType.OPERATIONAL, nodeConnectorId);
if (optNc.isPresent()) {
NodeConnector nc = optNc.get();
FlowCapableNodeConnector fcnc = nc.getAugmentation(FlowCapableNodeConnector.class);
MacAddress macAddress = fcnc.getHardwareAddress();
return HexEncode.bytesFromHexString(macAddress.getValue());
}
return null;
}
Aggregations