Reenable Neutron using YANG models
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / LispNeutronService.java
index bbaf7f61884dce4878db4416c556249db2f1e84d..327400050f300a591c5aaac6b9f02f9e575ecfc3 100644 (file)
@@ -5,77 +5,58 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.lispflowmapping.neutron;
 
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+public class LispNeutronService implements ILispNeutronService, BindingAwareProvider {
 
-public class LispNeutronService implements ILispNeutronService, BindingAwareProvider  {
-
-    protected static final Logger LOG = LoggerFactory.getLogger(LispNeutronService.class);
+    private static final Logger LOG = LoggerFactory.getLogger(LispNeutronService.class);
     private IFlowMapping mappingService;
     private OdlMappingserviceService lfmDbService;
-    private static ILispNeutronService neutronService;
-
+    protected DataBroker broker;
 
-    void setBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
-        LOG.debug("LISP NEUTRON BindingAwareBroker set!");
+    public LispNeutronService(IFlowMapping mappingService, BindingAwareBroker bindingAwareBroker) {
+        this.mappingService = mappingService;
         bindingAwareBroker.registerProvider(this);
-        neutronService = this;
-    }
-
-    void unsetBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
-
-    }
-
-    public static ILispNeutronService getLispNeutronService() {
-        return neutronService;
+        LOG.info("LISP NEUTRON SERVICE has been registered");
     }
 
-
     public IFlowMapping getMappingService() {
         return this.mappingService;
     }
 
+    @Override
     public OdlMappingserviceService getMappingDbService() {
         return this.lfmDbService;
     }
 
-    public void setMappingService(IFlowMapping mappingService) {
-        LOG.debug("MappingService set in Lisp Neutron");
-        this.mappingService = mappingService;
-    }
-
-    public void unsetMappingService(IFlowMapping mappingService) {
-        LOG.debug("MappingService was unset in LISP Neutron");
-        this.mappingService = null;
-    }
-
     @Override
     public void onSessionInitiated(ProviderContext session) {
-        LOG.debug("LFMDBSERVICE IS BEING FILLED! SESSION INITIATED");
+        LOG.info("LFMDBSERVICE IS BEING FILLED! SESSION INITIATED");
         RpcProviderRegistry rpcRegistry = session.getSALService(RpcProviderRegistry.class);
         lfmDbService = rpcRegistry.getRpcService(OdlMappingserviceService.class);
-        LOG.debug("LFMDBSERVICE was FILLED! SESSION INITIATED");
-
-    }
+        broker = session.getSALService(DataBroker.class);
 
-    public void stop() {
-        LOG.info("LISP Neutron Service is down!");
+        DelegatingDataTreeListener.initiateListener(Network.class, this, broker);
+        DelegatingDataTreeListener.initiateListener(Subnet.class, this, broker);
+        DelegatingDataTreeListener.initiateListener(Port.class, this, broker);
+        LOG.debug("LFMDBSERVICE was FILLED! SESSION INITIATED");
     }
 
-    public void destroy() {
-        LOG.debug("LISP Neutron Service is destroyed!");
+    public void close() {
         mappingService = null;
+        LOG.info("LISP Neutron Service is down!");
     }
-
 }