1 package org.opendaylight.ovsdb.neutron;
3 import java.net.HttpURLConnection;
5 import org.opendaylight.controller.containermanager.ContainerConfig;
6 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
7 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
12 * Handle requests for Neutron Network.
14 public class NetworkHandler extends BaseHandler
15 implements INeutronNetworkAware {
19 static final Logger logger = LoggerFactory.getLogger(NetworkHandler.class);
22 * Invoked when a network creation is requested
23 * to indicate if the specified network can be created.
25 * @param network An instance of proposed new Neutron Network object.
26 * @return A HTTP status code to the creation request.
29 public int canCreateNetwork(NeutronNetwork network) {
30 if (network.isShared()) {
31 logger.error(" Network shared attribute not supported ");
32 return HttpURLConnection.HTTP_NOT_ACCEPTABLE;
35 return HttpURLConnection.HTTP_CREATED;
39 * Invoked to take action after a network has been created.
41 * @param network An instance of new Neutron Network object.
44 public void neutronNetworkCreated(NeutronNetwork network) {
45 int result = HttpURLConnection.HTTP_BAD_REQUEST;
47 result = canCreateNetwork(network);
48 if (result != HttpURLConnection.HTTP_CREATED) {
49 logger.debug("Network creation failed {} ", result);
53 TenantNetworkManager.getManager().networkCreated(network.getID());
57 * Invoked when a network update is requested
58 * to indicate if the specified network can be changed
59 * using the specified delta.
61 * @param delta Updates to the network object using patch semantics.
62 * @param original An instance of the Neutron Network object
64 * @return A HTTP status code to the update request.
67 public int canUpdateNetwork(NeutronNetwork delta,
68 NeutronNetwork original) {
69 return HttpURLConnection.HTTP_OK;
73 * Invoked to take action after a network has been updated.
75 * @param network An instance of modified Neutron Network object.
78 public void neutronNetworkUpdated(NeutronNetwork network) {
83 * Invoked when a network deletion is requested
84 * to indicate if the specified network can be deleted.
86 * @param network An instance of the Neutron Network object to be deleted.
87 * @return A HTTP status code to the deletion request.
90 public int canDeleteNetwork(NeutronNetwork network) {
91 return HttpURLConnection.HTTP_OK;
95 * Invoked to take action after a network has been deleted.
97 * @param network An instance of deleted Neutron Network object.
100 public void neutronNetworkDeleted(NeutronNetwork network) {
102 int result = canDeleteNetwork(network);
103 if (result != HttpURLConnection.HTTP_OK) {
104 logger.error(" deleteNetwork validation failed for result - {} ",
108 String networkID = convertNeutronIDToKey(network.getID());
110 ContainerConfig config = new ContainerConfig();
111 config.setContainer(networkID);
112 containerManager.removeContainer(config);