itm-direct tunnel related changes for scaling 87/68187/16
authorEdw7n <n.edwin.anthony@ericsson.com>
Tue, 10 Apr 2018 15:42:13 +0000 (21:12 +0530)
committerSam Hague <shague@redhat.com>
Fri, 27 Apr 2018 18:30:37 +0000 (18:30 +0000)
depends on genius RPC implementation:
https://git.opendaylight.org/gerrit/#/c/68397/

Change-Id: Ib65733e577182067d02d0e90234c06591da09074
Signed-off-by: Edw7n <n.edwin.anthony@ericsson.com>
27 files changed:
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpInterfaceEventListener.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpManager.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpNeutronPortListener.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpPktHandler.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/jobs/DhcpInterfaceAddJob.java
elanmanager/api/pom.xml
elanmanager/api/src/main/java/org/opendaylight/netvirt/elan/arp/responder/ArpResponderUtil.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanItmUtils.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/BaseVrfEntryHandler.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/BgpRouteVrfEntryHandler.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/EvpnVrfEntryHandler.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/NexthopManager.java
fibmanager/impl/src/main/resources/org/opendaylight/blueprint/fibmanager.xml
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/AbstractSnatService.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/ConntrackBasedSnatService.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/ExternalNetworkGroupInstaller.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/ExternalRoutersListener.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FlatVlanConntrackBasedSnatService.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NaptSwitchHA.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatUtil.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/SnatServiceImplFactory.java
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VxlanGreConntrackBasedSnatService.java
vpnmanager/api/src/main/java/org/opendaylight/netvirt/vpnmanager/api/VpnExtraRouteHelper.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnManagerImpl.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/arp/responder/ArpResponderHandler.java
vpnmanager/impl/src/main/resources/org/opendaylight/blueprint/vpnmanager.xml

index e8edbc088c939efafd02c747dfe86082ca6fddf1..71a4e11427502036f7ab6cd886fc0e8246cc62b8 100644 (file)
@@ -609,7 +609,7 @@ public class DhcpExternalTunnelManager implements IDhcpExternalTunnelManager {
         builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(dhcpIpAddress).setSha(dhcpMacAddress)
                 .setLportTag(lportTag);
         builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName,
-                dhcpIpAddress, dhcpMacAddress));
+                dhcpIpAddress, dhcpMacAddress, itmRpcService));
         elanService.addExternalTunnelArpResponderFlow(builder.buildForInstallFlow(), elanInstanceName);
     }
 
index af96970426e61427e318a05d53981ee7184d90ed..faf2e8d36a10228698e1603de4ba06b531072e8b 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.re
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -44,11 +45,13 @@ public class DhcpInterfaceEventListener
     private final IInterfaceManager interfaceManager;
     private final IElanService elanService;
     private final DhcpPortCache dhcpPortCache;
+    private final ItmRpcService itmRpcService;
 
     public DhcpInterfaceEventListener(DhcpManager dhcpManager, DataBroker dataBroker,
                                       DhcpExternalTunnelManager dhcpExternalTunnelManager,
                                       IInterfaceManager interfaceManager, IElanService elanService,
-                                      DhcpPortCache dhcpPortCache, JobCoordinator jobCoordinator) {
+                                      DhcpPortCache dhcpPortCache, JobCoordinator jobCoordinator,
+                                      ItmRpcService itmRpcService) {
         super(Interface.class, DhcpInterfaceEventListener.class);
         this.dhcpManager = dhcpManager;
         this.dataBroker = dataBroker;
@@ -57,6 +60,7 @@ public class DhcpInterfaceEventListener
         this.elanService = elanService;
         this.dhcpPortCache = dhcpPortCache;
         this.jobCoordinator = jobCoordinator;
+        this.itmRpcService = itmRpcService;
         registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
     }
 
@@ -137,7 +141,7 @@ public class DhcpInterfaceEventListener
         NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
         BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
         DhcpInterfaceAddJob job = new DhcpInterfaceAddJob(dhcpManager, dhcpExternalTunnelManager, dataBroker,
-                add, dpnId, interfaceManager, elanService);
+                add, dpnId, interfaceManager, elanService, itmRpcService);
         jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
     }
 
index c23efbce782dcca94c06fc20ecf7c965bcf5726f..587a1f2bed6ff0bf8bfc4935466598addea3d994 100644 (file)
@@ -34,6 +34,7 @@ import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants;
 import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
@@ -54,6 +55,7 @@ public class DhcpManager {
     private final IElanService elanService;
     private final JobCoordinator jobCoordinator;
     private DhcpPortCache dhcpPortCache;
+    private final ItmRpcService itmRpcService;
 
     private volatile int dhcpOptLeaseTime = 0;
     private volatile String dhcpOptDefDomainName;
@@ -66,7 +68,7 @@ public class DhcpManager {
             final DhcpserviceConfig config, final DataBroker dataBroker,
             final DhcpExternalTunnelManager dhcpExternalTunnelManager, final IInterfaceManager interfaceManager,
             @Named("elanService") IElanService ielanService, final DhcpPortCache dhcpPortCache,
-            final JobCoordinator jobCoordinator) {
+            final JobCoordinator jobCoordinator, final ItmRpcService itmRpcService) {
         this.mdsalUtil = mdsalApiManager;
         this.neutronVpnService = neutronVpnManager;
         this.config = config;
@@ -76,6 +78,7 @@ public class DhcpManager {
         this.elanService = ielanService;
         this.dhcpPortCache = dhcpPortCache;
         this.jobCoordinator = jobCoordinator;
+        this.itmRpcService = itmRpcService;
         configureLeaseDuration(DhcpMConstants.DEFAULT_LEASE_TIME);
     }
 
@@ -84,7 +87,7 @@ public class DhcpManager {
         LOG.trace("Netvirt DHCP Manager Init .... {}",config.isControllerDhcpEnabled());
         if (config.isControllerDhcpEnabled()) {
             dhcpInterfaceEventListener = new DhcpInterfaceEventListener(this, broker, dhcpExternalTunnelManager,
-                    interfaceManager, elanService, dhcpPortCache, jobCoordinator);
+                    interfaceManager, elanService, dhcpPortCache, jobCoordinator, itmRpcService);
             dhcpInterfaceConfigListener = new DhcpInterfaceConfigListener(broker, dhcpExternalTunnelManager, this,
                     jobCoordinator);
             LOG.info("DHCP Service initialized");
index c3319840b90aae3ed87eb3a779067df9d8bab6d6..5bfe0e4a75569ab252398e53edf0ddff24c3ea7a 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.netvirt.elanmanager.api.ElanHelper;
 import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
@@ -57,11 +58,14 @@ public class DhcpNeutronPortListener
     private final IInterfaceManager interfaceManager;
     private final JobCoordinator jobCoordinator;
     private final DhcpManager dhcpManager;
+    private final ItmRpcService itmRpcService;
 
     @Inject
     public DhcpNeutronPortListener(DataBroker db, DhcpExternalTunnelManager dhcpExternalTunnelManager,
             @Named("elanService") IElanService ielanService, IInterfaceManager interfaceManager,
-            DhcpserviceConfig config, final JobCoordinator jobCoordinator, DhcpManager dhcpManager) {
+            DhcpserviceConfig config, final JobCoordinator jobCoordinator, DhcpManager dhcpManager,
+            ItmRpcService itmRpcService) {
+
         super(Port.class, DhcpNeutronPortListener.class);
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
         this.elanService = ielanService;
@@ -71,6 +75,7 @@ public class DhcpNeutronPortListener
         this.config = config;
         this.jobCoordinator = jobCoordinator;
         this.dhcpManager = dhcpManager;
+        this.itmRpcService = itmRpcService;
     }
 
     @PostConstruct
@@ -195,7 +200,7 @@ public class DhcpNeutronPortListener
                                 arpInput.getDpId());
                         ArpReponderInputBuilder builder = new ArpReponderInputBuilder(arpInput);
                         builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager,
-                                arpInput.getInterfaceName(), arpInput.getSpa(), arpInput.getSha()));
+                                arpInput.getInterfaceName(), arpInput.getSpa(), arpInput.getSha(), itmRpcService));
                         elanService.addArpResponderFlow(builder.buildForInstallFlow());
                     });
                 })));
