Merge "MD-SAL OVSDB SB - handle update to ovsdb node."
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / FloatingIPHandler.java
index f04338e460679ca4ebecb8270468c3e1c747eaaa..55fc3a67f008fa688182fdce2742c8ac9d6cdc5d 100644 (file)
@@ -9,11 +9,10 @@
  */
 package org.opendaylight.ovsdb.openstack.netvirt;
 
-import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
+import org.opendaylight.neutron.spi.INeutronFloatingIPAware;
+import org.opendaylight.neutron.spi.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,9 +31,7 @@ public class FloatingIPHandler extends AbstractHandler
     static final Logger logger = LoggerFactory.getLogger(FloatingIPHandler.class);
 
     // The implementation for each of these services is resolved by the OSGi Service Manager
-    private volatile OvsdbConfigurationService ovsdbConfigurationService;
-    private volatile OvsdbConnectionService connectionService;
-    private volatile OvsdbInventoryListener ovsdbInventoryListener;
+    private volatile NeutronL3Adapter neutronL3Adapter;
 
     /**
      * Services provide this interface method to indicate if the specified floatingIP can be created
@@ -60,9 +57,7 @@ public class FloatingIPHandler extends AbstractHandler
      */
     @Override
     public void neutronFloatingIPCreated(NeutronFloatingIP floatingIP) {
-        logger.debug(" Floating IP created {}, uuid {}",
-                     floatingIP.getFixedIPAddress(),
-                     floatingIP.getFloatingIPUUID());
+        enqueueEvent(new NorthboundEvent(floatingIP, Action.ADD));
     }
 
     /**
@@ -91,9 +86,7 @@ public class FloatingIPHandler extends AbstractHandler
      */
     @Override
     public void neutronFloatingIPUpdated(NeutronFloatingIP floatingIP) {
-        logger.debug(" Floating IP updated {}, uuid {}",
-                     floatingIP.getFixedIPAddress(),
-                     floatingIP.getFloatingIPUUID());
+        enqueueEvent(new NorthboundEvent(floatingIP, Action.UPDATE));
     }
 
     /**
@@ -119,9 +112,7 @@ public class FloatingIPHandler extends AbstractHandler
      */
     @Override
     public void neutronFloatingIPDeleted(NeutronFloatingIP floatingIP) {
-        logger.debug(" Floating IP deleted {}, uuid {}",
-                     floatingIP.getFixedIPAddress(),
-                     floatingIP.getFloatingIPUUID());
+        enqueueEvent(new NorthboundEvent(floatingIP, Action.DELETE));
     }
 
     /**
@@ -138,8 +129,13 @@ public class FloatingIPHandler extends AbstractHandler
         }
         NorthboundEvent ev = (NorthboundEvent) abstractEvent;
         switch (ev.getAction()) {
-            // TODO: add handling of events here, once callbacks do something
-            //       other than logging.
+            case ADD:
+                // fall through
+            case DELETE:
+                // fall through
+            case UPDATE:
+                neutronL3Adapter.handleNeutronFloatingIPEvent(ev.getNeutronFloatingIP(), ev.getAction());
+                break;
             default:
                 logger.warn("Unable to process event action " + ev.getAction());
                 break;