use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received 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.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project genius by opendaylight.
the class InterfaceConfigListener method update.
@Override
protected void update(InstanceIdentifier<Interface> key, Interface interfaceOld, Interface interfaceNew) {
interfaceManagerCommonUtils.addInterfaceToCache(interfaceNew);
if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY, IfmConstants.INTERFACE_CONFIG_ENTITY)) {
return;
}
LOG.debug("Received Interface Update Event: {}, {}, {}", key, interfaceOld, interfaceNew);
ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
if (parentRefs == null || parentRefs.getParentInterface() == null && !InterfaceManagerCommonUtils.isTunnelInterface(interfaceNew)) {
// If parentRefs are missing, try to find a matching parent and
// update - this will trigger another DCN
updateInterfaceParentRefs(interfaceNew);
}
if (parentRefs == null || parentRefs.getDatapathNodeIdentifier() == null && parentRefs.getParentInterface() == null) {
LOG.debug("parent refs not specified for {}, or parentRefs {} missing DPN/parentInterface", interfaceNew.getName(), parentRefs);
return;
}
RendererConfigUpdateWorker configWorker = new RendererConfigUpdateWorker(key, interfaceOld, interfaceNew, interfaceNew.getName());
String synchronizationKey = getSynchronizationKey(interfaceNew, parentRefs);
coordinator.enqueueJob(synchronizationKey, configWorker, IfmConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project genius by opendaylight.
the class InterfaceConfigListener method add.
@Override
protected void add(InstanceIdentifier<Interface> key, Interface interfaceNew) {
interfaceManagerCommonUtils.addInterfaceToCache(interfaceNew);
if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY, IfmConstants.INTERFACE_CONFIG_ENTITY)) {
return;
}
LOG.debug("Received Interface Add Event: {}, {}", key, interfaceNew);
ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
if (parentRefs == null || parentRefs.getParentInterface() == null) {
// If parentRefs are missing, try to find a matching parent and
// update - this will trigger another DCN
updateInterfaceParentRefs(interfaceNew);
}
if (parentRefs == null || parentRefs.getDatapathNodeIdentifier() == null && parentRefs.getParentInterface() == null) {
LOG.debug("parent refs not specified for {}", interfaceNew.getName());
return;
}
RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs, interfaceNew.getName());
String synchronizationKey = getSynchronizationKey(interfaceNew, parentRefs);
coordinator.enqueueJob(synchronizationKey, configWorker, IfmConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received 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.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project controller by opendaylight.
the class RoutedServiceIT method testServiceRegistration.
@Test
public void testServiceRegistration() {
assertNotNull(broker);
final BindingAwareProvider provider1 = new AbstractTestProvider() {
@Override
public void onSessionInitiated(final ProviderContext session) {
assertNotNull(session);
firstReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
}
};
LOG.info("Register provider 1 with first implementation of routeSimpleService - service1");
broker.registerProvider(provider1);
assertNotNull("Registration should not be null", firstReg);
assertSame(odlRoutedService1, firstReg.getInstance());
final BindingAwareProvider provider2 = new AbstractTestProvider() {
@Override
public void onSessionInitiated(final ProviderContext session) {
assertNotNull(session);
secondReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
}
};
LOG.info("Register provider 2 with second implementation of routeSimpleService - service2");
broker.registerProvider(provider2);
assertNotNull("Registration should not be null", firstReg);
assertSame(odlRoutedService2, secondReg.getInstance());
assertNotSame(secondReg, firstReg);
final BindingAwareConsumer consumer = session -> consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class);
LOG.info("Register routeService consumer");
broker.registerConsumer(consumer);
assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1, consumerService);
final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
LOG.info("Provider 1 registers path of node 1");
firstReg.registerPath(TestContext.class, nodeOnePath);
/**
* Consumer creates addFlow message for node one and sends it to the
* MD-SAL
*/
final RoutedSimpleRouteInput simpleRouteFirstFoo = createSimpleRouteInput(nodeOnePath);
consumerService.routedSimpleRoute(simpleRouteFirstFoo);
/**
* Verifies that implementation of the first provider received the same
* message from MD-SAL.
*/
verify(odlRoutedService1).routedSimpleRoute(simpleRouteFirstFoo);
/**
* Verifies that second instance was not invoked with first message
*/
verify(odlRoutedService2, times(0)).routedSimpleRoute(simpleRouteFirstFoo);
LOG.info("Provider 2 registers path of node 2");
final InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
secondReg.registerPath(TestContext.class, nodeTwo);
/**
* Consumer sends message to nodeTwo for three times. Should be
* processed by second instance.
*/
final RoutedSimpleRouteInput simpleRouteSecondFoo = createSimpleRouteInput(nodeTwo);
consumerService.routedSimpleRoute(simpleRouteSecondFoo);
consumerService.routedSimpleRoute(simpleRouteSecondFoo);
consumerService.routedSimpleRoute(simpleRouteSecondFoo);
/**
* Verifies that second instance was invoked 3 times with second message
* and first instance wasn't invoked.
*/
verify(odlRoutedService2, times(3)).routedSimpleRoute(simpleRouteSecondFoo);
verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteSecondFoo);
LOG.info("Unregistration of the path for the node one in the first provider");
firstReg.unregisterPath(TestContext.class, nodeOnePath);
LOG.info("Provider 2 registers path of node 1");
secondReg.registerPath(TestContext.class, nodeOnePath);
/**
* A consumer sends third message to node 1
*/
final RoutedSimpleRouteInput simpleRouteThirdFoo = createSimpleRouteInput(nodeOnePath);
consumerService.routedSimpleRoute(simpleRouteThirdFoo);
/**
* Verifies that provider 1 wasn't invoked and provider 2 was invoked 1
* time.
* TODO: fix unregister path
*/
// verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteThirdFoo);
verify(odlRoutedService2).routedSimpleRoute(simpleRouteThirdFoo);
}
Aggregations