use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector in project genius by opendaylight.
the class FlowNodeConnectorInventoryTranslatorImpl method remove.
@Override
public void remove(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector del, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
Counter counter;
if (compareInstanceIdentifierTail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
String nodeConnectorIdentifier = getNodeConnectorId(String.valueOf(nodeConnIdent.firstKeyOf(NodeConnector.class).getId()));
long dataPathId = getDpIdFromPortName(nodeConnectorIdentifier);
if (dpnToPortMultiMap.containsKey(dataPathId)) {
LOG.debug("Node Connector {} removed", nodeConnectorIdentifier);
dpnToPortMultiMap.remove(dataPathId, nodeConnectorIdentifier);
counter = packetInCounter.label("OFSwitch").label(String.valueOf(dataPathId)).label("portsperswitch");
counter.decrement();
PortNameMapping.updatePortMap("openflow:" + dataPathId + ":" + del.getName(), nodeConnectorIdentifier, "DELETE");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector in project genius by opendaylight.
the class FlowNodeConnectorInventoryTranslatorImpl method add.
@Override
public void add(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector add, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
Counter counter;
if (compareInstanceIdentifierTail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
String nodeConnectorIdentifier = getNodeConnectorId(String.valueOf(nodeConnIdent.firstKeyOf(NodeConnector.class).getId()));
long dataPathId = getDpIdFromPortName(nodeConnectorIdentifier);
if (entityOwnershipUtils.isEntityOwner(FcapsConstants.SERVICE_ENTITY_TYPE, getNodeId(dataPathId))) {
if (!dpnToPortMultiMap.containsEntry(dataPathId, nodeConnectorIdentifier)) {
LOG.debug("Node Connector {} added", nodeConnectorIdentifier);
dpnToPortMultiMap.put(dataPathId, nodeConnectorIdentifier);
counter = packetInCounter.label("OFSwitch").label(String.valueOf(dataPathId)).label("portsperswitch");
counter.increment();
PortNameMapping.updatePortMap("openflow:" + dataPathId + ":" + add.getName(), nodeConnectorIdentifier, "ADD");
} else {
LOG.error("Duplicate Event.Node Connector already added");
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector in project openflowplugin by opendaylight.
the class ShellUtil method getNodeInfo.
public static OFNode getNodeInfo(final Long nodeId, final DataBroker broker) {
OFNode ofNode = null;
ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(NODE_PREFIX + nodeId))).build();
Optional<Node> result;
try {
CheckedFuture<Optional<Node>, ReadFailedException> checkedFuture = tx.read(LogicalDatastoreType.OPERATIONAL, path);
result = checkedFuture.get();
if (result.isPresent()) {
Node node = result.get();
String name = null;
List<NodeConnector> nodeConnectors = null;
List<String> portList = new ArrayList<>();
FlowCapableNode flowCapableNode = node.<FlowCapableNode>getAugmentation(FlowCapableNode.class);
if (flowCapableNode != null) {
name = node.<FlowCapableNode>getAugmentation(FlowCapableNode.class).getDescription();
} else {
LOG.error("Error while converting OFNode:{} to FlowCapableNode: {}", node.getId());
return null;
}
nodeConnectors = node.getNodeConnector();
for (NodeConnector nodeConnector : nodeConnectors) {
FlowCapableNodeConnector flowCapableNodeConnector = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
if (flowCapableNodeConnector == null) {
LOG.error("Error for OFNode:{} while reading nodeConnectors {}", node.getId());
return null;
} else {
String portName = flowCapableNodeConnector.getName();
portList.add(portName);
}
}
ofNode = new OFNode(nodeId, name, portList);
} else {
LOG.error("OFNode with nodeId {} not present Inventory DS: {}", nodeId);
return null;
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("Error reading node {} from Inventory DS: {}", nodeId, e);
}
return ofNode;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImpl method processRemovedTerminationPoints.
private void processRemovedTerminationPoints(final DataTreeModification<FlowCapableNodeConnector> modification) {
final InstanceIdentifier<FlowCapableNodeConnector> removedNode = modification.getRootPath().getRootIdentifier();
final TpId terminationPointId = provideTopologyTerminationPointId(removedNode);
final InstanceIdentifier<TerminationPoint> iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint(terminationPointId, removedNode);
if (iiToTopologyTerminationPoint != null) {
final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> node = iiToTopologyTerminationPoint.firstIdentifierOf(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class);
operationProcessor.enqueueOperation(manager -> {
Optional<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> nodeOptional = Optional.empty();
try {
nodeOptional = Optional.ofNullable(manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, node).checkedGet().orNull());
} catch (ReadFailedException e) {
LOG.warn("Error occurred when trying to read NodeConnector: {}", e.getMessage());
LOG.debug("Error occurred when trying to read NodeConnector.. ", e);
}
if (nodeOptional.isPresent()) {
TopologyManagerUtil.removeAffectedLinks(terminationPointId, manager, II_TO_TOPOLOGY);
manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, iiToTopologyTerminationPoint);
}
});
} else {
LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting termination point.");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector 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");
}
Aggregations