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 : Madhu Venugopal, Brent Salisbury
10 package org.opendaylight.ovsdb.neutron;
12 import java.net.HttpURLConnection;
14 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
15 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * Handle requests for Neutron Network.
22 public class NetworkHandler extends BaseHandler
23 implements INeutronNetworkAware {
27 static final Logger logger = LoggerFactory.getLogger(NetworkHandler.class);
30 * Invoked when a network creation is requested
31 * to indicate if the specified network can be created.
33 * @param network An instance of proposed new Neutron Network object.
34 * @return A HTTP status code to the creation request.
37 public int canCreateNetwork(NeutronNetwork network) {
38 if (network.isShared()) {
39 logger.error(" Network shared attribute not supported ");
40 return HttpURLConnection.HTTP_NOT_ACCEPTABLE;
43 return HttpURLConnection.HTTP_CREATED;
47 * Invoked to take action after a network has been created.
49 * @param network An instance of new Neutron Network object.
52 public void neutronNetworkCreated(NeutronNetwork network) {
53 int result = HttpURLConnection.HTTP_BAD_REQUEST;
55 result = canCreateNetwork(network);
56 if (result != HttpURLConnection.HTTP_CREATED) {
57 logger.debug("Network creation failed {} ", result);
64 * Invoked when a network update is requested
65 * to indicate if the specified network can be changed
66 * using the specified delta.
68 * @param delta Updates to the network object using patch semantics.
69 * @param original An instance of the Neutron Network object
71 * @return A HTTP status code to the update request.
74 public int canUpdateNetwork(NeutronNetwork delta,
75 NeutronNetwork original) {
76 return HttpURLConnection.HTTP_OK;
80 * Invoked to take action after a network has been updated.
82 * @param network An instance of modified Neutron Network object.
85 public void neutronNetworkUpdated(NeutronNetwork network) {
90 * Invoked when a network deletion is requested
91 * to indicate if the specified network can be deleted.
93 * @param network An instance of the Neutron Network object to be deleted.
94 * @return A HTTP status code to the deletion request.
97 public int canDeleteNetwork(NeutronNetwork network) {
98 return HttpURLConnection.HTTP_OK;
102 * Invoked to take action after a network has been deleted.
104 * @param network An instance of deleted Neutron Network object.
107 public void neutronNetworkDeleted(NeutronNetwork network) {
109 int result = canDeleteNetwork(network);
110 if (result != HttpURLConnection.HTTP_OK) {
111 logger.error(" deleteNetwork validation failed for result - {} ",
115 TenantNetworkManager.getManager().networkDeleted(network.getID());