use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project genius by opendaylight.
the class ArpUtilImpl method sendArpRequest.
@Override
public Future<RpcResult<Void>> sendArpRequest(SendArpRequestInput arpReqInput) {
LOG.trace("rpc sendArpRequest invoked for ip {}", arpReqInput.getIpaddress());
BigInteger dpnId;
byte[] payload;
String interfaceName = null;
byte[] srcIpBytes;
byte[] dstIpBytes;
byte[] srcMac;
RpcResultBuilder<Void> failureBuilder = RpcResultBuilder.failed();
RpcResultBuilder<Void> successBuilder = RpcResultBuilder.success();
try {
dstIpBytes = getIpAddressBytes(arpReqInput.getIpaddress());
} catch (UnknownHostException e) {
LOG.error("Cannot get IP address", e);
failureBuilder.withError(ErrorType.APPLICATION, ArpConstants.UNKNOWN_IP_ADDRESS_SUPPLIED);
return Futures.immediateFuture(failureBuilder.build());
}
int localErrorCount = 0;
for (InterfaceAddress interfaceAddress : arpReqInput.getInterfaceAddress()) {
try {
interfaceName = interfaceAddress.getInterface();
srcIpBytes = getIpAddressBytes(interfaceAddress.getIpAddress());
GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
checkNotNull(portResult);
dpnId = portResult.getDpid();
Long portid = portResult.getPortno();
checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId), ArpConstants.DPN_NOT_FOUND_ERROR, interfaceName);
NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
checkNotNull(ref, ArpConstants.NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
LOG.trace("sendArpRequest received dpnId {} out interface {}", dpnId, interfaceName);
if (interfaceAddress.getMacaddress() == null) {
srcMac = MDSALUtil.getMacAddressForNodeConnector(dataBroker, (InstanceIdentifier<NodeConnector>) ref.getValue());
} else {
String macAddr = interfaceAddress.getMacaddress().getValue();
srcMac = HexEncode.bytesFromHexString(macAddr);
}
checkNotNull(srcMac, ArpConstants.FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, ref.getValue());
checkNotNull(srcIpBytes, ArpConstants.FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
payload = ArpPacketUtil.getPayload(ArpConstants.ARP_REQUEST_OP, srcMac, srcIpBytes, ArpPacketUtil.ETHERNET_BROADCAST_DESTINATION, dstIpBytes);
List<Action> actions = getEgressAction(interfaceName);
sendPacketOutWithActions(dpnId, payload, ref, actions);
LOG.trace("sent arp request for {}", arpReqInput.getIpaddress());
} catch (UnknownHostException | PacketException | InterruptedException | ExecutionException | ReadFailedException e) {
LOG.trace("failed to send arp req for {} on interface {}", arpReqInput.getIpaddress(), interfaceName);
failureBuilder.withError(ErrorType.APPLICATION, ArpConstants.FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName, e);
successBuilder.withError(ErrorType.APPLICATION, ArpConstants.FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName, e);
localErrorCount++;
}
}
if (localErrorCount == arpReqInput.getInterfaceAddress().size()) {
// All the requests failed
return Futures.immediateFuture(failureBuilder.build());
}
return Futures.immediateFuture(successBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project genius by opendaylight.
the class InterfaceInventoryStateListener method remove.
@Override
protected void remove(InstanceIdentifier<FlowCapableNodeConnector> key, FlowCapableNodeConnector flowCapableNodeConnectorOld) {
if (interfacemgrProvider.isItmDirectTunnelsEnabled() && interfaceManagerCommonUtils.isTunnelInternal(flowCapableNodeConnectorOld.getName())) {
LOG.debug("ITM Direct Tunnels is enabled, ignoring node connector removed for internal tunnel {}", flowCapableNodeConnectorOld.getName());
return;
}
if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY, IfmConstants.INTERFACE_CONFIG_ENTITY)) {
return;
}
LOG.debug("Received NodeConnector Remove Event: {}, {}", key, flowCapableNodeConnectorOld);
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
String portName = InterfaceManagerCommonUtils.getPortNameForInterface(nodeConnectorId, flowCapableNodeConnectorOld.getName());
remove(nodeConnectorId, null, flowCapableNodeConnectorOld, portName, true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector in project genius by opendaylight.
the class MDSALUtil method getNodeConnRef.
public static NodeConnectorRef getNodeConnRef(String nodeId, String port) {
StringBuilder sb = new StringBuilder();
sb.append(nodeId);
sb.append(SEPARATOR);
sb.append(port);
String nodeConnectorKeyAsString = sb.toString();
NodeConnectorId nodeConnectorId = new NodeConnectorId(nodeConnectorKeyAsString);
NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
InstanceIdentifierBuilder<Node> nodeInstanceIdentifierBuilder = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
InstanceIdentifierBuilder<NodeConnector> nodeConnectorInstanceIdentifierBuilder = nodeInstanceIdentifierBuilder.child(NodeConnector.class, nodeConnectorKey);
InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier = nodeConnectorInstanceIdentifierBuilder.toInstance();
NodeConnectorRef nodeConnectorRef = new NodeConnectorRef(nodeConnectorInstanceIdentifier);
return nodeConnectorRef;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector 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.inventory.rev130819.node.NodeConnector 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.");
}
}
Aggregations