index 9ce9b18582f8cc4dd8767be8284e7e1bba34a9eb..3201cd6a19983fc764efa1ac74e23c7769378c16 100644 (file)
@@ -52,6 +52,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.network.AllocationPool;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
@@ -83,6 +86,7 @@ public class DhcpPktHandler implements PacketProcessingListener {
     private final DhcpserviceConfig config;
     private final DhcpAllocationPoolManager dhcpAllocationPoolMgr;
     private final DataBroker broker;
+    private final ItmRpcService itmRpcService;
 
     @Inject
     public DhcpPktHandler(final DhcpManager dhcpManager,
@@ -92,7 +96,8 @@ public class DhcpPktHandler implements PacketProcessingListener {
                           final IInterfaceManager interfaceManager,
                           final DhcpserviceConfig config,
                           final DhcpAllocationPoolManager dhcpAllocationPoolMgr,
-                          final DataBroker dataBroker) {
+                          final DataBroker dataBroker,
+                          final ItmRpcService itmRpcService) {
         this.interfaceManagerRpc = interfaceManagerRpc;
         this.pktService = pktService;
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
@@ -101,6 +106,7 @@ public class DhcpPktHandler implements PacketProcessingListener {
         this.config = config;
         this.dhcpAllocationPoolMgr = dhcpAllocationPoolMgr;
         this.broker = dataBroker;
+        this.itmRpcService = itmRpcService;
     }
 
     //TODO: Handle this in a separate thread
@@ -714,25 +720,38 @@ public class DhcpPktHandler implements PacketProcessingListener {
     }
 
     private List<Action> getEgressAction(String interfaceName, BigInteger tunnelId) {
-        List<Action> actions = null;
         try {
-            GetEgressActionsForInterfaceInputBuilder egressAction =
-                    new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
-            if (tunnelId != null) {
+            if (interfaceManager.isItmDirectTunnelsEnabled() && tunnelId != null) {
+                GetEgressActionsForTunnelInputBuilder egressAction =
+                        new GetEgressActionsForTunnelInputBuilder().setIntfName(interfaceName);
                 egressAction.setTunnelKey(tunnelId.longValue());
-            }
-            Future<RpcResult<GetEgressActionsForInterfaceOutput>> result =
-                    interfaceManagerRpc.getEgressActionsForInterface(egressAction.build());
-            RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
-            if (!rpcResult.isSuccessful()) {
-                LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}",
-                        interfaceName, rpcResult.getErrors());
+                RpcResult<GetEgressActionsForTunnelOutput> rpcResult =
+                        itmRpcService.getEgressActionsForTunnel(egressAction.build()).get();
+                if (!rpcResult.isSuccessful()) {
+                    LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}",
+                            interfaceName, rpcResult.getErrors());
+                } else {
+                    return rpcResult.getResult().getAction();
+                }
             } else {
-                actions = rpcResult.getResult().getAction();
+                GetEgressActionsForInterfaceInputBuilder egressAction =
+                        new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
+                if (tunnelId != null) {
+                    egressAction.setTunnelKey(tunnelId.longValue());
+                }
+                Future<RpcResult<GetEgressActionsForInterfaceOutput>> result =
+                        interfaceManagerRpc.getEgressActionsForInterface(egressAction.build());
+                RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
+                if (!rpcResult.isSuccessful()) {
+                    LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}",
+                            interfaceName, rpcResult.getErrors());
+                } else {
+                    return rpcResult.getResult().getAction();
+                }
             }
         } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Exception when egress actions for interface {}", interfaceName, e);
         }
-        return actions;
+        return Collections.emptyList();
     }
 }
index d44962433e63eeb17bb789e6b38dea1ade4122c5..337ad2bcc251cc3c802ad45c5d9ece2e02a2bc97 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort;
@@ -46,10 +47,12 @@ public class DhcpInterfaceAddJob implements Callable<List<ListenableFuture<Void>
     private final BigInteger dpnId;
     private final IInterfaceManager interfaceManager;
     private final IElanService elanService;
+    private final ItmRpcService itmRpcService;
 
     public DhcpInterfaceAddJob(DhcpManager dhcpManager, DhcpExternalTunnelManager dhcpExternalTunnelManager,
                                DataBroker dataBroker, Interface interfaceAdd, BigInteger dpnId,
-                               IInterfaceManager interfaceManager, IElanService elanService) {
+                               IInterfaceManager interfaceManager, IElanService elanService,
+                               ItmRpcService itmRpcService) {
         this.dhcpManager = dhcpManager;
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
         this.dataBroker = dataBroker;
@@ -58,6 +61,7 @@ public class DhcpInterfaceAddJob implements Callable<List<ListenableFuture<Void>
         this.dpnId = dpnId;
         this.interfaceManager = interfaceManager;
         this.elanService = elanService;
+        this.itmRpcService = itmRpcService;
     }
 
     @Override
@@ -103,7 +107,7 @@ public class DhcpInterfaceAddJob implements Callable<List<ListenableFuture<Void>
             builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip())
                     .setSha(subnetToDhcp.get().getPortMacaddress()).setLportTag(interfaceAdd.getIfIndex());
             builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName,
-                    subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress()));
+                    subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress(), itmRpcService));
             elanService.addArpResponderFlow(builder.buildForInstallFlow());
             return futures;
         }
