/*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (c) 2013, 2015 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Brent Salisbury, Madhu Venugopal
*/
package org.opendaylight.ovsdb.openstack.netvirt;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleAware;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
+import java.net.HttpURLConnection;
+import org.opendaylight.neutron.spi.INeutronSecurityGroupAware;
+import org.opendaylight.neutron.spi.INeutronSecurityRuleAware;
+import org.opendaylight.neutron.spi.NeutronSecurityGroup;
+import org.opendaylight.neutron.spi.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.HttpURLConnection;
-
/**
* Handle requests for OpenStack Neutron v2.0 Port Security API calls.
*/
public class PortSecurityHandler extends AbstractHandler
- implements INeutronSecurityGroupAware, INeutronSecurityRuleAware{
+ implements INeutronSecurityGroupAware, INeutronSecurityRuleAware, ConfigInterface {
- static final Logger logger = LoggerFactory.getLogger(PortSecurityHandler.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PortSecurityHandler.class);
@Override
public int canCreateNeutronSecurityGroup(NeutronSecurityGroup neutronSecurityGroup) {
@Override
public void neutronSecurityGroupCreated(NeutronSecurityGroup neutronSecurityGroup) {
- int result = HttpURLConnection.HTTP_BAD_REQUEST;
-
- result = canCreateNeutronSecurityGroup(neutronSecurityGroup);
+ int result = canCreateNeutronSecurityGroup(neutronSecurityGroup);
if (result != HttpURLConnection.HTTP_CREATED) {
- logger.debug("Neutron Security Group creation failed {} ", result);
- return;
+ LOG.debug("Neutron Security Group creation failed {} ", result);
}
}
@Override
public void neutronSecurityGroupUpdated(NeutronSecurityGroup neutronSecurityGroup) {
- return;
+ // Nothing to do
}
@Override
//TODO: Trigger flowmod removals
int result = canDeleteNeutronSecurityGroup(neutronSecurityGroup);
if (result != HttpURLConnection.HTTP_OK) {
- logger.error(" delete Neutron Security Rule validation failed for result - {} ", result);
- return;
+ LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
}
}
@Override
public void neutronSecurityRuleCreated(NeutronSecurityRule neutronSecurityRule) {
- int result = HttpURLConnection.HTTP_BAD_REQUEST;
-
- result = canCreateNeutronSecurityRule(neutronSecurityRule);
+ int result = canCreateNeutronSecurityRule(neutronSecurityRule);
if (result != HttpURLConnection.HTTP_CREATED) {
- logger.debug("Neutron Security Group creation failed {} ", result);
- return;
+ LOG.debug("Neutron Security Group creation failed {} ", result);
}
}
@Override
public void neutronSecurityRuleUpdated(NeutronSecurityRule neutronSecurityRule) {
- return;
+ // Nothing to do
}
@Override
public void neutronSecurityRuleDeleted(NeutronSecurityRule neutronSecurityRule) {
int result = canDeleteNeutronSecurityRule(neutronSecurityRule);
if (result != HttpURLConnection.HTTP_OK) {
- logger.error(" delete Neutron Security Rule validation failed for result - {} ", result);
- return;
+ LOG.error(" delete Neutron Security Rule validation failed for result - {} ", result);
}
}
@Override
public void processEvent(AbstractEvent abstractEvent) {
if (!(abstractEvent instanceof NorthboundEvent)) {
- logger.error("Unable to process abstract event " + abstractEvent);
+ LOG.error("Unable to process abstract event {}", abstractEvent);
return;
}
NorthboundEvent ev = (NorthboundEvent) abstractEvent;
// TODO: add handling of events here, once callbacks do something
// other than logging.
default:
- logger.warn("Unable to process event action " + ev.getAction());
+ LOG.warn("Unable to process event action {}", ev.getAction());
break;
}
}
+ @Override
+ public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+ eventDispatcher =
+ (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
+ eventDispatcher.eventHandlerAdded(
+ bundleContext.getServiceReference(INeutronSecurityGroupAware.class.getName()), this);
+ }
+
+ @Override
+ public void setDependencies(Object impl) {}
}
\ No newline at end of file