2 * Copyright (c) 2013, 2015 Red Hat, Inc. and others. All rights reserved.
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
9 package org.opendaylight.ovsdb.openstack.netvirt;
11 import java.net.HttpURLConnection;
13 import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
14 import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
15 import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityGroupAware;
16 import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityRuleAware;
17 import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
18 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
19 import org.osgi.framework.ServiceReference;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Handle requests for OpenStack Neutron v2.0 Port Security API calls.
26 public class PortSecurityHandler extends AbstractHandler
27 implements INeutronSecurityGroupAware, INeutronSecurityRuleAware, ConfigInterface {
29 private static final Logger LOG = LoggerFactory.getLogger(PortSecurityHandler.class);
32 public int canCreateNeutronSecurityGroup(NeutronSecurityGroup neutronSecurityGroup) {
33 return HttpURLConnection.HTTP_CREATED;
37 public void neutronSecurityGroupCreated(NeutronSecurityGroup neutronSecurityGroup) {
38 int result = canCreateNeutronSecurityGroup(neutronSecurityGroup);
39 if (result != HttpURLConnection.HTTP_CREATED) {
40 LOG.debug("Neutron Security Group creation failed {} ", result);
45 public int canUpdateNeutronSecurityGroup(NeutronSecurityGroup delta, NeutronSecurityGroup original) {
46 return HttpURLConnection.HTTP_OK;
50 public void neutronSecurityGroupUpdated(NeutronSecurityGroup neutronSecurityGroup) {
55 public int canDeleteNeutronSecurityGroup(NeutronSecurityGroup neutronSecurityGroup) {
56 return HttpURLConnection.HTTP_OK;
60 public void neutronSecurityGroupDeleted(NeutronSecurityGroup neutronSecurityGroup) {
61 //TODO: Trigger flowmod removals
62 int result = canDeleteNeutronSecurityGroup(neutronSecurityGroup);
63 if (result != HttpURLConnection.HTTP_OK) {
64 LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
69 * Invoked when a Security Rules creation is requested
70 * to indicate if the specified Rule can be created.
72 * @param neutronSecurityRule An instance of proposed new Neutron Security Rule object.
73 * @return A HTTP status code to the creation request.
77 public int canCreateNeutronSecurityRule(NeutronSecurityRule neutronSecurityRule) {
78 return HttpURLConnection.HTTP_CREATED;
82 public void neutronSecurityRuleCreated(NeutronSecurityRule neutronSecurityRule) {
83 int result = canCreateNeutronSecurityRule(neutronSecurityRule);
84 if (result != HttpURLConnection.HTTP_CREATED) {
85 LOG.debug("Neutron Security Group creation failed {} ", result);
90 public int canUpdateNeutronSecurityRule(NeutronSecurityRule delta, NeutronSecurityRule original) {
91 return HttpURLConnection.HTTP_OK;
95 public void neutronSecurityRuleUpdated(NeutronSecurityRule neutronSecurityRule) {
100 public int canDeleteNeutronSecurityRule(NeutronSecurityRule neutronSecurityRule) {
101 return HttpURLConnection.HTTP_OK;
105 public void neutronSecurityRuleDeleted(NeutronSecurityRule neutronSecurityRule) {
106 int result = canDeleteNeutronSecurityRule(neutronSecurityRule);
107 if (result != HttpURLConnection.HTTP_OK) {
108 LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
115 * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
116 * @see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
119 public void processEvent(AbstractEvent abstractEvent) {
120 if (!(abstractEvent instanceof NorthboundEvent)) {
121 LOG.error("Unable to process abstract event {}", abstractEvent);
124 NorthboundEvent ev = (NorthboundEvent) abstractEvent;
125 switch (ev.getAction()) {
126 // TODO: add handling of events here, once callbacks do something
127 // other than logging.
129 LOG.warn("Unable to process event action {}", ev.getAction());
135 public void setDependencies(ServiceReference serviceReference) {
137 (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
138 eventDispatcher.eventHandlerAdded(serviceReference, this);
142 public void setDependencies(Object impl) {}