Search in sources :

Example 26 with NodeConnector

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);
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) MultipartRequestPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) 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) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 27 with NodeConnector

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;
}
Also used : NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) Nullable(javax.annotation.Nullable)

Example 28 with NodeConnector

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.");
    }
}
Also used : FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) FlowCapableNodeConnectorStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)

Example 29 with NodeConnector

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());
}
Also used : FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) Test(org.junit.Test)

Example 30 with NodeConnector

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;
}
Also used : NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)20 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)16 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)13 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)12 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)9 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)7 BigInteger (java.math.BigInteger)4 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)4 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)3 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)3 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)3 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Test (org.junit.Test)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 Tunnel (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel)2