2 * Copyright (C) 2014 Red Hat, Inc.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 * Authors : Dave Tucker, Flavio Fernandes
10 package org.opendaylight.ovsdb.openstack.netvirt;
12 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
13 import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
14 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
15 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
16 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 import java.net.HttpURLConnection;
24 * Handle requests for Neutron Floating IP.
26 public class FloatingIPHandler extends AbstractHandler
27 implements INeutronFloatingIPAware {
32 static final Logger logger = LoggerFactory.getLogger(FloatingIPHandler.class);
34 // The implementation for each of these services is resolved by the OSGi Service Manager
35 private volatile OvsdbConfigurationService ovsdbConfigurationService;
36 private volatile OvsdbConnectionService connectionService;
37 private volatile OvsdbInventoryListener ovsdbInventoryListener;
40 * Services provide this interface method to indicate if the specified floatingIP can be created
43 * instance of proposed new Neutron FloatingIP object
45 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
46 * results in the create operation being interrupted and the returned status value reflected in the
50 public int canCreateFloatingIP(NeutronFloatingIP floatingIP) {
51 return HttpURLConnection.HTTP_OK;
56 * Services provide this interface method for taking action after a floatingIP has been created
59 * instance of new Neutron FloatingIP object
62 public void neutronFloatingIPCreated(NeutronFloatingIP floatingIP) {
63 logger.debug(" Floating IP created {}, uuid {}",
64 floatingIP.getFixedIPAddress(),
65 floatingIP.getFloatingIPUUID());
69 * Services provide this interface method to indicate if the specified floatingIP can be changed using the specified
73 * updates to the floatingIP object using patch semantics
75 * instance of the Neutron FloatingIP object to be updated
77 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
78 * results in the update operation being interrupted and the returned status value reflected in the
82 public int canUpdateFloatingIP(NeutronFloatingIP delta, NeutronFloatingIP original) {
83 return HttpURLConnection.HTTP_OK;
87 * Services provide this interface method for taking action after a floatingIP has been updated
90 * instance of modified Neutron FloatingIP object
93 public void neutronFloatingIPUpdated(NeutronFloatingIP floatingIP) {
94 logger.debug(" Floating IP updated {}, uuid {}",
95 floatingIP.getFixedIPAddress(),
96 floatingIP.getFloatingIPUUID());
100 * Services provide this interface method to indicate if the specified floatingIP can be deleted
103 * instance of the Neutron FloatingIP object to be deleted
105 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
106 * results in the delete operation being interrupted and the returned status value reflected in the
110 public int canDeleteFloatingIP(NeutronFloatingIP floatingIP) {
111 return HttpURLConnection.HTTP_OK;
115 * Services provide this interface method for taking action after a floatingIP has been deleted
118 * instance of deleted Neutron FloatingIP object
121 public void neutronFloatingIPDeleted(NeutronFloatingIP floatingIP) {
122 logger.debug(" Floating IP deleted {}, uuid {}",
123 floatingIP.getFixedIPAddress(),
124 floatingIP.getFloatingIPUUID());
130 * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
131 * @see EventDispatcher
134 public void processEvent(AbstractEvent abstractEvent) {
135 if (!(abstractEvent instanceof NorthboundEvent)) {
136 logger.error("Unable to process abstract event " + abstractEvent);
139 NorthboundEvent ev = (NorthboundEvent) abstractEvent;
140 switch (ev.getAction()) {
141 // TODO: add handling of events here, once callbacks do something
142 // other than logging.
144 logger.warn("Unable to process event action " + ev.getAction());