X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=inline;f=openstack%2Fnet-virt%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fopenstack%2Fnetvirt%2FFloatingIPHandler.java;h=30e28ea438cfe4e0cdb284f262929ef744ec83c4;hb=72fe035fa1234f1f5a068979e5d71ea94e901e2b;hp=f04338e460679ca4ebecb8270468c3e1c747eaaa;hpb=ffb336975be25f06abbb291628916bbcda21818b;p=netvirt.git diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/FloatingIPHandler.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/FloatingIPHandler.java index f04338e460..30e28ea438 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/FloatingIPHandler.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/FloatingIPHandler.java @@ -1,40 +1,35 @@ /* - * Copyright (C) 2014 Red Hat, Inc. + * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Dave Tucker, Flavio Fernandes */ + 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 java.net.HttpURLConnection; +import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP; +import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFloatingIPAware; +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.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.HttpURLConnection; - /** * 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 static final Logger LOG = 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 +55,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 +84,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,30 +110,45 @@ 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)); } /** * Process the event. * * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled. - * @see EventDispatcher + * @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); + LOG.error("Unable to process abstract event {}", abstractEvent); return; } 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()); + LOG.warn("Unable to process event action {}", ev.getAction()); break; } } + + @Override + public void setDependencies(ServiceReference serviceReference) { + eventDispatcher = + (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this); + neutronL3Adapter = + (NeutronL3Adapter) ServiceHelper.getGlobalInstance(NeutronL3Adapter.class, this); + eventDispatcher.eventHandlerAdded(serviceReference, this); + } + + @Override + public void setDependencies(Object impl) {} }