Search in sources :

Example 21 with NodeConnector

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.

the class LLDPSpeaker method nodeConnectorRemoved.

@Override
public void nodeConnectorRemoved(final InstanceIdentifier<NodeConnector> nodeConnectorInstanceId) {
    Preconditions.checkNotNull(nodeConnectorInstanceId);
    nodeConnectorMap.remove(nodeConnectorInstanceId);
    NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInstanceId).getId();
    LOG.trace("Port removed from node-connector map : {}", nodeConnectorId.getValue());
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)

Example 22 with NodeConnector

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.

the class LLDPSpeaker method nodeConnectorAdded.

@Override
public void nodeConnectorAdded(final InstanceIdentifier<NodeConnector> nodeConnectorInstanceId, final FlowCapableNodeConnector flowConnector) {
    NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInstanceId).getId();
    // port, so first we check if we actually need to perform any action
    if (nodeConnectorMap.containsKey(nodeConnectorInstanceId)) {
        LOG.debug("Port {} already in LLDPSpeaker.nodeConnectorMap, no need for additional processing", nodeConnectorId.getValue());
        return;
    }
    // Prepare to build LLDP payload
    InstanceIdentifier<Node> nodeInstanceId = nodeConnectorInstanceId.firstIdentifierOf(Node.class);
    NodeId nodeId = InstanceIdentifier.keyOf(nodeInstanceId).getId();
    MacAddress srcMacAddress = flowConnector.getHardwareAddress();
    Long outputPortNo = flowConnector.getPortNumber().getUint32();
    // No need to send LLDP frames on local ports
    if (outputPortNo == null) {
        LOG.debug("Port {} is local, not sending LLDP frames through it", nodeConnectorId.getValue());
        return;
    }
    // Generate packet with destination switch and port
    TransmitPacketInput packet;
    try {
        packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(nodeConnectorInstanceId)).setNode(new NodeRef(nodeInstanceId)).setPayload(LLDPUtil.buildLldpFrame(nodeId, nodeConnectorId, srcMacAddress, outputPortNo, addressDestionation)).build();
    } catch (NoSuchAlgorithmException | PacketException e) {
        LOG.error("Error building LLDP frame", e);
        return;
    }
    // Save packet to node connector id -> packet map to transmit it periodically on the configured interval.
    nodeConnectorMap.put(nodeConnectorInstanceId, packet);
    LOG.debug("Port {} added to LLDPSpeaker.nodeConnectorMap", nodeConnectorId.getValue());
    // Transmit packet for first time immediately
    final Future<RpcResult<Void>> resultFuture = packetProcessingService.transmitPacket(packet);
    JdkFutures.addErrorLogging(resultFuture, LOG, "transmitPacket");
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)

Example 23 with NodeConnector

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslator method processAddedConnector.

private void processAddedConnector(final DataTreeModification<T> modification) {
    final InstanceIdentifier<T> identifier = modification.getRootPath().getRootIdentifier();
    InstanceIdentifier<NodeConnector> nodeConnectorInstanceId = identifier.firstIdentifierOf(NodeConnector.class);
    if (compareIITail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
        FlowCapableNodeConnector flowConnector = (FlowCapableNodeConnector) modification.getRootNode().getDataAfter();
        if (!isPortDown(flowConnector)) {
            notifyNodeConnectorAppeared(nodeConnectorInstanceId, flowConnector);
        } else {
            iiToDownFlowCapableNodeConnectors.put(nodeConnectorInstanceId, flowConnector);
        }
    }
}
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) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)

Example 24 with NodeConnector

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.

the class FlowTableStatNotificationSupplierImpl method createNotification.

@Override
public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics, final InstanceIdentifier<FlowTableStatistics> path) {
    Preconditions.checkArgument(flowTableStatistics != null);
    Preconditions.checkArgument(path != null);
    final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
    ftsmBuilder.setKey(new FlowTableAndStatisticsMapKey(new TableId(path.firstKeyOf(Table.class, TableKey.class).getId())));
    final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
    return builder.build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) FlowTableAndStatisticsMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey) FlowTableStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder)

Example 25 with NodeConnector

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project openflowplugin by opendaylight.

the class DeviceContextImpl method writePortStatusMessage.

private void writePortStatusMessage(final PortStatus portStatusMessage) {
    final FlowCapableNodeConnector flowCapableNodeConnector = portStatusTranslator.translate(portStatusMessage, getDeviceInfo(), null);
    final KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> iiToNodeConnector = getDeviceInfo().getNodeInstanceIdentifier().child(NodeConnector.class, new NodeConnectorKey(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), portStatusMessage.getPortNo(), OpenflowVersion.get(deviceInfo.getVersion()))));
    writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector, new NodeConnectorBuilder().setKey(iiToNodeConnector.getKey()).addAugmentation(FlowCapableNodeConnectorStatisticsData.class, new FlowCapableNodeConnectorStatisticsDataBuilder().build()).addAugmentation(FlowCapableNodeConnector.class, flowCapableNodeConnector).build());
    submitTransaction();
    if (PortReason.OFPPRDELETE.equals(portStatusMessage.getReason())) {
        addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector);
        submitTransaction();
    }
}
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) FlowCapableNodeConnectorStatisticsDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder) NodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) FlowCapableNodeConnectorStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)

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