2 * Copyright (C) 2013 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.INeutronRouterAware;
13 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
14 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface;
15 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
16 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
17 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 import java.net.HttpURLConnection;
25 * Handle requests for Neutron Router.
27 public class RouterHandler extends AbstractHandler
28 implements INeutronRouterAware {
33 static final Logger logger = LoggerFactory.getLogger(RouterHandler.class);
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 router can be created
43 * instance of proposed new Neutron Router 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 canCreateRouter(NeutronRouter router) {
51 return HttpURLConnection.HTTP_OK;
55 * Services provide this interface method for taking action after a router has been created
58 * instance of new Neutron Router object
61 public void neutronRouterCreated(NeutronRouter router) {
62 logger.debug(" Router created {}, uuid {}", router.getName(), router.getRouterUUID());
66 * Services provide this interface method to indicate if the specified router can be changed using the specified
70 * updates to the router object using patch semantics
72 * instance of the Neutron Router object to be updated
74 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
75 * results in the update operation being interrupted and the returned status value reflected in the
79 public int canUpdateRouter(NeutronRouter delta, NeutronRouter original) {
80 return HttpURLConnection.HTTP_OK;
84 * Services provide this interface method for taking action after a router has been updated
87 * instance of modified Neutron Router object
90 public void neutronRouterUpdated(NeutronRouter router) {
91 logger.debug(" Router updated {}", router.getName());
95 * Services provide this interface method to indicate if the specified router can be deleted
98 * instance of the Neutron Router object to be deleted
100 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
101 * results in the delete operation being interrupted and the returned status value reflected in the
105 public int canDeleteRouter(NeutronRouter router) {
106 return HttpURLConnection.HTTP_OK;
110 * Services provide this interface method for taking action after a router has been deleted
113 * instance of deleted Router Network object
116 public void neutronRouterDeleted(NeutronRouter router) {
117 logger.debug(" Router deleted {}, uuid {}", router.getName(), router.getRouterUUID());
121 * Services provide this interface method to indicate if the specified interface can be attached to the specified
125 * instance of the base Neutron Router object
126 * @param routerInterface
127 * instance of the NeutronRouter_Interface to be attached to the router
129 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
130 * results in the attach operation being interrupted and the returned status value reflected in the
134 public int canAttachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) {
135 logger.debug(" Router {} asked if it can attach interface {}. Subnet {}",
137 routerInterface.getPortUUID(),
138 routerInterface.getSubnetUUID());
139 return HttpURLConnection.HTTP_OK;
143 * Services provide this interface method for taking action after an interface has been added to a router
146 * instance of the base Neutron Router object
147 * @param routerInterface
148 * instance of the NeutronRouter_Interface being attached to the router
151 public void neutronRouterInterfaceAttached(NeutronRouter router, NeutronRouter_Interface routerInterface) {
152 logger.debug(" Router {} interface {} attached. Subnet {}", router.getName(), routerInterface.getPortUUID(),
153 routerInterface.getSubnetUUID());
157 * Services provide this interface method to indicate if the specified interface can be detached from the specified
161 * instance of the base Neutron Router object
162 * @param routerInterface
163 * instance of the NeutronRouter_Interface to be detached to the router
165 * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
166 * results in the detach operation being interrupted and the returned status value reflected in the
170 public int canDetachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) {
171 logger.debug(" Router {} asked if it can detach interface {}. Subnet {}",
173 routerInterface.getPortUUID(),
174 routerInterface.getSubnetUUID());
176 return HttpURLConnection.HTTP_OK;
180 * Services provide this interface method for taking action after an interface has been removed from a router
183 * instance of the base Neutron Router object
184 * @param routerInterface
185 * instance of the NeutronRouter_Interface being detached from the router
188 public void neutronRouterInterfaceDetached(NeutronRouter router, NeutronRouter_Interface routerInterface) {
189 logger.debug(" Router {} interface {} detached. Subnet {}", router.getName(), routerInterface.getPortUUID(),
190 routerInterface.getSubnetUUID());