Merge "DHCP Handling for TOR VM"
[vpnservice.git] / dhcpservice / dhcpservice-impl / src / main / java / org / opendaylight / vpnservice / dhcpservice / DhcpProvider.java
index 439d7352ada125065e56709c544c8a17d38d72f4..f86b46424ec7de44a7f67eb263f2a0ecf9dcb214 100644 (file)
@@ -7,15 +7,18 @@
  */
 package org.opendaylight.vpnservice.dhcpservice;
 
-import org.opendaylight.vpnservice.neutronvpn.interfaces.INeutronVpnManager;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
-import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.vpnservice.neutronvpn.interfaces.INeutronVpnManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,6 +35,15 @@ public class DhcpProvider implements BindingAwareProvider, AutoCloseable {
     private DhcpConfigListener dhcpConfigListener;
     private OdlInterfaceRpcService interfaceManagerRpc;
     private DhcpInterfaceEventListener dhcpInterfaceEventListener;
+    private DhcpExternalTunnelManager dhcpExternalTunnelManager;
+    private DhcpNeutronPortListener dhcpNeutronPortListener;
+    private DhcpLogicalSwitchListener dhcpLogicalSwitchListener;
+    private DhcpUCastMacListener dhcpUCastMacListener;
+    private ItmRpcService itmRpcService;
+    private DhcpInterfaceConfigListener dhcpInterfaceConfigListener;
+    private EntityOwnershipService entityOwnershipService;
+    private DhcpDesignatedDpnListener dhcpDesignatedDpnListener;
+    private DhcpL2GatewayConnectionListener dhcpL2GatewayConnectionListener;
 
     @Override
     public void onSessionInitiated(ProviderContext session) {
@@ -42,19 +54,29 @@ public class DhcpProvider implements BindingAwareProvider, AutoCloseable {
             dhcpManager = new DhcpManager(dataBroker);
             dhcpManager.setMdsalManager(mdsalManager);
             dhcpManager.setNeutronVpnService(neutronVpnManager);
-            dhcpPktHandler = new DhcpPktHandler(dataBroker, dhcpManager);
+            dhcpExternalTunnelManager = new DhcpExternalTunnelManager(dataBroker, mdsalManager, itmRpcService, entityOwnershipService);
+            dhcpPktHandler = new DhcpPktHandler(dataBroker, dhcpManager, dhcpExternalTunnelManager);
             dhcpPktHandler.setPacketProcessingService(pktProcessingService);
             dhcpPktHandler.setInterfaceManagerRpc(interfaceManagerRpc);
             packetListener = notificationService.registerNotificationListener(dhcpPktHandler);
-            dhcpNodeListener = new NodeListener(dataBroker, dhcpManager);
+            dhcpNodeListener = new NodeListener(dataBroker, dhcpManager, dhcpExternalTunnelManager);
             dhcpConfigListener = new DhcpConfigListener(dataBroker, dhcpManager);
-            dhcpInterfaceEventListener = new DhcpInterfaceEventListener(dhcpManager, dataBroker);
+            dhcpInterfaceEventListener = new DhcpInterfaceEventListener(dhcpManager, dataBroker, dhcpExternalTunnelManager);
+            dhcpInterfaceConfigListener = new DhcpInterfaceConfigListener(dataBroker, dhcpExternalTunnelManager);
+            dhcpLogicalSwitchListener = new DhcpLogicalSwitchListener(dhcpExternalTunnelManager, dataBroker);
+            dhcpUCastMacListener = new DhcpUCastMacListener(dhcpExternalTunnelManager, dataBroker);
+            dhcpUCastMacListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+            dhcpNeutronPortListener = new DhcpNeutronPortListener(dataBroker, dhcpExternalTunnelManager);
+            dhcpNeutronPortListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+            dhcpDesignatedDpnListener = new DhcpDesignatedDpnListener(dhcpExternalTunnelManager, dataBroker);
+            dhcpDesignatedDpnListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+            dhcpL2GatewayConnectionListener = new DhcpL2GatewayConnectionListener(dataBroker, dhcpExternalTunnelManager);
+            dhcpL2GatewayConnectionListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
         } catch (Exception e) {
             LOG.error("Error initializing services {}", e);
         }
     }
 
-
     public void setMdsalManager(IMdsalApiManager mdsalManager) {
         this.mdsalManager = mdsalManager;
     }
@@ -84,4 +106,12 @@ public class DhcpProvider implements BindingAwareProvider, AutoCloseable {
     public void setInterfaceManagerRpc(OdlInterfaceRpcService interfaceManagerRpc) {
         this.interfaceManagerRpc = interfaceManagerRpc;
     }
+
+    public void setItmRpcService(ItmRpcService itmRpcService) {
+        this.itmRpcService = itmRpcService;
+    }
+
+    public void setEntityOwnershipService(EntityOwnershipService entityOwnershipService) {
+        this.entityOwnershipService = entityOwnershipService;
+    }
 }