Bug 5182 - Customized name support for VLAN trunk should be supported
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / listeners / InterfaceConfigListener.java
index 6e911667b56576ba0c7027419cfd9bcd4d2e0898..24c72e55551c950b21a8acb5cb3b6bb727458e6d 100644 (file)
@@ -16,8 +16,10 @@ import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
 import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigAddHelper;
 import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigRemoveHelper;
 import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigUpdateHelper;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -35,11 +37,17 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
     private static final Logger LOG = LoggerFactory.getLogger(InterfaceConfigListener.class);
     private DataBroker dataBroker;
     private IdManagerService idManager;
+    private AlivenessMonitorService alivenessMonitorService;
+    private IMdsalApiManager mdsalApiManager;
 
-    public InterfaceConfigListener(final DataBroker dataBroker, final IdManagerService idManager) {
+    public InterfaceConfigListener(final DataBroker dataBroker, final IdManagerService idManager,
+                                   final AlivenessMonitorService alivenessMonitorService,
+                                   final IMdsalApiManager mdsalApiManager) {
         super(Interface.class, InterfaceConfigListener.class);
         this.dataBroker = dataBroker;
         this.idManager = idManager;
+        this.alivenessMonitorService = alivenessMonitorService;
+        this.mdsalApiManager = mdsalApiManager;
     }
 
     @Override
@@ -59,15 +67,17 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         String parentInterface = null;
 
         ParentRefs parentRefs = interfaceOld.getAugmentation(ParentRefs.class);
-        if (parentRefs != null) {
-            parentInterface = parentRefs.getParentInterface();
+        /* parentInterface = parentRefs.getParentInterface();
             if (parentInterface != null && !parentInterface.equals(ifName)) {
                 return;
             }
             if (parentRefs.getDatapathNodeIdentifier() == null) {
                 return;
             }
-        }
+            if(parentInterface == null){
+                LOG.error("parent interface not specified for {}",interfaceOld.getName());
+            }
+        }*/
 
         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
         RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld, ifName, parentRefs);
@@ -80,14 +90,15 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         String ifNameNew = interfaceNew.getName();
         String parentInterface = null;
 
-        ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
-        if (parentRefs != null) {
-            parentInterface = parentRefs.getParentInterface();
+        /*ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
+        if (parentRefs == null) {
+            LOG.error("parent refs not specified for {}",interfaceNew.getName());
         }
 
-        if (parentInterface != null && !parentInterface.equals(ifNameNew)) {
+        if (parentInterface == null) {
+            LOG.error("parent interface not specified for {}",interfaceOld.getName());
             return;
-        }
+        }*/
 
         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
         RendererConfigUpdateWorker worker = new RendererConfigUpdateWorker(key, interfaceOld, interfaceNew, ifNameNew);
@@ -101,13 +112,13 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         String parentInterface = null;
 
         ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
-        if (parentRefs != null) {
-            parentInterface = parentRefs.getParentInterface();
+        if (parentRefs == null) {
+            LOG.error("parent refs not specified for {}",interfaceNew.getName());
         }
 
-        if (parentInterface != null && !parentInterface.equals(ifName)) {
-            return;
-        }
+        /*if(parentInterface == null){
+            LOG.error("parent interface not specified for {}",interfaceNew.getName());
+        }*/
 
         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
         RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs, ifName);
@@ -132,7 +143,8 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         public List<ListenableFuture<Void>> call() throws Exception {
             // If another renderer(for eg : CSS) needs to be supported, check can be performed here
             // to call the respective helpers.
-            return OvsInterfaceConfigAddHelper.addConfiguration(dataBroker, parentRefs, interfaceNew, idManager);
+            return OvsInterfaceConfigAddHelper.addConfiguration(dataBroker, parentRefs, interfaceNew,
+                    idManager, alivenessMonitorService, mdsalApiManager);
         }
 
         @Override
@@ -166,7 +178,8 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         public List<ListenableFuture<Void>> call() throws Exception {
             // If another renderer(for eg : CSS) needs to be supported, check can be performed here
             // to call the respective helpers.
-            return OvsInterfaceConfigUpdateHelper.updateConfiguration(dataBroker, idManager, interfaceNew, interfaceOld);
+            return OvsInterfaceConfigUpdateHelper.updateConfiguration(dataBroker, alivenessMonitorService, idManager,
+                    mdsalApiManager, interfaceNew, interfaceOld);
         }
 
         @Override
@@ -201,7 +214,8 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         public List<ListenableFuture<Void>> call() throws Exception {
             // If another renderer(for eg : CSS) needs to be supported, check can be performed here
             // to call the respective helpers.
-            return OvsInterfaceConfigRemoveHelper.removeConfiguration(dataBroker, interfaceOld, idManager, parentRefs);
+            return OvsInterfaceConfigRemoveHelper.removeConfiguration(dataBroker, alivenessMonitorService,
+                    interfaceOld, idManager, mdsalApiManager, parentRefs);
         }
 
         @Override