IFM: InterfaceStatecache not updated correctly
[genius.git] / interfacemanager / interfacemanager-impl / src / main / java / org / opendaylight / genius / interfacemanager / InterfacemgrProvider.java
index cc61324b50aee94e9915753cae6520cb70ccbeca..7a306159ba57cbc461bfe1a5aa756dcb58d8a10b 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.genius.interfacemanager.statusanddiag.InterfaceStatusMon
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+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;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
@@ -93,6 +93,8 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
     private InterfaceManagerRpcService interfaceManagerRpcService;
     private BindingAwareBroker.RpcRegistration<OdlInterfaceRpcService> rpcRegistration;
     private NodeConnectorStatsImpl nodeConnectorStatsManager;
+    private CacheInterfaceConfigListener cacheInterfaceConfigListener;
+    private CacheInterfaceStateListener cacheInterfaceStateListener;
 
     public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) {
         this.rpcProviderRegistry = rpcProviderRegistry;
@@ -107,6 +109,10 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
         this.notificationService = notificationService;
     }
 
+    public DataBroker getDataBroker(){
+        return this.dataBroker;
+    }
+
     @Override
     public void onSessionInitiated(ProviderContext session) {
         LOG.info("InterfacemgrProvider Session Initiated");
@@ -136,7 +142,7 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
             terminationPointStateListener = new TerminationPointStateListener(dataBroker);
             terminationPointStateListener.registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
 
-            flowBasedServicesConfigListener = new FlowBasedServicesConfigListener(dataBroker);
+            flowBasedServicesConfigListener = new FlowBasedServicesConfigListener(this);
             flowBasedServicesConfigListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
 
             flowBasedServicesInterfaceStateListener =
@@ -153,6 +159,10 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
             alivenessMonitorListener = new org.opendaylight.genius.interfacemanager.listeners.AlivenessMonitorListener(dataBroker);
             notificationService.registerNotificationListener(alivenessMonitorListener);
 
+            cacheInterfaceConfigListener = new CacheInterfaceConfigListener(dataBroker);
+
+            cacheInterfaceStateListener = new CacheInterfaceStateListener(dataBroker);
+
             //Initialize nodeconnectorstatsimpl
             nodeConnectorStatsManager = new NodeConnectorStatsImpl(dataBroker, notificationService,
                     session.getRpcService(OpendaylightPortStatisticsService.class), session.getRpcService(OpendaylightFlowTableStatisticsService.class));
@@ -187,6 +197,8 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
         LOG.info("InterfacemgrProvider Closed");
         interfaceConfigListener.close();
         rpcRegistration.close();
+        cacheInterfaceConfigListener.close();
+        cacheInterfaceStateListener.close();
     }
 
     public RpcProviderRegistry getRpcProviderRegistry() {
@@ -225,7 +237,6 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
 
     @Override
     public InterfaceInfo getInterfaceInfo(String interfaceName) {
-        //FIXME [ELANBE] This is not working yet, fix this
 
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface
                 ifState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
@@ -244,28 +255,20 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
 
         NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(intf.getName(), dataBroker);
         InterfaceInfo.InterfaceType interfaceType = IfmUtil.getInterfaceType(intf);
-        InterfaceInfo interfaceInfo = null;
+        InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
         BigInteger dpId = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_DPID;
         Integer portNo = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_PORT_NO;
         if (ncId != null) {
             dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId));
             portNo = Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId));
         }
-
         if (interfaceType == InterfaceInfo.InterfaceType.VLAN_INTERFACE) {
             interfaceInfo = IfmUtil.getVlanInterfaceInfo(interfaceName, intf, dpId);
-        } else if (interfaceType == InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE || interfaceType == InterfaceInfo.InterfaceType.GRE_TRUNK_INTERFACE) {/*
-            trunkInterfaceInfo trunkInterfaceInfo = (TrunkInterfaceInfo) ConfigIfmUtil.getTrunkInterfaceInfo(ifName, ConfigIfmUtil.getInterfaceByIfName(dataBroker, ifName));
-            String higherLayerIf = inf.getHigherLayerIf().get(0);
-            Interface vlanInterface = ConfigIfmUtil.getInterfaceByIfName(dataBroker, higherLayerIf);
-            trunkInterfaceInfo.setPortName(vlanInterface.getAugmentation(BaseConfig.class).getParentInterface());
-            trunkInterfaceManager.updateTargetMacAddressInInterfaceInfo(trunkInterfaceInfo, trunkInterface);
-            if (trunkInterface.getPhysAddress() != null) {
-                trunkInterfaceInfo.setLocalMacAddress(trunkInterface.getPhysAddress().getValue());
-            }
-            interfaceInfo = trunkInterfaceInfo;
-            interfaceInfo.setL2domainGroupId(IfmUtil.getGroupId(OperationalIfmUtil.getInterfaceStateByIfName(dataBroker, higherLayerIf).getIfIndex(), InterfaceType.VLAN_INTERFACE));
-        */
+        } else if (interfaceType == InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE ||
+                interfaceType == InterfaceInfo.InterfaceType.GRE_TRUNK_INTERFACE) {
+            // TODO : since there is no logical grouping for tunnel interfaces, there is no need
+            // for this code as of now. will be revisited once the support comes
+
         } else {
             LOG.error("Type of Interface {} is unknown", interfaceName);
             return null;
@@ -451,4 +454,4 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
         return InterfaceManagerCommonUtils.getAllTunnelInterfaces(dataBroker,
                 InterfaceInfo.InterfaceType.VXLAN_TRUNK_INTERFACE);
     }
-}
\ No newline at end of file
+}