index 1be607a7b9ab8f020c81d867b72cbc67451c81ed..11c311cda4163e40005db27f3e69ea8c4f36857b 100644 (file)
@@ -51,6 +51,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <artifactId>interfacemanager-api</artifactId>
             <version>${genius.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.genius</groupId>
+            <artifactId>itm-api</artifactId>
+            <version>${genius.version}</version>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>neutronvpn-api</artifactId>
index 7434eb219a718c137e557939c61186966e2ca195..946b643728292b03448c3bc4492b865d77557daf 100644 (file)
@@ -56,6 +56,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase;
@@ -193,12 +196,14 @@ public final class ArpResponderUtil {
      *            MacAddress for which ARP Response packet is to be generated
      * @return List of ARP Responder Actions actions
      */
-    public static List<Action> getActions(IInterfaceManager ifaceMgrRpcService, String ifName, String ipAddress,
-            String macAddress) {
+    public static List<Action> getActions(IInterfaceManager ifaceMgrRpcService, ItmRpcService itmRpcService,
+                                          String ifName, String ipAddress, String macAddress,
+                                          boolean isTunnelInterface) {
 
         AtomicInteger actionCounter = new AtomicInteger();
         List<Action> actions = arpActions.apply(actionCounter, macAddress, ipAddress);
-        actions.addAll(getEgressActionsForInterface(ifaceMgrRpcService, ifName, actionCounter.get()));
+        actions.addAll(getEgressActionsForInterface(ifaceMgrRpcService, itmRpcService, ifName, actionCounter.get(),
+                isTunnelInterface));
         LOG.trace("Total Number of actions is {}", actionCounter);
         return actions;
 
@@ -254,8 +259,9 @@ public final class ArpResponderUtil {
      * Get instruction list for ARP responder flows.
      */
     public static List<Instruction> getInterfaceInstructions(IInterfaceManager ifaceMgrRpcService, String interfaceName,
-            String ipAddress, String macAddress) {
-        List<Action> actions = ArpResponderUtil.getActions(ifaceMgrRpcService, interfaceName, ipAddress, macAddress);
+            String ipAddress, String macAddress, ItmRpcService itmRpcService) {
+        List<Action> actions = ArpResponderUtil.getActions(ifaceMgrRpcService, itmRpcService, interfaceName, ipAddress,
+                macAddress, false);
         return Collections.singletonList(MDSALUtil.buildApplyActionsInstruction(actions));
     }
 
@@ -269,10 +275,13 @@ public final class ArpResponderUtil {
      * action needs to be replaced with goto instruction.
      */
     public static List<Instruction> getExtInterfaceInstructions(IInterfaceManager ifaceMgrRpcService,
-            String extInterfaceName, String ipAddress, String macAddress) {
+                                                                ItmRpcService itmRpcService,
+                                                                String extInterfaceName, String ipAddress,
+                                                                String macAddress) {
         AtomicInteger tableId = new AtomicInteger(-1);
         List<Instruction> instructions = new ArrayList<>();
-        List<Action> actions = getActions(ifaceMgrRpcService, extInterfaceName, ipAddress, macAddress);
+        List<Action> actions = getActions(ifaceMgrRpcService, itmRpcService, extInterfaceName, ipAddress, macAddress,
+                false);
         actions.removeIf(v -> {
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = v
                     .getAction();
@@ -441,11 +450,30 @@ public final class ArpResponderUtil {
      *            Action Key
      * @return List of Egress Actions
      */
-    public static List<Action> getEgressActionsForInterface(IInterfaceManager ifaceMgrRpcService, String ifName,
-            int actionCounter) {
-        List<ActionInfo> actionInfos = ifaceMgrRpcService.getInterfaceEgressActions(ifName);
-        AtomicInteger counter = new AtomicInteger(actionCounter);
-        return actionInfos.stream().map(v -> v.buildAction(counter.getAndIncrement())).collect(Collectors.toList());
+    public static List<Action> getEgressActionsForInterface(IInterfaceManager ifaceMgrRpcService,
+                                                            ItmRpcService itmRpcService, String ifName,
+                                                            int actionCounter, boolean isTunnelInterface) {
+        if (isTunnelInterface && ifaceMgrRpcService.isItmDirectTunnelsEnabled()) {
+            try {
+                RpcResult result = itmRpcService.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder()
+                        .setIntfName(ifName).build()).get();
+                List<Action> listActions = new ArrayList<>();
+                if (!result.isSuccessful()) {
+                    LOG.error("getEgressActionsForInterface: RPC Call to Get egress actions for interface {} "
+                            + "returned with Errors {}", ifName, result.getErrors());
+                } else {
+                    listActions = ((GetEgressActionsForTunnelOutput) result.getResult()).getAction();
+                }
+                return listActions;
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.error("getEgressActionsForInterface: Exception when egress actions for interface {}", ifName, e);
+            }
+        } else {
+            List<ActionInfo> actionInfos = ifaceMgrRpcService.getInterfaceEgressActions(ifName);
+            AtomicInteger counter = new AtomicInteger(actionCounter);
+            return actionInfos.stream().map(v -> v.buildAction(counter.getAndIncrement())).collect(Collectors.toList());
+        }
+        return Collections.emptyList();
     }
 
     /**
index f4aeb825860b124bc155227f28f69b8679c44f18..791f3209a07c2f8da8075de9a918c3d1e5fb8bbb 100644 (file)
@@ -15,6 +15,7 @@ import java.util.concurrent.Future;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -27,6 +28,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameOutput;
@@ -46,13 +50,15 @@ public class ElanItmUtils {
     private final DataBroker broker;
     private final ItmRpcService itmRpcService;
     private final OdlInterfaceRpcService interfaceManagerRpcService;
+    private final IInterfaceManager interfaceManager;
 
     @Inject
-    public ElanItmUtils(DataBroker broker, ItmRpcService itmRpcService,
-            OdlInterfaceRpcService interfaceManagerRpcService) {
+    public ElanItmUtils(final DataBroker broker, final ItmRpcService itmRpcService,
+            final OdlInterfaceRpcService interfaceManagerRpcService, final IInterfaceManager interfaceManager) {
         this.broker = broker;
         this.itmRpcService = itmRpcService;
         this.interfaceManagerRpcService = interfaceManagerRpcService;
+        this.interfaceManager = interfaceManager;
     }
 
     /**
@@ -199,25 +205,28 @@ public class ElanItmUtils {
      */
     @SuppressWarnings("checkstyle:IllegalCatch")
     public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey) {
-        List<Action> result = Collections.emptyList();
         try {
             GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder()
                     .setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
 
             Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService
                     .getEgressActionsForInterface(getEgressActInput);
-            if (egressActionsOutputFuture.get().isSuccessful()) {
-                GetEgressActionsForInterfaceOutput egressActionsOutput = egressActionsOutputFuture.get().getResult();
-                result = egressActionsOutput.getAction();
+
+            GetEgressActionsForTunnelInput getEgressActInputItm = new GetEgressActionsForTunnelInputBuilder()
+                    .setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
+
+            Future<RpcResult<GetEgressActionsForTunnelOutput>> egressActionsOutputItm =
+                    itmRpcService.getEgressActionsForTunnel(getEgressActInputItm);
+            if (egressActionsOutputFuture.get().isSuccessful() && !interfaceManager.isItmDirectTunnelsEnabled()) {
+                return egressActionsOutputFuture.get().getResult().getAction();
+            } else if (egressActionsOutputItm.get().isSuccessful() && interfaceManager.isItmDirectTunnelsEnabled()) {
+                return egressActionsOutputItm.get().getResult().getAction();
             }
         } catch (Exception e) {
             LOG.error("Error in RPC call getEgressActionsForInterface {}", e);
         }
-
-        if (result == null || result.isEmpty()) {
-            LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
-        }
-        return result;
+        LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
+        return Collections.emptyList();
     }
 
     /**
index 938e0ededaa6e3837ebbe721eb4a1874ff5f1f86..694b47e78513650db577b6f5515b42290d262343 100644 (file)
@@ -325,8 +325,7 @@ public class BaseVrfEntryHandler implements AutoCloseable {
     protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, long vpnId, VrfEntry vrfEntry,
                                            List<ActionInfo> actionInfos, String rd) {
         Class<? extends TunnelTypeBase> tunnelType =
-                VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(),
-                        adjacencyResult.getInterfaceName());
+                VpnExtraRouteHelper.getTunnelType(nextHopManager.getItmManager(), adjacencyResult.getInterfaceName());
         if (tunnelType == null) {
             LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
             return;
@@ -398,7 +397,7 @@ public class BaseVrfEntryHandler implements AutoCloseable {
                 addRewriteDstMacAction(vpnId, vrfEntry, null, actionInfos);
             }
             List<ActionInfo> egressActions = nextHopManager.getEgressActionsForInterface(egressInterface,
-                    actionInfos.size());
+                    actionInfos.size(), true);
             if (egressActions.isEmpty()) {
                 LOG.error(
                         "Failed to retrieve egress action for prefix {} route-paths {} interface {}. "
index ffa75d25f880417c1b3316418ccb7868daf554d9..ec2fc6b4b14e8b0672e5e04a4d03b87e238dd6a1 100644 (file)
@@ -387,9 +387,8 @@ public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler
     @Override
     protected void addTunnelInterfaceActions(NexthopManager.AdjacencyResult adjacencyResult, long vpnId,
             VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
-        Class<? extends TunnelTypeBase> tunnelType =
-                VpnExtraRouteHelper.getTunnelType(getNextHopManager().getInterfaceManager(),
-                        adjacencyResult.getInterfaceName());
+        Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper
+                .getTunnelType(getNextHopManager().getItmManager(), adjacencyResult.getInterfaceName());
         if (tunnelType == null) {
             LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
             return;
index 8435f47c2e24cf5784c0c68e87c9517fd19b2bd0..d6715650aae6ac1d5805d4311c7afbbc39dcce5c 100644 (file)
@@ -258,7 +258,8 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
             }
             actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
             List<ActionInfo> egressActions =
-                    nexthopManager.getEgressActionsForInterface(adjacencyResult.getInterfaceName(), actionInfos.size());
+                    nexthopManager.getEgressActionsForInterface(adjacencyResult.getInterfaceName(), actionInfos.size(),
+                            true);
             if (egressActions.isEmpty()) {
                 LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}."
                         + " Aborting remote FIB entry creation..", vrfEntry.getDestPrefix(),
index 6d222cee0f26795de93b79182605d8dd3640a753..342c75fd529f2344b1d7fbbd6405cff9f437fe33 100644 (file)
@@ -27,6 +27,7 @@ import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.itm.globals.ITMConstants;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
@@ -80,6 +81,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.Tun
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelsState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder;
@@ -137,7 +139,7 @@ public class NexthopManager implements AutoCloseable {
 
     private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalApiManager;
-    private final OdlInterfaceRpcService interfaceManager;
+    private final OdlInterfaceRpcService odlInterfaceRpcService;
     private final ItmRpcService itmManager;
     private final IdManagerService idManager;
     private final IElanService elanService;
@@ -145,6 +147,7 @@ public class NexthopManager implements AutoCloseable {
     private final SalGroupService salGroupService;
     private final JobCoordinator jobCoordinator;
     private final FibUtil fibUtil;
+    private final IInterfaceManager interfaceManager;
     private volatile L3VPNTransportTypes configuredTransportTypeL3VPN = L3VPNTransportTypes.Invalid;
 
     /**
@@ -154,30 +157,32 @@ public class NexthopManager implements AutoCloseable {
      * @param dataBroker       - dataBroker reference
      * @param mdsalApiManager  - mdsalApiManager reference
      * @param idManager        - idManager reference
-     * @param interfaceManager - interfaceManager reference
+     * @param odlInterfaceRpcService - odlInterfaceRpcService reference
      * @param itmManager       - itmManager reference
      */
     @Inject
     public NexthopManager(final DataBroker dataBroker,
                           final IMdsalApiManager mdsalApiManager,
                           final IdManagerService idManager,
-                          final OdlInterfaceRpcService interfaceManager,
+                          final OdlInterfaceRpcService odlInterfaceRpcService,
                           final ItmRpcService itmManager,
                           final LockManagerService lockManager,
                           final IElanService elanService,
                           final SalGroupService salGroupService,
                           final JobCoordinator jobCoordinator,
-                          final FibUtil fibUtil) {
+                          final FibUtil fibUtil,
+                          final IInterfaceManager interfaceManager) {
         this.dataBroker = dataBroker;
         this.mdsalApiManager = mdsalApiManager;
         this.idManager = idManager;
-        this.interfaceManager = interfaceManager;
+        this.odlInterfaceRpcService = odlInterfaceRpcService;
         this.itmManager = itmManager;
         this.elanService = elanService;
         this.salGroupService = salGroupService;
         this.jobCoordinator = jobCoordinator;
         this.fibUtil = fibUtil;
         this.lockManager = lockManager;
+        this.interfaceManager = interfaceManager;
         createIdPool();
     }
 
@@ -201,8 +206,8 @@ public class NexthopManager implements AutoCloseable {
         return "nexthop." + vpnId + ipAddress;
     }
 
-    public OdlInterfaceRpcService getInterfaceManager() {
-        return interfaceManager;
+    public ItmRpcService getItmManager() {
+        return itmManager;
     }
 
     protected long createNextHopPointer(String nexthopKey) {
@@ -236,50 +241,69 @@ public class NexthopManager implements AutoCloseable {
         }
     }
 
-    protected List<ActionInfo> getEgressActionsForInterface(final String ifName, int actionKey) {
-        List<ActionInfo> listActionInfo = new ArrayList<>();
+    protected List<ActionInfo> getEgressActionsForInterface(final String ifName, int actionKey,
+                                                            boolean isTunnelInterface) {
+        RpcResult rpcResult;
+        List<Action> actions;
         try {
-            Future<RpcResult<GetEgressActionsForInterfaceOutput>> result =
-                interfaceManager.getEgressActionsForInterface(
-                    new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).build());
-            RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
-            if (!rpcResult.isSuccessful()) {
-                LOG.error("RPC Call to Get egress actions for interface {} returned with Errors {}",
-                    ifName, rpcResult.getErrors());
+            if (isTunnelInterface && interfaceManager.isItmDirectTunnelsEnabled()) {
+                rpcResult = itmManager.getEgressActionsForTunnel(
+                        new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName).build()).get();
+                if (!rpcResult.isSuccessful()) {
+                    LOG.error("RPC Call to Get egress tunnel actions for interface {} returned with Errors {}",
+                            ifName, rpcResult.getErrors());
+                    return Collections.emptyList();
+                } else {
+                    GetEgressActionsForInterfaceOutput output =
+                            (GetEgressActionsForInterfaceOutput)rpcResult.getResult();
+                    actions = output.getAction();
+                }
             } else {
-                List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions =
-                    rpcResult.getResult().getAction();
-                for (Action action : actions) {
-                    actionKey = action.getKey().getOrder() + actionKey;
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
-                        actionClass = action.getAction();
-                    if (actionClass instanceof OutputActionCase) {
-                        listActionInfo.add(new ActionOutput(actionKey,
-                            ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
-                    } else if (actionClass instanceof PushVlanActionCase) {
-                        listActionInfo.add(new ActionPushVlan(actionKey));
-                    } else if (actionClass instanceof SetFieldCase) {
-                        if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
-                            int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch()
-                                .getVlanId().getVlanId().getValue();
-                            listActionInfo.add(new ActionSetFieldVlanVid(actionKey, vlanVid));
-                        }
-                    } else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
-                        Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
-                        listActionInfo.add(new ActionNxResubmit(actionKey, tableId));
-                    } else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
-                        NxRegLoad nxRegLoad =
-                            ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
-                        listActionInfo.add(new ActionRegLoad(actionKey, NxmNxReg6.class,
-                            nxRegLoad.getDst().getStart(), nxRegLoad.getDst().getEnd(),
-                            nxRegLoad.getValue().longValue()));
+                rpcResult = odlInterfaceRpcService.getEgressActionsForInterface(
+                        new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).build()).get();
+                if (!rpcResult.isSuccessful()) {
+                    LOG.error("RPC Call to Get egress vm actions for interface {} returned with Errors {}",
+                            ifName, rpcResult.getErrors());
+                    return Collections.emptyList();
+                } else {
+                    GetEgressActionsForInterfaceOutput output =
+                            (GetEgressActionsForInterfaceOutput)rpcResult.getResult();
+                    actions = output.getAction();
+                }
+            }
+            List<ActionInfo> listActionInfo = new ArrayList<>();
+            for (Action action : actions) {
+                actionKey = action.getKey().getOrder() + actionKey;
+                org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
+                    actionClass = action.getAction();
+                if (actionClass instanceof OutputActionCase) {
+                    listActionInfo.add(new ActionOutput(actionKey,
+                        ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
+                } else if (actionClass instanceof PushVlanActionCase) {
+                    listActionInfo.add(new ActionPushVlan(actionKey));
+                } else if (actionClass instanceof SetFieldCase) {
+                    if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
+                        int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch()
+                            .getVlanId().getVlanId().getValue();
+                        listActionInfo.add(new ActionSetFieldVlanVid(actionKey, vlanVid));
                     }
+                } else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
+                    Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
+                    listActionInfo.add(new ActionNxResubmit(actionKey, tableId));
+                } else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
+                    NxRegLoad nxRegLoad =
+                        ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
+                    listActionInfo.add(new ActionRegLoad(actionKey, NxmNxReg6.class,
+                        nxRegLoad.getDst().getStart(), nxRegLoad.getDst().getEnd(),
+                        nxRegLoad.getValue().longValue()));
                 }
             }
+            return listActionInfo;
         } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Exception when egress actions for interface {}", ifName, e);
         }
-        return listActionInfo;
+        LOG.warn("Exception when egress actions for interface {}", ifName);
+        return Collections.emptyList();
     }
 
     protected String getTunnelInterfaceName(BigInteger srcDpId, BigInteger dstDpId) {
@@ -378,7 +402,7 @@ public class NexthopManager implements AutoCloseable {
                             // FIXME: Log message here.
                             LOG.debug("mac address for new local nexthop is null");
                         }
-                        listActionInfo.addAll(getEgressActionsForInterface(ifName, actionKey));
+                        listActionInfo.addAll(getEgressActionsForInterface(ifName, actionKey, false));
                         BucketInfo bucket = new BucketInfo(listActionInfo);
 
                         listBucketInfo.add(bucket);
@@ -881,9 +905,7 @@ public class NexthopManager implements AutoCloseable {
             if (!FibUtil.isTunnelInterface(adjacencyResult)) {
                 return;
             }
-            Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper
-                    .getTunnelType(interfaceManager,
-                            egressInterface);
+            Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(itmManager, egressInterface);
             Interface ifState = fibUtil.getInterfaceStateFromOperDS(egressInterface);
             if (ifState == null || ifState.getOperStatus() != OperStatus.Up) {
                 LOG.trace("Tunnel not up {}", egressInterface);
@@ -921,7 +943,7 @@ public class NexthopManager implements AutoCloseable {
             if (egressActionMap.containsKey(egressInterface)) {
                 egressActions = egressActionMap.get(egressInterface);
             } else {
-                egressActions = getEgressActionsForInterface(egressInterface, actionInfos.size());
+                egressActions = getEgressActionsForInterface(egressInterface, actionInfos.size(), true);
                 egressActionMap.put(egressInterface, egressActions);
             }
             if (egressActions.isEmpty()) {
@@ -984,7 +1006,7 @@ public class NexthopManager implements AutoCloseable {
             GetEgressActionsForInterfaceInputBuilder egressAction =
                     new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setActionKey(actionKey);
             Future<RpcResult<GetEgressActionsForInterfaceOutput>> result =
-                    interfaceManager.getEgressActionsForInterface(egressAction.build());
+                    odlInterfaceRpcService.getEgressActionsForInterface(egressAction.build());
             RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
             if (!rpcResult.isSuccessful()) {
                 LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}",
index 2c5523c00629e21ecdf70f82a8acda08b9d11d15..02b745c0bf83404a26800ae13eaa9ec530cf2836 100644 (file)
@@ -18,6 +18,8 @@
   <reference id="interVpnLinkCache"
              interface="org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache"
              availability="optional"/>
+  <reference id="iInterfaceManager"
+             interface="org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager" />
 
   <odl:rpc-service id="idManagerService"
                    interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService"/>
index 59bac165c18aa50e14f019e14ac979f50266b7f9..27e30aa2b23c5a92ca0c0fe635668a0b99ebcbd2 100644 (file)
@@ -13,6 +13,7 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
@@ -66,19 +67,20 @@ public abstract class AbstractSnatService implements SnatServiceListener {
     protected final IdManagerService idManager;
     protected final NAPTSwitchSelector naptSwitchSelector;
     protected final ItmRpcService itmManager;
-    protected final OdlInterfaceRpcService interfaceManager;
+    protected final OdlInterfaceRpcService odlInterfaceRpcService;
+    protected final IInterfaceManager interfaceManager;
 
     protected AbstractSnatService(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
-            final ItmRpcService itmManager,
-            final OdlInterfaceRpcService interfaceManager,
-            final IdManagerService idManager,
-            final NAPTSwitchSelector naptSwitchSelector) {
+                                  final ItmRpcService itmManager, final OdlInterfaceRpcService odlInterfaceRpcService,
+                                  final IdManagerService idManager, final NAPTSwitchSelector naptSwitchSelector,
+                                  final IInterfaceManager interfaceManager) {
         this.dataBroker = dataBroker;
         this.mdsalManager = mdsalManager;
         this.itmManager = itmManager;
         this.interfaceManager = interfaceManager;
         this.idManager = idManager;
         this.naptSwitchSelector = naptSwitchSelector;
+        this.odlInterfaceRpcService = odlInterfaceRpcService;
     }
 
     protected DataBroker getDataBroker() {
@@ -212,7 +214,8 @@ public abstract class AbstractSnatService implements SnatServiceListener {
         List<BucketInfo> listBucketInfo = new ArrayList<>();
         if (ifNamePrimary != null) {
             LOG.debug("installSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
-            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
+            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager,
+                    interfaceManager, ifNamePrimary, routerId);
         }
         BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
         listBucketInfo.add(0, bucketPrimary);
index 84f3daea78abc61ef9960dd88b43d91d5604f20f..f3fba7806258c3625a291de0f2a508fc55487bd6 100644 (file)
@@ -11,6 +11,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
 import org.opendaylight.genius.mdsalutil.MatchInfo;
@@ -54,9 +55,11 @@ public abstract class ConntrackBasedSnatService extends AbstractSnatService {
     protected static final int DNAT_CT_STATE_MASK = 0x80;
 
     public ConntrackBasedSnatService(DataBroker dataBroker, IMdsalApiManager mdsalManager, ItmRpcService itmManager,
-            OdlInterfaceRpcService interfaceManager, IdManagerService idManager,
-            NAPTSwitchSelector naptSwitchSelector) {
-        super(dataBroker, mdsalManager, itmManager, interfaceManager, idManager, naptSwitchSelector);
+                                     IdManagerService idManager, NAPTSwitchSelector naptSwitchSelector,
+                                     OdlInterfaceRpcService odlInterfaceRpcService,
+                                     IInterfaceManager interfaceManager) {
+        super(dataBroker, mdsalManager, itmManager, odlInterfaceRpcService, idManager, naptSwitchSelector,
+                interfaceManager);
     }
 
     @Override
index cce5582db342e432929f76dc543617104667e4b8..f61e77d4ccfed33264855650a4da61098ea4833a 100644 (file)
@@ -19,6 +19,7 @@ import java.util.List;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.GroupEntity;
@@ -32,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap;
 import org.slf4j.Logger;
@@ -44,20 +46,26 @@ public class ExternalNetworkGroupInstaller {
     private final IMdsalApiManager mdsalManager;
     private final IElanService elanService;
     private final IdManagerService idManager;
-    private final OdlInterfaceRpcService interfaceManager;
+    private final OdlInterfaceRpcService odlInterfaceRpcService;
     private final JobCoordinator coordinator;
+    private final ItmRpcService itmRpcService;
+    private final  IInterfaceManager interfaceManager;
 
     @Inject
     public ExternalNetworkGroupInstaller(final DataBroker broker, final IMdsalApiManager mdsalManager,
-                                     final IElanService elanService, final IdManagerService idManager,
-                                     final OdlInterfaceRpcService interfaceManager,
-                                     final JobCoordinator coordinator) {
+                                         final IElanService elanService, final IdManagerService idManager,
+                                         final OdlInterfaceRpcService odlInterfaceRpcService,
+                                         final JobCoordinator coordinator, final ItmRpcService itmRpcService,
+                                         final IInterfaceManager interfaceManager) {
+
         this.broker = broker;
         this.mdsalManager = mdsalManager;
         this.elanService = elanService;
         this.idManager = idManager;
-        this.interfaceManager = interfaceManager;
+        this.odlInterfaceRpcService = odlInterfaceRpcService;
         this.coordinator = coordinator;
+        this.itmRpcService = itmRpcService;
+        this.interfaceManager = interfaceManager;
     }
 
     public void installExtNetGroupEntries(Subnetmap subnetMap) {
@@ -136,7 +144,7 @@ public class ExternalNetworkGroupInstaller {
         LOG.info("installExtNetGroupEntries : Installing ext-net group {} entry for subnet {} with macAddress {} "
                 + "(extInterfaces: {})", groupId, subnetName, macAddress, Arrays.toString(extInterfaces.toArray()));
         for (String extInterface : extInterfaces) {
-            BigInteger dpId = NatUtil.getDpnForInterface(interfaceManager, extInterface);
+            BigInteger dpId = NatUtil.getDpnForInterface(odlInterfaceRpcService, extInterface);
             if (BigInteger.ZERO.equals(dpId)) {
                 LOG.info("installExtNetGroupEntries: No DPN for interface {}. NAT ext-net flow will not be installed "
                     + "for subnet {}", extInterface, subnetName);
@@ -211,8 +219,8 @@ public class ExternalNetworkGroupInstaller {
         final int setFieldEthDestActionPos = 0;
         List<ActionInfo> egressActionList = new ArrayList<>();
         if (extInterface != null) {
-            egressActionList = NatUtil.getEgressActionsForInterface(interfaceManager, extInterface, null,
-                setFieldEthDestActionPos + 1);
+            egressActionList = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmRpcService,
+                    interfaceManager, extInterface, null, setFieldEthDestActionPos + 1);
         }
         if (Strings.isNullOrEmpty(macAddress) || egressActionList.isEmpty()) {
             if (Strings.isNullOrEmpty(macAddress)) {
@@ -238,7 +246,7 @@ public class ExternalNetworkGroupInstaller {
     }
 
     private GroupEntity buildEmptyExtNetGroupEntity(String subnetName, long groupId, String extInterface) {
-        BigInteger dpId = NatUtil.getDpnForInterface(interfaceManager, extInterface);
+        BigInteger dpId = NatUtil.getDpnForInterface(odlInterfaceRpcService, extInterface);
         if (BigInteger.ZERO.equals(dpId)) {
             LOG.error("buildEmptyExtNetGroupEntity: No DPN for interface {}. NAT ext-net flow will not be installed "
                     + "for subnet {}", extInterface, subnetName);
index f3f7008fdb10b85e3b33d3d86a511c612f0389aa..bac3c1e39e90de8743fa1d98b0fbffa0fcaa318a 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
@@ -149,7 +150,7 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
     private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalManager;
     private final ItmRpcService itmManager;
-    private final OdlInterfaceRpcService interfaceManager;
+    private final OdlInterfaceRpcService odlInterfaceRpcService;
     private final IdManagerService idManager;
     private final NaptManager naptManager;
     private final NAPTSwitchSelector naptSwitchSelector;
@@ -168,11 +169,12 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
     private final IElanService elanManager;
     private final JobCoordinator coordinator;
     private final UpgradeState upgradeState;
+    private final IInterfaceManager interfaceManager;
 
     @Inject
     public ExternalRoutersListener(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
                                    final ItmRpcService itmManager,
-                                   final OdlInterfaceRpcService interfaceManager,
+                                   final OdlInterfaceRpcService odlInterfaceRpcService,
                                    final IdManagerService idManager,
                                    final NaptManager naptManager,
                                    final NAPTSwitchSelector naptSwitchSelector,
@@ -190,12 +192,13 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
                                    final NatserviceConfig config,
                                    final IElanService elanManager,
                                    final JobCoordinator coordinator,
-                                   final UpgradeState upgradeState) {
+                                   final UpgradeState upgradeState,
+                                   final IInterfaceManager interfaceManager) {
         super(Routers.class, ExternalRoutersListener.class);
         this.dataBroker = dataBroker;
         this.mdsalManager = mdsalManager;
         this.itmManager = itmManager;
-        this.interfaceManager = interfaceManager;
+        this.odlInterfaceRpcService = odlInterfaceRpcService;
         this.idManager = idManager;
         this.naptManager = naptManager;
         this.naptSwitchSelector = naptSwitchSelector;
@@ -213,6 +216,7 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
         this.centralizedSwitchScheduler = centralizedSwitchScheduler;
         this.coordinator = coordinator;
         this.upgradeState = upgradeState;
+        this.interfaceManager = interfaceManager;
         if (config != null) {
             this.natMode = config.getNatMode();
         } else {
@@ -840,7 +844,8 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
 
         if (ifNamePrimary != null) {
             LOG.debug("handleSwitches : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
-            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
+            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager,
+                    interfaceManager, ifNamePrimary, routerId);
             if (listActionInfoPrimary.isEmpty()) {
                 LOG.error("handleSwitches : Unable to retrieve output actions on Non-NAPT switch {} for router {}"
                         + " towards Napt-switch {} via tunnel interface {}", dpnId, routerName, primarySwitchId,
@@ -865,7 +870,8 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
         if (ifNamePrimary != null) {
             LOG.debug("getBucketInfoForNonNaptSwitches : On Non- Napt switch , Primary Tunnel interface is {}",
                     ifNamePrimary);
-            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
+            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager,
+                    interfaceManager, ifNamePrimary, routerId);
             if (listActionInfoPrimary.isEmpty()) {
                 LOG.error("getBucketInfoForNonNaptSwitches : Unable to retrieve output actions on Non-NAPT switch {} "
                         + "for router {} towards Napt-switch {} via tunnel interface {}",
index a9237f781909e6f7035359e4922a7bbaf1d6db42..486bf7daa753697b1f82d96308cd0f039199d9c4 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.netvirt.natservice.internal;
 import java.math.BigInteger;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
@@ -24,9 +25,11 @@ public class FlatVlanConntrackBasedSnatService extends ConntrackBasedSnatService
     private static final Logger LOG = LoggerFactory.getLogger(FlatVlanConntrackBasedSnatService.class);
 
     public FlatVlanConntrackBasedSnatService(DataBroker dataBroker, IMdsalApiManager mdsalManager,
-            ItmRpcService itmManager, OdlInterfaceRpcService interfaceManager, IdManagerService idManager,
-            NAPTSwitchSelector naptSwitchSelector) {
-        super(dataBroker, mdsalManager, itmManager, interfaceManager, idManager, naptSwitchSelector);
+                                             ItmRpcService itmManager, OdlInterfaceRpcService odlInterfaceRpcService,
+                                             IdManagerService idManager, NAPTSwitchSelector naptSwitchSelector,
+                                             IInterfaceManager interfaceManager) {
+        super(dataBroker, mdsalManager, itmManager, idManager, naptSwitchSelector,
+                odlInterfaceRpcService, interfaceManager);
     }
 
     @Override
index f80f85a660d63784472828ad54814238d24de15e..a93f1f6aec7aff0cf30496dc4dd43eac53644eef 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
@@ -91,7 +92,7 @@ public class NaptSwitchHA {
     private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalManager;
     private final ItmRpcService itmManager;
-    private final OdlInterfaceRpcService interfaceManager;
+    private final OdlInterfaceRpcService odlInterfaceRpcService;
     private final IdManagerService idManager;
     private final NAPTSwitchSelector naptSwitchSelector;
     private final ExternalRoutersListener externalRouterListener;
@@ -101,6 +102,7 @@ public class NaptSwitchHA {
     private final EvpnNaptSwitchHA evpnNaptSwitchHA;
     private final SnatServiceManager natServiceManager;
     private final NatMode natMode;
+    private final IInterfaceManager interfaceManager;
 
     private volatile Collection<String> externalIpsCache;
 
@@ -108,7 +110,7 @@ public class NaptSwitchHA {
     public NaptSwitchHA(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
                         final ExternalRoutersListener externalRouterListener,
                         final ItmRpcService itmManager,
-                        final OdlInterfaceRpcService interfaceManager,
+                        final OdlInterfaceRpcService odlInterfaceRpcService,
                         final IdManagerService idManager,
                         final NAPTSwitchSelector naptSwitchSelector,
                         final IFibManager fibManager,
@@ -116,12 +118,13 @@ public class NaptSwitchHA {
                         final IElanService elanManager,
                         final SnatServiceManager natServiceManager,
                         final NatserviceConfig config,
-                        final NaptEventHandler naptEventHandler) {
+                        final NaptEventHandler naptEventHandler,
+                        final IInterfaceManager interfaceManager) {
         this.dataBroker = dataBroker;
         this.mdsalManager = mdsalManager;
         this.externalRouterListener = externalRouterListener;
         this.itmManager = itmManager;
-        this.interfaceManager = interfaceManager;
+        this.odlInterfaceRpcService = odlInterfaceRpcService;
         this.idManager = idManager;
         this.naptSwitchSelector = naptSwitchSelector;
         this.naptEventHandler = naptEventHandler;
@@ -129,6 +132,7 @@ public class NaptSwitchHA {
         this.evpnNaptSwitchHA = evpnNaptSwitchHA;
         this.elanManager = elanManager;
         this.natServiceManager = natServiceManager;
+        this.interfaceManager = interfaceManager;
         if (config != null) {
             this.natMode = config.getNatMode();
         } else {
@@ -724,7 +728,8 @@ public class NaptSwitchHA {
             LOG.debug("handleGroupInNeighborSwitches : TunnelInterface {} between ordinary switch {} and naptSwitch {}",
                 ifNamePrimary, dpnId, naptSwitch);
             List<ActionInfo> listActionInfoPrimary =
-                NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
+                NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager, interfaceManager,
+                        ifNamePrimary, routerId);
             BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
             listBucketInfo.add(bucketPrimary);
         } else {
index 51fbb6e2f9e28116636941f9fc80baabe7768315..bbe0e8cd529cec746e5c3b8a16ab561849b1cbfb 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.FlowEntityBuilder;
@@ -88,6 +89,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.Dpn
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
@@ -1265,60 +1269,87 @@ public final class NatUtil {
     }
 
     @Nonnull
-    public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService interfaceManager, String ifName,
+    public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService odlInterfaceRpcService,
+                                                                ItmRpcService itmRpcService,
+                                                                IInterfaceManager interfaceManager, String ifName,
                                                                 Long tunnelKey) {
-        return getEgressActionsForInterface(interfaceManager, ifName, tunnelKey, 0);
+        return getEgressActionsForInterface(odlInterfaceRpcService, itmRpcService, interfaceManager,
+                ifName, tunnelKey, 0);
     }
 
     @Nonnull
-    public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService interfaceManager, String ifName,
-                                                                Long tunnelKey, int pos) {
+    public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService odlInterfaceRpcService,
+                                                                ItmRpcService itmRpcService,
+                                                                IInterfaceManager interfaceManager,
+                                                                String ifName, Long tunnelKey, int pos) {
         LOG.debug("getEgressActionsForInterface : called for interface {}", ifName);
-        GetEgressActionsForInterfaceInputBuilder egressActionsBuilder = new GetEgressActionsForInterfaceInputBuilder()
+        GetEgressActionsForInterfaceInputBuilder egressActionsIfmBuilder =
+                new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName);
+        GetEgressActionsForTunnelInputBuilder egressActionsItmBuilder = new GetEgressActionsForTunnelInputBuilder()
             .setIntfName(ifName);
         if (tunnelKey != null) {
-            egressActionsBuilder.setTunnelKey(tunnelKey);
+            egressActionsIfmBuilder.setTunnelKey(tunnelKey);
+            egressActionsItmBuilder.setTunnelKey(tunnelKey);
         }
 
-        List<ActionInfo> listActionInfo = new ArrayList<>();
         try {
-            Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManager
-                .getEgressActionsForInterface(egressActionsBuilder.build());
-            RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
-            if (!rpcResult.isSuccessful()) {
-                LOG.error("getEgressActionsForInterface : RPC Call to Get egress actions for interface {} "
-                        + "returned with Errors {}", ifName, rpcResult.getErrors());
+            RpcResult<GetEgressActionsForTunnelOutput> rpcResultItm = null;
+            RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = null;
+            List<Action> actions = Collections.emptyList();
+            if (interfaceManager.isItmDirectTunnelsEnabled()) {
+                rpcResultItm =
+                        itmRpcService.getEgressActionsForTunnel(egressActionsItmBuilder.build()).get();
             } else {
-                List<Action> actions = rpcResult.getResult().getAction();
-                for (Action action : actions) {
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
-                        actionClass = action.getAction();
-                    if (actionClass instanceof OutputActionCase) {
-                        listActionInfo.add(new ActionOutput(pos++,
-                            ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
-                    } else if (actionClass instanceof PushVlanActionCase) {
-                        listActionInfo.add(new ActionPushVlan(pos++));
-                    } else if (actionClass instanceof SetFieldCase) {
-                        if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
-                            int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId()
-                                .getVlanId().getValue();
-                            listActionInfo.add(new ActionSetFieldVlanVid(pos++, vlanVid));
-                        }
-                    } else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
-                        Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
-                        listActionInfo.add(new ActionNxResubmit(pos++, tableId));
-                    } else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
-                        NxRegLoad nxRegLoad =
-                            ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
-                        listActionInfo.add(new ActionRegLoad(pos++, NxmNxReg6.class, nxRegLoad.getDst().getStart(),
-                            nxRegLoad.getDst().getEnd(), nxRegLoad.getValue().longValue()));
+                rpcResult =
+                        odlInterfaceRpcService.getEgressActionsForInterface(egressActionsIfmBuilder.build()).get();
+            }
+
+            if (!interfaceManager.isItmDirectTunnelsEnabled() && rpcResult != null) {
+                if (!rpcResult.isSuccessful()) {
+                    LOG.error("getEgressActionsForInterface : RPC Call to Get egress actions for interface {} "
+                            + "returned with Errors {}", ifName, rpcResult.getErrors());
+                } else {
+                    actions = rpcResult.getResult().getAction();
+                }
+            } else if (interfaceManager.isItmDirectTunnelsEnabled() && rpcResultItm != null) {
+                if (!rpcResultItm.isSuccessful()) {
+                    LOG.error("getEgressActionsForTunnels : RPC Call to Get egress actions for Tunnels {} "
+                            + "returned with Errors {}", ifName, rpcResultItm.getErrors());
+                } else {
+                    actions = rpcResultItm.getResult().getAction();
+                }
+            }
+            List<ActionInfo> listActionInfo = new ArrayList<>();
+            for (Action action : actions) {
+                org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
+                    actionClass = action.getAction();
+                if (actionClass instanceof OutputActionCase) {
+                    listActionInfo.add(new ActionOutput(pos++,
+                        ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
+                } else if (actionClass instanceof PushVlanActionCase) {
+                    listActionInfo.add(new ActionPushVlan(pos++));
+                } else if (actionClass instanceof SetFieldCase) {
+                    if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
+                        int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId()
+                            .getVlanId().getValue();
+                        listActionInfo.add(new ActionSetFieldVlanVid(pos++, vlanVid));
                     }
+                } else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
+                    Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
+                    listActionInfo.add(new ActionNxResubmit(pos++, tableId));
+                } else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
+                    NxRegLoad nxRegLoad =
+                        ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
+                    listActionInfo.add(new ActionRegLoad(pos++, NxmNxReg6.class, nxRegLoad.getDst().getStart(),
+                        nxRegLoad.getDst().getEnd(), nxRegLoad.getValue().longValue()));
                 }
             }
+            return listActionInfo;
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("Exception when egress actions for interface {}", ifName, e);
         }
-        return listActionInfo;
+        LOG.error("Error when getting egress actions for interface {}", ifName);
+        return Collections.emptyList();
     }
 
     public static Port getNeutronPortForRouterGetewayIp(DataBroker broker, IpAddress targetIP) {
index 660a8f6ead77b11296e45729716f0250c17dcc41..a57264c604b0888c63edc858a6737693c46ed281 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.netvirt.natservice.internal;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.infrautils.inject.AbstractLifecycle;
 import org.opendaylight.netvirt.elanmanager.api.IElanService;
@@ -30,28 +31,30 @@ public class SnatServiceImplFactory extends AbstractLifecycle {
     private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalManager;
     private final ItmRpcService itmManager;
-    private final OdlInterfaceRpcService interfaceManager;
+    private final OdlInterfaceRpcService odlInterfaceRpcService;
     private final IdManagerService idManager;
     private final NAPTSwitchSelector naptSwitchSelector;
     private final NatMode natMode;
     private final INeutronVpnManager nvpnManager;
     private final ExternalRoutersListener externalRouterListener;
     private final IElanService elanManager;
+    private final IInterfaceManager interfaceManager;
 
     @Inject
     public SnatServiceImplFactory(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
-            final ItmRpcService itmManager,
-            final OdlInterfaceRpcService interfaceManager,
-            final IdManagerService idManager,
-            final NAPTSwitchSelector naptSwitchSelector,
-            final NatserviceConfig config,
-            final INeutronVpnManager nvpnManager,
-            final ExternalRoutersListener externalRouterListener,
-            final IElanService elanManager) {
+                                  final ItmRpcService itmManager,
+                                  final OdlInterfaceRpcService odlInterfaceRpcService,
+                                  final IdManagerService idManager,
+                                  final NAPTSwitchSelector naptSwitchSelector,
+                                  final NatserviceConfig config,
+                                  final INeutronVpnManager nvpnManager,
+                                  final ExternalRoutersListener externalRouterListener,
+                                  final IElanService elanManager,
+                                  final IInterfaceManager interfaceManager) {
         this.dataBroker = dataBroker;
         this.mdsalManager = mdsalManager;
         this.itmManager = itmManager;
-        this.interfaceManager = interfaceManager;
+        this.odlInterfaceRpcService = odlInterfaceRpcService;
         this.idManager = idManager;
         this.naptSwitchSelector = naptSwitchSelector;
         if (config != null) {
@@ -62,6 +65,7 @@ public class SnatServiceImplFactory extends AbstractLifecycle {
         this.nvpnManager = nvpnManager;
         this.externalRouterListener = externalRouterListener;
         this.elanManager = elanManager;
+        this.interfaceManager = interfaceManager;
     }
 
     @Override
@@ -77,8 +81,8 @@ public class SnatServiceImplFactory extends AbstractLifecycle {
     public AbstractSnatService createFlatVlanSnatServiceImpl() {
 
         if (natMode == NatMode.Conntrack) {
-            return new FlatVlanConntrackBasedSnatService(dataBroker, mdsalManager, itmManager, interfaceManager,
-                    idManager, naptSwitchSelector);
+            return new FlatVlanConntrackBasedSnatService(dataBroker, mdsalManager, itmManager, odlInterfaceRpcService,
+                    idManager, naptSwitchSelector, interfaceManager);
         }
         return null;
     }
@@ -88,8 +92,8 @@ public class SnatServiceImplFactory extends AbstractLifecycle {
         if (natMode == NatMode.Conntrack) {
             NatOverVxlanUtil.validateAndCreateVxlanVniPool(dataBroker, nvpnManager, idManager,
                     NatConstants.ODL_VNI_POOL_NAME);
-            return new VxlanGreConntrackBasedSnatService(dataBroker, mdsalManager, itmManager, interfaceManager,
-                    idManager, naptSwitchSelector, externalRouterListener, elanManager);
+            return new VxlanGreConntrackBasedSnatService(dataBroker, mdsalManager, itmManager, odlInterfaceRpcService,
+                    idManager, naptSwitchSelector, externalRouterListener, elanManager, interfaceManager);
         }
         return null;
     }
index 531080aa6b401ccf1822f3ce537a4a6d3da502b4..a3598dc1e5ffed8266495c5946a16ff8b20dc5c1 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.GroupEntity;
@@ -59,10 +60,12 @@ public class VxlanGreConntrackBasedSnatService extends ConntrackBasedSnatService
     private final IElanService elanManager;
 
     public VxlanGreConntrackBasedSnatService(DataBroker dataBroker, IMdsalApiManager mdsalManager,
-            ItmRpcService itmManager, OdlInterfaceRpcService interfaceManager, IdManagerService idManager,
-            NAPTSwitchSelector naptSwitchSelector,
-            ExternalRoutersListener externalRouterListener, IElanService elanManager) {
-        super(dataBroker, mdsalManager, itmManager, interfaceManager, idManager, naptSwitchSelector);
+                                             ItmRpcService itmManager, OdlInterfaceRpcService odlInterfaceRpcService,
+                                             IdManagerService idManager, NAPTSwitchSelector naptSwitchSelector,
+                                             ExternalRoutersListener externalRouterListener, IElanService elanManager,
+                                             IInterfaceManager interfaceManager) {
+        super(dataBroker, mdsalManager, itmManager, idManager, naptSwitchSelector, odlInterfaceRpcService,
+                interfaceManager);
         this.externalRouterListener = externalRouterListener;
         this.elanManager = elanManager;
     }
@@ -300,7 +303,8 @@ public class VxlanGreConntrackBasedSnatService extends ConntrackBasedSnatService
         List<BucketInfo> listBucketInfo = new ArrayList<>();
         if (ifNamePrimary != null) {
             LOG.debug("installSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
-            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
+            listActionInfoPrimary = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmManager,
+                    interfaceManager, ifNamePrimary, routerId);
         }
         BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
         listBucketInfo.add(0, bucketPrimary);
index 78f0ec2d9385a20a54ef4751b79ac94f08ddd196..d5b2dd6fa3f07770957c4ff4180e255638438ca6 100644 (file)
@@ -21,9 +21,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetTunnelTypeInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetTunnelTypeOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelTypeOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.ExtrarouteRdsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.extraroute.rds.map.ExtrarouteRds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.extraroute.rds.map.ExtrarouteRdsKey;
@@ -127,11 +127,10 @@ public final class VpnExtraRouteHelper {
         return extraRoutesList;
     }
 
-    public static Class<? extends TunnelTypeBase> getTunnelType(OdlInterfaceRpcService interfaceManager,
-            String ifName) {
+    public static Class<? extends TunnelTypeBase> getTunnelType(ItmRpcService itmRpcService, String ifName) {
         try {
-            Future<RpcResult<GetTunnelTypeOutput>> result = interfaceManager.getTunnelType(
-                    new GetTunnelTypeInputBuilder().setIntfName(ifName).build());
+            Future<RpcResult<GetTunnelTypeOutput>> result =
+                    itmRpcService.getTunnelType(new GetTunnelTypeInputBuilder().setIntfName(ifName).build());
             RpcResult<GetTunnelTypeOutput> rpcResult = result.get();
             if (!rpcResult.isSuccessful()) {
                 LOG.warn("RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
index 6497f8101577dc6390ce5ce689c7e32f0812bcb0..8010ed730c6f9abb489c0135478341eac18e4159 100644 (file)
@@ -59,6 +59,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency;
@@ -91,6 +92,7 @@ public class VpnManagerImpl implements IVpnManager {
     private final InterVpnLinkCache interVpnLinkCache;
     private final DataTreeEventCallbackRegistrar eventCallbacks;
     private final UpgradeState upgradeState;
+    private final ItmRpcService itmRpcService;
 
     @Inject
     public VpnManagerImpl(final DataBroker dataBroker,
@@ -105,7 +107,8 @@ public class VpnManagerImpl implements IVpnManager {
                           final IBgpManager bgpManager,
                           final InterVpnLinkCache interVpnLinkCache,
                           final DataTreeEventCallbackRegistrar dataTreeEventCallbackRegistrar,
-                          final UpgradeState upgradeState) {
+                          final UpgradeState upgradeState,
+                          final ItmRpcService itmRpcService) {
         this.dataBroker = dataBroker;
         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
         this.idManager = idManagerService;
@@ -120,6 +123,7 @@ public class VpnManagerImpl implements IVpnManager {
         this.interVpnLinkCache = interVpnLinkCache;
         this.eventCallbacks = dataTreeEventCallbackRegistrar;
         this.upgradeState = upgradeState;
+        this.itmRpcService = itmRpcService;
     }
 
     @PostConstruct
@@ -672,7 +676,8 @@ public class VpnManagerImpl implements IVpnManager {
         instructions.add(
                 new InstructionWriteMetadata(BigInteger.ZERO, MetaDataUtil.METADATA_MASK_SH_FLAG).buildInstruction(1));
         instructions.addAll(
-                ArpResponderUtil.getExtInterfaceInstructions(interfaceManager, extInterfaceName, fixedIp, macAddress));
+                ArpResponderUtil.getExtInterfaceInstructions(interfaceManager, itmRpcService, extInterfaceName,
+                        fixedIp, macAddress));
         ArpReponderInputBuilder builder = new ArpReponderInputBuilder().setDpId(dpnId)
                 .setInterfaceName(extInterfaceName).setSpa(fixedIp).setSha(macAddress).setLportTag(lportTag);
         builder.setInstructions(instructions);
index 4bea1affb5a4aebead54491a14a77aae4b38becd..eda4fe9a0bfe3155ee78e3b82aeb2e8bce04d8ad 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.netvirt.vpnmanager.VpnUtil;
 import org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,6 +48,11 @@ public class ArpResponderHandler {
      */
     private final IInterfaceManager interfaceManager;
 
+    /**
+     * RPC to access ITM APIs.
+     */
+    private final ItmRpcService itmRpcService;
+
     /**
      * Constructor.
      *
@@ -59,10 +65,12 @@ public class ArpResponderHandler {
      *
      */
     @Inject
-    public ArpResponderHandler(DataBroker dataBroker, IElanService elanService, IInterfaceManager interfaceManager) {
+    public ArpResponderHandler(DataBroker dataBroker, IElanService elanService, IInterfaceManager interfaceManager,
+                               ItmRpcService itmRpcService) {
         this.dataBroker = dataBroker;
         this.elanService = elanService;
         this.interfaceManager = interfaceManager;
+        this.itmRpcService = itmRpcService;
     }
 
     /**
@@ -86,8 +94,8 @@ public class ArpResponderHandler {
         LOG.trace("Creating the ARP Responder flow for VPN Interface {}", interfaceName);
         ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
         builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(gatewayIp).setSha(mac).setLportTag(lportTag);
-        builder.setInstructions(
-                ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, gatewayIp, mac));
+        builder.setInstructions(ArpResponderUtil
+                .getInterfaceInstructions(interfaceManager, interfaceName, gatewayIp, mac, itmRpcService));
         elanService.addArpResponderFlow(builder.buildForInstallFlow());
     }
 
index a2a9d077283fb071bf5a9d3b9155a10f0b8dbbd3..06b098bdce4951750754cfc2239d3bea0c7f9153 100644 (file)
@@ -44,6 +44,8 @@
                    interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService" />
   <odl:rpc-service id="alivenessMonitorService"
                    interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService" />
+  <odl:rpc-service id="itmRpcService"
+                   interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService"/>
 
   <service ref="dpnInVpnChangeListener" odl:type="default"
            interface="org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.OdlL3vpnListener" />