import org.opendaylight.neutron.spi.NeutronFirewall;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-/**
- * Deprecated as all Neutron FWaaS is experimental and so doesn't meet
- * the scope of neutron northbound
- *
- * @deprecated
- */
-
public class NeutronFirewallInterface extends AbstractNeutronInterface implements INeutronFirewallCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallInterface.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronFirewallInterface.class);
private ConcurrentMap<String, NeutronFirewall> firewallDB = new ConcurrentHashMap<String, NeutronFirewall>();
super(providerContext);
}
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- logger.error(e.getMessage());
- return false;
- }
- }
- }
- return true;
- }
-
@Override
public boolean neutronFirewallExists(String uuid) {
return firewallDB.containsKey(uuid);
@Override
public NeutronFirewall getNeutronFirewall(String uuid) {
if (!neutronFirewallExists(uuid)) {
- logger.debug("No Firewall Have Been Defined");
+ LOGGER.debug("No Firewall Have Been Defined");
return null;
}
return firewallDB.get(uuid);
NeutronFirewall firewall = entry.getValue();
allFirewalls.add(firewall);
}
- logger.debug("Exiting getFirewalls, Found {} OpenStackFirewall", allFirewalls.size());
+ LOGGER.debug("Exiting getFirewalls, Found {} OpenStackFirewall", allFirewalls.size());
List<NeutronFirewall> ans = new ArrayList<NeutronFirewall>();
ans.addAll(allFirewalls);
return ans;
return null;
}
-
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronFirewallInterface neutronFirewallInterface = new NeutronFirewallInterface(providerContext);
+ ServiceRegistration<INeutronFirewallCRUD> neutronFirewallInterfaceRegistration = context.registerService(INeutronFirewallCRUD.class, neutronFirewallInterface, null);
+ if(neutronFirewallInterfaceRegistration != null) {
+ registrations.add(neutronFirewallInterfaceRegistration);
+ }
+ }
}