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