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 : Brent Salisbury, Madhu Venugopal
11 package org.opendaylight.ovsdb.neutron;
13 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupAware;
14 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleAware;
15 import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
16 import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 import java.net.HttpURLConnection;
23 * Handle requests for OpenStack Neutron v2.0 Port Security API calls.
25 public class PortSecurityHandler extends BaseHandler
26 implements INeutronSecurityGroupAware, INeutronSecurityRuleAware{
28 static final Logger logger = LoggerFactory.getLogger(PortSecurityHandler.class);
31 public int canCreateNeutronSecurityGroup(NeutronSecurityGroup neutronSecurityGroup) {
32 return HttpURLConnection.HTTP_CREATED;
36 public void neutronSecurityGroupCreated(NeutronSecurityGroup neutronSecurityGroup) {
37 int result = HttpURLConnection.HTTP_BAD_REQUEST;
39 result = canCreateNeutronSecurityGroup(neutronSecurityGroup);
40 if (result != HttpURLConnection.HTTP_CREATED) {
41 logger.debug("Neutron Security Group creation failed {} ", result);
47 public int canUpdateNeutronSecurityGroup(NeutronSecurityGroup delta, NeutronSecurityGroup original) {
48 return HttpURLConnection.HTTP_OK;
52 public void neutronSecurityGroupUpdated(NeutronSecurityGroup neutronSecurityGroup) {
57 public int canDeleteNeutronSecurityGroup(NeutronSecurityGroup neutronSecurityGroup) {
58 return HttpURLConnection.HTTP_OK;
62 public void neutronSecurityGroupDeleted(NeutronSecurityGroup neutronSecurityGroup) {
63 //TODO: Trigger flowmod removals
64 int result = canDeleteNeutronSecurityGroup(neutronSecurityGroup);
65 if (result != HttpURLConnection.HTTP_OK) {
66 logger.error(" delete Neutron Security Rule validation failed for result - {} ", result);
72 * Invoked when a Security Rules creation is requested
73 * to indicate if the specified Rule can be created.
75 * @param neutronSecurityRule An instance of proposed new Neutron Security Rule object.
76 * @return A HTTP status code to the creation request.
80 public int canCreateNeutronSecurityRule(NeutronSecurityRule neutronSecurityRule) {
81 return HttpURLConnection.HTTP_CREATED;
85 public void neutronSecurityRuleCreated(NeutronSecurityRule neutronSecurityRule) {
86 int result = HttpURLConnection.HTTP_BAD_REQUEST;
88 result = canCreateNeutronSecurityRule(neutronSecurityRule);
89 if (result != HttpURLConnection.HTTP_CREATED) {
90 logger.debug("Neutron Security Group creation failed {} ", result);
96 public int canUpdateNeutronSecurityRule(NeutronSecurityRule delta, NeutronSecurityRule original) {
97 return HttpURLConnection.HTTP_OK;
101 public void neutronSecurityRuleUpdated(NeutronSecurityRule neutronSecurityRule) {
106 public int canDeleteNeutronSecurityRule(NeutronSecurityRule neutronSecurityRule) {
107 return HttpURLConnection.HTTP_OK;
111 public void neutronSecurityRuleDeleted(NeutronSecurityRule neutronSecurityRule) {
112 int result = canDeleteNeutronSecurityRule(neutronSecurityRule);
113 if (result != HttpURLConnection.HTTP_OK) {
114 logger.error(" delete Neutron Security Rule validation failed for result - {} ", result);