*/
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.api.EventDispatcher;
+import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Handle requests for Neutron Floating IP.
*/
public class FloatingIPHandler extends AbstractHandler
- implements INeutronFloatingIPAware {
+ implements INeutronFloatingIPAware, ConfigInterface {
- /**
- * Logger instance.
- */
static final Logger logger = LoggerFactory.getLogger(FloatingIPHandler.class);
- private volatile OvsdbConfigurationService ovsdbConfigurationService;
- private volatile OvsdbConnectionService connectionService;
- private volatile OvsdbInventoryListener ovsdbInventoryListener;
+ // The implementation for each of these services is resolved by the OSGi Service Manager
+ private volatile NeutronL3Adapter neutronL3Adapter;
+ private volatile EventDispatcher eventDispatcher;
/**
* Services provide this interface method to indicate if the specified floatingIP can be created
*/
@Override
public void neutronFloatingIPCreated(NeutronFloatingIP floatingIP) {
- logger.debug(" Floating IP created {}, uuid {}",
- floatingIP.getFixedIPAddress(),
- floatingIP.getFloatingIPUUID());
+ enqueueEvent(new NorthboundEvent(floatingIP, Action.ADD));
}
/**
*/
@Override
public void neutronFloatingIPUpdated(NeutronFloatingIP floatingIP) {
- logger.debug(" Floating IP updated {}, uuid {}",
- floatingIP.getFixedIPAddress(),
- floatingIP.getFloatingIPUUID());
+ enqueueEvent(new NorthboundEvent(floatingIP, Action.UPDATE));
}
/**
*/
@Override
public void neutronFloatingIPDeleted(NeutronFloatingIP floatingIP) {
- logger.debug(" Floating IP deleted {}, uuid {}",
- floatingIP.getFixedIPAddress(),
- floatingIP.getFloatingIPUUID());
+ enqueueEvent(new NorthboundEvent(floatingIP, Action.DELETE));
}
+
+ /**
+ * Process the event.
+ *
+ * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
+ * @see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
+ */
+ @Override
+ public void processEvent(AbstractEvent abstractEvent) {
+ if (!(abstractEvent instanceof NorthboundEvent)) {
+ logger.error("Unable to process abstract event " + abstractEvent);
+ return;
+ }
+ NorthboundEvent ev = (NorthboundEvent) abstractEvent;
+ switch (ev.getAction()) {
+ 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;
+ }
+ }
+
+ @Override
+ public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+ eventDispatcher =
+ (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
+ eventDispatcher.eventHandlerAdded(
+ bundleContext.getServiceReference(INeutronFloatingIPAware.class.getName()), this);
+ super.setDispatcher(eventDispatcher);
+ neutronL3Adapter =
+ (NeutronL3Adapter) ServiceHelper.getGlobalInstance(NeutronL3Adapter.class, this);
+ }
+
+ @Override
+ public void setDependencies(Object impl) {}
}