<version>${networkconfig.neutron.version}</version>
<classifier>features</classifier>
<type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>dummyprovider</artifactId>
+ <version>${networkconfig.neutron.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin</groupId>
<bundle>mvn:org.opendaylight.ovsdb/utils.servicehelper/${ovsdb.utils.servicehelper.version}</bundle>
<bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt/${openstack.netvirt.version}</bundle>
<bundle>mvn:org.opendaylight.ovsdb/openstack.net-virt-providers/${openstack.netvirt.providers.version}</bundle>
+ <bundle>mvn:org.opendaylight.neutron/dummyprovider/${networkconfig.neutron.version}</bundle>
<configfile finalname="etc/opendaylight/karaf/netvirt-impl-default-config.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt/${project.version}/xml/config</configfile>
<configfile finalname="etc/opendaylight/karaf/netvirt-providers-impl-default-config.xml">mvn:org.opendaylight.ovsdb/openstack.net-virt-providers/${project.version}/xml/config</configfile>
</feature>
<groupId>org.opendaylight.controller.model</groupId>
<artifactId>model-inventory</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.neutron</groupId>
- <artifactId>neutron-spi</artifactId>
- <version>${networkconfig.neutron.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-base</artifactId>
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.MdsalHelper;
import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
import java.math.BigInteger;
import java.util.List;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSecurityRule;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.EgressAclProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import java.math.BigInteger;
import java.util.List;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSecurityRule;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.IngressAclProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.MdsalHelper;
import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSecurityRule;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSecurityRule;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
</scm>
<properties>
- <networkconfig.neutron.version>0.6.0-SNAPSHOT</networkconfig.neutron.version>
+ <neutron.model.version>0.6.0-SNAPSHOT</neutron.model.version>
<ovsdb.utils.config.version>1.2.1-SNAPSHOT</ovsdb.utils.config.version>
<ovsdb.utils.servicehelper.version>1.2.1-SNAPSHOT</ovsdb.utils.servicehelper.version>
<powermock.version>1.5.2</powermock.version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.neutron</groupId>
- <artifactId>neutron-spi</artifactId>
- <version>${networkconfig.neutron.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>southbound-api</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>model</artifactId>
+ <version>${neutron.model.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>utils.config</artifactId>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-yang-types</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<Embed-Dependency>utils.config;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>
+ org.opendaylight.ovsdb.openstack.netvirt.translator,
org.opendaylight.ovsdb.openstack.netvirt.api,
org.opendaylight.ovsdb.openstack.netvirt
</Export-Package>
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.neutron.spi.*;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.*;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronFirewallInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronFirewallPolicyInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronFirewallRuleInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronFloatingIPInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronLoadBalancerHealthMonitorInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronLoadBalancerInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronLoadBalancerListenerInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronLoadBalancerPoolInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronLoadBalancerPoolMemberInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronNetworkInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronPortInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronRouterInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronSecurityGroupInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronSecurityRuleInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl.NeutronSubnetInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFirewallAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFirewallPolicyAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFirewallRuleAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFloatingIPAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolMemberAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronNetworkAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronPortAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronRouterAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityGroupAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityRuleAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSubnetAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.*;
import org.opendaylight.ovsdb.openstack.netvirt.impl.*;
import org.osgi.framework.BundleActivator;
public class ConfigActivator implements BundleActivator {
private static final Logger LOG = LoggerFactory.getLogger(ConfigActivator.class);
+ private List<ServiceRegistration<?>> translatorCRUDRegistrations = new ArrayList<ServiceRegistration<?>>();
private List<Pair<Object, ServiceRegistration>> servicesAndRegistrations = new ArrayList<>();
private ProviderContext providerContext;
@Override
public void start(BundleContext context) throws Exception {
LOG.info("ConfigActivator start:");
+ registerCRUDServiceProviders(context, this.providerContext);
ConfigurationServiceImpl configurationService = new ConfigurationServiceImpl();
registerService(context, new String[] {ConfigurationService.class.getName()},
trackService(context, RoutingProvider.class, neutronL3Adapter);
trackService(context, L3ForwardingProvider.class, neutronL3Adapter);
trackService(context, GatewayMacResolver.class, neutronL3Adapter);
+ trackService(context, IngressAclProvider.class, securityServices);
+ trackService(context, EgressAclProvider.class, securityServices);
// We no longer need to track the services, avoid keeping references around
servicesAndRegistrations.clear();
}
+ private void registerCRUDServiceProviders(BundleContext context,
+ ProviderContext providerContext) {
+ LOG.debug("Registering CRUD service providers");
+ NeutronRouterInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronPortInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronSubnetInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronNetworkInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronSecurityGroupInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronSecurityRuleInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronFirewallInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronFirewallPolicyInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronFirewallRuleInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronLoadBalancerInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronLoadBalancerPoolInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronLoadBalancerListenerInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronLoadBalancerHealthMonitorInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronLoadBalancerPoolMemberInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ NeutronFloatingIPInterface.registerNewInterface(context, providerContext, translatorCRUDRegistrations);
+ }
+
private void trackService(BundleContext context, final Class<?> clazz, final ConfigInterface... dependents) {
@SuppressWarnings("unchecked")
ServiceTracker tracker = new ServiceTracker(context, clazz, null) {
@Override
public void stop(BundleContext context) throws Exception {
- LOG.info("ConfigActivator stop");
+ LOG.info("Stop Translator CRUD service provides");
// ServiceTrackers and services are already released when bundle stops,
// so we don't need to close the trackers or unregister the services
+ for (ServiceRegistration registration : translatorCRUDRegistrations) {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
+
}
private ServiceRegistration<?> registerService(BundleContext bundleContext, String[] interfaces,
import java.net.HttpURLConnection;
-import org.opendaylight.neutron.spi.INeutronFirewallAware;
-import org.opendaylight.neutron.spi.INeutronFirewallPolicyAware;
-import org.opendaylight.neutron.spi.INeutronFirewallRuleAware;
-import org.opendaylight.neutron.spi.NeutronFirewall;
-import org.opendaylight.neutron.spi.NeutronFirewallPolicy;
-import org.opendaylight.neutron.spi.NeutronFirewallRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewall;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallPolicy;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFirewallAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFirewallPolicyAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFirewallRuleAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.osgi.framework.ServiceReference;
/**
* Process the event.
*
- * @param abstractEvent@see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
+ * @param abstractEvent new FWaas Event@see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
*/
@Override
public void processEvent(AbstractEvent abstractEvent) {
import java.net.HttpURLConnection;
-import org.opendaylight.neutron.spi.INeutronFloatingIPAware;
-import org.opendaylight.neutron.spi.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFloatingIPAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
import java.util.List;
import java.util.Map;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerAware;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
/**
* Useful utility for extracting the loadbalancer instance
* configuration from the neutron LB cache
+ * @param neutronLB neutron load balancer object
+ * @return returns load balancer configuration
*/
public LoadBalancerConfiguration extractLBConfiguration(NeutronLoadBalancer neutronLB) {
String loadBalancerName = neutronLB.getLoadBalancerName();
import java.util.List;
import java.util.Map;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolAware;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
/**
* Useful utility for extracting the loadbalancer instance. With
* each LB pool, we allow multiple VIP and LB to be instantiated.
+ * @param neutronLBPool Neutron load balancer pool object
+ * @return list of loadbalancer configuration of pool members
*/
public List<LoadBalancerConfiguration> extractLBConfiguration(NeutronLoadBalancerPool neutronLBPool) {
String poolProtocol = neutronLBPool.getLoadBalancerPoolProtocol();
import java.util.List;
import java.util.Map;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolMemberAware;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolMemberAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
/**
* Useful utility for extracting the loadbalancer instance
* configuration from the neutron LB cache based on member info
+ * @param neutronLBPoolMember Neutron LB pool member object
+ * @return load balancer configuration of the pool member
*/
public LoadBalancerConfiguration extractLBConfiguration(NeutronLoadBalancerPoolMember neutronLBPoolMember) {
String memberID = neutronLBPoolMember.getID();
import java.net.HttpURLConnection;
import java.util.List;
-import org.opendaylight.neutron.spi.INeutronNetworkAware;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronNetworkAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
package org.opendaylight.ovsdb.openstack.netvirt;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSubnet;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import java.util.AbstractMap;
import java.util.Iterator;
/**
* Look up in the NeutronPortsCRUD cache and return the MAC address for a corresponding IP address
+ * @param neutronPortsCache Reference to port cache to get existing port related data. This interface
+ * basically read data from the md-sal data store.
+ * @param subnetID subnet to which given port is attached
* @param ipAddr IP address of a member or VM
* @return MAC address registered with that IP address
*/
/**
* Look up in the NeutronNetworkCRUD cache and NeutronSubnetCRUD cache for
* extracting the provider segmentation_type and segmentation_id
+ * @param neutronNetworkCache Reference to neutron network cache to get existing network related data.
+ * This interface basically read data from the md-sal data store.
+ * @param neutronSubnetCache Reference to neutron subnet cache to get existing subnet related data.
+ * This interface basically read data from the md-sal data store.
* @param subnetID Subnet UUID
* @return {Type: ID} pair for that subnet ID
*/
package org.opendaylight.ovsdb.openstack.netvirt;
-import org.opendaylight.neutron.spi.NeutronFloatingIP;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronRouter;
-import org.opendaylight.neutron.spi.NeutronRouter_Interface;
-import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
public class NorthboundEvent extends AbstractEvent {
import java.net.HttpURLConnection;
import java.util.List;
-import org.opendaylight.neutron.spi.INeutronPortAware;
-import org.opendaylight.neutron.spi.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronPortAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
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.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityGroupAware;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityRuleAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.osgi.framework.ServiceReference;
import java.net.HttpURLConnection;
-import org.opendaylight.neutron.spi.INeutronRouterAware;
-import org.opendaylight.neutron.spi.NeutronRouter;
-import org.opendaylight.neutron.spi.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronRouterAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
import java.util.List;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.api.*;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import java.net.HttpURLConnection;
-import org.opendaylight.neutron.spi.INeutronSubnetAware;
-import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSubnetAware;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
package org.opendaylight.ovsdb.openstack.netvirt.api;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import java.util.List;
* For OpenFlow 1.3 the Integration Bridge is required and must have a physical device connected.
* @param bridgeNode the {@link Node} that represents bridge
* @param ovsdbNode the {@link Node} where the bridge is configured
- * @param network the {@link org.opendaylight.neutron.spi.NeutronNetwork}
+ * @param network the {@link org.opendaylight.ovsdb.openstack.netvirt.translator}
* @return True or False
*/
boolean isNodeVlanReady(Node bridgeNode, Node ovsdbNode, NeutronNetwork network);
* Returns true if the bridges required for the provider network type are created
* If the bridges are not created, this method will attempt to create them
* @param node the {@link Node} to query
- * @param network the {@link org.opendaylight.neutron.spi.NeutronNetwork}
+ * @param network the {@link org.opendaylight.ovsdb.openstack.netvirt.translator}
* @return True or False
*/
boolean createLocalNetwork(Node node, NeutronNetwork network);
/**
* Returns the physical interface mapped to the given neutron physical network.
- * @param node
- * @param physicalNetwork
- * @return
+ * @param node the {@link Node} to query
+ * @param physicalNetwork neutron physical network
+ * @return name of the physical interface
*/
String getPhysicalInterfaceName(Node node, String physicalNetwork);
public interface ConfigurationService {
/**
- * Returns the name configured name of the Integration Bridge
+ * @return the name configured name of the Integration Bridge
*/
String getIntegrationBridgeName();
/**
* Configures the name of the Integration Bridge
+ * @param integrationBridgeName name of integration bridge
*/
void setIntegrationBridgeName(String integrationBridgeName);
/**
- * Returns the name configured name of the Network Bridge
+ * @return the name configured name of the Network Bridge
*/
String getNetworkBridgeName();
/**
* Configures the name of the Network Bridge
+ * @param networkBridgeName Name of the network bridge
*/
void setNetworkBridgeName(String networkBridgeName);
/**
- * Returns the name configured name of the ExternalBridge
+ * @return the name configured name of the ExternalBridge
*/
String getExternalBridgeName();
/**
* Configures the name of the External Bridge
+ * @param externalBridgeName Name of external bridge
*/
void setExternalBridgeName(String externalBridgeName);
/**
- * Returns the key used to access the Tunnel Endpoint configuration from Open vSwitch
+ * @return the key used to access the Tunnel Endpoint configuration from Open vSwitch
*/
String getTunnelEndpointKey();
/**
* Sets the key used to access the Tunnel Endpoint configuration from Open vSwitch
+ * @param tunnelEndpointKey key of tunnel end point
*/
void setTunnelEndpointKey(String tunnelEndpointKey);
/**
- * Returns a Map of patch port names where the key is a tuple of source bridge and destination bridge
+ * @return a Map of patch port names where the key is a tuple of source bridge and destination bridge
*/
Map<Pair<String, String>, String> getPatchPortNames();
/**
* Sets the Map of source/destination bridges to patch port name
+ * @param patchPortNames Map of source/destination bridges to patch port name
*/
void setPatchPortNames(Map<Pair<String, String>, String> patchPortNames);
String getPatchPortName(Pair portTuple);
/**
- * Returns the key used to access the Tunnel Endpoint configuration from Open vSwitch
+ * @return the key used to access the Tunnel Endpoint configuration from Open vSwitch
*/
String getProviderMappingsKey();
/**
* Sets the key used to access the Tunnel Endpoint configuration from Open vSwitch
+ * @param providerMappingsKey provide mapping key
*/
void setProviderMappingsKey(String providerMappingsKey);
/**
- * Gets the default provider mapping
+ * @return Gets the default provider mapping
*/
String getDefaultProviderMapping();
/**
* Sets the default provider mapping
+ * @param providerMapping provider mapping
*/
void setDefaultProviderMapping(String providerMapping);
import java.util.List;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
/**
* This interface allows egress Port Security flows to be written to devices.
* periodicRefresh flag.
* @param externalNetworkBridgeDpid This bridge will be used for sending ARP request
* @param gatewayIp ARP request will be send for this ip address
+ * @param sourceIpAddress Source IP address for the ARP request (localhost)
+ * @param sourceMacAddress Source MAC address for the ARP request (localhost)
* @param periodicRefresh Do you want to periodically refresh the gateway mac?
- * @return
+ * @return ListenableFuture that contains the mac address of gateway ip.
*/
public ListenableFuture<MacAddress> resolveMacAddress( final Long externalNetworkBridgeDpid, final Ipv4Address gatewayIp,
final Ipv4Address sourceIpAddress, final MacAddress sourceMacAddress, final Boolean periodicRefresh);
/**
* Method will stop the periodic refresh of the given gateway ip address.
- * @param gatewayIp
+ * @param gatewayIp Gateway IP Address
*/
public void stopPeriodicRefresh(final Ipv4Address gatewayIp);
}
import java.util.List;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
/**
* This interface allows ingress Port Security flows to be written to devices.
package org.opendaylight.ovsdb.openstack.netvirt.api;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.osgi.framework.ServiceReference;
public interface NetworkingProvider {
/**
- * Returns the name of the NetworkingProvider
+ * @return the name of the NetworkingProvider
*/
String getName();
/**
- * Return true if the provider supports Network Service Instances
+ * @return true if the provider supports Network Service Instances
*/
boolean supportsServices();
/**
- * Return true if the provider supports per-tenant or "static" tunneling
+ * @return true if the provider supports per-tenant or "static" tunneling
*/
boolean hasPerTenantTunneling();
/**
* Handle Interface Update Callback Method
+ * @param network Neutron Network attached to the interface
+ * @param source Source node where interface is attached
+ * @param intf Termination point attached to the node
+ * @return true if interface update handled successfully
*/
boolean handleInterfaceUpdate(NeutronNetwork network, Node source, OvsdbTerminationPointAugmentation intf);
/**
* Handle Interface Delete Callback Method
+ * @param tunnelType Type of the tunnel (e.g. vxlan)
+ * @param network Neutron Network associated with the removed interface
+ * @param source Source node where interface was attached
+ * @param intf Termination point associated to the deleted interface
+ * @param isLastInstanceOnNode is last interface attached to the node ?
+ * @return true if interface delete handled successfully
*/
boolean handleInterfaceDelete(String tunnelType, NeutronNetwork network, Node source,
OvsdbTerminationPointAugmentation intf, boolean isLastInstanceOnNode);
* This method provides a set of common functionalities to initialize the Flow rules of an OVSDB node
* that are Openflow Version specific. Hence we have this method in addition to the following
* Openflow Node specific initialization method.
+ * @param node Node on which flow rules are going to be installed
*/
void initializeFlowRules(Node node);
/**
* Initialize the Flow rules for a given OpenFlow node
+ * @param openflowNode Node on which flow rules are going to be installed
*/
void initializeOFFlowRules(Node openflowNode);
}
package org.opendaylight.ovsdb.openstack.netvirt.api;
-import java.util.List;
-
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import java.util.List;
+
/**
* Open vSwitch isolates Tenant Networks using VLANs on the Integration Bridge.
* This class manages the provisioning of these VLANs
*/
List<Neutron_IPs> getVmListForSecurityGroup(List<Neutron_IPs> srcAddressList,
String securityGroupUuid);
+ /**
+ * Add or remove the security groups rules from the port.
+ * @param port the neutron port.
+ * @param securityGroup the security group associated with the port.
+ * @param write whether to add/delete flow.
+ */
+ void syncSecurityGroup(NeutronPort port, List<NeutronSecurityGroup> securityGroup, boolean write);
}
package org.opendaylight.ovsdb.openstack.netvirt.api;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
/**
* Get the Neutron Network ID for a given Segmentation ID
+ * @param segmentationId segmentation id of the neutron network
+ * @return Neutron network id associated with the given segmentation id
*/
String getNetworkId(String segmentationId);
/**
* Network Created Callback
+ * @param node target node
+ * @param networkId Id of neutron network
+ * @return vlan assigned to the network
*/
int networkCreated(Node node, String networkId);
/**
* Network Deleted Callback
+ * @param id Id of the neutron network
*/
void networkDeleted(String id);
NeutronNetwork getTenantNetwork(OvsdbTerminationPointAugmentation terminationPointAugmentation);
package org.opendaylight.ovsdb.openstack.netvirt.impl;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
*
* @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
* @param path {@link InstanceIdentifier} for path to read
- * @param <D> the data object type
+ * @param data object of type D
* @return the result of the request
*/
public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean merge(
*
* @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
* @param path {@link InstanceIdentifier} for path to read
- * @param <D> the data object type
+ * @param data object of type D
* @return the result of the request
*/
public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean put(
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronFloatingIP;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronRouter;
-import org.opendaylight.neutron.spi.NeutronRouter_Interface;
-import org.opendaylight.neutron.spi.NeutronSubnet;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
import org.opendaylight.ovsdb.openstack.netvirt.api.*;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
private volatile ArpProvider arpProvider;
private volatile RoutingProvider routingProvider;
private volatile GatewayMacResolver gatewayMacResolver;
+ private volatile SecurityServicesManager securityServicesManager;
private class FloatIpData {
// br-int of node where floating ip is associated with tenant port
*/
public void handleNeutronPortEvent(final NeutronPort neutronPort, Action action) {
LOG.debug("Neutron port {} event : {}", action, neutronPort.toString());
+
+ this.processSecurityGroupUpdate(neutronPort);
if (!this.enabled) {
return;
}
* way around) on OpenFlow Table 100.
*
* @param actionIn the {@link org.opendaylight.ovsdb.openstack.netvirt.api.Action} action to be handled.
- * @param neutronFloatingIP An {@link org.opendaylight.neutron.spi.NeutronFloatingIP} instance of NeutronFloatingIP object.
+ * @param neutronFloatingIP An {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP} instance of NeutronFloatingIP object.
*/
public void handleNeutronFloatingIPEvent(final NeutronFloatingIP neutronFloatingIP,
Action actionIn) {
* Process the event.
*
* @param action the {@link org.opendaylight.ovsdb.openstack.netvirt.api.Action} action to be handled.
- * @param neutronNetwork An {@link org.opendaylight.neutron.spi.NeutronNetwork} instance of NeutronFloatingIP object.
+ * @param neutronNetwork An {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork} instance of NeutronFloatingIP object.
*/
public void handleNeutronNetworkEvent(final NeutronNetwork neutronNetwork, Action action) {
LOG.debug("neutronNetwork {}: network: {}", action, neutronNetwork);
* @param bridgeNode An instance of Node object.
* @param intf An {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105
* .OvsdbTerminationPointAugmentation} instance of OvsdbTerminationPointAugmentation object.
- * @param neutronNetwork An {@link org.opendaylight.neutron.spi.NeutronNetwork} instance of NeutronNetwork
+ * @param neutronNetwork An {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork} instance of NeutronNetwork
* object.
* @param action the {@link org.opendaylight.ovsdb.openstack.netvirt.api.Action} action to be handled.
*/
}
}
+ private void processSecurityGroupUpdate(NeutronPort neutronPort) {
+ LOG.trace("processSecurityGroupUpdate:" + neutronPort);
+ /**
+ * Get updated data and original data for the the changed. Identify the security groups that got
+ * added and removed and call the appropriate providers for updating the flows.
+ */
+ try {
+ NeutronPort originalPort = neutronPort.getOriginalPort();
+ if (null == originalPort) {
+ LOG.debug("processSecurityGroupUpdate: originalport is empty");
+ return;
+ }
+ List<NeutronSecurityGroup> addedGroup = getsecurityGroupChanged(neutronPort,
+ neutronPort.getOriginalPort());
+ List<NeutronSecurityGroup> deletedGroup = getsecurityGroupChanged(neutronPort.getOriginalPort(),
+ neutronPort);
+
+ if (null != addedGroup && !addedGroup.isEmpty()) {
+ securityServicesManager.syncSecurityGroup(neutronPort,addedGroup,true);
+ }
+ if (null != deletedGroup && !deletedGroup.isEmpty()) {
+ securityServicesManager.syncSecurityGroup(neutronPort,deletedGroup,false);
+ }
+
+ } catch (Exception e) {
+ LOG.error("Exception in processSecurityGroupUpdate", e);
+ }
+ }
+
+ private List<NeutronSecurityGroup> getsecurityGroupChanged(NeutronPort port1, NeutronPort port2) {
+ LOG.trace("getsecurityGroupChanged:" + "Port1:" + port1 + "Port2" + port2);
+ ArrayList<NeutronSecurityGroup> list1 = new ArrayList<NeutronSecurityGroup>(port1.getSecurityGroups());
+ ArrayList<NeutronSecurityGroup> list2 = new ArrayList<NeutronSecurityGroup>(port2.getSecurityGroups());
+ for (Iterator<NeutronSecurityGroup> iterator = list1.iterator(); iterator.hasNext();) {
+ NeutronSecurityGroup securityGroup1 = iterator.next();
+ for (NeutronSecurityGroup securityGroup2 :list2) {
+ if (securityGroup1.getID().equals(securityGroup2.getID())) {
+ iterator.remove();
+ }
+ }
+ }
+ return list1;
+ }
+
private void programL3ForwardingStage1(Node node, Long dpid, String providerSegmentationId,
String macAddress, String ipStr,
Action actionForNode) {
(Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
gatewayMacResolver =
(GatewayMacResolver) ServiceHelper.getGlobalInstance(GatewayMacResolver.class, this);
+ securityServicesManager =
+ (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
initL3AdapterMembers();
}
package org.opendaylight.ovsdb.openstack.netvirt.impl;
import com.google.common.collect.Sets;
+
import java.util.Set;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryService;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronFloatingIPChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronNetworkChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronPortChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronRouterChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronSubnetChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronLoadBalancerPoolChangeListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl.NeutronLoadBalancerPoolMemberChangeListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@Override
public void providersReady() {
ovsdbDataChangeListener.start();
+ initializeNeutronModelsDataChangeListeners(dataBroker);
initializeNetvirtTopology();
}
LOG.error("Error initializing netvirt topology");
}
}
+
+ private void initializeNeutronModelsDataChangeListeners(
+ DataBroker db) {
+ new NeutronNetworkChangeListener(db);
+ new NeutronSubnetChangeListener(db);
+ new NeutronPortChangeListener(db);
+ new NeutronRouterChangeListener(db);
+ new NeutronFloatingIPChangeListener(db);
+ new NeutronLoadBalancerPoolChangeListener(db);
+ new NeutronLoadBalancerPoolMemberChangeListener(db);
+ }
+
}
package org.opendaylight.ovsdb.openstack.netvirt.impl;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSubnet;
-import org.opendaylight.neutron.spi.Neutron_IPs;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
+import org.opendaylight.ovsdb.openstack.netvirt.api.EgressAclProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.IngressAclProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
-
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
public class SecurityServicesImpl implements ConfigInterface, SecurityServicesManager {
private static final Logger LOG = LoggerFactory.getLogger(TenantNetworkManagerImpl.class);
private volatile INeutronPortCRUD neutronPortCache;
private volatile INeutronSubnetCRUD neutronSubnetCache;
private volatile Southbound southbound;
+ private volatile INeutronNetworkCRUD neutronNetworkCache;
+ private volatile ConfigurationService configurationService;
+ private volatile IngressAclProvider ingressAclProvider;
+ private volatile EgressAclProvider egressAclProvider;
+ private volatile SecurityServicesManager securityServicesManager;
@Override
public boolean isPortSecurityReady(OvsdbTerminationPointAugmentation terminationPointAugmentation) {
}
+ @Override
+ public void syncSecurityGroup(NeutronPort port, List<NeutronSecurityGroup> securityGroupList, boolean write) {
+ LOG.trace("syncSecurityGroup:" + securityGroupList + " Write:" + Boolean.valueOf(write));
+ if (null != port && null != port.getSecurityGroups()) {
+ Node node = getNode(port);
+ NeutronNetwork neutronNetwork = neutronNetworkCache.getNetwork(port.getNetworkUUID());
+ String segmentationId = neutronNetwork.getProviderSegmentationID();
+ OvsdbTerminationPointAugmentation intf = getInterface(node, port);
+ long localPort = southbound.getOFPort(intf);
+ String attachedMac = southbound.getInterfaceExternalIdsValue(intf, Constants.EXTERNAL_ID_VM_MAC);
+ if (attachedMac == null) {
+ LOG.debug("programVlanRules: No AttachedMac seen in {}", intf);
+ return;
+ }
+ long dpid = getDpidOfIntegrationBridge(node);
+ List<Neutron_IPs> srcAddressList = securityServicesManager.getIpAddressList(node, intf);
+ for (NeutronSecurityGroup securityGroupInPort:securityGroupList) {
+ ingressAclProvider.programPortSecurityAcl(dpid, segmentationId, attachedMac, localPort,
+ securityGroupInPort, srcAddressList, write);
+ egressAclProvider.programPortSecurityAcl(dpid, segmentationId, attachedMac, localPort,
+ securityGroupInPort, srcAddressList, write);
+ }
+ }
+ }
+
+ private long getDpidOfIntegrationBridge(Node node) {
+ LOG.trace("getDpidOfIntegrationBridge:" + node);
+ long dpid = 0L;
+ if (southbound.getBridgeName(node).equals(configurationService.getIntegrationBridgeName())) {
+ dpid = getDpid(node);
+ }
+ return dpid;
+ }
+
+ private long getDpid(Node node) {
+ LOG.trace("getDpid" + node);
+ long dpid = southbound.getDataPathId(node);
+ if (dpid == 0) {
+ LOG.warn("getDpid: dpid not found: {}", node);
+ }
+ return dpid;
+ }
+
+ private Node getNode(NeutronPort port) {
+ LOG.trace("getNode:Port" + port);
+ List<Node> toplogyNodes = southbound.readOvsdbTopologyNodes();
+
+ for (Node topologyNode : toplogyNodes) {
+ try {
+ Node node = southbound.getBridgeNode(topologyNode,Constants.INTEGRATION_BRIDGE);
+ List<OvsdbTerminationPointAugmentation> ovsdbPorts = southbound.getTerminationPointsOfBridge(node);
+ for (OvsdbTerminationPointAugmentation ovsdbPort : ovsdbPorts) {
+ String uuid = southbound.getInterfaceExternalIdsValue(ovsdbPort,
+ Constants.EXTERNAL_ID_INTERFACE_ID);
+ if (null != uuid && uuid.equals(port.getID())) {
+ return node;
+ }
+ }
+ } catch (Exception e) {
+ LOG.error("Exception during handlingNeutron network delete", e);
+ }
+ }
+ return null;
+ }
+
+ private OvsdbTerminationPointAugmentation getInterface(Node node, NeutronPort port) {
+ LOG.trace("getInterface:Node:" + node + " Port:" + port);
+ try {
+ List<OvsdbTerminationPointAugmentation> ovsdbPorts = southbound.getTerminationPointsOfBridge(node);
+ for (OvsdbTerminationPointAugmentation ovsdbPort : ovsdbPorts) {
+ String uuid = southbound.getInterfaceExternalIdsValue(ovsdbPort,
+ Constants.EXTERNAL_ID_INTERFACE_ID);
+ if (null != uuid && uuid.equals(port.getID())) {
+ return ovsdbPort;
+ }
+ }
+ } catch (Exception e) {
+ LOG.error("Exception during handlingNeutron network delete", e);
+ }
+ return null;
+ }
+
@Override
public void setDependencies(ServiceReference serviceReference) {
southbound =
(Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
+ neutronNetworkCache =
+ (INeutronNetworkCRUD) ServiceHelper.getGlobalInstance(INeutronNetworkCRUD.class, this);
+ configurationService =
+ (ConfigurationService) ServiceHelper.getGlobalInstance(ConfigurationService.class, this);
+ securityServicesManager =
+ (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
}
@Override
neutronPortCache = (INeutronPortCRUD)impl;
} else if (impl instanceof INeutronSubnetCRUD) {
neutronSubnetCache = (INeutronSubnetCRUD) impl;
+ } else if (impl instanceof IngressAclProvider) {
+ ingressAclProvider = (IngressAclProvider) impl;
+ } else if (impl instanceof EgressAclProvider) {
+ egressAclProvider = (EgressAclProvider) impl;
}
}
}
/**
* Method read ports from bridge node. Method will check if the provided node
* has the ports details, if not, it will read from Operational data store.
- * @param node
- * @return
+ * @param node Target bridge to getch termination points from.
+ * @return List of termination points on the given bridge
*/
public List<OvsdbTerminationPointAugmentation> getTerminationPointsOfBridge(Node node) {
List<OvsdbTerminationPointAugmentation> tpAugmentations = extractTerminationPointAugmentations(node);
package org.opendaylight.ovsdb.openstack.netvirt.impl;
import com.google.common.base.Preconditions;
+
import java.util.List;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+/**
+ * This class contains behaviour common to Neutron configuration objects
+ */
+public interface INeutronObject {
+
+ String getID();
+
+ void setID(String id);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Firewall as a service
+ * (FWaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields:
+ * Implemented fields are as follows:
+ *
+ * id uuid-str
+ * tenant_id uuid-str
+ * name String
+ * description String
+ * admin_state_up Bool
+ * status String
+ * shared Bool
+ * firewall_policy_id uuid-str
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ *
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronFirewall implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String firewallUUID;
+
+ @XmlElement (name = "tenant_id")
+ String firewallTenantID;
+
+ @XmlElement (name = "name")
+ String firewallName;
+
+ @XmlElement (name = "description")
+ String firewallDescription;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean firewallAdminStateIsUp;
+
+ @XmlElement (name = "status")
+ String firewallStatus;
+
+ @XmlElement (defaultValue = "false", name = "shared")
+ Boolean firewallIsShared;
+
+ @XmlElement (name = "firewall_policy_id")
+ String neutronFirewallPolicyID;
+
+ public String getID() {
+ return firewallUUID;
+ }
+
+ public void setID(String id) {
+ firewallUUID = id;
+ }
+
+ // @deprecated use getID()
+ public String getFirewallUUID() {
+ return firewallUUID;
+ }
+
+ // @deprecated use setID()
+ public void setFirewallUUID(String firewallUUID) {
+ this.firewallUUID = firewallUUID;
+ }
+
+ public String getFirewallTenantID() {
+ return firewallTenantID;
+ }
+
+ public void setFirewallTenantID(String firewallTenantID) {
+ this.firewallTenantID = firewallTenantID;
+ }
+
+ public String getFirewallName() {
+ return firewallName;
+ }
+
+ public void setFirewallName(String firewallName) {
+ this.firewallName = firewallName;
+ }
+
+ public String getFirewallDescription() {
+ return firewallDescription;
+ }
+
+ public void setFirewallDescription(String firewallDescription) {
+ this.firewallDescription = firewallDescription;
+ }
+
+ public Boolean getFirewallAdminStateIsUp() {
+ return firewallAdminStateIsUp;
+ }
+
+ public void setFirewallAdminStateIsUp(Boolean firewallAdminStateIsUp) {
+ this.firewallAdminStateIsUp = firewallAdminStateIsUp;
+ }
+
+ public String getFirewallStatus() {
+ return firewallStatus;
+ }
+
+ public void setFirewallStatus(String firewallStatus) {
+ this.firewallStatus = firewallStatus;
+ }
+
+ public Boolean getFirewallIsShared() {
+ return firewallIsShared;
+ }
+
+ public void setFirewallIsShared(Boolean firewallIsShared) {
+ this.firewallIsShared = firewallIsShared;
+ }
+
+ public String getFirewallPolicyID() {
+ return neutronFirewallPolicyID;
+ }
+
+ public void setNeutronFirewallPolicyID(String firewallPolicy) {
+ this.neutronFirewallPolicyID = firewallPolicy;
+ }
+
+ public NeutronFirewall extractFields(List<String> fields) {
+ NeutronFirewall ans = new NeutronFirewall();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setFirewallTenantID(this.getFirewallTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setFirewallName(this.getFirewallName());
+ }
+ if(s.equals("description")) {
+ ans.setFirewallDescription(this.getFirewallDescription());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setFirewallAdminStateIsUp(firewallAdminStateIsUp);
+ }
+ if (s.equals("status")) {
+ ans.setFirewallStatus(this.getFirewallStatus());
+ }
+ if (s.equals("shared")) {
+ ans.setFirewallIsShared(firewallIsShared);
+ }
+ if (s.equals("firewall_policy_id")) {
+ ans.setNeutronFirewallPolicyID(this.getFirewallPolicyID());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronFirewall{" +
+ "firewallUUID='" + firewallUUID + '\'' +
+ ", firewallTenantID='" + firewallTenantID + '\'' +
+ ", firewallName='" + firewallName + '\'' +
+ ", firewallDescription='" + firewallDescription + '\'' +
+ ", firewallAdminStateIsUp=" + firewallAdminStateIsUp +
+ ", firewallStatus='" + firewallStatus + '\'' +
+ ", firewallIsShared=" + firewallIsShared +
+ ", firewallRulePolicyID=" + neutronFirewallPolicyID +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Firewall as a service
+ * (FWaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields.
+ * The implemented fields are as follows:
+ *
+ * id uuid-str
+ * tenant_id uuid-str
+ * name String
+ * description String
+ * shared Boolean
+ * firewall_rules List
+ * audited Boolean
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ *
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronFirewallPolicy implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String firewallPolicyUUID;
+
+ @XmlElement (name = "tenant_id")
+ String firewallPolicyTenantID;
+
+ @XmlElement (name = "name")
+ String firewallPolicyName;
+
+ @XmlElement (name = "description")
+ String firewallPolicyDescription;
+
+ @XmlElement (defaultValue = "false", name = "shared")
+ Boolean firewallPolicyIsShared;
+
+ @XmlElement (name = "firewall_rules")
+ List<String> firewallPolicyRules;
+
+ @XmlElement (defaultValue = "false", name = "audited")
+ Boolean firewallPolicyIsAudited;
+
+ public Boolean getFirewallPolicyIsAudited() {
+ return firewallPolicyIsAudited;
+ }
+
+ public void setFirewallPolicyIsAudited(Boolean firewallPolicyIsAudited) {
+ this.firewallPolicyIsAudited = firewallPolicyIsAudited;
+ }
+
+ public void setFirewallPolicyRules(List<String> firewallPolicyRules) {
+ this.firewallPolicyRules = firewallPolicyRules;
+ }
+
+ public List<String> getFirewallPolicyRules() {
+ return firewallPolicyRules;
+ }
+
+ public Boolean getFirewallPolicyIsShared() {
+ return firewallPolicyIsShared;
+ }
+
+ public void setFirewallPolicyIsShared(Boolean firewallPolicyIsShared) {
+ this.firewallPolicyIsShared = firewallPolicyIsShared;
+ }
+
+ public String getFirewallPolicyDescription() {
+ return firewallPolicyDescription;
+ }
+
+ public void setFirewallPolicyDescription(String firewallPolicyDescription) {
+ this.firewallPolicyDescription = firewallPolicyDescription;
+ }
+
+ public String getFirewallPolicyName() {
+ return firewallPolicyName;
+ }
+
+ public void setFirewallPolicyName(String firewallPolicyName) {
+ this.firewallPolicyName = firewallPolicyName;
+ }
+
+ public String getFirewallPolicyTenantID() {
+ return firewallPolicyTenantID;
+ }
+
+ public void setFirewallPolicyTenantID(String firewallPolicyTenantID) {
+ this.firewallPolicyTenantID = firewallPolicyTenantID;
+ }
+
+ public String getID() {
+ return firewallPolicyUUID;
+ }
+
+ public void setID(String id) {
+ firewallPolicyUUID = id;
+ }
+
+ // @deprecated use getID()
+ public String getFirewallPolicyUUID() {
+ return firewallPolicyUUID;
+ }
+
+ // @deprecated use setID()
+ public void setFirewallPolicyUUID(String firewallPolicyUUID) {
+ this.firewallPolicyUUID = firewallPolicyUUID;
+ }
+
+ public NeutronFirewallPolicy extractFields(List<String> fields) {
+ NeutronFirewallPolicy ans = new NeutronFirewallPolicy();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setFirewallPolicyTenantID(this.getFirewallPolicyTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setFirewallPolicyName(this.getFirewallPolicyName());
+ }
+ if(s.equals("description")) {
+ ans.setFirewallPolicyDescription(this.getFirewallPolicyDescription());
+ }
+ if (s.equals("shared")) {
+ ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
+ }
+ if (s.equals("firewall_rules")) {
+ List<String> firewallRuleList = new ArrayList<String>();
+ firewallRuleList.addAll(this.getFirewallPolicyRules());
+ ans.setFirewallPolicyRules(firewallRuleList);
+ }
+ if (s.equals("audited")) {
+ ans.setFirewallPolicyIsAudited(firewallPolicyIsAudited);
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronFirewallPolicy{" +
+ "firewallPolicyUUID='" + firewallPolicyUUID + '\'' +
+ ", firewallPolicyTenantID='" + firewallPolicyTenantID + '\'' +
+ ", firewallPolicyName='" + firewallPolicyName + '\'' +
+ ", firewallPolicyDescription='" + firewallPolicyDescription + '\'' +
+ ", firewallPolicyIsShared=" + firewallPolicyIsShared +
+ ", firewallPolicyRules=" + firewallPolicyRules +
+ ", firewallPolicyIsAudited='" + firewallPolicyIsAudited + '\'' +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Firewall as a service
+ * (FWaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields.
+ * The implemented fields are as follows:
+ *
+ * tenant_id uuid-str
+ * name String
+ * description String
+ * admin_state_up Bool
+ * status String
+ * shared Bool
+ * firewall_policy_id uuid-str
+ * protocol String
+ * ip_version Integer
+ * source_ip_address String (IP addr or CIDR)
+ * destination_ip_address String (IP addr or CIDR)
+ * source_port Integer
+ * destination_port Integer
+ * position Integer
+ * action String
+ * enabled Bool
+ * id uuid-str
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ *
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronFirewallRule implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String firewallRuleUUID;
+
+ @XmlElement(name = "tenant_id")
+ String firewallRuleTenantID;
+
+ @XmlElement(name = "name")
+ String firewallRuleName;
+
+ @XmlElement(name = "description")
+ String firewallRuleDescription;
+
+ @XmlElement(name = "status")
+ String firewallRuleStatus;
+
+ @XmlElement(defaultValue = "false", name = "shared")
+ Boolean firewallRuleIsShared;
+
+ @XmlElement(name = "firewall_policy_id")
+ String firewallRulePolicyID;
+
+ @XmlElement(name = "protocol")
+ String firewallRuleProtocol;
+
+ @XmlElement(name = "ip_version")
+ Integer firewallRuleIpVer;
+
+ @XmlElement(name = "source_ip_address")
+ String firewallRuleSrcIpAddr;
+
+ @XmlElement(name = "destination_ip_address")
+ String firewallRuleDstIpAddr;
+
+ @XmlElement(name = "source_port")
+ Integer firewallRuleSrcPort;
+
+ @XmlElement(name = "destination_port")
+ Integer firewallRuleDstPort;
+
+ @XmlElement(name = "position")
+ Integer firewallRulePosition;
+
+ @XmlElement(name = "action")
+ String firewallRuleAction;
+
+ @XmlElement(name = "enabled")
+ Boolean firewallRuleIsEnabled;
+
+ public Boolean getFirewallRuleIsEnabled() {
+ return firewallRuleIsEnabled;
+ }
+
+ public void setFirewallRuleIsEnabled(Boolean firewallRuleIsEnabled) {
+ this.firewallRuleIsEnabled = firewallRuleIsEnabled;
+ }
+
+ public String getFirewallRuleAction() {
+ return firewallRuleAction;
+ }
+
+ public void setFirewallRuleAction(String firewallRuleAction) {
+ this.firewallRuleAction = firewallRuleAction;
+ }
+
+ public Integer getFirewallRulePosition() {
+ return firewallRulePosition;
+ }
+
+ public void setFirewallRulePosition(Integer firewallRulePosition) {
+ this.firewallRulePosition = firewallRulePosition;
+ }
+
+ public Integer getFirewallRuleDstPort() {
+ return firewallRuleDstPort;
+ }
+
+ public void setFirewallRuleDstPort(Integer firewallRuleDstPort) {
+ this.firewallRuleDstPort = firewallRuleDstPort;
+ }
+
+ public Integer getFirewallRuleSrcPort() {
+ return firewallRuleSrcPort;
+ }
+
+ public void setFirewallRuleSrcPort(Integer firewallRuleSrcPort) {
+ this.firewallRuleSrcPort = firewallRuleSrcPort;
+ }
+
+ public String getFirewallRuleDstIpAddr() {
+ return firewallRuleDstIpAddr;
+ }
+
+ public void setFirewallRuleDstIpAddr(String firewallRuleDstIpAddr) {
+ this.firewallRuleDstIpAddr = firewallRuleDstIpAddr;
+ }
+
+ public String getFirewallRuleSrcIpAddr() {
+ return firewallRuleSrcIpAddr;
+ }
+
+ public void setFirewallRuleSrcIpAddr(String firewallRuleSrcIpAddr) {
+ this.firewallRuleSrcIpAddr = firewallRuleSrcIpAddr;
+ }
+
+ public Integer getFirewallRuleIpVer() {
+ return firewallRuleIpVer;
+ }
+
+ public void setFirewallRuleIpVer(Integer firewallRuleIpVer) {
+ this.firewallRuleIpVer = firewallRuleIpVer;
+ }
+
+ public String getFirewallRuleProtocol() {
+ return firewallRuleProtocol;
+ }
+
+ public void setFirewallRuleProtocol(String firewallRuleProtocol) {
+ this.firewallRuleProtocol = firewallRuleProtocol;
+ }
+
+ public String getFirewallRulePolicyID() {
+ return firewallRulePolicyID;
+ }
+
+ public void setFirewallRulesPolicyID(String firewallRulePolicyID) {
+ this.firewallRulePolicyID = firewallRulePolicyID;
+ }
+
+ public Boolean getFirewallRuleIsShared() {
+ return firewallRuleIsShared;
+ }
+
+ public void setFirewallRuleIsShared(Boolean firewallRuleIsShared) {
+ this.firewallRuleIsShared = firewallRuleIsShared;
+ }
+
+ public String getFirewallRuleStatus() {
+ return firewallRuleStatus;
+ }
+
+ public void setFirewallRuleStatus(String firewallRuleStatus) {
+ this.firewallRuleStatus = firewallRuleStatus;
+ }
+
+ public String getFirewallRuleDescription() {
+ return firewallRuleDescription;
+ }
+
+ public void setFirewallRuleDescription(String firewallRuleDescription) {
+ this.firewallRuleDescription = firewallRuleDescription;
+ }
+
+ public String getFirewallRuleName() {
+ return firewallRuleName;
+ }
+
+ public void setFirewallRuleName(String firewallRuleName) {
+ this.firewallRuleName = firewallRuleName;
+ }
+
+ public String getFirewallRuleTenantID() {
+ return firewallRuleTenantID;
+ }
+
+ public void setFirewallRuleTenantID(String firewallRuleTenantID) {
+ this.firewallRuleTenantID = firewallRuleTenantID;
+ }
+
+ public String getID() {
+ return firewallRuleUUID;
+ }
+
+ public void setID(String id) {
+ firewallRuleUUID = id;
+ }
+
+ // @deprecated use getID()
+ public String getFirewallRuleUUID() {
+ return firewallRuleUUID;
+ }
+
+ // @deprecated use setID()
+ public void setFireWallRuleID(String firewallRuleUUID) {
+ this.firewallRuleUUID = firewallRuleUUID;
+ }
+
+ public NeutronFirewallRule extractFields(List<String> fields) {
+ NeutronFirewallRule ans = new NeutronFirewallRule();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setFirewallRuleTenantID(this.getFirewallRuleTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setFirewallRuleName(this.getFirewallRuleName());
+ }
+ if (s.equals("description")) {
+ ans.setFirewallRuleDescription(this.getFirewallRuleDescription());
+ }
+ if (s.equals("status")) {
+ ans.setFirewallRuleStatus(this.getFirewallRuleStatus());
+ }
+ if (s.equals("shared")) {
+ ans.setFirewallRuleIsShared(firewallRuleIsShared);
+ }
+ if (s.equals("firewall_policy_id")) {
+ ans.setFirewallRulesPolicyID(this.getFirewallRulePolicyID());
+ }
+ if (s.equals("protocol")) {
+ ans.setFirewallRuleProtocol(this.getFirewallRuleProtocol());
+ }
+ if (s.equals("source_ip_address")) {
+ ans.setFirewallRuleSrcIpAddr(this.getFirewallRuleSrcIpAddr());
+ }
+ if (s.equals("destination_ip_address")) {
+ ans.setFirewallRuleDstIpAddr(this.getFirewallRuleDstIpAddr());
+ }
+ if (s.equals("source_port")) {
+ ans.setFirewallRuleSrcPort(this.getFirewallRuleSrcPort());
+ }
+ if (s.equals("destination_port")) {
+ ans.setFirewallRuleDstPort(this.getFirewallRuleDstPort());
+ }
+ if (s.equals("position")) {
+ ans.setFirewallRulePosition(this.getFirewallRulePosition());
+ }
+ if (s.equals("action")) {
+ ans.setFirewallRuleAction(this.getFirewallRuleAction());
+ }
+ if (s.equals("enabled")) {
+ ans.setFirewallRuleIsEnabled(firewallRuleIsEnabled);
+ }
+
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "firewallPolicyRules{" +
+ "firewallRuleUUID='" + firewallRuleUUID + '\'' +
+ ", firewallRuleTenantID='" + firewallRuleTenantID + '\'' +
+ ", firewallRuleName='" + firewallRuleName + '\'' +
+ ", firewallRuleDescription='" + firewallRuleDescription + '\'' +
+ ", firewallRuleStatus='" + firewallRuleStatus + '\'' +
+ ", firewallRuleIsShared=" + firewallRuleIsShared +
+ ", firewallRulePolicyID=" + firewallRulePolicyID +
+ ", firewallRuleProtocol='" + firewallRuleProtocol + '\'' +
+ ", firewallRuleIpVer=" + firewallRuleIpVer +
+ ", firewallRuleSrcIpAddr='" + firewallRuleSrcIpAddr + '\'' +
+ ", firewallRuleDstIpAddr='" + firewallRuleDstIpAddr + '\'' +
+ ", firewallRuleSrcPort=" + firewallRuleSrcPort +
+ ", firewallRuleDstPort=" + firewallRuleDstPort +
+ ", firewallRulePosition=" + firewallRulePosition +
+ ", firewallRuleAction='" + firewallRuleAction + '\'' +
+ ", firewallRuleIsEnabled=" + firewallRuleIsEnabled +
+ '}';
+ }
+
+ public void initDefaults() {
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronFloatingIP implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement (name = "id")
+ String floatingIPUUID;
+
+ @XmlElement (name = "floating_network_id")
+ String floatingNetworkUUID;
+
+ @XmlElement (name = "port_id")
+ String portUUID;
+
+ @XmlElement (name = "fixed_ip_address")
+ String fixedIPAddress;
+
+ @XmlElement (name = "floating_ip_address")
+ String floatingIPAddress;
+
+ @XmlElement (name = "tenant_id")
+ String tenantUUID;
+
+ @XmlElement (name="router_id")
+ String routerUUID;
+
+ @XmlElement (name="status")
+ String status;
+
+ public NeutronFloatingIP() {
+ }
+
+ public String getID() {
+ return floatingIPUUID;
+ }
+
+ public void setID(String id) {
+ floatingIPUUID = id;
+ }
+
+ // @deprecated use getID()
+ public String getFloatingIPUUID() {
+ return floatingIPUUID;
+ }
+
+ // @deprecated use setID()
+ public void setFloatingIPUUID(String floatingIPUUID) {
+ this.floatingIPUUID = floatingIPUUID;
+ }
+
+ public String getFloatingNetworkUUID() {
+ return floatingNetworkUUID;
+ }
+
+ public void setFloatingNetworkUUID(String floatingNetworkUUID) {
+ this.floatingNetworkUUID = floatingNetworkUUID;
+ }
+
+ public String getPortUUID() {
+ return portUUID;
+ }
+
+ public String getRouterUUID() {
+ return routerUUID;
+ }
+
+ public void setPortUUID(String portUUID) {
+ this.portUUID = portUUID;
+ }
+
+ public String getFixedIPAddress() {
+ return fixedIPAddress;
+ }
+
+ public void setFixedIPAddress(String fixedIPAddress) {
+ this.fixedIPAddress = fixedIPAddress;
+ }
+
+ public String getFloatingIPAddress() {
+ return floatingIPAddress;
+ }
+
+ public void setFloatingIPAddress(String floatingIPAddress) {
+ this.floatingIPAddress = floatingIPAddress;
+ }
+
+ public String getTenantUUID() {
+ return tenantUUID;
+ }
+
+ public void setTenantUUID(String tenantUUID) {
+ this.tenantUUID = tenantUUID;
+ }
+
+ public void setRouterUUID(String routerUUID) {
+ this.routerUUID = routerUUID;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * This method copies selected fields from the object and returns them
+ * as a new object, suitable for marshaling.
+ *
+ * @param fields
+ * List of attributes to be extracted
+ * @return an OpenStackFloatingIPs object with only the selected fields
+ * populated
+ */
+
+ public NeutronFloatingIP extractFields(List<String> fields) {
+ NeutronFloatingIP ans = new NeutronFloatingIP();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("floating_network_id")) {
+ ans.setFloatingNetworkUUID(this.getFloatingNetworkUUID());
+ }
+ if (s.equals("port_id")) {
+ ans.setPortUUID(this.getPortUUID());
+ }
+ if (s.equals("fixed_ip_address")) {
+ ans.setFixedIPAddress(this.getFixedIPAddress());
+ }
+ if (s.equals("floating_ip_address")) {
+ ans.setFloatingIPAddress(this.getFloatingIPAddress());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setTenantUUID(this.getTenantUUID());
+ }
+ if (s.equals("router_id")) {
+ ans.setRouterUUID(this.getRouterUUID());
+ }
+ if (s.equals("status")) {
+ ans.setStatus(this.getStatus());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronFloatingIP{" +
+ "fipUUID='" + floatingIPUUID + '\'' +
+ ", fipFloatingNetworkId='" + floatingNetworkUUID + '\'' +
+ ", fipPortUUID='" + portUUID + '\'' +
+ ", fipFixedIPAddress='" + fixedIPAddress + '\'' +
+ ", fipFloatingIPAddress=" + floatingIPAddress +
+ ", fipTenantId='" + tenantUUID + '\'' +
+ ", fipRouterId='" + routerUUID + '\'' +
+ ", fipStatus='" + status + '\'' +
+ '}';
+ }
+
+ public void initDefaults() {
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Load Balancer as a service
+ * (LBaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields:
+ * Implemented fields are as follows:
+ *
+ * id uuid-str
+ * tenant_id uuid-str
+ * name String
+ * description String
+ * status String
+ * vip_address IP address
+ * vip_subnet uuid-str
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronLoadBalancer implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String loadBalancerID;
+
+ @XmlElement (name = "tenant_id")
+ String loadBalancerTenantID;
+
+ @XmlElement (name = "name")
+ String loadBalancerName;
+
+ @XmlElement (name = "description")
+ String loadBalancerDescription;
+
+ @XmlElement (name = "status")
+ String loadBalancerStatus;
+
+ @XmlElement (name = "admin_state_up")
+ Boolean loadBalancerAdminStateUp;
+
+ @XmlElement (name = "vip_address")
+ String loadBalancerVipAddress;
+
+ @XmlElement (name = "vip_subnet_id")
+ String loadBalancerVipSubnetID;
+
+ public String getID() {
+ return loadBalancerID;
+ }
+
+ public void setID(String id) {
+ loadBalancerID = id;
+ }
+
+ // @deprecated use getID()
+ public String getLoadBalancerID() {
+ return loadBalancerID;
+ }
+
+ // @deprecated use setID()
+ public void setLoadBalancerID(String loadBalancerID) {
+ this.loadBalancerID = loadBalancerID;
+ }
+
+ public String getLoadBalancerTenantID() {
+ return loadBalancerTenantID;
+ }
+
+ public void setLoadBalancerTenantID(String loadBalancerTenantID) {
+ this.loadBalancerTenantID = loadBalancerTenantID;
+ }
+
+ public String getLoadBalancerName() {
+ return loadBalancerName;
+ }
+
+ public void setLoadBalancerName(String loadBalancerName) {
+ this.loadBalancerName = loadBalancerName;
+ }
+
+ public String getLoadBalancerDescription() {
+ return loadBalancerDescription;
+ }
+
+ public void setLoadBalancerDescription(String loadBalancerDescription) {
+ this.loadBalancerDescription = loadBalancerDescription;
+ }
+
+ public String getLoadBalancerStatus() {
+ return loadBalancerStatus;
+ }
+
+ public void setLoadBalancerStatus(String loadBalancerStatus) {
+ this.loadBalancerStatus = loadBalancerStatus;
+ }
+
+ public Boolean getLoadBalancerAdminStateUp() {
+ return loadBalancerAdminStateUp;
+ }
+
+ public void setLoadBalancerAdminStateUp(Boolean loadBalancerAdminStateUp) {
+ this.loadBalancerAdminStateUp = loadBalancerAdminStateUp;
+ }
+
+ public String getLoadBalancerVipAddress() {
+ return loadBalancerVipAddress;
+ }
+
+ public void setLoadBalancerVipAddress(String loadBalancerVipAddress) {
+ this.loadBalancerVipAddress = loadBalancerVipAddress;
+ }
+
+ public String getLoadBalancerVipSubnetID() {
+ return loadBalancerVipSubnetID;
+ }
+
+ public void setLoadBalancerVipSubnetID(String loadBalancerVipSubnetID) {
+ this.loadBalancerVipSubnetID = loadBalancerVipSubnetID;
+ }
+
+ public NeutronLoadBalancer extractFields(List<String> fields) {
+ NeutronLoadBalancer ans = new NeutronLoadBalancer();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setLoadBalancerTenantID(this.getLoadBalancerTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setLoadBalancerName(this.getLoadBalancerName());
+ }
+ if(s.equals("description")) {
+ ans.setLoadBalancerDescription(this.getLoadBalancerDescription());
+ }
+ if (s.equals("vip_address")) {
+ ans.setLoadBalancerVipAddress(this.getLoadBalancerVipAddress());
+ }
+ if (s.equals("vip_subnet_id")) {
+ ans.setLoadBalancerVipSubnetID(this.getLoadBalancerVipSubnetID());
+ }
+ if (s.equals("status")) {
+ ans.setLoadBalancerStatus(this.getLoadBalancerStatus());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setLoadBalancerAdminStateUp(this.getLoadBalancerAdminStateUp());
+ }
+ }
+ return ans;
+ }
+
+ @Override public String toString() {
+ return "NeutronLoadBalancer{" +
+ "loadBalancerID='" + loadBalancerID + '\'' +
+ ", loadBalancerTenantID='" + loadBalancerTenantID + '\'' +
+ ", loadBalancerName='" + loadBalancerName + '\'' +
+ ", loadBalancerDescription='" + loadBalancerDescription + '\'' +
+ ", loadBalancerStatus='" + loadBalancerStatus + '\'' +
+ ", loadBalancerAdminStateUp='" + loadBalancerAdminStateUp + '\'' +
+ ", loadBalancerVipAddress='" + loadBalancerVipAddress + '\'' +
+ ", loadBalancerVipSubnetID='" + loadBalancerVipSubnetID + '\'' +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Load Balancer as a service
+ * (LBaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields:
+ * Implemented fields are as follows:
+ *
+ *
+ * id uuid-str
+ * tenant_id uuid-str
+ * type String
+ * delay Integer
+ * timeout Integer
+ * max_retries Integer
+ * http_method String
+ * url_path String
+ * expected_codes String
+ * admin_state_up Boolean
+ * status String
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronLoadBalancerHealthMonitor
+ implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String loadBalancerHealthMonitorID;
+
+ @XmlElement (name = "tenant_id")
+ String loadBalancerHealthMonitorTenantID;
+
+ @XmlElement (name = "type")
+ String loadBalancerHealthMonitorType;
+
+ @XmlElement (name = "delay")
+ Integer loadBalancerHealthMonitorDelay;
+
+ @XmlElement (name = "timeout")
+ Integer loadBalancerHealthMonitorTimeout;
+
+ @XmlElement (name = "max_retries")
+ Integer loadBalancerHealthMonitorMaxRetries;
+
+ @XmlElement (name = "http_method")
+ String loadBalancerHealthMonitorHttpMethod;
+
+ @XmlElement (name = "url_path")
+ String loadBalancerHealthMonitorUrlPath;
+
+ @XmlElement (name = "expected_codes")
+ String loadBalancerHealthMonitorExpectedCodes;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean loadBalancerHealthMonitorAdminStateIsUp;
+
+ @XmlElement (name = "pools")
+ List<Neutron_ID> loadBalancerHealthMonitorPools;
+
+ public String getID() {
+ return loadBalancerHealthMonitorID;
+ }
+
+ public void setID(String id) {
+ loadBalancerHealthMonitorID = id;
+ }
+
+ // @deprecated use getID()
+ public String getLoadBalancerHealthMonitorID() {
+ return loadBalancerHealthMonitorID;
+ }
+
+ // @deprecated use setID()
+ public void setLoadBalancerHealthMonitorID(String loadBalancerHealthMonitorID) {
+ this.loadBalancerHealthMonitorID = loadBalancerHealthMonitorID;
+ }
+
+ public String getLoadBalancerHealthMonitorTenantID() {
+ return loadBalancerHealthMonitorTenantID;
+ }
+
+ public void setLoadBalancerHealthMonitorTenantID(String loadBalancerHealthMonitorTenantID) {
+ this.loadBalancerHealthMonitorTenantID = loadBalancerHealthMonitorTenantID;
+ }
+
+ public String getLoadBalancerHealthMonitorType() {
+ return loadBalancerHealthMonitorType;
+ }
+
+ public void setLoadBalancerHealthMonitorType(String loadBalancerHealthMonitorType) {
+ this.loadBalancerHealthMonitorType = loadBalancerHealthMonitorType;
+ }
+
+ public Integer getLoadBalancerHealthMonitorDelay() {
+ return loadBalancerHealthMonitorDelay;
+ }
+
+ public void setLoadBalancerHealthMonitorDelay(Integer loadBalancerHealthMonitorDelay) {
+ this.loadBalancerHealthMonitorDelay = loadBalancerHealthMonitorDelay;
+ }
+
+ public Integer getLoadBalancerHealthMonitorTimeout() {
+ return loadBalancerHealthMonitorTimeout;
+ }
+
+ public void setLoadBalancerHealthMonitorTimeout(Integer loadBalancerHealthMonitorTimeout) {
+ this.loadBalancerHealthMonitorTimeout = loadBalancerHealthMonitorTimeout;
+ }
+
+ public Integer getLoadBalancerHealthMonitorMaxRetries() {
+ return loadBalancerHealthMonitorMaxRetries;
+ }
+
+ public void setLoadBalancerHealthMonitorMaxRetries(Integer loadBalancerHealthMonitorMaxRetries) {
+ this.loadBalancerHealthMonitorMaxRetries = loadBalancerHealthMonitorMaxRetries;
+ }
+
+ public String getLoadBalancerHealthMonitorHttpMethod() {
+ return loadBalancerHealthMonitorHttpMethod;
+ }
+
+ public void setLoadBalancerHealthMonitorHttpMethod(String loadBalancerHealthMonitorHttpMethod) {
+ this.loadBalancerHealthMonitorHttpMethod = loadBalancerHealthMonitorHttpMethod;
+ }
+
+ public String getLoadBalancerHealthMonitorUrlPath() {
+ return loadBalancerHealthMonitorUrlPath;
+ }
+
+ public void setLoadBalancerHealthMonitorUrlPath(String loadBalancerHealthMonitorUrlPath) {
+ this.loadBalancerHealthMonitorUrlPath = loadBalancerHealthMonitorUrlPath;
+ }
+
+ public String getLoadBalancerHealthMonitorExpectedCodes() {
+ return loadBalancerHealthMonitorExpectedCodes;
+ }
+
+ public void setLoadBalancerHealthMonitorExpectedCodes(String loadBalancerHealthMonitorExpectedCodes) {
+ this.loadBalancerHealthMonitorExpectedCodes = loadBalancerHealthMonitorExpectedCodes;
+ }
+
+ public Boolean getLoadBalancerHealthMonitorAdminStateIsUp() {
+ return loadBalancerHealthMonitorAdminStateIsUp;
+ }
+
+ public void setLoadBalancerHealthMonitorAdminStateIsUp(Boolean loadBalancerHealthMonitorAdminStateIsUp) {
+ this.loadBalancerHealthMonitorAdminStateIsUp = loadBalancerHealthMonitorAdminStateIsUp;
+ }
+
+ public List<Neutron_ID> getLoadBalancerHealthMonitorPools() {
+ return loadBalancerHealthMonitorPools;
+ }
+
+ public void setLoadBalancerHealthMonitorPools(List<Neutron_ID> loadBalancerHealthMonitorPools) {
+ this.loadBalancerHealthMonitorPools = loadBalancerHealthMonitorPools;
+ }
+
+ public NeutronLoadBalancerHealthMonitor extractFields(List<String> fields) {
+ NeutronLoadBalancerHealthMonitor ans = new NeutronLoadBalancerHealthMonitor();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setLoadBalancerHealthMonitorTenantID(this.getLoadBalancerHealthMonitorTenantID());
+ }
+ if (s.equals("type")) {
+ ans.setLoadBalancerHealthMonitorType(this.getLoadBalancerHealthMonitorType());
+ }
+ if (s.equals("delay")) {
+ ans.setLoadBalancerHealthMonitorDelay(this.getLoadBalancerHealthMonitorDelay());
+ }
+ if (s.equals("timeout")) {
+ ans.setLoadBalancerHealthMonitorTimeout(this.getLoadBalancerHealthMonitorTimeout());
+ }
+ if (s.equals("max_retries")) {
+ ans.setLoadBalancerHealthMonitorMaxRetries(this.getLoadBalancerHealthMonitorMaxRetries());
+ }
+ if (s.equals("http_method")) {
+ ans.setLoadBalancerHealthMonitorHttpMethod(this.getLoadBalancerHealthMonitorHttpMethod());
+ }
+ if(s.equals("url_path")) {
+ ans.setLoadBalancerHealthMonitorUrlPath(this.getLoadBalancerHealthMonitorUrlPath());
+ }
+ if (s.equals("expected_codes")) {
+ ans.setLoadBalancerHealthMonitorExpectedCodes(this.getLoadBalancerHealthMonitorExpectedCodes());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setLoadBalancerHealthMonitorAdminStateIsUp(loadBalancerHealthMonitorAdminStateIsUp);
+ }
+ }
+ return ans;
+ }
+
+ @Override public String toString() {
+ return "NeutronLoadBalancerHealthMonitor{" +
+ "loadBalancerHealthMonitorID='" + loadBalancerHealthMonitorID + '\'' +
+ ", loadBalancerHealthMonitorTenantID='" + loadBalancerHealthMonitorTenantID + '\'' +
+ ", loadBalancerHealthMonitorType='" + loadBalancerHealthMonitorType + '\'' +
+ ", loadBalancerHealthMonitorDelay=" + loadBalancerHealthMonitorDelay +
+ ", loadBalancerHealthMonitorTimeout=" + loadBalancerHealthMonitorTimeout +
+ ", loadBalancerHealthMonitorMaxRetries=" + loadBalancerHealthMonitorMaxRetries +
+ ", loadBalancerHealthMonitorHttpMethod='" + loadBalancerHealthMonitorHttpMethod + '\'' +
+ ", loadBalancerHealthMonitorUrlPath='" + loadBalancerHealthMonitorUrlPath + '\'' +
+ ", loadBalancerHealthMonitorExpectedCodes='" + loadBalancerHealthMonitorExpectedCodes + '\'' +
+ ", loadBalancerHealthMonitorAdminStateIsUp=" + loadBalancerHealthMonitorAdminStateIsUp +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Load Balancer as a service
+ * (LBaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields:
+ * Implemented fields are as follows:
+ *
+ * id uuid-str
+ * default_pool_id String
+ * tenant_id uuid-str
+ * name String
+ * description String
+ * shared Bool
+ * protocol String
+ * protocol_port String
+ * load_balancer_id String
+ * admin_state_up Boolean
+ * status String
+ *
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronLoadBalancerListener
+ implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String loadBalancerListenerID;
+
+ @XmlElement (name = "default_pool_id")
+ String neutronLoadBalancerListenerDefaultPoolID;
+
+ @XmlElement (name = "connection_limit")
+ Integer neutronLoadBalancerListenerConnectionLimit;
+
+ @XmlElement (name = "tenant_id")
+ String loadBalancerListenerTenantID;
+
+ @XmlElement (name = "name")
+ String loadBalancerListenerName;
+
+ @XmlElement (name = "description")
+ String loadBalancerListenerDescription;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean loadBalancerListenerAdminStateIsUp;
+
+ @XmlElement (name = "protocol")
+ String neutronLoadBalancerListenerProtocol;
+
+ @XmlElement (name = "protocol_port")
+ String neutronLoadBalancerListenerProtocolPort;
+
+ @XmlElement (name = "load_balancers")
+ List<Neutron_ID> neutronLoadBalancerListenerLoadBalancerIDs;
+
+ public String getID() {
+ return loadBalancerListenerID;
+ }
+
+ public void setID(String id) {
+ loadBalancerListenerID = id;
+ }
+
+ // @deprecated use getID()
+ public String getLoadBalancerListenerID() {
+ return loadBalancerListenerID;
+ }
+
+ // @deprecated use setID()
+ public void setLoadBalancerListenerID(String loadBalancerListenerID) {
+ this.loadBalancerListenerID = loadBalancerListenerID;
+ }
+
+ public String getLoadBalancerListenerTenantID() {
+ return loadBalancerListenerTenantID;
+ }
+
+ public void setLoadBalancerListenerTenantID(String loadBalancerListenerTenantID) {
+ this.loadBalancerListenerTenantID = loadBalancerListenerTenantID;
+ }
+
+ public String getLoadBalancerListenerName() {
+ return loadBalancerListenerName;
+ }
+
+ public void setLoadBalancerListenerName(String loadBalancerListenerName) {
+ this.loadBalancerListenerName = loadBalancerListenerName;
+ }
+
+ public String getLoadBalancerListenerDescription() {
+ return loadBalancerListenerDescription;
+ }
+
+ public void setLoadBalancerListenerDescription(String loadBalancerListenerDescription) {
+ this.loadBalancerListenerDescription = loadBalancerListenerDescription;
+ }
+
+ public Boolean getLoadBalancerListenerAdminStateIsUp() {
+ return loadBalancerListenerAdminStateIsUp;
+ }
+
+ public void setLoadBalancerListenerAdminStateIsUp(Boolean loadBalancerListenerAdminStateIsUp) {
+ this.loadBalancerListenerAdminStateIsUp = loadBalancerListenerAdminStateIsUp;
+ }
+
+ public String getNeutronLoadBalancerListenerProtocol() {
+ return neutronLoadBalancerListenerProtocol;
+ }
+
+ public void setNeutronLoadBalancerListenerProtocol(String neutronLoadBalancerListenerProtocol) {
+ this.neutronLoadBalancerListenerProtocol = neutronLoadBalancerListenerProtocol;
+ }
+
+ public String getNeutronLoadBalancerListenerProtocolPort() {
+ return neutronLoadBalancerListenerProtocolPort;
+ }
+
+ public void setNeutronLoadBalancerListenerProtocolPort(String neutronLoadBalancerListenerProtocolPort) {
+ this.neutronLoadBalancerListenerProtocolPort = neutronLoadBalancerListenerProtocolPort;
+ }
+
+ public String getNeutronLoadBalancerListenerDefaultPoolID() {
+ return neutronLoadBalancerListenerDefaultPoolID;
+ }
+
+ public void setNeutronLoadBalancerListenerDefaultPoolID(String neutronLoadBalancerListenerDefaultPoolID) {
+ this.neutronLoadBalancerListenerDefaultPoolID = neutronLoadBalancerListenerDefaultPoolID;
+ }
+
+ public Integer getNeutronLoadBalancerListenerConnectionLimit() {
+ return neutronLoadBalancerListenerConnectionLimit;
+ }
+
+ public void setNeutronLoadBalancerListenerConnectionLimit(Integer neutronLoadBalancerListenerConnectionLimit) {
+ this.neutronLoadBalancerListenerConnectionLimit = neutronLoadBalancerListenerConnectionLimit;
+ }
+
+ public List<Neutron_ID> getNeutronLoadBalancerListenerLoadBalancerIDs() {
+ return neutronLoadBalancerListenerLoadBalancerIDs;
+ }
+
+ public void setNeutronLoadBalancerListenerLoadBalancerIDs(List<Neutron_ID> neutronLoadBalancerListenerLoadBalancerIDs) {
+ this.neutronLoadBalancerListenerLoadBalancerIDs = neutronLoadBalancerListenerLoadBalancerIDs;
+ }
+
+ public NeutronLoadBalancerListener extractFields(List<String> fields) {
+ NeutronLoadBalancerListener ans = new NeutronLoadBalancerListener();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if(s.equals("default_pool_id")) {
+ ans.setNeutronLoadBalancerListenerDefaultPoolID(this.getNeutronLoadBalancerListenerDefaultPoolID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setLoadBalancerListenerTenantID(this.getLoadBalancerListenerTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setLoadBalancerListenerName(this.getLoadBalancerListenerName());
+ }
+ if(s.equals("description")) {
+ ans.setLoadBalancerListenerDescription(this.getLoadBalancerListenerDescription());
+ }
+ if (s.equals("protocol")) {
+ ans.setNeutronLoadBalancerListenerProtocol(this.getNeutronLoadBalancerListenerProtocol());
+ }
+ if (s.equals("protocol_port")) {
+ ans.setNeutronLoadBalancerListenerProtocolPort(this.getNeutronLoadBalancerListenerProtocolPort());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setLoadBalancerListenerAdminStateIsUp(loadBalancerListenerAdminStateIsUp);
+ }
+ }
+ return ans;
+ }
+
+ @Override public String toString() {
+ return "NeutronLoadBalancerListener{" +
+ "loadBalancerListenerID='" + loadBalancerListenerID + '\'' +
+ ", neutronLoadBalancerListenerDefaultPoolID='" + neutronLoadBalancerListenerDefaultPoolID + '\'' +
+ ", neutronLoadBalancerListenerConnectionLimit='" + neutronLoadBalancerListenerConnectionLimit + '\'' +
+ ", loadBalancerListenerTenantID='" + loadBalancerListenerTenantID + '\'' +
+ ", loadBalancerListenerName='" + loadBalancerListenerName + '\'' +
+ ", loadBalancerListenerDescription='" + loadBalancerListenerDescription + '\'' +
+ ", loadBalancerListenerAdminStateIsUp=" + loadBalancerListenerAdminStateIsUp +
+ ", neutronLoadBalancerListenerProtocol='" + neutronLoadBalancerListenerProtocol + '\'' +
+ ", neutronLoadBalancerListenerProtocolPort='" + neutronLoadBalancerListenerProtocolPort + '\'' +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OpenStack Neutron v2.0 Load Balancer as a service
+ * (LBaaS) bindings. See OpenStack Network API
+ * v2.0 Reference for description of the fields:
+ * Implemented fields are as follows:
+ *
+ * id uuid-str
+ * tenant_id uuid-str
+ * name String
+ * description String
+ * protocol String
+ * lb_algorithm String
+ * healthmonitor_id String
+ * admin_state_up Bool
+ * status String
+ * members List <NeutronLoadBalancerPoolMember>
+ * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronLoadBalancerPool implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String loadBalancerPoolID;
+
+ @XmlElement (name = "tenant_id")
+ String loadBalancerPoolTenantID;
+
+ @XmlElement (name = "name")
+ String loadBalancerPoolName;
+
+ @XmlElement (name = "description")
+ String loadBalancerPoolDescription;
+
+ @XmlElement (name = "protocol")
+ String loadBalancerPoolProtocol;
+
+ @XmlElement (name = "lb_algorithm")
+ String loadBalancerPoolLbAlgorithm;
+
+ @XmlElement (name = "healthmonitor_id")
+ String neutronLoadBalancerPoolHealthMonitorID;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean loadBalancerPoolAdminStateIsUp;
+
+ @XmlElement(name = "listeners")
+ List<Neutron_ID> loadBalancerPoolListeners;
+
+ @XmlElement(name = "session_persistence")
+ NeutronLoadBalancer_SessionPersistence loadBalancerPoolSessionPersistence;
+
+ @XmlElement(name = "members")
+ List<NeutronLoadBalancerPoolMember> loadBalancerPoolMembers;
+
+ public NeutronLoadBalancerPool() {
+ }
+
+ public String getID() {
+ return loadBalancerPoolID;
+ }
+
+ public void setID(String id) {
+ loadBalancerPoolID = id;
+ }
+
+ // @deprecated use getID()
+ public String getLoadBalancerPoolID() {
+ return loadBalancerPoolID;
+ }
+
+ // @deprecated use setID()
+ public void setLoadBalancerPoolID(String loadBalancerPoolID) {
+ this.loadBalancerPoolID = loadBalancerPoolID;
+ }
+
+ public String getLoadBalancerPoolTenantID() {
+ return loadBalancerPoolTenantID;
+ }
+
+ public void setLoadBalancerPoolTenantID(String loadBalancerPoolTenantID) {
+ this.loadBalancerPoolTenantID = loadBalancerPoolTenantID;
+ }
+
+ public String getLoadBalancerPoolName() {
+ return loadBalancerPoolName;
+ }
+
+ public void setLoadBalancerPoolName(String loadBalancerPoolName) {
+ this.loadBalancerPoolName = loadBalancerPoolName;
+ }
+
+ public String getLoadBalancerPoolDescription() {
+ return loadBalancerPoolDescription;
+ }
+
+ public void setLoadBalancerPoolDescription(String loadBalancerPoolDescription) {
+ this.loadBalancerPoolDescription = loadBalancerPoolDescription;
+ }
+
+ public String getLoadBalancerPoolProtocol() {
+ return loadBalancerPoolProtocol;
+ }
+
+ public void setLoadBalancerPoolProtocol(String loadBalancerPoolProtocol) {
+ this.loadBalancerPoolProtocol = loadBalancerPoolProtocol;
+ }
+
+ public String getLoadBalancerPoolLbAlgorithm() {
+ return loadBalancerPoolLbAlgorithm;
+ }
+
+ public void setLoadBalancerPoolLbAlgorithm(String loadBalancerPoolLbAlgorithm) {
+ this.loadBalancerPoolLbAlgorithm = loadBalancerPoolLbAlgorithm;
+ }
+
+ public String getNeutronLoadBalancerPoolHealthMonitorID() {
+ return neutronLoadBalancerPoolHealthMonitorID;
+ }
+
+ public void setNeutronLoadBalancerPoolHealthMonitorID(String neutronLoadBalancerPoolHealthMonitorID) {
+ this.neutronLoadBalancerPoolHealthMonitorID = neutronLoadBalancerPoolHealthMonitorID;
+ }
+
+ public Boolean getLoadBalancerPoolAdminIsStateIsUp() {
+ return loadBalancerPoolAdminStateIsUp;
+ }
+
+ public void setLoadBalancerPoolAdminStateIsUp(Boolean loadBalancerPoolAdminStateIsUp) {
+ this.loadBalancerPoolAdminStateIsUp = loadBalancerPoolAdminStateIsUp;
+ }
+
+ public NeutronLoadBalancer_SessionPersistence getLoadBalancerPoolSessionPersistence() {
+ return loadBalancerPoolSessionPersistence;
+ }
+
+ public void setLoadBalancerSessionPersistence(NeutronLoadBalancer_SessionPersistence loadBalancerPoolSessionPersistence) {
+ this.loadBalancerPoolSessionPersistence = loadBalancerPoolSessionPersistence;
+ }
+
+ public List<Neutron_ID> getLoadBalancerPoolListeners() {
+ return loadBalancerPoolListeners;
+ }
+
+ public void setLoadBalancerPoolListeners(List<Neutron_ID> loadBalancerPoolListeners) {
+ this.loadBalancerPoolListeners = loadBalancerPoolListeners;
+ }
+
+ public List<NeutronLoadBalancerPoolMember> getLoadBalancerPoolMembers() {
+ /*
+ * Update the pool_id of the member to that this.loadBalancerPoolID
+ */
+ if (loadBalancerPoolMembers != null) {
+ for (NeutronLoadBalancerPoolMember member: loadBalancerPoolMembers) {
+ member.setPoolID(loadBalancerPoolID);
+ }
+ return loadBalancerPoolMembers;
+ }
+ return loadBalancerPoolMembers;
+ }
+
+ public void setLoadBalancerPoolMembers(List<NeutronLoadBalancerPoolMember> loadBalancerPoolMembers) {
+ this.loadBalancerPoolMembers = loadBalancerPoolMembers;
+ }
+
+ public void addLoadBalancerPoolMember(NeutronLoadBalancerPoolMember loadBalancerPoolMember) {
+ this.loadBalancerPoolMembers.add(loadBalancerPoolMember);
+ }
+
+ public void removeLoadBalancerPoolMember(NeutronLoadBalancerPoolMember loadBalancerPoolMember) {
+ this.loadBalancerPoolMembers.remove(loadBalancerPoolMember);
+ }
+
+ public NeutronLoadBalancerPool extractFields(List<String> fields) {
+ NeutronLoadBalancerPool ans = new NeutronLoadBalancerPool();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setLoadBalancerPoolTenantID(this.getLoadBalancerPoolTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setLoadBalancerPoolName(this.getLoadBalancerPoolName());
+ }
+ if(s.equals("description")) {
+ ans.setLoadBalancerPoolDescription(this.getLoadBalancerPoolDescription());
+ }
+ if(s.equals("protocol")) {
+ ans.setLoadBalancerPoolProtocol(this.getLoadBalancerPoolProtocol());
+ }
+ if (s.equals("lb_algorithm")) {
+ ans.setLoadBalancerPoolLbAlgorithm(this.getLoadBalancerPoolLbAlgorithm());
+ }
+ if (s.equals("healthmonitor_id")) {
+ ans.setNeutronLoadBalancerPoolHealthMonitorID(this.getNeutronLoadBalancerPoolHealthMonitorID());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setLoadBalancerPoolAdminStateIsUp(loadBalancerPoolAdminStateIsUp);
+ }
+ if (s.equals("members")) {
+ ans.setLoadBalancerPoolMembers(getLoadBalancerPoolMembers());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronLoadBalancerPool{" +
+ "id='" + loadBalancerPoolID + '\'' +
+ ", tenantID='" + loadBalancerPoolTenantID + '\'' +
+ ", name='" + loadBalancerPoolName + '\'' +
+ ", description='" + loadBalancerPoolDescription + '\'' +
+ ", protocol=" + loadBalancerPoolProtocol +'\''+
+ ", lbAlgorithm='" + loadBalancerPoolLbAlgorithm + '\'' +
+ ", healthmonitorID=" + neutronLoadBalancerPoolHealthMonitorID +
+ ", adminStateUp=" + loadBalancerPoolAdminStateIsUp +
+// todo: add loadBalancerPoolMembers as joined string
+ '}';
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronLoadBalancerPoolMember
+ implements Serializable, INeutronObject {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * TODO: Plumb into LBaaS Pool. Members are nested underneath Pool CRUD.
+ */
+ @XmlElement (name = "id")
+ String poolMemberID;
+
+ @XmlElement (name = "tenant_id")
+ String poolMemberTenantID;
+
+ @XmlElement (name = "address")
+ String poolMemberAddress;
+
+ @XmlElement (name = "protocol_port")
+ Integer poolMemberProtoPort;
+
+ @XmlElement (name = "admin_state_up")
+ Boolean poolMemberAdminStateIsUp;
+
+ @XmlElement (name = "weight")
+ Integer poolMemberWeight;
+
+ @XmlElement (name = "subnet_id")
+ String poolMemberSubnetID;
+
+ String poolID;
+
+ public NeutronLoadBalancerPoolMember() {
+ }
+
+ @XmlTransient
+ public String getPoolID() {
+ return poolID;
+ }
+
+ public void setPoolID(String poolID) {
+ this.poolID = poolID;
+ }
+
+ public String getID() {
+ return poolMemberID;
+ }
+
+ public void setID(String id) {
+ poolMemberID = id;
+ }
+
+ // @deprecated use getID()
+ public String getPoolMemberID() {
+ return poolMemberID;
+ }
+
+ // @deprecated use setID()
+ public void setPoolMemberID(String poolMemberID) {
+ this.poolMemberID = poolMemberID;
+ }
+
+ public String getPoolMemberTenantID() {
+ return poolMemberTenantID;
+ }
+
+ public void setPoolMemberTenantID(String poolMemberTenantID) {
+ this.poolMemberTenantID = poolMemberTenantID;
+ }
+
+ public String getPoolMemberAddress() {
+ return poolMemberAddress;
+ }
+
+ public void setPoolMemberAddress(String poolMemberAddress) {
+ this.poolMemberAddress = poolMemberAddress;
+ }
+
+ public Integer getPoolMemberProtoPort() {
+ return poolMemberProtoPort;
+ }
+
+ public void setPoolMemberProtoPort(Integer poolMemberProtoPort) {
+ this.poolMemberProtoPort = poolMemberProtoPort;
+ }
+
+ public Boolean getPoolMemberAdminStateIsUp() {
+ return poolMemberAdminStateIsUp;
+ }
+
+ public void setPoolMemberAdminStateIsUp(Boolean poolMemberAdminStateIsUp) {
+ this.poolMemberAdminStateIsUp = poolMemberAdminStateIsUp;
+ }
+
+ public Integer getPoolMemberWeight() {
+ return poolMemberWeight;
+ }
+
+ public void setPoolMemberWeight(Integer poolMemberWeight) {
+ this.poolMemberWeight = poolMemberWeight;
+ }
+
+ public String getPoolMemberSubnetID() {
+ return poolMemberSubnetID;
+ }
+
+ public void setPoolMemberSubnetID(String poolMemberSubnetID) {
+ this.poolMemberSubnetID = poolMemberSubnetID;
+ }
+
+ public NeutronLoadBalancerPoolMember extractFields(List<String> fields) {
+ NeutronLoadBalancerPoolMember ans = new NeutronLoadBalancerPoolMember();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("pool_id")) {
+ ans.setPoolID(this.getPoolID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setPoolMemberTenantID(this.getPoolMemberTenantID());
+ }
+ if (s.equals("address")) {
+ ans.setPoolMemberAddress(this.getPoolMemberAddress());
+ }
+ if(s.equals("protocol_port")) {
+ ans.setPoolMemberProtoPort(this.getPoolMemberProtoPort());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setPoolMemberAdminStateIsUp(poolMemberAdminStateIsUp);
+ }
+ if(s.equals("weight")) {
+ ans.setPoolMemberWeight(this.getPoolMemberWeight());
+ }
+ if(s.equals("subnet_id")) {
+ ans.setPoolMemberSubnetID(this.getPoolMemberSubnetID());
+ }
+ }
+ return ans;
+ }
+ @Override public String toString() {
+ return "NeutronLoadBalancerPoolMember{" +
+ "poolMemberID='" + poolMemberID + '\'' +
+ ", poolID='" + poolID + '\'' +
+ ", poolMemberTenantID='" + poolMemberTenantID + '\'' +
+ ", poolMemberAddress='" + poolMemberAddress + '\'' +
+ ", poolMemberProtoPort=" + poolMemberProtoPort +
+ ", poolMemberAdminStateIsUp=" + poolMemberAdminStateIsUp +
+ ", poolMemberWeight=" + poolMemberWeight +
+ ", poolMemberSubnetID='" + poolMemberSubnetID + '\'' +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronLoadBalancer_SessionPersistence implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "cookie_name")
+ String cookieName;
+
+ @XmlElement(name = "type")
+ String type;
+
+ public NeutronLoadBalancer_SessionPersistence() {
+ }
+
+ public NeutronLoadBalancer_SessionPersistence(String cookieName, String type) {
+ this.cookieName = cookieName;
+ this.type = type;
+ }
+
+ public String getCookieName() {
+ return cookieName;
+ }
+
+ public void setCookieName(String cookieName) {
+ this.cookieName = cookieName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "network")
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronNetwork implements Serializable, INeutronObject {
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement (name = "id")
+ String networkUUID;
+
+ @XmlElement (name = "name")
+ String networkName;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean adminStateUp;
+
+ @XmlElement (defaultValue = "false", name = "shared")
+ Boolean shared;
+
+ @XmlElement (name = "tenant_id")
+ String tenantID;
+
+ // @XmlElement (defaultValue = "false", name = "router:external")
+ @XmlElement (defaultValue="false", namespace="router", name="external")
+ Boolean routerExternal;
+
+ // @XmlElement (defaultValue = "flat", name = "provider:network_type")
+ @XmlElement (namespace="provider", name="network_type")
+ String providerNetworkType;
+
+ // @XmlElement (name = "provider:physical_network")
+ @XmlElement (namespace="provider", name="physical_network")
+ String providerPhysicalNetwork;
+
+ // @XmlElement (name = "provider:segmentation_id")
+ @XmlElement (namespace="provider", name="segmentation_id")
+ String providerSegmentationID;
+
+ @XmlElement (name = "status")
+ String status;
+
+ @XmlElement (name = "subnets")
+ List<String> subnets;
+
+ @XmlElement (name="segments")
+ List<NeutronNetwork_Segment> segments;
+
+ @XmlElement (name="vlan_transparent")
+ Boolean vlanTransparent;
+
+ @XmlElement (name="mtu")
+ Integer mtu;
+
+ /* This attribute lists the ports associated with an instance
+ * which is needed for determining if that instance can be deleted
+ */
+
+ public NeutronNetwork() {
+ }
+
+ public void initDefaults() {
+ subnets = new ArrayList<String>();
+ if (status == null) {
+ status = "ACTIVE";
+ }
+ if (adminStateUp == null) {
+ adminStateUp = true;
+ }
+ if (shared == null) {
+ shared = false;
+ }
+ if (routerExternal == null) {
+ routerExternal = false;
+ }
+ if (providerNetworkType == null) {
+ providerNetworkType = "flat";
+ }
+ }
+
+ public String getID() { return networkUUID; }
+
+ public void setID(String id) { this.networkUUID = id; }
+
+ public String getNetworkUUID() {
+ return networkUUID;
+ }
+
+ public void setNetworkUUID(String networkUUID) {
+ this.networkUUID = networkUUID;
+ }
+
+ public String getNetworkName() {
+ return networkName;
+ }
+
+ public void setNetworkName(String networkName) {
+ this.networkName = networkName;
+ }
+
+ public boolean isAdminStateUp() {
+ return adminStateUp;
+ }
+
+ public Boolean getAdminStateUp() { return adminStateUp; }
+
+ public void setAdminStateUp(boolean newValue) {
+ adminStateUp = newValue;
+ }
+
+ public boolean isShared() { return shared; }
+
+ public Boolean getShared() { return shared; }
+
+ public void setShared(boolean newValue) {
+ shared = newValue;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public void setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ }
+
+ public boolean isRouterExternal() { return routerExternal; }
+
+ public Boolean getRouterExternal() { return routerExternal; }
+
+ public void setRouterExternal(boolean newValue) {
+ routerExternal = newValue;
+ }
+
+ public String getProviderNetworkType() {
+ return providerNetworkType;
+ }
+
+ public void setProviderNetworkType(String providerNetworkType) {
+ this.providerNetworkType = providerNetworkType;
+ }
+
+ public String getProviderPhysicalNetwork() {
+ return providerPhysicalNetwork;
+ }
+
+ public void setProviderPhysicalNetwork(String providerPhysicalNetwork) {
+ this.providerPhysicalNetwork = providerPhysicalNetwork;
+ }
+
+ public String getProviderSegmentationID() {
+ return providerSegmentationID;
+ }
+
+ public void setProviderSegmentationID(String providerSegmentationID) {
+ this.providerSegmentationID = providerSegmentationID;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public List<String> getSubnets() {
+ return subnets;
+ }
+
+ public void setSubnets(List<String> subnets) {
+ this.subnets = subnets;
+ }
+
+ public void addSubnet(String uuid) {
+ subnets.add(uuid);
+ }
+
+ public void removeSubnet(String uuid) {
+ subnets.remove(uuid);
+ }
+
+ public void setSegments(List<NeutronNetwork_Segment> segments) {
+ this.segments = segments;
+ }
+
+ public List<NeutronNetwork_Segment> getSegments() {
+ return segments;
+ }
+
+ public Boolean getVlanTransparent() {
+ return vlanTransparent;
+ }
+
+ public void setVlanTransparent(Boolean input) {
+ this.vlanTransparent = input;
+ }
+
+ public Integer getMtu() {
+ return mtu;
+ }
+
+ public void setMtu(Integer input) {
+ mtu = input;
+ }
+
+ /**
+ * This method copies selected fields from the object and returns them
+ * as a new object, suitable for marshaling.
+ *
+ * @param fields
+ * List of attributes to be extracted
+ * @return an OpenStackNetworks object with only the selected fields
+ * populated
+ */
+
+ public NeutronNetwork extractFields(List<String> fields) {
+ NeutronNetwork ans = new NeutronNetwork();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setNetworkUUID(this.getNetworkUUID());
+ }
+ if (s.equals("name")) {
+ ans.setNetworkName(this.getNetworkName());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setAdminStateUp(adminStateUp);
+ }
+ if (s.equals("status")) {
+ ans.setStatus(this.getStatus());
+ }
+ if (s.equals("subnets")) {
+ List<String> subnetList = new ArrayList<String>();
+ subnetList.addAll(this.getSubnets());
+ ans.setSubnets(subnetList);
+ }
+ if (s.equals("shared")) {
+ ans.setShared(shared);
+ }
+ if (s.equals("tenant_id")) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if (s.equals("external")) {
+ ans.setRouterExternal(this.getRouterExternal());
+ }
+ if (s.equals("segmentation_id")) {
+ ans.setProviderSegmentationID(this.getProviderSegmentationID());
+ }
+ if (s.equals("physical_network")) {
+ ans.setProviderPhysicalNetwork(this.getProviderPhysicalNetwork());
+ }
+ if (s.equals("network_type")) {
+ ans.setProviderNetworkType(this.getProviderNetworkType());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronNetwork [networkUUID=" + networkUUID + ", networkName=" + networkName + ", adminStateUp="
+ + adminStateUp + ", shared=" + shared + ", tenantID=" + tenantID + ", routerExternal=" + routerExternal
+ + ", providerNetworkType=" + providerNetworkType + ", providerPhysicalNetwork="
+ + providerPhysicalNetwork + ", providerSegmentationID=" + providerSegmentationID + ", status=" + status
+ + ", subnets=" + subnets + ", segments = " + segments + "]";
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "network")
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronNetwork_Segment implements Serializable {
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ private static final long serialVersionUID = 1L;
+
+ // @XmlElement (defaultValue="flat", name="provider:network_type")
+ @XmlElement (defaultValue="flat", namespace="provider", name="network_type")
+ String providerNetworkType;
+
+ // @XmlElement (name="provider:physical_network")
+ @XmlElement (namespace="provider", name="physical_network")
+ String providerPhysicalNetwork;
+
+ // @XmlElement (name="provider:segmentation_id")
+ @XmlElement (namespace="provider", name="segmentation_id")
+ String providerSegmentationID;
+
+ public NeutronNetwork_Segment() {
+ }
+
+ public String getProviderNetworkType() {
+ return providerNetworkType;
+ }
+
+ public void setProviderNetworkType(String providerNetworkType) {
+ this.providerNetworkType = providerNetworkType;
+ }
+
+ public String getProviderPhysicalNetwork() {
+ return providerPhysicalNetwork;
+ }
+
+ public void setProviderPhysicalNetwork(String providerPhysicalNetwork) {
+ this.providerPhysicalNetwork = providerPhysicalNetwork;
+ }
+
+ public String getProviderSegmentationID() {
+ return providerSegmentationID;
+ }
+
+ public void setProviderSegmentationID(String providerSegmentationID) {
+ this.providerSegmentationID = providerSegmentationID;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronNetwork_Segment [ " +
+ ", providerNetworkType=" + providerNetworkType +
+ ", providerPhysicalNetwork=" + providerPhysicalNetwork +
+ ", providerSegmentationID=" + providerSegmentationID + "]";
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronPort implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement (name = "id")
+ String portUUID;
+
+ @XmlElement (name = "network_id")
+ String networkUUID;
+
+ @XmlElement (name = "name")
+ String name;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean adminStateUp;
+
+ @XmlElement (name = "status")
+ String status;
+
+ @XmlElement (name = "mac_address")
+ String macAddress;
+
+ @XmlElement (name = "fixed_ips")
+ List<Neutron_IPs> fixedIPs;
+
+ @XmlElement (name = "device_id")
+ String deviceID;
+
+ @XmlElement (name = "device_owner")
+ String deviceOwner;
+
+ @XmlElement (name = "tenant_id")
+ String tenantID;
+
+ @XmlElement (name = "security_groups")
+ List<NeutronSecurityGroup> securityGroups;
+
+ @XmlElement (name = "allowed_address_pairs")
+ List<NeutronPort_AllowedAddressPairs> allowedAddressPairs;
+
+ //@XmlElement (name = "binding:host_id")
+ @XmlElement (namespace = "binding", name = "host_id")
+ String bindinghostID;
+
+ //@XmlElement (name = "binding:vnic_type")
+ @XmlElement (namespace = "binding", name = "vnic_type")
+ String bindingvnicType;
+
+ //@XmlElement (name = "binding:vif_type")
+ @XmlElement (namespace = "binding", name = "vif_type")
+ String bindingvifType;
+
+ //@XmlElement (name = "binding:vif_details")
+ @XmlElement (namespace = "binding", name = "vif_details")
+ List<NeutronPort_VIFDetail> vifDetails;
+
+ @XmlElement (name = "extra_dhcp_opts")
+ List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
+
+ NeutronPort originalPort;
+
+ public NeutronPort() {
+ }
+
+ public String getID() { return portUUID; }
+
+ public void setID(String id) { this.portUUID = id; }
+
+ public String getPortUUID() {
+ return portUUID;
+ }
+
+ public void setPortUUID(String portUUID) {
+ this.portUUID = portUUID;
+ }
+
+ public String getNetworkUUID() {
+ return networkUUID;
+ }
+
+ public void setNetworkUUID(String networkUUID) {
+ this.networkUUID = networkUUID;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isAdminStateUp() {
+ if (adminStateUp == null) {
+ return true;
+ }
+ return adminStateUp;
+ }
+
+ public Boolean getAdminStateUp() { return adminStateUp; }
+
+ public void setAdminStateUp(Boolean newValue) {
+ adminStateUp = newValue;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ public List<Neutron_IPs> getFixedIPs() {
+ return fixedIPs;
+ }
+
+ public void setFixedIPs(List<Neutron_IPs> fixedIPs) {
+ this.fixedIPs = fixedIPs;
+ }
+
+ public String getDeviceID() {
+ return deviceID;
+ }
+
+ public void setDeviceID(String deviceID) {
+ this.deviceID = deviceID;
+ }
+
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ public void setDeviceOwner(String deviceOwner) {
+ this.deviceOwner = deviceOwner;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public void setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ }
+
+ public List<NeutronSecurityGroup> getSecurityGroups() {
+ return securityGroups;
+ }
+
+ public void setSecurityGroups(List<NeutronSecurityGroup> securityGroups) {
+ this.securityGroups = securityGroups;
+ }
+
+ public List<NeutronPort_AllowedAddressPairs> getAllowedAddressPairs() {
+ return allowedAddressPairs;
+ }
+
+ public void setAllowedAddressPairs(List<NeutronPort_AllowedAddressPairs> allowedAddressPairs) {
+ this.allowedAddressPairs = allowedAddressPairs;
+ }
+
+ public List<NeutronPort_ExtraDHCPOption> getExtraDHCPOptions() {
+ return extraDHCPOptions;
+ }
+
+ public void setExtraDHCPOptions(List<NeutronPort_ExtraDHCPOption> extraDHCPOptions) {
+ this.extraDHCPOptions = extraDHCPOptions;
+ }
+
+ public List<NeutronPort_VIFDetail> getVIFDetail() {
+ return vifDetails;
+ }
+
+ public void setVIFDetail(List<NeutronPort_VIFDetail> vifDetails) {
+ this.vifDetails = vifDetails;
+ }
+
+ public String getBindinghostID() {
+ return bindinghostID;
+ }
+
+ public void setBindinghostID(String bindinghostID) {
+ this.bindinghostID = bindinghostID;
+ }
+
+ public String getBindingvnicType() {
+ return bindingvnicType;
+ }
+
+ public void setBindingvnicType(String bindingvnicType) {
+ this.bindingvnicType = bindingvnicType;
+ }
+
+ public String getBindingvifType() {
+ return bindingvifType;
+ }
+
+ public void setBindingvifType(String bindingvifType) {
+ this.bindingvifType = bindingvifType;
+ }
+
+ public NeutronPort getOriginalPort() {
+ return originalPort;
+ }
+
+
+ public void setOriginalPort(NeutronPort originalPort) {
+ this.originalPort = originalPort;
+ }
+
+ /**
+ * This method copies selected fields from the object and returns them
+ * as a new object, suitable for marshaling.
+ *
+ * @param fields
+ * List of attributes to be extracted
+ * @return an OpenStackPorts object with only the selected fields
+ * populated
+ */
+
+ public NeutronPort extractFields(List<String> fields) {
+ NeutronPort ans = new NeutronPort();
+ for (String field: fields) {
+ if ("id".equals(field)) {
+ ans.setPortUUID(this.getPortUUID());
+ }
+ if ("network_id".equals(field)) {
+ ans.setNetworkUUID(this.getNetworkUUID());
+ }
+ if ("name".equals(field)) {
+ ans.setName(this.getName());
+ }
+ if ("admin_state_up".equals(field)) {
+ ans.setAdminStateUp(this.getAdminStateUp());
+ }
+ if ("status".equals(field)) {
+ ans.setStatus(this.getStatus());
+ }
+ if ("mac_address".equals(field)) {
+ ans.setMacAddress(this.getMacAddress());
+ }
+ if ("fixed_ips".equals(field)) {
+ ans.setFixedIPs(new ArrayList<Neutron_IPs>(this.getFixedIPs()));
+ }
+ if ("device_id".equals(field)) {
+ ans.setDeviceID(this.getDeviceID());
+ }
+ if ("device_owner".equals(field)) {
+ ans.setDeviceOwner(this.getDeviceOwner());
+ }
+ if ("tenant_id".equals(field)) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if ("security_groups".equals(field)) {
+ ans.setSecurityGroups(new ArrayList<NeutronSecurityGroup>(this.getSecurityGroups()));
+ }
+ }
+ return ans;
+ }
+
+ public void initDefaults() {
+ adminStateUp = true;
+ if (status == null) {
+ status = "ACTIVE";
+ }
+ if (fixedIPs == null) {
+ fixedIPs = new ArrayList<Neutron_IPs>();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronPort [portUUID=" + portUUID + ", networkUUID=" + networkUUID + ", name=" + name
+ + ", adminStateUp=" + adminStateUp + ", status=" + status + ", macAddress=" + macAddress
+ + ", fixedIPs=" + fixedIPs + ", deviceID=" + deviceID + ", deviceOwner=" + deviceOwner + ", tenantID="
+ + tenantID + ", securityGroups=" + securityGroups
+ + ", bindinghostID=" + bindinghostID + ", bindingvnicType=" + bindingvnicType
+ + ", bindingvnicType=" + bindingvnicType + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronPort_AllowedAddressPairs implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement (name = "port_id")
+ String portID;
+
+ @XmlElement (name = "mac_address")
+ String macAddress;
+
+ @XmlElement (name = "ip_address")
+ String ipAddress;
+
+ public NeutronPort_AllowedAddressPairs() {
+ }
+
+ public NeutronPort_AllowedAddressPairs(String portID, String macAddress, String ipAddress) {
+ this.portID = portID;
+ this.macAddress = macAddress;
+ this.ipAddress = ipAddress;
+ }
+
+ public String getPortID() { return(portID); }
+
+ public void setPortID(String portID) { this.portID = portID; }
+
+ public String getMacAddress() { return(macAddress); }
+
+ public void setMacAddress(String macAddress) { this.macAddress = macAddress; }
+
+ public String getIpAddress() { return(ipAddress); }
+
+ public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronPort_ExtraDHCPOption implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement (name = "opt_value")
+ String value;
+
+ @XmlElement (name = "opt_name")
+ String name;
+
+ public NeutronPort_ExtraDHCPOption() {
+ }
+
+ public NeutronPort_ExtraDHCPOption(String value, String name) {
+ this.value = value;
+ this.name = name;
+ }
+
+ public String getValue() { return(value); }
+
+ public void setValue(String value) { this.value = value; }
+
+ public String getName() { return(name); }
+
+ public void setName(String name) { this.name = name; }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronPort_VIFDetail implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement (name = "port_filter")
+ Boolean portFilter;
+
+ @XmlElement (name = "ovs_hybrid_plug")
+ Boolean ovsHybridPlug;
+
+ public NeutronPort_VIFDetail() {
+ }
+
+ public NeutronPort_VIFDetail(Boolean portFilter, Boolean ovsHybridPlug) {
+ this.portFilter = portFilter;
+ this.ovsHybridPlug = ovsHybridPlug;
+ }
+
+ public Boolean getPortFilter() { return(portFilter); }
+
+ public void setPortFilter(Boolean portFilter) { this.portFilter = portFilter; }
+
+ public Boolean getOvsHybridPlug() { return(ovsHybridPlug); }
+
+ public void setOvsHybridPlug(Boolean ovsHybridPlug) { this.ovsHybridPlug = ovsHybridPlug; }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronRouter implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+ @XmlElement (name = "id")
+ String routerUUID;
+
+ @XmlElement (name = "name")
+ String name;
+
+ @XmlElement (defaultValue = "true", name = "admin_state_up")
+ Boolean adminStateUp;
+
+ @XmlElement (name = "status")
+ String status;
+
+ @XmlElement (name = "tenant_id")
+ String tenantID;
+
+ @XmlElement (name = "external_gateway_info", nillable = true)
+ NeutronRouter_NetworkReference externalGatewayInfo;
+
+ @XmlElement (name = "distributed")
+ Boolean distributed;
+
+ @XmlElement (name = "gw_port_id", nillable = true)
+ String gatewayPortId;
+
+ @XmlElement (name = "routes")
+ List<String> routes;
+
+ /* Holds a map of OpenStackRouterInterfaces by subnet UUID
+ * used for internal mapping to DOVE
+ */
+ Map<String, NeutronRouter_Interface> interfaces;
+
+ public NeutronRouter() {
+ interfaces = new HashMap<String, NeutronRouter_Interface>();
+ }
+
+ public String getID() { return routerUUID; }
+
+ public void setID(String id) { this.routerUUID = id; }
+
+ public String getRouterUUID() {
+ return routerUUID;
+ }
+
+ public void setRouterUUID(String routerUUID) {
+ this.routerUUID = routerUUID;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isAdminStateUp() {
+ if (adminStateUp == null) {
+ return true;
+ }
+ return adminStateUp;
+ }
+
+ public Boolean getAdminStateUp() { return adminStateUp; }
+
+ public void setAdminStateUp(Boolean newValue) {
+ adminStateUp = newValue;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public void setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ }
+
+ public NeutronRouter_NetworkReference getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+
+ public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+
+ public Boolean getDistributed() {
+ return distributed;
+ }
+
+ public void setDistributed(Boolean distributed) {
+ this.distributed = distributed;
+ }
+
+ public String getGatewayPortId() {
+ return gatewayPortId;
+ }
+
+ public void setGatewayPortId(String gatewayPortId) {
+ this.gatewayPortId = gatewayPortId;
+ }
+
+ public List<String> getRoutes() {
+ return routes;
+ }
+
+ public void setRoutes(List<String> routes) {
+ this.routes = routes;
+ }
+
+ /**
+ * This method copies selected fields from the object and returns them
+ * as a new object, suitable for marshaling.
+ *
+ * @param fields
+ * List of attributes to be extracted
+ * @return an OpenStackRouters object with only the selected fields
+ * populated
+ */
+ public NeutronRouter extractFields(List<String> fields) {
+ NeutronRouter ans = new NeutronRouter();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setRouterUUID(this.getRouterUUID());
+ }
+ if (s.equals("name")) {
+ ans.setName(this.getName());
+ }
+ if (s.equals("admin_state_up")) {
+ ans.setAdminStateUp(this.getAdminStateUp());
+ }
+ if (s.equals("status")) {
+ ans.setStatus(this.getStatus());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if (s.equals("external_gateway_info")) {
+ ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
+ }
+ if (s.equals("distributed")) {
+ ans.setDistributed(this.getDistributed());
+ }
+ if (s.equals("gw_port_id")) {
+ ans.setGatewayPortId(this.getGatewayPortId());
+ }
+ if (s.equals("routes")){
+ ans.setRoutes(this.getRoutes());
+ }
+ }
+ return ans;
+ }
+
+ public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
+ interfaces = input;
+ }
+
+ public Map<String, NeutronRouter_Interface> getInterfaces() {
+ return interfaces;
+ }
+
+ public void addInterface(String s, NeutronRouter_Interface i) {
+ interfaces.put(s, i);
+ }
+
+ public void removeInterface(String s) {
+ interfaces.remove(s);
+ }
+
+ public void initDefaults() {
+ adminStateUp = true;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronRouter [" +
+ "id=" + routerUUID +
+ ", name=" + name +
+ ", adminStateUp=" + adminStateUp +
+ ", status=" + status +
+ ", tenantID=" + tenantID +
+ ", external_gateway_info=" + externalGatewayInfo +
+ ", distributed=" + distributed +
+ ", gw_port_id=" + gatewayPortId +
+ ", routes=" + routes +
+ ", interfaces=" + interfaces +
+ "]";
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronRouter_Interface implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement (name = "subnet_id")
+ String subnetUUID;
+
+ @XmlElement (name = "port_id")
+ String portUUID;
+
+ @XmlElement (name = "id")
+ String id;
+
+ @XmlElement (name = "tenant_id")
+ String tenantID;
+
+ public NeutronRouter_Interface() {
+ }
+
+ public NeutronRouter_Interface(String subnetUUID, String portUUID) {
+ this.subnetUUID = subnetUUID;
+ this.portUUID = portUUID;
+ }
+
+ public String getSubnetUUID() {
+ return subnetUUID;
+ }
+
+ public void setSubnetUUID(String subnetUUID) {
+ this.subnetUUID = subnetUUID;
+ }
+
+ public String getPortUUID() {
+ return portUUID;
+ }
+
+ public void setPortUUID(String portUUID) {
+ this.portUUID = portUUID;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public void setID(String id) {
+ this.id = id;
+ }
+
+ public void setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronRouterInterface [" +
+ "subnetUUID=" + subnetUUID +
+ ", portUUID=" + portUUID +
+ ", id=" + id +
+ ", tenantID=" + tenantID + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronRouter_NetworkReference implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "network_id")
+ String networkID;
+
+ @XmlElement(name = "enable_snat")
+ Boolean enableSNAT;
+
+ @XmlElement(name = "external_fixed_ips")
+ List<Neutron_IPs> externalFixedIPs;
+
+ public NeutronRouter_NetworkReference() {
+ }
+
+ public String getNetworkID() {
+ return networkID;
+ }
+
+ public void setNetworkID(String networkID) {
+ this.networkID = networkID;
+ }
+
+ public Boolean getEnableSNAT() {
+ return enableSNAT;
+ }
+
+ public void setEnableSNAT(Boolean enableSNAT) {
+ this.enableSNAT = enableSNAT;
+ }
+
+ public List<Neutron_IPs> getExternalFixedIPs() {
+ return externalFixedIPs;
+ }
+
+ public void setExternalFixedIPs(List<Neutron_IPs> externalFixedIPs) {
+ this.externalFixedIPs = externalFixedIPs;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronRouterNetworkReference [networkID=" + networkID +
+ " enableSNAT=" + enableSNAT +
+ " externalFixedIPs=" + externalFixedIPs + "]";
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * OpenStack Neutron v2.0 Security Group bindings.
+ * See OpenStack Network API v2.0 Reference for description of
+ * annotated attributes. The current fields are as follows:
+ * <p>
+ * id uuid-str unique ID for the security group.
+ * name String name of the security group.
+ * description String name of the security group.
+ * tenant_id uuid-str Owner of security rule..
+ * security_group_rules List<NeutronSecurityRule> nested RO in the sec group.
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSecurityGroup implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String securityGroupUUID;
+
+ @XmlElement(name = "name")
+ String securityGroupName;
+
+ @XmlElement(name = "description")
+ String securityGroupDescription;
+
+ @XmlElement(name = "tenant_id")
+ String securityGroupTenantID;
+
+ @XmlElement(name = "security_group_rules")
+ List<NeutronSecurityRule> neutronSecurityRule;
+
+ public NeutronSecurityGroup() {
+ neutronSecurityRule = new ArrayList<NeutronSecurityRule>();
+
+ }
+
+ public String getID() {
+ return securityGroupUUID;
+ }
+
+ public void setID(String id) {
+ securityGroupUUID = id;
+ }
+
+ // @deprecated use getID()
+ public String getSecurityGroupUUID() {
+ return securityGroupUUID;
+ }
+
+ // @deprecated use setID()
+ public void setSecurityGroupUUID(String securityGroupUUID) {
+ this.securityGroupUUID = securityGroupUUID;
+ }
+
+ public String getSecurityGroupName() {
+ return securityGroupName;
+ }
+
+ public void setSecurityGroupName(String securityGroupName) {
+ this.securityGroupName = securityGroupName;
+ }
+
+ public String getSecurityGroupDescription() {
+ return securityGroupDescription;
+ }
+
+ public void setSecurityGroupDescription(String securityGroupDescription) {
+ this.securityGroupDescription = securityGroupDescription;
+ }
+
+ public String getSecurityGroupTenantID() {
+ return securityGroupTenantID;
+ }
+
+ public void setSecurityGroupTenantID(String securityGroupTenantID) {
+ this.securityGroupTenantID = securityGroupTenantID;
+ }
+
+ // Rules In Group
+ public List<NeutronSecurityRule> getSecurityRules() {
+ return neutronSecurityRule;
+ }
+
+ public void setSecurityRules(List<NeutronSecurityRule> neutronSecurityRule) {
+ this.neutronSecurityRule = neutronSecurityRule;
+ }
+
+ public NeutronSecurityGroup extractFields(List<String> fields) {
+ NeutronSecurityGroup ans = new NeutronSecurityGroup ();
+ Iterator<String> i = fields.iterator ();
+ while (i.hasNext ()) {
+ String s = i.next ();
+ if (s.equals ("id")) {
+ ans.setID (this.getID ());
+ }
+ if (s.equals ("name")) {
+ ans.setSecurityGroupName (this.getSecurityGroupName ());
+ }
+ if (s.equals ("description")) {
+ ans.setSecurityGroupDescription (this.getSecurityGroupDescription ());
+ }
+ if (s.equals ("tenant_id")) {
+ ans.setSecurityGroupTenantID (this.getSecurityGroupTenantID ());
+ }
+ if (s.equals ("security_group_rules")) {
+ ans.setSecurityRules (this.getSecurityRules ());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronSecurityGroup{" +
+ "securityGroupUUID='" + securityGroupUUID + '\'' +
+ ", securityGroupName='" + securityGroupName + '\'' +
+ ", securityGroupDescription='" + securityGroupDescription + '\'' +
+ ", securityGroupTenantID='" + securityGroupTenantID + '\'' +
+ ", securityRules=" + neutronSecurityRule + "]";
+ }
+
+ public void initDefaults() {
+ //TODO verify no defaults values are nessecary required.
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * See OpenStack Network API v2.0 Reference for description of
+ * annotated attributes. The current fields are as follows:
+ * <p>
+ * id uuid (String) UUID for the security group rule.
+ * security_rule_id uuid (String) The security group to associate rule.
+ * direction String Direction the VM traffic (ingress/egress).
+ * security_group_id The security group to associate rule with.
+ * protocol String IP Protocol (icmp, tcp, udp, etc).
+ * port_range_min Integer Port at start of range
+ * port_range_max Integer Port at end of range
+ * ethertype String ethertype in L2 packet (IPv4, IPv6, etc)
+ * remote_ip_prefix String (IP cidr) CIDR for address range.
+ * remote_group_id uuid-str Source security group to apply to rule.
+ * tenant_id uuid-str Owner of security rule. Admin only outside tenant.
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSecurityRule implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "id")
+ String securityRuleUUID;
+
+ @XmlElement(name = "direction")
+ String securityRuleDirection;
+
+ @XmlElement(name = "protocol")
+ String securityRuleProtocol;
+
+ @XmlElement(name = "port_range_min")
+ Integer securityRulePortMin;
+
+ @XmlElement(name = "port_range_max")
+ Integer securityRulePortMax;
+
+ @XmlElement(name = "ethertype")
+ String securityRuleEthertype;
+
+ @XmlElement(name = "remote_ip_prefix")
+ String securityRuleRemoteIpPrefix;
+
+ @XmlElement(name = "remote_group_id")
+ String securityRemoteGroupID;
+
+ @XmlElement(name = "security_group_id")
+ String securityRuleGroupID;
+
+ @XmlElement(name = "tenant_id")
+ String securityRuleTenantID;
+
+ public NeutronSecurityRule() {
+ }
+
+ public String getID() {
+ return securityRuleUUID;
+ }
+
+ public void setID(String id) {
+ securityRuleUUID = id;
+ }
+
+ // @deprecated use getID()
+ public String getSecurityRuleUUID() {
+ return securityRuleUUID;
+ }
+
+ // @deprecated use setID()
+ public void setSecurityRuleUUID(String securityRuleUUID) {
+ this.securityRuleUUID = securityRuleUUID;
+ }
+
+ public String getSecurityRuleDirection() {
+ return securityRuleDirection;
+ }
+
+ public void setSecurityRuleDirection(String securityRuleDirection) {
+ this.securityRuleDirection = securityRuleDirection;
+ }
+
+ public String getSecurityRuleProtocol() {
+ return securityRuleProtocol;
+ }
+
+ public void setSecurityRuleProtocol(String securityRuleProtocol) {
+ this.securityRuleProtocol = securityRuleProtocol;
+ }
+
+ public Integer getSecurityRulePortMin() {
+ return securityRulePortMin;
+ }
+
+ public void setSecurityRulePortMin(Integer securityRulePortMin) {
+ this.securityRulePortMin = securityRulePortMin;
+ }
+
+ public Integer getSecurityRulePortMax() {
+ return securityRulePortMax;
+ }
+
+ public void setSecurityRulePortMax(Integer securityRulePortMax) {
+ this.securityRulePortMax = securityRulePortMax;
+ }
+
+ public String getSecurityRuleEthertype() {
+ return securityRuleEthertype;
+ }
+
+ public void setSecurityRuleEthertype(String securityRuleEthertype) {
+ this.securityRuleEthertype = securityRuleEthertype;
+ }
+
+ public String getSecurityRuleRemoteIpPrefix() {
+ return securityRuleRemoteIpPrefix;
+ }
+
+ public void setSecurityRuleRemoteIpPrefix(String securityRuleRemoteIpPrefix) {
+ this.securityRuleRemoteIpPrefix = securityRuleRemoteIpPrefix;
+ }
+
+ public String getSecurityRemoteGroupID() {
+ return securityRemoteGroupID;
+ }
+
+ public void setSecurityRemoteGroupID(String securityRemoteGroupID) {
+ this.securityRemoteGroupID = securityRemoteGroupID;
+ }
+
+ public String getSecurityRuleGroupID() {
+ return securityRuleGroupID;
+ }
+
+ public void setSecurityRuleGroupID(String securityRuleGroupID) {
+ this.securityRuleGroupID = securityRuleGroupID;
+ }
+
+ public String getSecurityRuleTenantID() {
+ return securityRuleTenantID;
+ }
+
+ public void setSecurityRuleTenantID(String securityRuleTenantID) {
+ this.securityRuleTenantID = securityRuleTenantID;
+ }
+
+ public NeutronSecurityRule extractFields(List<String> fields) {
+ NeutronSecurityRule ans = new NeutronSecurityRule();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("direction")) {
+ ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
+ }
+ if (s.equals("protocol")) {
+ ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
+ }
+ if (s.equals("port_range_min")) {
+ ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
+ }
+ if (s.equals("port_range_max")) {
+ ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
+ }
+ if (s.equals("ethertype")) {
+ ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
+ }
+ if (s.equals("remote_ip_prefix")) {
+ ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
+ }
+ if (s.equals("remote_group_id")) {
+ ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
+ }
+ if (s.equals("security_group_id")) {
+ ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronSecurityRule{" +
+ "securityRuleUUID='" + securityRuleUUID + '\'' +
+ ", securityRuleDirection='" + securityRuleDirection + '\'' +
+ ", securityRuleProtocol='" + securityRuleProtocol + '\'' +
+ ", securityRulePortMin=" + securityRulePortMin +
+ ", securityRulePortMax=" + securityRulePortMax +
+ ", securityRuleEthertype='" + securityRuleEthertype + '\'' +
+ ", securityRuleRemoteIpPrefix='" + securityRuleRemoteIpPrefix + '\'' +
+ ", securityRemoteGroupID=" + securityRemoteGroupID +
+ ", securityRuleGroupID='" + securityRuleGroupID + '\'' +
+ ", securityRuleTenantID='" + securityRuleTenantID + '\'' +
+ '}';
+ }
+
+ public void initDefaults() {
+ //TODO verify no defaults values are nessecary required.
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.Inet6Address;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSubnet implements Serializable, INeutronObject {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(NeutronCRUDInterfaces.class);
+
+ private static final long serialVersionUID = 1L;
+ private static final int IPV4_VERSION = 4;
+ private static final int IPV6_VERSION = 6;
+ private static final int IPV6_LENGTH = 128;
+ private static final int IPV6_LENGTH_BYTES = 8;
+ private static final long IPV6_LSB_MASK = 0x000000FF;
+ private static final int IPV6_BYTE_OFFSET = 7;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement (name = "id")
+ String subnetUUID;
+
+ @XmlElement (name = "network_id")
+ String networkUUID;
+
+ @XmlElement (name = "name")
+ String name;
+
+ @XmlElement (defaultValue = "4", name = "ip_version")
+ Integer ipVersion;
+
+ @XmlElement (name = "cidr")
+ String cidr;
+
+ @XmlElement (name = "gateway_ip")
+ String gatewayIP;
+
+ @XmlElement (name = "dns_nameservers")
+ List<String> dnsNameservers;
+
+ @XmlElement (name = "allocation_pools")
+ List<NeutronSubnetIPAllocationPool> allocationPools;
+
+ @XmlElement (name = "host_routes")
+ List<NeutronSubnet_HostRoute> hostRoutes;
+
+ @XmlElement (defaultValue = "true", name = "enable_dhcp")
+ Boolean enableDHCP;
+
+ @XmlElement (name = "tenant_id")
+ String tenantID;
+
+ @XmlElement (name = "ipv6_address_mode", nillable = true)
+ String ipV6AddressMode;
+
+ @XmlElement (name = "ipv6_ra_mode", nillable = true)
+ String ipV6RaMode;
+
+ /* stores the OpenStackPorts associated with an instance
+ * used to determine if that instance can be deleted.
+ *
+ * @deprecated, will be removed in Boron
+ */
+
+ List<NeutronPort> myPorts;
+
+ public NeutronSubnet() {
+ myPorts = new ArrayList<NeutronPort>();
+ }
+
+ // @deprecated - will be removed in Boron
+ public void setPorts(List<NeutronPort> arg) {
+ myPorts = arg;
+ }
+
+ public String getID() { return subnetUUID; }
+
+ public void setID(String id) { this.subnetUUID = id; }
+
+ public String getSubnetUUID() {
+ return subnetUUID;
+ }
+
+ public void setSubnetUUID(String subnetUUID) {
+ this.subnetUUID = subnetUUID;
+ }
+
+ public String getNetworkUUID() {
+ return networkUUID;
+ }
+
+ public void setNetworkUUID(String networkUUID) {
+ this.networkUUID = networkUUID;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getIpVersion() {
+ return ipVersion;
+ }
+
+ public void setIpVersion(Integer ipVersion) {
+ this.ipVersion = ipVersion;
+ }
+
+ public String getCidr() {
+ return cidr;
+ }
+
+ public void setCidr(String cidr) {
+ this.cidr = cidr;
+ }
+
+ public String getGatewayIP() {
+ return gatewayIP;
+ }
+
+ public void setGatewayIP(String gatewayIP) {
+ this.gatewayIP = gatewayIP;
+ }
+
+ public List<String> getDnsNameservers() {
+ return dnsNameservers;
+ }
+
+ public void setDnsNameservers(List<String> dnsNameservers) {
+ this.dnsNameservers = dnsNameservers;
+ }
+
+ public List<NeutronSubnetIPAllocationPool> getAllocationPools() {
+ return allocationPools;
+ }
+
+ public void setAllocationPools(List<NeutronSubnetIPAllocationPool> allocationPools) {
+ this.allocationPools = allocationPools;
+ }
+
+ public List<NeutronSubnet_HostRoute> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ public void setHostRoutes(List<NeutronSubnet_HostRoute> hostRoutes) {
+ this.hostRoutes = hostRoutes;
+ }
+
+ public boolean isEnableDHCP() {
+ if (enableDHCP == null) {
+ return true;
+ }
+ return enableDHCP;
+ }
+
+ public Boolean getEnableDHCP() { return enableDHCP; }
+
+ public void setEnableDHCP(Boolean newValue) {
+ enableDHCP = newValue;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public void setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ }
+
+ public String getIpV6AddressMode() { return ipV6AddressMode; }
+
+ public void setIpV6AddressMode(String ipV6AddressMode) { this.ipV6AddressMode = ipV6AddressMode; }
+
+ public String getIpV6RaMode() { return ipV6RaMode; }
+
+ public void setIpV6RaMode(String ipV6RaMode) { this.ipV6RaMode = ipV6RaMode; }
+
+ /**
+ * This method copies selected fields from the object and returns them
+ * as a new object, suitable for marshaling.
+ *
+ * @param fields
+ * List of attributes to be extracted
+ * @return an OpenStackSubnets object with only the selected fields
+ * populated
+ */
+
+ public NeutronSubnet extractFields(List<String> fields) {
+ NeutronSubnet ans = new NeutronSubnet();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setSubnetUUID(this.getSubnetUUID());
+ }
+ if (s.equals("network_id")) {
+ ans.setNetworkUUID(this.getNetworkUUID());
+ }
+ if (s.equals("name")) {
+ ans.setName(this.getName());
+ }
+ if (s.equals("ip_version")) {
+ ans.setIpVersion(this.getIpVersion());
+ }
+ if (s.equals("cidr")) {
+ ans.setCidr(this.getCidr());
+ }
+ if (s.equals("gateway_ip")) {
+ ans.setGatewayIP(this.getGatewayIP());
+ }
+ if (s.equals("dns_nameservers")) {
+ List<String> nsList = new ArrayList<String>();
+ nsList.addAll(this.getDnsNameservers());
+ ans.setDnsNameservers(nsList);
+ }
+ if (s.equals("allocation_pools")) {
+ List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ aPools.addAll(this.getAllocationPools());
+ ans.setAllocationPools(aPools);
+ }
+ if (s.equals("host_routes")) {
+ List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+ hRoutes.addAll(this.getHostRoutes());
+ ans.setHostRoutes(hRoutes);
+ }
+ if (s.equals("enable_dhcp")) {
+ ans.setEnableDHCP(this.getEnableDHCP());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if (s.equals("ipv6_address_mode")) {
+ ans.setIpV6AddressMode(this.getIpV6AddressMode());
+ }
+ if (s.equals("ipv6_ra_mode")) {
+ ans.setIpV6RaMode(this.getIpV6RaMode());
+ }
+ }
+ return ans;
+ }
+
+ // @deprecated - will be removed in Boron
+ public List<NeutronPort> getPortsInSubnet() {
+ return myPorts;
+ }
+
+ // @deprecated - will be removed in Boron
+ public List<NeutronPort> getPortsInSubnet(String ignore) {
+ List<NeutronPort> answer = new ArrayList<NeutronPort>();
+ for (NeutronPort port : myPorts) {
+ if (!port.getDeviceOwner().equalsIgnoreCase(ignore)) {
+ answer.add(port);
+ }
+ }
+ return answer;
+ }
+
+ /* test to see if the cidr address used to define this subnet
+ * is a valid network address (an necessary condition when creating
+ * a new subnet)
+ */
+ public boolean isValidCIDR() {
+ // fix for Bug 2290 - need to wrap the existing test as
+ // IPv4 because SubnetUtils doesn't support IPv6
+ if (ipVersion == IPV4_VERSION) {
+ try {
+ SubnetUtils util = new SubnetUtils(cidr);
+ SubnetInfo info = util.getInfo();
+ if (!info.getNetworkAddress().equals(info.getAddress())) {
+ return false;
+ }
+ } catch (IllegalArgumentException e) {
+ LOGGER.warn("Failure in isValidCIDR()", e);
+ return false;
+ }
+ return true;
+ }
+ if (ipVersion == IPV6_VERSION) {
+ // fix for Bug2290 - this is custom code because no classes
+ // with ODL-friendly licenses have been found
+ // extract address (in front of /) and length (after /)
+ String[] parts = cidr.split("/");
+ if (parts.length != 2) {
+ return false;
+ }
+ try {
+ int length = Integer.parseInt(parts[1]);
+ //TODO?: limit check on length
+ // convert to byte array
+ byte[] addrBytes = ((Inet6Address) InetAddress.getByName(parts[0])).getAddress();
+ int i;
+ for (i = length; i < IPV6_LENGTH; i++) {
+ if (((((int) addrBytes[i/IPV6_LENGTH_BYTES]) & IPV6_LSB_MASK) & (1 << (IPV6_BYTE_OFFSET-(i%IPV6_LENGTH_BYTES)))) != 0) {
+ return(false);
+ }
+ }
+ return(true);
+ } catch (UnknownHostException e) {
+ LOGGER.warn("Failure in isValidCIDR()", e);
+ return(false);
+ }
+ }
+ return false;
+ }
+
+ /* test to see if the gateway IP specified overlaps with specified
+ * allocation pools (an error condition when creating a new subnet
+ * or assigning a gateway IP)
+ */
+ public boolean gatewayIP_Pool_overlap() {
+ Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
+ while (i.hasNext()) {
+ NeutronSubnetIPAllocationPool pool = i.next();
+ if (ipVersion == IPV4_VERSION && pool.contains(gatewayIP)) {
+ return true;
+ }
+ if (ipVersion == IPV6_VERSION && pool.containsV6(gatewayIP)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean initDefaults() {
+ if (enableDHCP == null) {
+ enableDHCP = true;
+ }
+ if (ipVersion == null) {
+ ipVersion = IPV4_VERSION;
+ }
+ dnsNameservers = new ArrayList<String>();
+ if (hostRoutes == null) {
+ hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+ }
+ if (allocationPools == null) {
+ allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ if (ipVersion == IPV4_VERSION) {
+ try {
+ SubnetUtils util = new SubnetUtils(cidr);
+ SubnetInfo info = util.getInfo();
+ if (gatewayIP == null || ("").equals(gatewayIP)) {
+ gatewayIP = info.getLowAddress();
+ }
+ if (allocationPools.size() < 1) {
+ NeutronSubnetIPAllocationPool source =
+ new NeutronSubnetIPAllocationPool(info.getLowAddress(),
+ info.getHighAddress());
+ allocationPools = source.splitPool(gatewayIP);
+ }
+ } catch (IllegalArgumentException e) {
+ LOGGER.warn("Failure in initDefault()", e);
+ return false;
+ }
+ }
+ if (ipVersion == IPV6_VERSION) {
+ String[] parts = cidr.split("/");
+ if (parts.length != 2) {
+ return false;
+ }
+ try {
+ int length = Integer.parseInt(parts[1]);
+ BigInteger lowAddress_bi = NeutronSubnetIPAllocationPool.convertV6(parts[0]);
+ String lowAddress = NeutronSubnetIPAllocationPool.bigIntegerToIP(lowAddress_bi.add(BigInteger.ONE));
+ BigInteger mask = BigInteger.ONE.shiftLeft(length).subtract(BigInteger.ONE);
+ String highAddress = NeutronSubnetIPAllocationPool.bigIntegerToIP(lowAddress_bi.add(mask).subtract(BigInteger.ONE));
+ if (gatewayIP == null || ("").equals(gatewayIP)) {
+ gatewayIP = lowAddress;
+ }
+ if (allocationPools.size() < 1) {
+ NeutronSubnetIPAllocationPool source =
+ new NeutronSubnetIPAllocationPool(lowAddress,
+ highAddress);
+ allocationPools = source.splitPoolV6(gatewayIP);
+ }
+ } catch (Exception e) {
+ LOGGER.warn("Failure in initDefault()", e);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /* this method tests to see if the supplied IPv4 address
+ * is valid for this subnet or not
+ */
+ public boolean isValidIP(String ipAddress) {
+ if (ipVersion == IPV4_VERSION) {
+ try {
+ SubnetUtils util = new SubnetUtils(cidr);
+ SubnetInfo info = util.getInfo();
+ return info.isInRange(ipAddress);
+ } catch (IllegalArgumentException e) {
+ LOGGER.warn("Failure in isValidIP()", e);
+ return false;
+ }
+ }
+
+ if (ipVersion == IPV6_VERSION) {
+ String[] parts = cidr.split("/");
+ try {
+ int length = Integer.parseInt(parts[1]);
+ byte[] cidrBytes = ((Inet6Address) InetAddress.getByName(parts[0])).getAddress();
+ byte[] ipBytes = ((Inet6Address) InetAddress.getByName(ipAddress)).getAddress();
+ int i;
+ for (i = 0; i < length; i++) {
+ if (((((int) cidrBytes[i/IPV6_LENGTH_BYTES]) & IPV6_LSB_MASK) & (1 << (IPV6_BYTE_OFFSET-(i%IPV6_LENGTH_BYTES)))) !=
+ ((((int) ipBytes[i/IPV6_LENGTH_BYTES]) & IPV6_LSB_MASK) & (1 << (IPV6_BYTE_OFFSET-(i%IPV6_LENGTH_BYTES))))) {
+ return(false);
+ }
+ }
+ return(true);
+ } catch (UnknownHostException e) {
+ LOGGER.warn("Failure in isValidIP()", e);
+ return(false);
+ }
+ }
+ return false;
+ }
+
+ /* method to get the lowest available address of the subnet.
+ * go through all the allocation pools and keep the lowest of their
+ * low addresses.
+ */
+ public String getLowAddr() {
+ String ans = null;
+ Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
+ while (i.hasNext()) {
+ NeutronSubnetIPAllocationPool pool = i.next();
+ if (ans == null) {
+ ans = pool.getPoolStart();
+ }
+ else {
+ if (ipVersion == IPV4_VERSION &&
+ NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
+ NeutronSubnetIPAllocationPool.convert(ans)) {
+ ans = pool.getPoolStart();
+ }
+ if (ipVersion == IPV6_VERSION &&
+ NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
+ ans = pool.getPoolStart();
+ }
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronSubnet [subnetUUID=" + subnetUUID + ", networkUUID=" + networkUUID + ", name=" + name
+ + ", ipVersion=" + ipVersion + ", cidr=" + cidr + ", gatewayIP=" + gatewayIP + ", dnsNameservers="
+ + dnsNameservers + ", allocationPools=" + allocationPools + ", hostRoutes=" + hostRoutes
+ + ", enableDHCP=" + enableDHCP + ", tenantID=" + tenantID
+ + ", ipv6AddressMode=" + ipV6AddressMode
+ + ", ipv6RaMode=" + ipV6RaMode + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.Inet6Address;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronSubnetIPAllocationPool implements Serializable {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(NeutronSubnetIPAllocationPool.class);
+
+ private static final long serialVersionUID = 1L;
+
+ private static final int BYTE_LENGTH = 8;
+ private static final int IPV4_DOTTED_QUADS = 4;
+ private static final int IPV4_DOTTED_QUAD_OFFSET = 3;
+ private static final int IPV4_DOTTED_QUAD_MASK = 255;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "start")
+ String poolStart;
+
+ @XmlElement(name = "end")
+ String poolEnd;
+
+ public NeutronSubnetIPAllocationPool() {
+ }
+
+ public NeutronSubnetIPAllocationPool(String lowAddress, String highAddress) {
+ poolStart = lowAddress;
+ poolEnd = highAddress;
+ }
+
+ public String getPoolStart() {
+ return poolStart;
+ }
+
+ public void setPoolStart(String poolStart) {
+ this.poolStart = poolStart;
+ }
+
+ public String getPoolEnd() {
+ return poolEnd;
+ }
+
+ public void setPoolEnd(String poolEnd) {
+ this.poolEnd = poolEnd;
+ }
+
+ /**
+ * This method determines if this allocation pool contains the
+ * input IPv4 address
+ *
+ * @param inputString
+ * IPv4 address in dotted decimal format
+ * @return a boolean on whether the pool contains the address or not
+ */
+
+ public boolean contains(String inputString) {
+ long inputIP = convert(inputString);
+ long startIP = convert(poolStart);
+ long endIP = convert(poolEnd);
+ return (inputIP >= startIP && inputIP <= endIP);
+ }
+
+ /**
+ * This static method converts the supplied IPv4 address to a long
+ * integer for comparison
+ *
+ * @param inputString
+ * IPv4 address in dotted decimal format
+ * @return high-endian representation of the IPv4 address as a long.
+ * This method will return 0 if the input is null.
+ */
+
+ static long convert(String inputString) {
+ long ans = 0;
+ if (inputString != null) {
+ String[] parts = inputString.split("\\.");
+ for (String part: parts) {
+ ans <<= BYTE_LENGTH;
+ ans |= Integer.parseInt(part);
+ }
+ }
+ return ans;
+ }
+
+ /**
+ * This method determines if this allocation pool contains the
+ * input IPv4 address
+ *
+ * @param inputString
+ * IPv4 address in dotted decimal format
+ * @return a boolean on whether the pool contains the address or not
+ */
+
+ public boolean containsV6(String inputString) {
+ BigInteger inputIP = convertV6(inputString);
+ BigInteger startIP = convertV6(poolStart);
+ BigInteger endIP = convertV6(poolEnd);
+ return (inputIP.compareTo(startIP) >= 0 && inputIP.compareTo(endIP) <= 0);
+ }
+
+ /**
+ * This static method converts the supplied IPv4 address to a long
+ * integer for comparison
+ *
+ * @param inputString
+ * IPv6 address in dotted decimal format
+ * @return high-endian representation of the IPv4 address as a BigInteger.
+ * This method will return 0 if the input is null.
+ */
+
+ static BigInteger convertV6(String inputString) {
+ if (inputString == null) {
+ return BigInteger.ZERO;
+ }
+ try {
+ return new BigInteger(((Inet6Address) InetAddress.getByName(inputString)).getAddress());
+ } catch (Exception e) {
+ LOGGER.error("convertV6 error", e);
+ return BigInteger.ZERO;
+ }
+ }
+
+ /**
+ * This static method converts the supplied high-ending long back
+ * into a dotted decimal representation of an IPv4 address
+ *
+ * @param l
+ * high-endian representation of the IPv4 address as a long
+ * @return IPv4 address in dotted decimal format
+ */
+ static String longToIP(long input) {
+ int part;
+ long ipLong = input;
+ String[] parts = new String[IPV4_DOTTED_QUADS];
+ for (part = 0; part < IPV4_DOTTED_QUADS; part++) {
+ parts[IPV4_DOTTED_QUAD_OFFSET-part] = String.valueOf(ipLong & IPV4_DOTTED_QUAD_MASK);
+ ipLong >>= BYTE_LENGTH;
+ }
+ return join(parts,".");
+ }
+
+ /**
+ * This static method converts the supplied high-ending long back
+ * into a dotted decimal representation of an IPv4 address
+ *
+ * @param l
+ * high-endian representation of the IPv4 address as a long
+ * @return IPv4 address in dotted decimal format
+ */
+ static String bigIntegerToIP(BigInteger b) {
+ try {
+ return Inet6Address.getByAddress(b.toByteArray()).getHostAddress();
+ } catch (Exception e) {
+ LOGGER.error("bigIntegerToIP", e);
+ return "ERROR";
+ }
+ }
+
+ /*
+ * helper routine used by longToIP
+ */
+ public static String join(String r[],String separator)
+ {
+ if (r.length == 0) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder();
+ int i;
+ for(i = 0;i < r.length - 1;i++) {
+ sb.append(r[i]);
+ sb.append(separator);
+ }
+ return sb.toString() + r[i];
+ }
+
+ /*
+ * This method splits the current instance by removing the supplied
+ * parameter.
+ *
+ * If the parameter is either the low or high address,
+ * then that member is adjusted and a list containing just this instance
+ * is returned.
+ *
+ * If the parameter is in the middle of the pool, then
+ * create two new instances, one ranging from low to parameter-1
+ * the other ranging from parameter+1 to high
+ */
+ public List<NeutronSubnetIPAllocationPool> splitPool(String ipAddress) {
+ List<NeutronSubnetIPAllocationPool> ans = new ArrayList<NeutronSubnetIPAllocationPool>();
+ long gIP = NeutronSubnetIPAllocationPool.convert(ipAddress);
+ long sIP = NeutronSubnetIPAllocationPool.convert(poolStart);
+ long eIP = NeutronSubnetIPAllocationPool.convert(poolEnd);
+ long i;
+ NeutronSubnetIPAllocationPool p = new NeutronSubnetIPAllocationPool();
+ boolean poolStarted = false;
+ for (i = sIP; i <= eIP; i++) {
+ if (i == sIP) {
+ if (i != gIP) {
+ p.setPoolStart(poolStart);
+ poolStarted = true;
+ } else {
+ //FIX for bug 533
+ p.setPoolStart(NeutronSubnetIPAllocationPool.longToIP(i+1));
+ }
+ }
+ if (i == eIP) {
+ if (i != gIP) {
+ p.setPoolEnd(poolEnd);
+ } else {
+ p.setPoolEnd(NeutronSubnetIPAllocationPool.longToIP(i-1));
+ }
+ ans.add(p);
+ }
+ if (i != sIP && i != eIP) {
+ if (i != gIP) {
+ if (!poolStarted) {
+ p.setPoolStart(NeutronSubnetIPAllocationPool.longToIP(i));
+ poolStarted = true;
+ }
+ } else {
+ p.setPoolEnd(NeutronSubnetIPAllocationPool.longToIP(i-1));
+ poolStarted = false;
+ ans.add(p);
+ p = new NeutronSubnetIPAllocationPool();
+ // Fix for 2120
+ p.setPoolStart(NeutronSubnetIPAllocationPool.longToIP(i+1));
+ poolStarted = true;
+ }
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronSubnetIPAllocationPool [" +
+ "start=" + poolStart +
+ ", end=" + poolEnd + "]";
+ }
+
+ /*
+ * This method splits the current instance by removing the supplied
+ * parameter.
+ *
+ * If the parameter is either the low or high address,
+ * then that member is adjusted and a list containing just this instance
+ * is returned.
+ new *
+ * If the parameter is in the middle of the pool, then
+ * create two new instances, one ranging from low to parameter-1
+ * the other ranging from parameter+1 to high
+ * If the pool is a single address, return null
+ */
+ public List<NeutronSubnetIPAllocationPool> splitPoolV6(String ipAddress) {
+ List<NeutronSubnetIPAllocationPool> ans = new ArrayList<NeutronSubnetIPAllocationPool>();
+ BigInteger gIP = NeutronSubnetIPAllocationPool.convertV6(ipAddress);
+ BigInteger sIP = NeutronSubnetIPAllocationPool.convertV6(poolStart);
+ BigInteger eIP = NeutronSubnetIPAllocationPool.convertV6(poolEnd);
+ if (gIP.compareTo(sIP) == 0 && gIP.compareTo(eIP) < 0) {
+ NeutronSubnetIPAllocationPool p = new NeutronSubnetIPAllocationPool();
+ p.setPoolStart(NeutronSubnetIPAllocationPool.bigIntegerToIP(sIP.add(BigInteger.ONE)));
+ p.setPoolEnd(poolEnd);
+ ans.add(p);
+ return(ans);
+ }
+ if (gIP.compareTo(eIP) == 0 && gIP.compareTo(sIP) > 0) {
+ NeutronSubnetIPAllocationPool p = new NeutronSubnetIPAllocationPool();
+ p.setPoolStart(poolStart);
+ p.setPoolEnd(NeutronSubnetIPAllocationPool.bigIntegerToIP(eIP.subtract(BigInteger.ONE)));
+ ans.add(p);
+ return(ans);
+ }
+ if (gIP.compareTo(eIP) < 0 && gIP.compareTo(sIP) > 0) {
+ NeutronSubnetIPAllocationPool p = new NeutronSubnetIPAllocationPool();
+ p.setPoolStart(poolStart);
+ p.setPoolEnd(NeutronSubnetIPAllocationPool.bigIntegerToIP(gIP.subtract(BigInteger.ONE)));
+ ans.add(p);
+ NeutronSubnetIPAllocationPool p2 = new NeutronSubnetIPAllocationPool();
+ p2.setPoolStart(NeutronSubnetIPAllocationPool.bigIntegerToIP(gIP.add(BigInteger.ONE)));
+ p2.setPoolEnd(poolEnd);
+ ans.add(p2);
+ return ans;
+ }
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronSubnet_HostRoute implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "destination")
+ String destination;
+
+ @XmlElement(name = "nexthop")
+ String nextHop;
+
+ /**
+ * HostRoute constructor
+ */
+ public NeutronSubnet_HostRoute() { }
+
+ @Override
+ public String toString() {
+ return "NeutronSubnetHostRoute [" +
+ "destination=" + destination +
+ ", nextHop=" + nextHop + "]";
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class Neutron_ID implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "id")
+ String uuid;
+
+ public Neutron_ID() { }
+
+ public Neutron_ID(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getID() {
+ return uuid;
+ }
+
+ public void setID(String uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public String toString() {
+ return "Neutron_ID{" + "id='" + uuid + '\'' + "}";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class Neutron_IPs implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "ip_address")
+ String ipAddress;
+
+ @XmlElement(name = "subnet_id")
+ String subnetUUID;
+
+ public Neutron_IPs() { }
+
+ public Neutron_IPs(String uuid) {
+ subnetUUID = uuid;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public String getSubnetUUID() {
+ return subnetUUID;
+ }
+
+ public void setSubnetUUID(String subnetUUID) {
+ this.subnetUUID = subnetUUID;
+ }
+
+ @Override
+ public String toString() {
+ return "Neutron_IPs{" +
+ "ipAddress='" + ipAddress + '\'' +
+ ", subnetUUID='" + subnetUUID + '\'' + "}";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewall;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack Firewall objects
+ */
+
+public interface INeutronFirewallCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *Firewall object exists
+ *
+ * @param uuid
+ * UUID of the Firewall object
+ * @return boolean
+ */
+
+ boolean neutronFirewallExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Firewall object exists
+ *
+ * @param uuid
+ * UUID of the Firewall object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewall}
+ * OpenStackFirewall class
+ */
+
+ NeutronFirewall getNeutronFirewall(String uuid);
+
+ /**
+ * Applications call this interface method to return all Firewall objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronFirewall> getAllNeutronFirewalls();
+
+ /**
+ * Applications call this interface method to add a Firewall object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronFirewall(NeutronFirewall input);
+
+ /**
+ * Applications call this interface method to remove a Neutron Firewall object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the Firewall object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronFirewall(String uuid);
+
+ /**
+ * Applications call this interface method to edit a Firewall object
+ *
+ * @param uuid
+ * identifier of the Firewall object
+ * @param delta
+ * OpenStackFirewall object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronFirewall(String uuid, NeutronFirewall delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the Firewall object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronFirewallInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallPolicy;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack Firewall Policy objects
+ *
+ */
+
+public interface INeutronFirewallPolicyCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *FirewallPolicy object exists
+ *
+ * @param uuid
+ * UUID of the Firewall Policy object
+ * @return boolean
+ */
+
+ boolean neutronFirewallPolicyExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * FirewallPolicy object exists
+ *
+ * @param uuid
+ * UUID of the Firewall Policy object
+ * @return {@link NeutronFirewallPolicy}
+ * OpenStackFirewallPolicy class
+ */
+
+ NeutronFirewallPolicy getNeutronFirewallPolicy(String uuid);
+
+ /**
+ * Applications call this interface method to return all Firewall Policy objects
+ *
+ * @return List of OpenStack Firewall Policy objects
+ */
+
+ List<NeutronFirewallPolicy> getAllNeutronFirewallPolicies();
+
+ /**
+ * Applications call this interface method to add a Firewall Policy object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronFirewallPolicy(NeutronFirewallPolicy input);
+
+ /**
+ * Applications call this interface method to remove a Neutron FirewallPolicy object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the Firewall Policy object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronFirewallPolicy(String uuid);
+
+ /**
+ * Applications call this interface method to edit a FirewallPolicy object
+ *
+ * @param uuid
+ * identifier of the Firewall Policy object
+ * @param delta
+ * OpenStackFirewallPolicy object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronFirewallPolicy(String uuid, NeutronFirewallPolicy delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the Firewall Policy object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronFirewallPolicyInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallRule;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack Firewall Rule objects
+ *
+ */
+
+public interface INeutronFirewallRuleCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *FirewallRule object exists
+ *
+ * @param uuid
+ * UUID of the Firewall Rule object
+ * @return boolean
+ */
+
+ boolean neutronFirewallRuleExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * FirewallRule object exists
+ *
+ * @param uuid
+ * UUID of the Firewall Rule object
+ * @return {@link NeutronFirewallRule}
+ * OpenStackFirewall Rule class
+ */
+
+ NeutronFirewallRule getNeutronFirewallRule(String uuid);
+
+ /**
+ * Applications call this interface method to return all Firewall Rule objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronFirewallRule> getAllNeutronFirewallRules();
+
+ /**
+ * Applications call this interface method to add a Firewall Rule object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronFirewallRule(NeutronFirewallRule input);
+
+ /**
+ * Applications call this interface method to remove a Neutron FirewallRule object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the Firewall Rule object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronFirewallRule(String uuid);
+
+ /**
+ * Applications call this interface method to edit a FirewallRule object
+ *
+ * @param uuid
+ * identifier of the Firewall Rule object
+ * @param delta
+ * OpenStackFirewallRule object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronFirewallRule(String uuid, NeutronFirewallRule delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the Firewall Rule object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronFirewallRuleInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+
+/**
+ * This interface defines the methods for CRUD of NB FloatingIP objects
+ *
+ */
+
+public interface INeutronFloatingIPCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * FloatingIP object exists
+ *
+ * @param uuid
+ * UUID of the FloatingIP object
+ * @return boolean
+ */
+
+ boolean floatingIPExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * FloatingIP object exists
+ *
+ * @param uuid
+ * UUID of the FloatingIP object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP}
+ * OpenStack FloatingIP class
+ */
+
+ NeutronFloatingIP getFloatingIP(String uuid);
+
+ /**
+ * Applications call this interface method to return all FloatingIP objects
+ *
+ * @return a Set of OpenStackFloatingIPs objects
+ */
+
+ List<NeutronFloatingIP> getAllFloatingIPs();
+
+ /**
+ * Applications call this interface method to add a FloatingIP object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackFloatingIP object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addFloatingIP(NeutronFloatingIP input);
+
+ /**
+ * Applications call this interface method to remove a FloatingIP object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the FloatingIP object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeFloatingIP(String uuid);
+
+ /**
+ * Applications call this interface method to edit a FloatingIP object
+ *
+ * @param uuid
+ * identifier of the FloatingIP object
+ * @param delta
+ * OpenStackFloatingIP object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateFloatingIP(String uuid, NeutronFloatingIP delta);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack LoadBalancer objects
+ *
+ */
+
+public interface INeutronLoadBalancerCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *LoadBalancer object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancer object
+ * @return boolean
+ */
+
+ boolean neutronLoadBalancerExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * LoadBalancer object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancer object
+ * @return {@link NeutronLoadBalancer}
+ * OpenStackLoadBalancer class
+ */
+
+ NeutronLoadBalancer getNeutronLoadBalancer(String uuid);
+
+ /**
+ * Applications call this interface method to return all LoadBalancer objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronLoadBalancer> getAllNeutronLoadBalancers();
+
+ /**
+ * Applications call this interface method to add a LoadBalancer object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronLoadBalancer(NeutronLoadBalancer input);
+
+ /**
+ * Applications call this interface method to remove a Neutron LoadBalancer object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the LoadBalancer object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronLoadBalancer(String uuid);
+
+ /**
+ * Applications call this interface method to edit a LoadBalancer object
+ *
+ * @param uuid
+ * identifier of the LoadBalancer object
+ * @param delta
+ * OpenStackLoadBalancer object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronLoadBalancer(String uuid, NeutronLoadBalancer delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the LoadBalancer object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronLoadBalancerInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerHealthMonitor;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack LoadBalancerHealthMonitor objects
+ *
+ */
+
+public interface INeutronLoadBalancerHealthMonitorCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *LoadBalancerHealthMonitor object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancerHealthMonitor object
+ * @return boolean
+ */
+
+ boolean neutronLoadBalancerHealthMonitorExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * LoadBalancerHealthMonitor object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancerHealthMonitor object
+ * @return {@link NeutronLoadBalancerHealthMonitor}
+ * OpenStackLoadBalancerHealthMonitor class
+ */
+
+ NeutronLoadBalancerHealthMonitor getNeutronLoadBalancerHealthMonitor(String uuid);
+
+ /**
+ * Applications call this interface method to return all LoadBalancerHealthMonitor objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronLoadBalancerHealthMonitor> getAllNeutronLoadBalancerHealthMonitors();
+
+ /**
+ * Applications call this interface method to add a LoadBalancerHealthMonitor object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronLoadBalancerHealthMonitor(NeutronLoadBalancerHealthMonitor input);
+
+ /**
+ * Applications call this interface method to remove a Neutron LoadBalancerHealthMonitor object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the LoadBalancerHealthMonitor object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronLoadBalancerHealthMonitor(String uuid);
+
+ /**
+ * Applications call this interface method to edit a LoadBalancerHealthMonitor object
+ *
+ * @param uuid
+ * identifier of the LoadBalancerHealthMonitor object
+ * @param delta
+ * OpenStackLoadBalancerHealthMonitor object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronLoadBalancerHealthMonitor(String uuid, NeutronLoadBalancerHealthMonitor delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the LoadBalancerHealthMonitor object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronLoadBalancerHealthMonitorInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerListener;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack LoadBalancerListener objects
+ *
+ */
+
+public interface INeutronLoadBalancerListenerCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *LoadBalancerListener object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancerListener object
+ * @return boolean
+ */
+
+ boolean neutronLoadBalancerListenerExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * LoadBalancerListener object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancerListener object
+ * @return {@link NeutronLoadBalancerListener}
+ * OpenStackLoadBalancerListener class
+ */
+
+ NeutronLoadBalancerListener getNeutronLoadBalancerListener(String uuid);
+
+ /**
+ * Applications call this interface method to return all LoadBalancerListener objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronLoadBalancerListener> getAllNeutronLoadBalancerListeners();
+
+ /**
+ * Applications call this interface method to add a LoadBalancerListener object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronLoadBalancerListener(NeutronLoadBalancerListener input);
+
+ /**
+ * Applications call this interface method to remove a Neutron LoadBalancerListener object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the LoadBalancerListener object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronLoadBalancerListener(String uuid);
+
+ /**
+ * Applications call this interface method to edit a LoadBalancerListener object
+ *
+ * @param uuid
+ * identifier of the LoadBalancerListener object
+ * @param delta
+ * OpenStackLoadBalancerListener object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronLoadBalancerListener(String uuid, NeutronLoadBalancerListener delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the LoadBalancerListener object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronLoadBalancerListenerInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack LoadBalancerPool objects
+ *
+ */
+
+public interface INeutronLoadBalancerPoolCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ *LoadBalancerPool object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancerPool object
+ * @return boolean
+ */
+
+ boolean neutronLoadBalancerPoolExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * LoadBalancerPool object exists
+ *
+ * @param uuid
+ * UUID of the LoadBalancerPool object
+ * @return {@link NeutronLoadBalancerPool}
+ * OpenStackLoadBalancerPool class
+ */
+
+ NeutronLoadBalancerPool getNeutronLoadBalancerPool(String uuid);
+
+ /**
+ * Applications call this interface method to return all LoadBalancerPool objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronLoadBalancerPool> getAllNeutronLoadBalancerPools();
+
+ /**
+ * Applications call this interface method to add a LoadBalancerPool object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronLoadBalancerPool(NeutronLoadBalancerPool input);
+
+ /**
+ * Applications call this interface method to remove a Neutron LoadBalancerPool object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the LoadBalancerPool object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronLoadBalancerPool(String uuid);
+
+ /**
+ * Applications call this interface method to edit a LoadBalancerPool object
+ *
+ * @param uuid
+ * identifier of the LoadBalancerPool object
+ * @param delta
+ * OpenStackLoadBalancerPool object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronLoadBalancerPool(String uuid, NeutronLoadBalancerPool delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the LoadBalancerPool object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronLoadBalancerPoolInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+
+public interface INeutronLoadBalancerPoolMemberCRUD {
+
+ /**
+ * Applications call this interface method to determine if a particular
+ *NeutronLoadBalancerPoolMember object exists
+ *
+ * @param uuid
+ * UUID of the NeutronLoadBalancerPoolMember object
+ * @return boolean
+ */
+
+ boolean neutronLoadBalancerPoolMemberExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * NeutronLoadBalancerPoolMember object exists
+ *
+ * @param uuid
+ * UUID of the NeutronLoadBalancerPoolMember object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember}
+ * OpenStackNeutronLoadBalancerPoolMember class
+ */
+
+ NeutronLoadBalancerPoolMember getNeutronLoadBalancerPoolMember(String uuid);
+
+ /**
+ * Applications call this interface method to return all NeutronLoadBalancerPoolMember objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronLoadBalancerPoolMember> getAllNeutronLoadBalancerPoolMembers();
+
+ /**
+ * Applications call this interface method to add a NeutronLoadBalancerPoolMember object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember input);
+
+ /**
+ * Applications call this interface method to remove a Neutron NeutronLoadBalancerPoolMember object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the NeutronLoadBalancerPoolMember object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronLoadBalancerPoolMember(String uuid);
+
+ /**
+ * Applications call this interface method to edit a NeutronLoadBalancerPoolMember object
+ *
+ * @param uuid
+ * identifier of the NeutronLoadBalancerPoolMember object
+ * @param delta
+ * OpenStackNeutronLoadBalancerPoolMember object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronLoadBalancerPoolMember(String uuid, NeutronLoadBalancerPoolMember delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the NeutronLoadBalancerPoolMember object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronLoadBalancerPoolMemberInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+
+/**
+ * This interface defines the methods for CRUD of NB network objects
+ *
+ */
+
+public interface INeutronNetworkCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * Network object exists
+ *
+ * @param uuid
+ * UUID of the Network object
+ * @return boolean
+ */
+
+ boolean networkExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Network object exists
+ *
+ * @param uuid
+ * UUID of the Network object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork}
+ * OpenStack Network class
+ */
+
+ NeutronNetwork getNetwork(String uuid);
+
+ /**
+ * Applications call this interface method to return all Network objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ List<NeutronNetwork> getAllNetworks();
+
+ /**
+ * Applications call this interface method to add a Network object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNetwork(NeutronNetwork input);
+
+ /**
+ * Applications call this interface method to remove a Network object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the network object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNetwork(String uuid);
+
+ /**
+ * Applications call this interface method to edit a Network object
+ *
+ * @param uuid
+ * identifier of the network object
+ * @param delta
+ * OpenStackNetwork object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNetwork(String uuid, NeutronNetwork delta);
+
+ /**
+ * Applications call this interface method to determine if a Network object
+ * is use
+ *
+ * @param netUUID
+ * identifier of the network object
+ *
+ * @return boolean on whether the network is in use or not
+ */
+
+ boolean networkInUse(String netUUID);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+
+/**
+ * This interface defines the methods for CRUD of NB Port objects
+ *
+ */
+
+public interface INeutronPortCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * Port object exists
+ *
+ * @param uuid
+ * UUID of the Port object
+ * @return boolean
+ */
+
+ boolean portExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Port object exists
+ *
+ * @param uuid
+ * UUID of the Port object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort}
+ * OpenStack Port class
+ */
+
+ NeutronPort getPort(String uuid);
+
+ /**
+ * Applications call this interface method to return all Port objects
+ *
+ * @return List of OpenStackPorts objects
+ */
+
+ List<NeutronPort> getAllPorts();
+
+ /**
+ * Applications call this interface method to add a Port object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackPort object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addPort(NeutronPort input);
+
+ /**
+ * Applications call this interface method to remove a Port object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the Port object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removePort(String uuid);
+
+ /**
+ * Applications call this interface method to edit a Port object
+ *
+ * @param uuid
+ * identifier of the Port object
+ * @param delta
+ * OpenStackPort object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updatePort(String uuid, NeutronPort delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param macAddress
+ * mac Address to be tested
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ *
+ * @deprecated - will be removed in Boron
+ */
+
+ boolean macInUse(String macAddress);
+
+ /**
+ * Applications call this interface method to retrieve the port associated with
+ * the gateway address of a subnet
+ *
+ * @param subnetUUID
+ * identifier of the subnet
+ * @return OpenStackPorts object if the port exists and null if it does not
+ *
+ * @deprecated - will be removed in Boron
+ */
+
+ NeutronPort getGatewayPort(String subnetUUID);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+
+/**
+ * This interface defines the methods for CRUD of NB Router objects
+ *
+ */
+
+public interface INeutronRouterCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * Router object exists
+ *
+ * @param uuid
+ * UUID of the Router object
+ * @return boolean
+ */
+
+ boolean routerExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Router object exists
+ *
+ * @param uuid
+ * UUID of the Router object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter}
+ * OpenStack Router class
+ */
+
+ NeutronRouter getRouter(String uuid);
+
+ /**
+ * Applications call this interface method to return all Router objects
+ *
+ * @return List of OpenStackRouters objects
+ */
+
+ List<NeutronRouter> getAllRouters();
+
+ /**
+ * Applications call this interface method to add a Router object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackRouter object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addRouter(NeutronRouter input);
+
+ /**
+ * Applications call this interface method to remove a Router object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the Router object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeRouter(String uuid);
+
+ /**
+ * Applications call this interface method to edit a Router object
+ *
+ * @param uuid
+ * identifier of the Router object
+ * @param delta
+ * OpenStackRouter object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateRouter(String uuid, NeutronRouter delta);
+
+ /**
+ * Applications call this interface method to check if a router is in use
+ *
+ * @param routerUUID
+ * identifier of the Router object
+ * @return boolean on whether the router is in use or not
+ */
+
+ boolean routerInUse(String routerUUID);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack Security Group objects
+ */
+
+public interface INeutronSecurityGroupCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * Security Group object exists
+ *
+ * @param uuid UUID of the Security Group object
+ * @return boolean
+ */
+
+ boolean neutronSecurityGroupExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Security Group object exists
+ *
+ * @param uuid UUID of the Security Group object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup}
+ * OpenStack Security Group class
+ */
+
+ NeutronSecurityGroup getNeutronSecurityGroup(String uuid);
+
+ /**
+ * Applications call this interface method to return all Security Group objects
+ *
+ * @return List of OpenStackSecurity Groups objects
+ */
+
+ List<NeutronSecurityGroup> getAllNeutronSecurityGroups();
+
+ /**
+ * Applications call this interface method to add a Security Group object to the
+ * concurrent map
+ *
+ * @param input OpenStackSecurity Group object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronSecurityGroup(NeutronSecurityGroup input);
+
+ /**
+ * Applications call this interface method to remove a Neutron Security Group object to the
+ * concurrent map
+ *
+ * @param uuid identifier for the security group object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronSecurityGroup(String uuid);
+
+ /**
+ * Applications call this interface method to edit a Security Group object
+ *
+ * @param uuid identifier of the security group object
+ * @param delta OpenStackSecurity Group object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronSecurityGroup(String uuid, NeutronSecurityGroup delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid identifier of the security group object
+ * @return boolean on whether the Security Groups is already in use
+ */
+
+ boolean neutronSecurityGroupInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+
+/**
+ * This interface defines the methods for CRUD of NB OpenStack Security Rule objects
+ */
+
+public interface INeutronSecurityRuleCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * Security Rule object exists
+ *
+ * @param uuid UUID of theSecurity Rule object
+ * @return boolean
+ */
+
+ boolean neutronSecurityRuleExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Security Rule object exists
+ *
+ * @param uuid UUID of the security rule object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule}
+ * OpenStackSecurity Rule class
+ */
+
+ NeutronSecurityRule getNeutronSecurityRule(String uuid);
+
+ /**
+ * Applications call this interface method to return all Security Rule objects
+ *
+ * @return List of OpenStack SecurityRules objects
+ */
+
+ List<NeutronSecurityRule> getAllNeutronSecurityRules();
+
+ /**
+ * Applications call this interface method to add a Security Rule object to the
+ * concurrent map
+ *
+ * @param input OpenStack security rule object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addNeutronSecurityRule(NeutronSecurityRule input);
+
+ /**
+ * Applications call this interface method to remove a Neutron Security Rule object to the
+ * concurrent map
+ *
+ * @param uuid identifier for the security rule object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeNeutronSecurityRule(String uuid);
+
+ /**
+ * Applications call this interface method to edit aSecurity Rule object
+ *
+ * @param uuid identifier of the security rule object
+ * @param delta OpenStackSecurity Rule object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateNeutronSecurityRule(String uuid, NeutronSecurityRule delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid identifier of the security rule object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ boolean neutronSecurityRuleInUse(String uuid);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+
+/**
+ * This interface defines the methods for CRUD of NB Subnet objects
+ *
+ */
+
+public interface INeutronSubnetCRUD {
+ /**
+ * Applications call this interface method to determine if a particular
+ * Subnet object exists
+ *
+ * @param uuid
+ * UUID of the Subnet object
+ * @return boolean
+ */
+
+ boolean subnetExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * Subnet object exists
+ *
+ * @param uuid
+ * UUID of the Subnet object
+ * @return {@link org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet}
+ * OpenStack Subnet class
+ */
+
+ NeutronSubnet getSubnet(String uuid);
+
+ /**
+ * Applications call this interface method to return all Subnet objects
+ *
+ * @return List of OpenStackSubnets objects
+ */
+
+ List<NeutronSubnet> getAllSubnets();
+
+ /**
+ * Applications call this interface method to add a Subnet object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackSubnet object
+ * @return boolean on whether the object was added or not
+ */
+
+ boolean addSubnet(NeutronSubnet input);
+
+ /**
+ * Applications call this interface method to remove a Subnet object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the Subnet object
+ * @return boolean on whether the object was removed or not
+ */
+
+ boolean removeSubnet(String uuid);
+
+ /**
+ * Applications call this interface method to edit a Subnet object
+ *
+ * @param uuid
+ * identifier of the Subnet object
+ * @param delta
+ * OpenStackSubnet object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ boolean updateSubnet(String uuid, NeutronSubnet delta);
+
+ /**
+ * Applications call this interface method to determine if a Subnet object
+ * is use
+ *
+ * @param subnetUUID
+ * identifier of the subnet object
+ *
+ * @return boolean on whether the subnet is in use or not
+ *
+ * @deprecated - will be removed in Boron
+ */
+
+ boolean subnetInUse(String subnetUUID);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronCRUDInterfaces {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(NeutronCRUDInterfaces.class);
+
+ private INeutronNetworkCRUD networkInterface;
+ private INeutronSubnetCRUD subnetInterface;
+ private INeutronPortCRUD portInterface;
+ private INeutronRouterCRUD routerInterface;
+ private INeutronFloatingIPCRUD fipInterface;
+ private INeutronSecurityGroupCRUD sgInterface;
+ private INeutronSecurityRuleCRUD srInterface;
+ private INeutronFirewallCRUD fwInterface;
+ private INeutronFirewallPolicyCRUD fwpInterface;
+ private INeutronFirewallRuleCRUD fwrInterface;
+ private INeutronLoadBalancerCRUD lbInterface;
+ private INeutronLoadBalancerPoolCRUD lbpInterface;
+ private INeutronLoadBalancerListenerCRUD lblInterface;
+ private INeutronLoadBalancerHealthMonitorCRUD lbhmInterface;
+ private INeutronLoadBalancerPoolMemberCRUD lbpmInterface;
+ public NeutronCRUDInterfaces() {
+ }
+
+ public INeutronNetworkCRUD getNetworkInterface() {
+ return networkInterface;
+ }
+
+ public INeutronSubnetCRUD getSubnetInterface() {
+ return subnetInterface;
+ }
+
+ public INeutronPortCRUD getPortInterface() {
+ return portInterface;
+ }
+
+ public INeutronRouterCRUD getRouterInterface() {
+ return routerInterface;
+ }
+
+ public INeutronFloatingIPCRUD getFloatingIPInterface() {
+ return fipInterface;
+ }
+
+ public INeutronSecurityGroupCRUD getSecurityGroupInterface() {
+ return sgInterface;
+ }
+
+ public INeutronSecurityRuleCRUD getSecurityRuleInterface() {
+ return srInterface;
+ }
+
+ public INeutronFirewallCRUD getFirewallInterface() {
+ return fwInterface;
+ }
+
+ public INeutronFirewallPolicyCRUD getFirewallPolicyInterface() {
+ return fwpInterface;
+ }
+
+ public INeutronFirewallRuleCRUD getFirewallRuleInterface() {
+ return fwrInterface;
+ }
+
+ public INeutronLoadBalancerCRUD getLoadBalancerInterface() {
+ return lbInterface;
+ }
+
+ public INeutronLoadBalancerPoolCRUD getLoadBalancerPoolInterface() {
+ return lbpInterface;
+ }
+
+ public INeutronLoadBalancerListenerCRUD getLoadBalancerListenerInterface() {
+ return lblInterface;
+ }
+
+ public INeutronLoadBalancerHealthMonitorCRUD getLoadBalancerHealthMonitorInterface() {
+ return lbhmInterface;
+ }
+
+ public INeutronLoadBalancerPoolMemberCRUD getLoadBalancerPoolMemberInterface() {
+ return lbpmInterface;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronNetworkCRUD(Object obj) {
+ networkInterface = (INeutronNetworkCRUD) getInstances(INeutronNetworkCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronSubnetCRUD(Object obj) {
+ subnetInterface = (INeutronSubnetCRUD) getInstances(INeutronSubnetCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronPortCRUD(Object obj) {
+ portInterface = (INeutronPortCRUD) getInstances(INeutronPortCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronRouterCRUD(Object obj) {
+ routerInterface = (INeutronRouterCRUD) getInstances(INeutronRouterCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronFloatingIPCRUD(Object obj) {
+ fipInterface = (INeutronFloatingIPCRUD) getInstances(INeutronFloatingIPCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronSecurityGroupCRUD(Object obj) {
+ sgInterface = (INeutronSecurityGroupCRUD) getInstances(INeutronSecurityGroupCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronSecurityRuleCRUD(Object obj) {
+ srInterface = (INeutronSecurityRuleCRUD) getInstances(INeutronSecurityRuleCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronFirewallCRUD(Object obj) {
+ fwInterface = (INeutronFirewallCRUD) getInstances(INeutronFirewallCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronFirewallPolicyCRUD(Object obj) {
+ fwpInterface = (INeutronFirewallPolicyCRUD) getInstances(INeutronFirewallPolicyCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronFirewallRuleCRUD(Object obj) {
+ fwrInterface = (INeutronFirewallRuleCRUD) getInstances(INeutronFirewallRuleCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronLoadBalancerCRUD(Object obj) {
+ lbInterface = (INeutronLoadBalancerCRUD) getInstances(INeutronLoadBalancerCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronLoadBalancerPoolCRUD(Object obj) {
+ lbpInterface = (INeutronLoadBalancerPoolCRUD) getInstances(INeutronLoadBalancerPoolCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronLoadBalancerListenerCRUD(Object obj) {
+ lblInterface = (INeutronLoadBalancerListenerCRUD) getInstances(INeutronLoadBalancerListenerCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronLoadBalancerHealthMonitorCRUD(Object obj) {
+ lbhmInterface = (INeutronLoadBalancerHealthMonitorCRUD) getInstances(INeutronLoadBalancerHealthMonitorCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronLoadBalancerPoolMemberCRUD(Object obj) {
+ lbpmInterface = (INeutronLoadBalancerPoolMemberCRUD) getInstances(INeutronLoadBalancerPoolMemberCRUD.class, obj);
+ return this;
+ }
+
+ public Object getInstances(Class<?> clazz, Object bundle) {
+ try {
+ BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass()).getBundleContext();
+
+ ServiceReference<?>[] services = null;
+ services = bCtx.getServiceReferences(clazz.getName(), null);
+ if (services != null) {
+ return bCtx.getService(services[0]);
+ }
+ } catch (Exception e) {
+ LOGGER.error("Error in getInstances", e);
+ }
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.INeutronObject;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
+
+
+public abstract class AbstractNeutronInterface<T extends DataObject, S extends INeutronObject> implements AutoCloseable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractNeutronInterface.class);
+ private static final int DEDASHED_UUID_LENGTH = 32;
+ private static final int DEDASHED_UUID_START = 0;
+ private static final int DEDASHED_UUID_DIV1 = 8;
+ private static final int DEDASHED_UUID_DIV2 = 12;
+ private static final int DEDASHED_UUID_DIV3 = 16;
+ private static final int DEDASHED_UUID_DIV4 = 20;
+
+ private DataBroker db;
+
+ AbstractNeutronInterface(ProviderContext providerContext) {
+ this.db = providerContext.getSALService(DataBroker.class);
+ }
+
+ public DataBroker getDataBroker() {
+ return db;
+ }
+
+ protected abstract InstanceIdentifier<T> createInstanceIdentifier(T item);
+
+ protected abstract T toMd(S neutronObject);
+
+ protected abstract T toMd(String uuid);
+
+ protected <T extends org.opendaylight.yangtools.yang.binding.DataObject> T readMd(InstanceIdentifier<T> path) {
+ T result = null;
+ final ReadOnlyTransaction transaction = getDataBroker().newReadOnlyTransaction();
+ CheckedFuture<Optional<T>, ReadFailedException> future = transaction.read(LogicalDatastoreType.CONFIGURATION, path);
+ if (future != null) {
+ Optional<T> optional;
+ try {
+ optional = future.checkedGet();
+ if (optional.isPresent()) {
+ result = optional.get();
+ }
+ } catch (ReadFailedException e) {
+ LOGGER.warn("Failed to read {}", path, e);
+ }
+ }
+ transaction.close();
+ return result;
+ }
+
+ protected boolean addMd(S neutronObject) {
+ // TODO think about adding existence logic
+ return updateMd(neutronObject);
+ }
+
+ protected boolean updateMd(S neutronObject) {
+ WriteTransaction transaction = getDataBroker().newWriteOnlyTransaction();
+ T item = toMd(neutronObject);
+ InstanceIdentifier<T> iid = createInstanceIdentifier(item);
+ transaction.put(LogicalDatastoreType.CONFIGURATION, iid, item,true);
+ CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+ try {
+ future.get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOGGER.warn("Transation failed ",e);
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean removeMd(T item) {
+ WriteTransaction transaction = getDataBroker().newWriteOnlyTransaction();
+ InstanceIdentifier<T> iid = createInstanceIdentifier(item);
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, iid);
+ CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+ try {
+ future.get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOGGER.warn("Transation failed ",e);
+ return false;
+ }
+ return true;
+ }
+
+ protected Uuid toUuid(String uuid) {
+ Preconditions.checkNotNull(uuid);
+ Uuid result;
+ try {
+ result = new Uuid(uuid);
+ } catch(IllegalArgumentException e) {
+ // OK... someone didn't follow RFC 4122... lets try this the hard way
+ String dedashed = uuid.replace("-", "");
+ if(dedashed.length() == DEDASHED_UUID_LENGTH) {
+ String redashed = dedashed.substring(DEDASHED_UUID_START, DEDASHED_UUID_DIV1)
+ + "-"
+ + dedashed.substring(DEDASHED_UUID_DIV1, DEDASHED_UUID_DIV2)
+ + "-"
+ + dedashed.substring(DEDASHED_UUID_DIV2, DEDASHED_UUID_DIV3)
+ + "-"
+ + dedashed.substring(DEDASHED_UUID_DIV3, DEDASHED_UUID_DIV4)
+ + "-"
+ + dedashed.substring(DEDASHED_UUID_DIV4, DEDASHED_UUID_LENGTH);
+ result = new Uuid(redashed);
+ } else {
+ throw e;
+ }
+ }
+ return result;
+ }
+
+ // this method uses reflection to update an object from it's delta.
+
+ protected 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("Error in overwrite", e);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void close() throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.INeutronObject;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewall;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronFirewallCRUD;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class NeutronFirewallInterface extends AbstractNeutronInterface implements INeutronFirewallCRUD {
+
+ NeutronFirewallInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ 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);
+ }
+ }
+
+ @Override
+ public boolean neutronFirewallExists(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public NeutronFirewall getNeutronFirewall(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<NeutronFirewall> getAllNeutronFirewalls() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean addNeutronFirewall(NeutronFirewall input) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeNeutronFirewall(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updateNeutronFirewall(String uuid, NeutronFirewall delta) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean neutronFirewallInUse(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected InstanceIdentifier createInstanceIdentifier(DataObject item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected DataObject toMd(INeutronObject neutronObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected DataObject toMd(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.INeutronObject;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallPolicy;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronFirewallPolicyCRUD;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ */
+
+public class NeutronFirewallPolicyInterface extends AbstractNeutronInterface implements INeutronFirewallPolicyCRUD {
+
+ NeutronFirewallPolicyInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronFirewallPolicyExists(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public NeutronFirewallPolicy getNeutronFirewallPolicy(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<NeutronFirewallPolicy> getAllNeutronFirewallPolicies() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean addNeutronFirewallPolicy(NeutronFirewallPolicy input) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeNeutronFirewallPolicy(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updateNeutronFirewallPolicy(String uuid,
+ NeutronFirewallPolicy delta) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean neutronFirewallPolicyInUse(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected InstanceIdentifier createInstanceIdentifier(DataObject item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected DataObject toMd(INeutronObject neutronObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected DataObject toMd(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronFirewallPolicyInterface neutronFirewallPolicyInterface = new NeutronFirewallPolicyInterface(providerContext);
+ ServiceRegistration<INeutronFirewallPolicyCRUD> neutronFirewallPolicyInterfaceRegistration = context.registerService(INeutronFirewallPolicyCRUD.class, neutronFirewallPolicyInterface, null);
+ if(neutronFirewallPolicyInterfaceRegistration != null) {
+ registrations.add(neutronFirewallPolicyInterfaceRegistration);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.INeutronObject;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronFirewallRuleCRUD;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class NeutronFirewallRuleInterface extends AbstractNeutronInterface implements INeutronFirewallRuleCRUD {
+
+ NeutronFirewallRuleInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronFirewallRuleExists(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public NeutronFirewallRule getNeutronFirewallRule(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<NeutronFirewallRule> getAllNeutronFirewallRules() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean addNeutronFirewallRule(NeutronFirewallRule input) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeNeutronFirewallRule(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updateNeutronFirewallRule(String uuid,
+ NeutronFirewallRule delta) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean neutronFirewallRuleInUse(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected InstanceIdentifier createInstanceIdentifier(DataObject item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected DataObject toMd(INeutronObject neutronObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected DataObject toMd(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronFirewallRuleInterface neutronFirewallRuleInterface = new NeutronFirewallRuleInterface(providerContext);
+ ServiceRegistration<INeutronFirewallRuleCRUD> neutronFirewallRuleInterfaceRegistration = context.registerService(INeutronFirewallRuleCRUD.class, neutronFirewallRuleInterface, null);
+ if(neutronFirewallRuleInterfaceRegistration != null) {
+ registrations.add(neutronFirewallRuleInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronFloatingIPCRUD;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.Floatingips;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.floatingips.Floatingip;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.floatingips.FloatingipBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+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;
+
+public class NeutronFloatingIPInterface extends AbstractNeutronInterface<Floatingip, NeutronFloatingIP> implements INeutronFloatingIPCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronFloatingIPInterface.class);
+
+ NeutronFloatingIPInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ // IfNBFloatingIPCRUD interface methods
+
+ @Override
+ public boolean floatingIPExists(String uuid) {
+ Floatingip fip = readMd(createInstanceIdentifier(toMd(uuid)));
+ return (fip != null);
+ }
+
+ @Override
+ public NeutronFloatingIP getFloatingIP(String uuid) {
+ Floatingip fip = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (fip == null) {
+ return null;
+ }
+ return fromMd(fip);
+ }
+
+ @Override
+ public List<NeutronFloatingIP> getAllFloatingIPs() {
+ Set<NeutronFloatingIP> allIPs = new HashSet<NeutronFloatingIP>();
+ Floatingips fips = readMd(createInstanceIdentifier());
+ if (fips != null) {
+ for (Floatingip fip: fips.getFloatingip()) {
+ allIPs.add(fromMd(fip));
+ }
+ }
+ LOGGER.debug("Exiting getAllFloatingIPs, Found {} FloatingIPs", allIPs.size());
+ List<NeutronFloatingIP> ans = new ArrayList<NeutronFloatingIP>();
+ ans.addAll(allIPs);
+ return ans;
+ }
+
+ @Override
+ public boolean addFloatingIP(NeutronFloatingIP input) {
+ if (floatingIPExists(input.getID())) {
+ return false;
+ }
+ return addMd(input);
+ }
+
+ @Override
+ public boolean removeFloatingIP(String uuid) {
+ NeutronFloatingIP fip = getFloatingIP(uuid);
+ if (fip == null) {
+ return false;
+ }
+ return removeMd(toMd(uuid));
+ }
+
+ @Override
+ public boolean updateFloatingIP(String uuid, NeutronFloatingIP delta) {
+ NeutronFloatingIP target = getFloatingIP(uuid);
+ if (target == null) {
+ return false;
+ }
+ delta.setPortUUID(target.getPortUUID());
+ delta.setFixedIPAddress(target.getFixedIPAddress());
+ return updateMd(delta);
+ }
+
+ @Override
+ protected Floatingip toMd(String uuid) {
+ FloatingipBuilder floatingipBuilder = new FloatingipBuilder();
+ floatingipBuilder.setUuid(toUuid(uuid));
+ return floatingipBuilder.build();
+ }
+
+ @Override
+ protected Floatingip toMd(NeutronFloatingIP floatingIp) {
+ FloatingipBuilder floatingipBuilder = new FloatingipBuilder();
+ if (floatingIp.getFixedIPAddress() != null) {
+ floatingipBuilder.setFixedIpAddress(new IpAddress(floatingIp.getFixedIPAddress().toCharArray()));
+ }
+ if(floatingIp.getFloatingIPAddress() != null) {
+ floatingipBuilder.setFloatingIpAddress(new IpAddress(floatingIp.getFloatingIPAddress().toCharArray()));
+ }
+ if (floatingIp.getFloatingNetworkUUID() != null) {
+ floatingipBuilder.setFloatingNetworkId(toUuid(floatingIp.getFloatingNetworkUUID()));
+ }
+ if (floatingIp.getPortUUID() != null) {
+ floatingipBuilder.setPortId(toUuid(floatingIp.getPortUUID()));
+ }
+ if (floatingIp.getRouterUUID() != null) {
+ floatingipBuilder.setRouterId(toUuid(floatingIp.getRouterUUID()));
+ }
+ if (floatingIp.getStatus() != null) {
+ floatingipBuilder.setStatus(floatingIp.getStatus());
+ }
+ if (floatingIp.getTenantUUID() != null) {
+ floatingipBuilder.setTenantId(toUuid(floatingIp.getTenantUUID()));
+ }
+ if (floatingIp.getID() != null) {
+ floatingipBuilder.setUuid(toUuid(floatingIp.getID()));
+ }
+ else {
+ LOGGER.warn("Attempting to write neutron floating IP without UUID");
+ }
+ return floatingipBuilder.build();
+ }
+
+ protected NeutronFloatingIP fromMd(Floatingip fip) {
+ NeutronFloatingIP result = new NeutronFloatingIP();
+ result.setID(String.valueOf(fip.getUuid().getValue()));
+ if (fip.getFloatingNetworkId() != null) {
+ result.setFloatingNetworkUUID(String.valueOf(fip.getFloatingNetworkId().getValue()));
+ }
+ if (fip.getPortId() != null) {
+ result.setPortUUID(String.valueOf(fip.getPortId().getValue()));
+ }
+ if (fip.getFixedIpAddress() != null ) {
+ result.setFixedIPAddress(String.valueOf(fip.getFixedIpAddress().getValue()));
+ }
+ if (fip.getFloatingIpAddress() != null) {
+ result.setFloatingIPAddress(String.valueOf(fip.getFloatingIpAddress().getValue()));
+ }
+ if (fip.getTenantId() != null) {
+ result.setTenantUUID(String.valueOf(fip.getTenantId().getValue()));
+ }
+ if (fip.getRouterId() != null) {
+ result.setRouterUUID(String.valueOf(fip.getRouterId().getValue()));
+ }
+ result.setStatus(fip.getStatus());
+ return result;
+ }
+
+ @Override
+ protected InstanceIdentifier<Floatingip> createInstanceIdentifier(
+ Floatingip item) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Floatingips.class)
+ .child(Floatingip.class,item.getKey());
+ }
+
+ protected InstanceIdentifier<Floatingips> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Floatingips.class);
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronFloatingIPInterface neutronFloatingIPInterface = new NeutronFloatingIPInterface(providerContext);
+ ServiceRegistration<INeutronFloatingIPCRUD> neutronFloatingIPInterfaceRegistration = context.registerService(INeutronFloatingIPCRUD.class, neutronFloatingIPInterface, null);
+ if (neutronFloatingIPInterfaceRegistration != null) {
+ registrations.add(neutronFloatingIPInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerHealthMonitor;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerHealthMonitorCRUD;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.Healthmonitors;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class NeutronLoadBalancerHealthMonitorInterface extends AbstractNeutronInterface<Healthmonitors, NeutronLoadBalancerHealthMonitor> implements INeutronLoadBalancerHealthMonitorCRUD {
+
+ NeutronLoadBalancerHealthMonitorInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerHealthMonitorExists(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public NeutronLoadBalancerHealthMonitor getNeutronLoadBalancerHealthMonitor(
+ String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<NeutronLoadBalancerHealthMonitor> getAllNeutronLoadBalancerHealthMonitors() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean addNeutronLoadBalancerHealthMonitor(
+ NeutronLoadBalancerHealthMonitor input) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeNeutronLoadBalancerHealthMonitor(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updateNeutronLoadBalancerHealthMonitor(String uuid,
+ NeutronLoadBalancerHealthMonitor delta) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean neutronLoadBalancerHealthMonitorInUse(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected InstanceIdentifier<Healthmonitors> createInstanceIdentifier(
+ Healthmonitors item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Healthmonitors toMd(NeutronLoadBalancerHealthMonitor neutronObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Healthmonitors toMd(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronLoadBalancerHealthMonitorInterface neutronLoadBalancerHealthMonitorInterface = new NeutronLoadBalancerHealthMonitorInterface(providerContext);
+ ServiceRegistration<INeutronLoadBalancerHealthMonitorCRUD> neutronLoadBalancerHealthMonitorInterfaceRegistration = context.registerService(INeutronLoadBalancerHealthMonitorCRUD.class, neutronLoadBalancerHealthMonitorInterface, null);
+ if(neutronLoadBalancerHealthMonitorInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerHealthMonitorInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.Loadbalancers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.loadbalancers.Loadbalancer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.loadbalancers.LoadbalancerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+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;
+
+/**
+ * TODO: Migrate this to consume the MD-SAL data store, so that it can read all the data from data store.
+ * No need to worry about the write/update related methods here. OVSDB net-virt will use these CRUD Interface
+ * only for reading. We will cleanup these interface/methods later.
+ */
+public class NeutronLoadBalancerInterface extends AbstractNeutronInterface<Loadbalancer, NeutronLoadBalancer> implements INeutronLoadBalancerCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronLoadBalancerInterface.class);
+ private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<String, NeutronLoadBalancer>();
+
+
+ NeutronLoadBalancerInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerExists(String uuid) {
+ return loadBalancerDB.containsKey(uuid);
+ }
+
+ @Override
+ public NeutronLoadBalancer getNeutronLoadBalancer(String uuid) {
+ if (!neutronLoadBalancerExists(uuid)) {
+ LOGGER.debug("No LoadBalancer Have Been Defined");
+ return null;
+ }
+ return loadBalancerDB.get(uuid);
+ }
+
+ @Override
+ public List<NeutronLoadBalancer> getAllNeutronLoadBalancers() {
+ Set<NeutronLoadBalancer> allLoadBalancers = new HashSet<NeutronLoadBalancer>();
+ for (Entry<String, NeutronLoadBalancer> entry : loadBalancerDB.entrySet()) {
+ NeutronLoadBalancer loadBalancer = entry.getValue();
+ allLoadBalancers.add(loadBalancer);
+ }
+ LOGGER.debug("Exiting getLoadBalancers, Found {} OpenStackLoadBalancer", allLoadBalancers.size());
+ List<NeutronLoadBalancer> ans = new ArrayList<NeutronLoadBalancer>();
+ ans.addAll(allLoadBalancers);
+ return ans;
+ }
+
+ @Override
+ public boolean addNeutronLoadBalancer(NeutronLoadBalancer input) {
+ if (neutronLoadBalancerExists(input.getID())) {
+ return false;
+ }
+ loadBalancerDB.putIfAbsent(input.getID(), input);
+ //TODO: add code to find INeutronLoadBalancerAware services and call newtorkCreated on them
+ return true;
+ }
+
+ @Override
+ public boolean removeNeutronLoadBalancer(String uuid) {
+ if (!neutronLoadBalancerExists(uuid)) {
+ return false;
+ }
+ loadBalancerDB.remove(uuid);
+ //TODO: add code to find INeutronLoadBalancerAware services and call newtorkDeleted on them
+ return true;
+ }
+
+ @Override
+ public boolean updateNeutronLoadBalancer(String uuid, NeutronLoadBalancer delta) {
+ if (!neutronLoadBalancerExists(uuid)) {
+ return false;
+ }
+ NeutronLoadBalancer target = loadBalancerDB.get(uuid);
+ return overwrite(target, delta);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerInUse(String loadBalancerUUID) {
+ return !neutronLoadBalancerExists(loadBalancerUUID);
+ }
+
+ @Override
+ protected Loadbalancer toMd(String uuid) {
+ LoadbalancerBuilder loadBalancersBuilder = new LoadbalancerBuilder();
+ loadBalancersBuilder.setUuid(toUuid(uuid));
+ return loadBalancersBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<Loadbalancer> createInstanceIdentifier(
+ Loadbalancer loadBalancer) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Loadbalancers.class)
+ .child(Loadbalancer.class, loadBalancer.getKey());
+ }
+
+ @Override
+ protected Loadbalancer toMd(NeutronLoadBalancer loadBalancer) {
+ LoadbalancerBuilder loadBalancersBuilder = new LoadbalancerBuilder();
+ loadBalancersBuilder.setAdminStateUp(loadBalancer.getLoadBalancerAdminStateUp());
+ if (loadBalancer.getLoadBalancerDescription() != null) {
+ loadBalancersBuilder.setDescr(loadBalancer.getLoadBalancerDescription());
+ }
+ if (loadBalancer.getLoadBalancerName() != null) {
+ loadBalancersBuilder.setName(loadBalancer.getLoadBalancerName());
+ }
+ if (loadBalancer.getLoadBalancerStatus() != null) {
+ loadBalancersBuilder.setStatus(loadBalancer.getLoadBalancerStatus());
+ }
+ if (loadBalancer.getLoadBalancerTenantID() != null) {
+ loadBalancersBuilder.setTenantId(toUuid(loadBalancer.getLoadBalancerTenantID()));
+ }
+ if (loadBalancer.getLoadBalancerVipAddress() != null) {
+ loadBalancersBuilder.setVipAddress(new IpAddress(loadBalancer.getLoadBalancerVipAddress().toCharArray()));
+ }
+ if (loadBalancer.getLoadBalancerVipSubnetID() != null) {
+ loadBalancersBuilder.setVipSubnetId(toUuid(loadBalancer.getLoadBalancerVipSubnetID()));
+ }
+ if (loadBalancer.getID() != null) {
+ loadBalancersBuilder.setUuid(toUuid(loadBalancer.getID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron load balancer without UUID");
+ }
+ return loadBalancersBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronLoadBalancerInterface neutronLoadBalancerInterface = new NeutronLoadBalancerInterface(providerContext);
+ ServiceRegistration<INeutronLoadBalancerCRUD> neutronLoadBalancerInterfaceRegistration = context.registerService(INeutronLoadBalancerCRUD.class, neutronLoadBalancerInterface, null);
+ if(neutronLoadBalancerInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerListener;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerListenerCRUD;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.Listeners;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class NeutronLoadBalancerListenerInterface extends AbstractNeutronInterface<Listeners, NeutronLoadBalancerListener> implements INeutronLoadBalancerListenerCRUD {
+
+ NeutronLoadBalancerListenerInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerListenerExists(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public NeutronLoadBalancerListener getNeutronLoadBalancerListener(
+ String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<NeutronLoadBalancerListener> getAllNeutronLoadBalancerListeners() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean addNeutronLoadBalancerListener(
+ NeutronLoadBalancerListener input) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeNeutronLoadBalancerListener(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updateNeutronLoadBalancerListener(String uuid,
+ NeutronLoadBalancerListener delta) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean neutronLoadBalancerListenerInUse(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected InstanceIdentifier<Listeners> createInstanceIdentifier(
+ Listeners item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Listeners toMd(NeutronLoadBalancerListener neutronObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Listeners toMd(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronLoadBalancerListenerInterface neutronLoadBalancerListenerInterface = new NeutronLoadBalancerListenerInterface(providerContext);
+ ServiceRegistration<INeutronLoadBalancerListenerCRUD> neutronLoadBalancerListenerInterfaceRegistration = context.registerService(INeutronLoadBalancerListenerCRUD.class, neutronLoadBalancerListenerInterface, null);
+ if(neutronLoadBalancerListenerInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerListenerInterfaceRegistration);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer_SessionPersistence;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_ID;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.Pools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.Pool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.PoolBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.pool.attributes.SessionPersistenceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+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 com.google.common.collect.ImmutableBiMap;
+
+/**
+ * TODO: Migrate this to consume the MD-SAL data store, so that it can read all the data from data store.
+ * No need to worry about the write/update related methods here. OVSDB net-virt will use these CRUD Interface
+ * only for reading. We will cleanup these interface/methods later.
+ */
+
+public class NeutronLoadBalancerPoolInterface extends AbstractNeutronInterface<Pool, NeutronLoadBalancerPool> implements INeutronLoadBalancerPoolCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronLoadBalancerPoolInterface.class);
+ private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<String, NeutronLoadBalancerPool>();
+
+ private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
+ = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
+ .put(ProtocolHttp.class,"HTTP")
+ .put(ProtocolHttps.class,"HTTPS")
+ .put(ProtocolTcp.class,"TCP")
+ .build();
+
+ NeutronLoadBalancerPoolInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerPoolExists(String uuid) {
+ return loadBalancerPoolDB.containsKey(uuid);
+ }
+
+ @Override
+ public NeutronLoadBalancerPool getNeutronLoadBalancerPool(String uuid) {
+ if (!neutronLoadBalancerPoolExists(uuid)) {
+ LOGGER.debug("No LoadBalancerPool has Been Defined");
+ return null;
+ }
+ return loadBalancerPoolDB.get(uuid);
+ }
+
+ @Override
+ public List<NeutronLoadBalancerPool> getAllNeutronLoadBalancerPools() {
+ Set<NeutronLoadBalancerPool> allLoadBalancerPools = new HashSet<NeutronLoadBalancerPool>();
+ for (Entry<String, NeutronLoadBalancerPool> entry : loadBalancerPoolDB.entrySet()) {
+ NeutronLoadBalancerPool loadBalancerPool = entry.getValue();
+ allLoadBalancerPools.add(loadBalancerPool);
+ }
+ LOGGER.debug("Exiting getLoadBalancerPools, Found {} OpenStackLoadBalancerPool", allLoadBalancerPools.size());
+ List<NeutronLoadBalancerPool> ans = new ArrayList<NeutronLoadBalancerPool>();
+ ans.addAll(allLoadBalancerPools);
+ return ans;
+ }
+
+ @Override
+ public boolean addNeutronLoadBalancerPool(NeutronLoadBalancerPool input) {
+ if (neutronLoadBalancerPoolExists(input.getID())) {
+ return false;
+ }
+ loadBalancerPoolDB.putIfAbsent(input.getID(), input);
+ //TODO: add code to find INeutronLoadBalancerPoolAware services and call newtorkCreated on them
+ return true;
+ }
+
+ @Override
+ public boolean removeNeutronLoadBalancerPool(String uuid) {
+ if (!neutronLoadBalancerPoolExists(uuid)) {
+ return false;
+ }
+ loadBalancerPoolDB.remove(uuid);
+ //TODO: add code to find INeutronLoadBalancerPoolAware services and call newtorkDeleted on them
+ return true;
+ }
+
+ @Override
+ public boolean updateNeutronLoadBalancerPool(String uuid, NeutronLoadBalancerPool delta) {
+ if (!neutronLoadBalancerPoolExists(uuid)) {
+ return false;
+ }
+ NeutronLoadBalancerPool target = loadBalancerPoolDB.get(uuid);
+ return overwrite(target, delta);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerPoolInUse(String loadBalancerPoolUUID) {
+ return !neutronLoadBalancerPoolExists(loadBalancerPoolUUID);
+ }
+
+ @Override
+ protected Pool toMd(String uuid) {
+ PoolBuilder poolsBuilder = new PoolBuilder();
+ poolsBuilder.setUuid(toUuid(uuid));
+ return poolsBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<Pool> createInstanceIdentifier(Pool pools) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Pools.class)
+ .child(Pool.class, pools.getKey());
+ }
+
+ @Override
+ protected Pool toMd(NeutronLoadBalancerPool pool) {
+ PoolBuilder poolBuilder = new PoolBuilder();
+ poolBuilder.setAdminStateUp(pool.getLoadBalancerPoolAdminIsStateIsUp());
+ if (pool.getLoadBalancerPoolDescription() != null) {
+ poolBuilder.setDescr(pool.getLoadBalancerPoolDescription());
+ }
+ if (pool.getNeutronLoadBalancerPoolHealthMonitorID() != null) {
+ poolBuilder.setHealthmonitorId(toUuid(pool.getNeutronLoadBalancerPoolHealthMonitorID()));
+ }
+ if (pool.getLoadBalancerPoolLbAlgorithm() != null) {
+ poolBuilder.setLbAlgorithm(pool.getLoadBalancerPoolLbAlgorithm());
+ }
+ if (pool.getLoadBalancerPoolListeners() != null) {
+ List<Uuid> listListener = new ArrayList<Uuid>();
+ for (Neutron_ID neutron_id : pool.getLoadBalancerPoolListeners()) {
+ listListener.add(toUuid(neutron_id.getID()));
+ }
+ poolBuilder.setListeners(listListener);
+ }
+ // because members are another container, we don't want to copy
+ // it over, so just skip it here
+ if (pool.getLoadBalancerPoolName() != null) {
+ poolBuilder.setName(pool.getLoadBalancerPoolName());
+ }
+ if (pool.getLoadBalancerPoolProtocol() != null) {
+ ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
+ PROTOCOL_MAP.inverse();
+ poolBuilder.setProtocol((Class<? extends ProtocolBase>) mapper.get(pool.getLoadBalancerPoolProtocol()));
+ }
+ if (pool.getLoadBalancerPoolSessionPersistence() != null) {
+ NeutronLoadBalancer_SessionPersistence sessionPersistence = pool.getLoadBalancerPoolSessionPersistence();
+ SessionPersistenceBuilder sessionPersistenceBuilder = new SessionPersistenceBuilder();
+ sessionPersistenceBuilder.setCookieName(sessionPersistence.getCookieName());
+ sessionPersistenceBuilder.setType(sessionPersistence.getType());
+ poolBuilder.setSessionPersistence(sessionPersistenceBuilder.build());
+ }
+ if (pool.getLoadBalancerPoolTenantID() != null) {
+ poolBuilder.setTenantId(toUuid(pool.getLoadBalancerPoolTenantID()));
+ }
+ if (pool.getID() != null) {
+ poolBuilder.setUuid(toUuid(pool.getID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron load balancer pool without UUID");
+ }
+ return poolBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronLoadBalancerPoolInterface neutronLoadBalancerPoolInterface = new NeutronLoadBalancerPoolInterface(providerContext);
+ ServiceRegistration<INeutronLoadBalancerPoolCRUD> neutronLoadBalancerPoolInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolCRUD.class, neutronLoadBalancerPoolInterface, null);
+ if(neutronLoadBalancerPoolInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerPoolInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolMemberCRUD;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.pool.Members;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class NeutronLoadBalancerPoolMemberInterface extends
+ AbstractNeutronInterface<Members, NeutronLoadBalancerPoolMember> implements INeutronLoadBalancerPoolMemberCRUD {
+
+ NeutronLoadBalancerPoolMemberInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronLoadBalancerPoolMemberExists(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public NeutronLoadBalancerPoolMember getNeutronLoadBalancerPoolMember(
+ String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<NeutronLoadBalancerPoolMember> getAllNeutronLoadBalancerPoolMembers() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean addNeutronLoadBalancerPoolMember(
+ NeutronLoadBalancerPoolMember input) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeNeutronLoadBalancerPoolMember(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updateNeutronLoadBalancerPoolMember(String uuid,
+ NeutronLoadBalancerPoolMember delta) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean neutronLoadBalancerPoolMemberInUse(String uuid) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected InstanceIdentifier<Members> createInstanceIdentifier(Members item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Members toMd(NeutronLoadBalancerPoolMember neutronObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Members toMd(String uuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronLoadBalancerPoolMemberInterface neutronLoadBalancerPoolMemberInterface = new NeutronLoadBalancerPoolMemberInterface(providerContext);
+ ServiceRegistration<INeutronLoadBalancerPoolMemberCRUD> neutronLoadBalancerPoolMemberInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolMemberCRUD.class, neutronLoadBalancerPoolMemberInterface, null);
+ if(neutronLoadBalancerPoolMemberInterfaceRegistration != null) {
+ registrations.add(neutronLoadBalancerPoolMemberInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork_Segment;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.ext.rev150712.NetworkL3Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.ext.rev150712.NetworkL3ExtensionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeFlat;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtensionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.SegmentsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+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 com.google.common.collect.ImmutableBiMap;
+
+public class NeutronNetworkInterface extends AbstractNeutronInterface<Network,NeutronNetwork> implements INeutronNetworkCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronNetworkInterface.class);
+
+ private static final ImmutableBiMap<Class<? extends NetworkTypeBase>,String> NETWORK_MAP
+ = new ImmutableBiMap.Builder<Class<? extends NetworkTypeBase>,String>()
+ .put(NetworkTypeFlat.class,"flat")
+ .put(NetworkTypeGre.class,"gre")
+ .put(NetworkTypeVlan.class,"vlan")
+ .put(NetworkTypeVxlan.class,"vxlan")
+ .build();
+
+ NeutronNetworkInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ // IfNBNetworkCRUD methods
+
+ @Override
+ public boolean networkExists(String uuid) {
+ Network network = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (network == null) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public NeutronNetwork getNetwork(String uuid) {
+ Network network = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (network == null) {
+ return null;
+ }
+ return fromMd(network);
+ }
+
+ @Override
+ public List<NeutronNetwork> getAllNetworks() {
+ Set<NeutronNetwork> allNetworks = new HashSet<NeutronNetwork>();
+ Networks networks = readMd(createInstanceIdentifier());
+ if (networks != null) {
+ for (Network network: networks.getNetwork()) {
+ allNetworks.add(fromMd(network));
+ }
+ }
+ LOGGER.debug("Exiting getAllNetworks, Found {} OpenStackNetworks", allNetworks.size());
+ List<NeutronNetwork> ans = new ArrayList<NeutronNetwork>();
+ ans.addAll(allNetworks);
+ return ans;
+ }
+
+ @Override
+ public boolean addNetwork(NeutronNetwork input) {
+ if (networkExists(input.getID())) {
+ return false;
+ }
+ addMd(input);
+ return true;
+ }
+
+ @Override
+ public boolean removeNetwork(String uuid) {
+ if (!networkExists(uuid)) {
+ return false;
+ }
+ return removeMd(toMd(uuid));
+ }
+
+ @Override
+ public boolean updateNetwork(String uuid, NeutronNetwork delta) {
+ if (!networkExists(uuid)) {
+ return false;
+ }
+/* note: because what we get is *not* a delta but (at this point) the updated
+ * object, this is much simpler - just replace the value and update the mdsal
+ * with it */
+ updateMd(delta);
+ return true;
+ }
+
+ @Override
+ public boolean networkInUse(String netUUID) {
+ if (!networkExists(netUUID)) {
+ return true;
+ }
+ return false;
+ }
+
+ protected NeutronNetwork fromMd(Network network) {
+ NeutronNetwork result = new NeutronNetwork();
+ result.setAdminStateUp(network.isAdminStateUp());
+ result.setNetworkName(network.getName());
+ result.setShared(network.isShared());
+ result.setStatus(network.getStatus());
+ if (network.getSubnets() != null) {
+ List<String> neutronSubnets = new ArrayList<String>();
+ for( Uuid subnet : network.getSubnets()) {
+ neutronSubnets.add(subnet.getValue());
+ }
+ result.setSubnets(neutronSubnets);
+ }
+// todo remove '-' chars as tenant id doesn't use them
+ result.setTenantID(network.getTenantId().getValue());
+ result.setID(network.getUuid().getValue());
+
+ NetworkL3Extension l3Extension = network.getAugmentation(NetworkL3Extension.class);
+ result.setRouterExternal(l3Extension.isExternal());
+
+ NetworkProviderExtension providerExtension = network.getAugmentation(NetworkProviderExtension.class);
+ result.setProviderPhysicalNetwork(providerExtension.getPhysicalNetwork());
+ result.setProviderSegmentationID(providerExtension.getSegmentationId());
+ result.setProviderNetworkType(NETWORK_MAP.get(providerExtension.getNetworkType()));
+ List<NeutronNetwork_Segment> segments = new ArrayList<NeutronNetwork_Segment>();
+ if (providerExtension.getSegments() != null) {
+ for (Segments segment: providerExtension.getSegments()) {
+ NeutronNetwork_Segment neutronSegment = new NeutronNetwork_Segment();
+ neutronSegment.setProviderPhysicalNetwork(segment.getPhysicalNetwork());
+ neutronSegment.setProviderSegmentationID(segment.getSegmentationId());
+ neutronSegment.setProviderNetworkType(NETWORK_MAP.get(segment.getNetworkType()));
+ segments.add(neutronSegment);
+ }
+ }
+ result.setSegments(segments);
+ return result;
+ }
+
+ private void fillExtensions(NetworkBuilder networkBuilder,
+ NeutronNetwork network) {
+ NetworkL3ExtensionBuilder l3ExtensionBuilder = new NetworkL3ExtensionBuilder();
+ if (network.getRouterExternal() != null) {
+ l3ExtensionBuilder.setExternal(network.getRouterExternal());
+ }
+
+ NetworkProviderExtensionBuilder providerExtensionBuilder = new NetworkProviderExtensionBuilder();
+ if (network.getProviderPhysicalNetwork() != null) {
+ providerExtensionBuilder.setPhysicalNetwork(network.getProviderPhysicalNetwork());
+ }
+ if (network.getProviderSegmentationID() != null) {
+ providerExtensionBuilder.setSegmentationId(network.getProviderSegmentationID());
+ }
+ if (network.getProviderNetworkType() != null) {
+ ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper =
+ NETWORK_MAP.inverse();
+ providerExtensionBuilder.setNetworkType((Class<? extends NetworkTypeBase>) mapper.get(network.getProviderNetworkType()));
+ }
+ if (network.getSegments() != null) {
+ List<Segments> segments = new ArrayList<Segments>();
+ long count = 0;
+ for( NeutronNetwork_Segment segment : network.getSegments()) {
+ count++;
+ SegmentsBuilder segmentsBuilder = new SegmentsBuilder();
+ if (segment.getProviderPhysicalNetwork() != null) {
+ segmentsBuilder.setPhysicalNetwork(segment.getProviderPhysicalNetwork());
+ }
+ if (segment.getProviderSegmentationID() != null) {
+ segmentsBuilder.setSegmentationId(segment.getProviderSegmentationID());
+ }
+ if (segment.getProviderNetworkType() != null) {
+ ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper =
+ NETWORK_MAP.inverse();
+ segmentsBuilder.setNetworkType((Class<? extends NetworkTypeBase>) mapper.get(segment.getProviderNetworkType()));
+ }
+ segmentsBuilder.setSegmentationIndex(Long.valueOf(count));
+ segments.add(segmentsBuilder.build());
+ }
+ providerExtensionBuilder.setSegments(segments);
+ }
+ if (network.getProviderSegmentationID() != null) {
+ providerExtensionBuilder.setSegmentationId(network.getProviderSegmentationID());
+ }
+
+ networkBuilder.addAugmentation(NetworkL3Extension.class,
+ l3ExtensionBuilder.build());
+ networkBuilder.addAugmentation(NetworkProviderExtension.class,
+ providerExtensionBuilder.build());
+ }
+
+ protected Network toMd(NeutronNetwork network) {
+ NetworkBuilder networkBuilder = new NetworkBuilder();
+ fillExtensions(networkBuilder, network);
+
+ networkBuilder.setAdminStateUp(network.getAdminStateUp());
+ if (network.getNetworkName() != null) {
+ networkBuilder.setName(network.getNetworkName());
+ }
+ if (network.getShared() != null) {
+ networkBuilder.setShared(network.getShared());
+ }
+ if (network.getStatus() != null) {
+ networkBuilder.setStatus(network.getStatus());
+ }
+ if (network.getSubnets() != null) {
+ List<Uuid> subnets = new ArrayList<Uuid>();
+ for( String subnet : network.getSubnets()) {
+ subnets.add(toUuid(subnet));
+ }
+ networkBuilder.setSubnets(subnets);
+ }
+ if (network.getTenantID() != null) {
+ networkBuilder.setTenantId(toUuid(network.getTenantID()));
+ }
+ if (network.getNetworkUUID() != null) {
+ networkBuilder.setUuid(toUuid(network.getNetworkUUID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron network without UUID");
+ }
+ return networkBuilder.build();
+ }
+
+ protected Network toMd(String uuid) {
+ NetworkBuilder networkBuilder = new NetworkBuilder();
+ networkBuilder.setUuid(toUuid(uuid));
+ return networkBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<Network> createInstanceIdentifier(Network network) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Networks.class)
+ .child(Network.class,network.getKey());
+ }
+
+ protected InstanceIdentifier<Networks> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Networks.class);
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronNetworkInterface neutronNetworkInterface = new NeutronNetworkInterface(providerContext);
+ ServiceRegistration<INeutronNetworkCRUD> neutronNetworkInterfaceRegistration = context.registerService(INeutronNetworkCRUD.class, neutronNetworkInterface, null);
+ if(neutronNetworkInterfaceRegistration != null) {
+ registrations.add(neutronNetworkInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort_AllowedAddressPairs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort_ExtraDHCPOption;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort_VIFDetail;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtensionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.binding.attributes.VifDetails;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.binding.attributes.VifDetailsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.AllowedAddressPairs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.AllowedAddressPairsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.ExtraDhcpOpts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.ExtraDhcpOptsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+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;
+
+public class NeutronPortInterface extends AbstractNeutronInterface<Port, NeutronPort> implements INeutronPortCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronPortInterface.class);
+
+ NeutronPortInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ // IfNBPortCRUD methods
+
+ @Override
+ public boolean portExists(String uuid) {
+ Port port = readMd(createInstanceIdentifier(toMd(uuid)));
+ return port != null;
+ }
+
+ @Override
+ public NeutronPort getPort(String uuid) {
+ Port port = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (port == null) {
+ return null;
+ }
+ return fromMd(port);
+ }
+
+ @Override
+ public List<NeutronPort> getAllPorts() {
+ Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Ports ports = readMd(createInstanceIdentifier());
+ if (ports != null) {
+ for (Port port : ports.getPort()) {
+ allPorts.add(fromMd(port));
+ }
+ }
+ LOGGER.debug("Exiting getAllPorts, Found {} OpenStackPorts", allPorts.size());
+ List<NeutronPort> ans = new ArrayList<NeutronPort>();
+ ans.addAll(allPorts);
+ return ans;
+ }
+
+ @Override
+ public boolean addPort(NeutronPort input) {
+ if (portExists(input.getID())) {
+ return false;
+ }
+ addMd(input);
+ return true;
+ }
+
+ @Override
+ public boolean removePort(String uuid) {
+ if (!portExists(uuid)) {
+ return false;
+ }
+ return removeMd(toMd(uuid));
+ }
+
+ @Override
+ public boolean updatePort(String uuid, NeutronPort delta) {
+ if (!portExists(uuid)) {
+ return false;
+ }
+ updateMd(delta);
+ return true;
+ }
+
+ // @deprecated, will be removed in Boron
+ @Override
+ public boolean macInUse(String macAddress) {
+ return false;
+ }
+
+ // @deprecated, will be removed in Boron
+ @Override
+ public NeutronPort getGatewayPort(String subnetUUID) {
+ return null;
+ }
+
+ @Override
+ protected InstanceIdentifier<Port> createInstanceIdentifier(Port port) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Ports.class)
+ .child(Port.class, port.getKey());
+ }
+
+ protected InstanceIdentifier<Ports> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Ports.class);
+ }
+
+ protected void addExtensions(Port port, NeutronPort result) {
+ PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
+ result.setBindinghostID(binding.getHostId());
+ if (binding.getVifDetails() != null) {
+ List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+ for (VifDetails vifDetail : binding.getVifDetails()) {
+ NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
+ detail.setPortFilter(vifDetail.isPortFilter());
+ detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
+ details.add(detail);
+ }
+ result.setVIFDetail(details);
+ }
+ result.setBindingvifType(binding.getVifType());
+ result.setBindingvnicType(binding.getVnicType());
+ }
+
+ protected NeutronPort fromMd(Port port) {
+ NeutronPort result = new NeutronPort();
+ result.setAdminStateUp(port.isAdminStateUp());
+ if (port.getAllowedAddressPairs() != null) {
+ List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
+ for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
+ NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
+ pair.setIpAddress(mdPair.getIpAddress());
+ pair.setMacAddress(mdPair.getMacAddress());
+ pair.setPortID(mdPair.getPortId());
+ pairs.add(pair);
+ }
+ result.setAllowedAddressPairs(pairs);
+ }
+ result.setDeviceID(port.getDeviceId());
+ result.setDeviceOwner(port.getDeviceOwner());
+ if (port.getExtraDhcpOpts() != null) {
+ List<NeutronPort_ExtraDHCPOption> options = new ArrayList<NeutronPort_ExtraDHCPOption>();
+ for (ExtraDhcpOpts opt : port.getExtraDhcpOpts()) {
+ NeutronPort_ExtraDHCPOption arg = new NeutronPort_ExtraDHCPOption();
+ arg.setName(opt.getOptName());
+ arg.setValue(opt.getOptValue());
+ options.add(arg);
+ }
+ result.setExtraDHCPOptions(options);
+ }
+ if (port.getFixedIps() != null) {
+ List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ for (FixedIps mdIP : port.getFixedIps()) {
+ Neutron_IPs ip = new Neutron_IPs();
+ ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
+ ip.setSubnetUUID(mdIP.getSubnetId().getValue());
+ ips.add(ip);
+ }
+ result.setFixedIPs(ips);
+ }
+ result.setMacAddress(port.getMacAddress());
+ result.setName(port.getName());
+ result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
+ if (port.getSecurityGroups() != null) {
+ Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>();
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
+ INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface();
+ for (Uuid sgUuid : port.getSecurityGroups()) {
+ allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
+ }
+ List<NeutronSecurityGroup> groups = new ArrayList<NeutronSecurityGroup>();
+ groups.addAll(allGroups);
+ result.setSecurityGroups(groups);
+ }
+ result.setStatus(port.getStatus());
+ if (port.getTenantId() != null) {
+ result.setTenantID(String.valueOf(port.getTenantId().getValue()).replace("-", ""));
+ }
+ result.setPortUUID(String.valueOf(port.getUuid().getValue()));
+ addExtensions(port, result);
+ return result;
+ }
+
+ @Override
+ protected Port toMd(NeutronPort neutronPort) {
+ PortBindingExtensionBuilder bindingBuilder = new PortBindingExtensionBuilder();
+ if (neutronPort.getBindinghostID() != null) {
+ bindingBuilder.setHostId(neutronPort.getBindinghostID());
+ }
+ if (neutronPort.getVIFDetail() != null) {
+ List<VifDetails> listVifDetail = new ArrayList<VifDetails>();
+ for (NeutronPort_VIFDetail detail: neutronPort.getVIFDetail()) {
+ VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
+ if (detail.getPortFilter() != null) {
+ vifDetailsBuilder.setPortFilter(detail.getPortFilter());
+ }
+ if (detail.getOvsHybridPlug() != null) {
+ vifDetailsBuilder.setOvsHybridPlug(detail.getOvsHybridPlug());
+ }
+ listVifDetail.add(vifDetailsBuilder.build());
+ }
+ bindingBuilder.setVifDetails(listVifDetail);
+ }
+ if (neutronPort.getBindingvifType() != null) {
+ bindingBuilder.setVifType(neutronPort.getBindingvifType());
+ }
+ if (neutronPort.getBindingvnicType() != null) {
+ bindingBuilder.setVnicType(neutronPort.getBindingvnicType());
+ }
+
+ PortBuilder portBuilder = new PortBuilder();
+ portBuilder.addAugmentation(PortBindingExtension.class,
+ bindingBuilder.build());
+ portBuilder.setAdminStateUp(neutronPort.isAdminStateUp());
+ if(neutronPort.getAllowedAddressPairs() != null) {
+ List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<AllowedAddressPairs>();
+ for (NeutronPort_AllowedAddressPairs allowedAddressPairs : neutronPort.getAllowedAddressPairs()) {
+ AllowedAddressPairsBuilder allowedAddressPairsBuilder = new AllowedAddressPairsBuilder();
+ allowedAddressPairsBuilder.setIpAddress(allowedAddressPairs.getIpAddress());
+ allowedAddressPairsBuilder.setMacAddress(allowedAddressPairs.getMacAddress());
+ allowedAddressPairsBuilder.setPortId(allowedAddressPairs.getPortID());
+ listAllowedAddressPairs.add(allowedAddressPairsBuilder.build());
+ }
+ portBuilder.setAllowedAddressPairs(listAllowedAddressPairs);
+ }
+ if (neutronPort.getDeviceID() != null) {
+ portBuilder.setDeviceId(neutronPort.getDeviceID());
+ }
+ if (neutronPort.getDeviceOwner() != null) {
+ portBuilder.setDeviceOwner(neutronPort.getDeviceOwner());
+ }
+ if (neutronPort.getExtraDHCPOptions() != null) {
+ List<ExtraDhcpOpts> listExtraDHCPOptions = new ArrayList<ExtraDhcpOpts>();
+ for (NeutronPort_ExtraDHCPOption extraDHCPOption : neutronPort.getExtraDHCPOptions()) {
+ ExtraDhcpOptsBuilder extraDHCPOptsBuilder = new ExtraDhcpOptsBuilder();
+ extraDHCPOptsBuilder.setOptName(extraDHCPOption.getName());
+ extraDHCPOptsBuilder.setOptValue(extraDHCPOption.getValue());
+ listExtraDHCPOptions.add(extraDHCPOptsBuilder.build());
+ }
+ portBuilder.setExtraDhcpOpts(listExtraDHCPOptions);
+ }
+ if (neutronPort.getFixedIPs() != null) {
+ List<FixedIps> listNeutronIPs = new ArrayList<FixedIps>();
+ for (Neutron_IPs neutron_IPs : neutronPort.getFixedIPs()) {
+ FixedIpsBuilder fixedIpsBuilder = new FixedIpsBuilder();
+ fixedIpsBuilder.setIpAddress(new IpAddress(neutron_IPs.getIpAddress().toCharArray()));
+ fixedIpsBuilder.setSubnetId(toUuid(neutron_IPs.getSubnetUUID()));
+ listNeutronIPs.add(fixedIpsBuilder.build());
+ }
+ portBuilder.setFixedIps(listNeutronIPs);
+ }
+ if (neutronPort.getMacAddress() != null) {
+ portBuilder.setMacAddress(neutronPort.getMacAddress());
+ }
+ if (neutronPort.getName() != null) {
+ portBuilder.setName(neutronPort.getName());
+ }
+ if (neutronPort.getNetworkUUID() != null) {
+ portBuilder.setNetworkId(toUuid(neutronPort.getNetworkUUID()));
+ }
+ if (neutronPort.getSecurityGroups() != null) {
+ List<Uuid> listSecurityGroups = new ArrayList<Uuid>();
+ for (NeutronSecurityGroup neutronSecurityGroup : neutronPort.getSecurityGroups()) {
+ listSecurityGroups.add(toUuid(neutronSecurityGroup.getID()));
+ }
+ portBuilder.setSecurityGroups(listSecurityGroups);
+ }
+ if (neutronPort.getStatus() != null) {
+ portBuilder.setStatus(neutronPort.getStatus());
+ }
+ if (neutronPort.getTenantID() != null) {
+ portBuilder.setTenantId(toUuid(neutronPort.getTenantID()));
+ }
+ if (neutronPort.getPortUUID() != null) {
+ portBuilder.setUuid(toUuid(neutronPort.getPortUUID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron port without UUID");
+ }
+ return portBuilder.build();
+ }
+
+ @Override
+ protected Port toMd(String uuid) {
+ PortBuilder portBuilder = new PortBuilder();
+ portBuilder.setUuid(toUuid(uuid));
+ return portBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronPortInterface neutronPortInterface = new NeutronPortInterface(providerContext);
+ ServiceRegistration<INeutronPortCRUD> neutronPortInterfaceRegistration = context.registerService(INeutronPortCRUD.class, neutronPortInterface, null);
+ if(neutronPortInterfaceRegistration != null) {
+ registrations.add(neutronPortInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_NetworkReference;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronRouterCRUD;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfoBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+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;
+
+public class NeutronRouterInterface extends AbstractNeutronInterface<Router, NeutronRouter> implements INeutronRouterCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronRouterInterface.class);
+ // methods needed for creating caches
+
+
+ NeutronRouterInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+
+ // IfNBRouterCRUD Interface methods
+
+ @Override
+ public boolean routerExists(String uuid) {
+ Router router = readMd(createInstanceIdentifier(toMd(uuid)));
+ return router != null;
+ }
+
+ @Override
+ public NeutronRouter getRouter(String uuid) {
+ Router router = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (router == null) {
+ return null;
+ }
+ return fromMd(router);
+ }
+
+ @Override
+ public List<NeutronRouter> getAllRouters() {
+ Set<NeutronRouter> allRouters = new HashSet<NeutronRouter>();
+ Routers routers = readMd(createInstanceIdentifier());
+ if (routers != null) {
+ for (Router router: routers.getRouter()) {
+ allRouters.add(fromMd(router));
+ }
+ }
+ LOGGER.debug("Exiting getAllRouters, Found {} Routers", allRouters.size());
+ List<NeutronRouter> ans = new ArrayList<NeutronRouter>();
+ ans.addAll(allRouters);
+ return ans;
+ }
+
+ @Override
+ public boolean addRouter(NeutronRouter input) {
+ if (routerExists(input.getID())) {
+ return false;
+ }
+ addMd(input);
+ return true;
+ }
+
+ @Override
+ public boolean removeRouter(String uuid) {
+ if (!routerExists(uuid)) {
+ return false;
+ }
+ return removeMd(toMd(uuid));
+ }
+
+ @Override
+ public boolean updateRouter(String uuid, NeutronRouter delta) {
+ if (!routerExists(uuid)) {
+ return false;
+ }
+ updateMd(delta);
+ return true;
+ }
+
+ @Override
+ public boolean routerInUse(String routerUUID) {
+ if (!routerExists(routerUUID)) {
+ return true;
+ }
+ NeutronRouter target = getRouter(routerUUID);
+ return (target.getInterfaces().size() > 0);
+ }
+
+ @Override
+ protected Router toMd(NeutronRouter router) {
+
+ RouterBuilder routerBuilder = new RouterBuilder();
+
+ if (router.getRouterUUID() != null) {
+ routerBuilder.setUuid(toUuid(router.getRouterUUID()));
+ }
+ if (router.getName() != null) {
+ routerBuilder.setName(router.getName());
+ }
+ if (router.getTenantID() != null && !router.getTenantID().isEmpty()) {
+ routerBuilder.setTenantId(toUuid(router.getTenantID()));
+ }
+ if (router.getStatus() != null) {
+ routerBuilder.setStatus(router.getStatus());
+ }
+ if (router.getGatewayPortId() != null && !router.getGatewayPortId().isEmpty()) {
+ routerBuilder.setGatewayPortId(toUuid(router.getGatewayPortId()));
+ }
+ routerBuilder.setAdminStateUp(router.getAdminStateUp());
+ routerBuilder.setDistributed(router.getDistributed());
+ if (router.getRoutes() != null) {
+ List<String> routes = new ArrayList<String>();
+ for (String route : router.getRoutes()) {
+ routes.add(route);
+ }
+ routerBuilder.setRoutes(routes);
+ }
+ if (router.getExternalGatewayInfo() != null) {
+ ExternalGatewayInfo externalGatewayInfo = null;
+ List<NeutronRouter_NetworkReference> neutronRouter_NetworkReferences = new ArrayList<NeutronRouter_NetworkReference>();
+ neutronRouter_NetworkReferences.add(router.getExternalGatewayInfo());
+ for (NeutronRouter_NetworkReference externalGatewayInfos : neutronRouter_NetworkReferences) {
+ ExternalGatewayInfoBuilder builder = new ExternalGatewayInfoBuilder();
+ builder.setEnableSnat(externalGatewayInfos.getEnableSNAT());
+ builder.setExternalNetworkId(toUuid(externalGatewayInfos.getNetworkID()));
+ if (externalGatewayInfos.getExternalFixedIPs() != null) {
+ List<ExternalFixedIps> externalFixedIps = new ArrayList<ExternalFixedIps>();
+ for (Neutron_IPs eIP : externalGatewayInfos.getExternalFixedIPs()) {
+ ExternalFixedIpsBuilder eFixedIpBuilder = new ExternalFixedIpsBuilder();
+ eFixedIpBuilder.setIpAddress(new IpAddress(eIP.getIpAddress().toCharArray()));
+ eFixedIpBuilder.setSubnetId(toUuid(eIP.getSubnetUUID()));
+ externalFixedIps.add(eFixedIpBuilder.build());
+ }
+ builder.setExternalFixedIps(externalFixedIps);
+ }
+ externalGatewayInfo = builder.build();
+ }
+ routerBuilder.setExternalGatewayInfo(externalGatewayInfo);
+ }
+ if (router.getInterfaces() != null) {
+ Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<String, NeutronRouter_Interface>();
+ List<Interfaces> interfaces = new ArrayList<Interfaces>();
+ for (Entry<String, NeutronRouter_Interface> entry : mapInterfaces.entrySet()) {
+ interfaces.add((Interfaces) entry.getValue());
+ }
+ routerBuilder.setInterfaces(interfaces);
+ }
+ if (router.getID() != null) {
+ routerBuilder.setUuid(toUuid(router.getID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron router without UUID");
+ }
+ return routerBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<Router> createInstanceIdentifier(Router router) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Routers.class)
+ .child(Router.class, router.getKey());
+ }
+
+ protected InstanceIdentifier<Routers> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class).child(Routers.class);
+ }
+
+ @Override
+ protected Router toMd(String uuid) {
+ RouterBuilder routerBuilder = new RouterBuilder();
+ routerBuilder.setUuid(toUuid(uuid));
+ return routerBuilder.build();
+ }
+
+ public NeutronRouter fromMd(Router router) {
+ NeutronRouter result = new NeutronRouter();
+ result.setID(String.valueOf(router.getUuid().getValue()));
+ result.setName(router.getName());
+ result.setTenantID(String.valueOf(router.getTenantId().getValue()));
+ result.setAdminStateUp(router.isAdminStateUp());
+ result.setStatus(router.getStatus());
+ result.setDistributed(router.isDistributed());
+ if (router.getGatewayPortId() != null) {
+ result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
+ }
+ if (router.getRoutes() != null) {
+ List<String> routes = new ArrayList<String>();
+ for (String route : router.getRoutes()) {
+ routes.add(route);
+ }
+ result.setRoutes(routes);
+ }
+
+ if (router.getExternalGatewayInfo() != null) {
+ NeutronRouter_NetworkReference extGwInfo = new NeutronRouter_NetworkReference();
+ extGwInfo.setNetworkID(String.valueOf(router.getExternalGatewayInfo().getExternalNetworkId().getValue()));
+ extGwInfo.setEnableSNAT(router.getExternalGatewayInfo().isEnableSnat());
+ if (router.getExternalGatewayInfo().getExternalFixedIps() != null) {
+ List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
+ for (ExternalFixedIps mdFixedIP : router.getExternalGatewayInfo().getExternalFixedIps()) {
+ Neutron_IPs fixedIP = new Neutron_IPs();
+ fixedIP.setSubnetUUID(String.valueOf(mdFixedIP.getSubnetId().getValue()));
+ fixedIP.setIpAddress(String.valueOf(mdFixedIP.getIpAddress().getValue()));
+ fixedIPs.add(fixedIP);
+ }
+ extGwInfo.setExternalFixedIPs(fixedIPs);
+ }
+ result.setExternalGatewayInfo(extGwInfo);
+ }
+
+ if (router.getInterfaces() != null) {
+ Map<String, NeutronRouter_Interface> interfaces = new HashMap<String, NeutronRouter_Interface>();
+ for (Interfaces mdInterface : router.getInterfaces()) {
+ NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
+ String id = String.valueOf(mdInterface.getUuid().getValue());
+ pojoInterface.setID(id);
+ pojoInterface.setTenantID(String.valueOf(mdInterface.getTenantId().getValue()));
+ pojoInterface.setSubnetUUID(String.valueOf(mdInterface.getSubnetId().getValue()));
+ pojoInterface.setPortUUID(String.valueOf(mdInterface.getPortId().getValue()));
+ interfaces.put(id, pojoInterface);
+ }
+ result.setInterfaces(interfaces);
+ }
+ return result;
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronRouterInterface neutronRouterInterface = new NeutronRouterInterface(providerContext);
+ ServiceRegistration<INeutronRouterCRUD> neutronRouterInterfaceRegistration = context.registerService(INeutronRouterCRUD.class, neutronRouterInterface, null);
+ if(neutronRouterInterfaceRegistration != null) {
+ registrations.add(neutronRouterInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.SecurityGroups;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroupBuilder;
+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;
+
+
+public class NeutronSecurityGroupInterface extends AbstractNeutronInterface<SecurityGroup,NeutronSecurityGroup> implements INeutronSecurityGroupCRUD {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSecurityGroupInterface.class);
+
+ NeutronSecurityGroupInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ public boolean neutronSecurityGroupExists(String uuid) {
+ SecurityGroup group = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (group == null) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public NeutronSecurityGroup getNeutronSecurityGroup(String uuid) {
+ SecurityGroup group = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (group == null) {
+ return null;
+ }
+ return fromMd(group);
+ }
+
+ @Override
+ public List<NeutronSecurityGroup> getAllNeutronSecurityGroups() {
+ Set<NeutronSecurityGroup> allSecurityGroups = new HashSet<NeutronSecurityGroup>();
+ SecurityGroups groups = readMd(createInstanceIdentifier());
+ if (groups != null) {
+ for (SecurityGroup group: groups.getSecurityGroup()) {
+ allSecurityGroups.add(fromMd(group));
+ }
+ }
+ LOGGER.debug("Exiting getSecurityGroups, Found {} OpenStackSecurityGroup", allSecurityGroups.size());
+ List<NeutronSecurityGroup> ans = new ArrayList<NeutronSecurityGroup>();
+ ans.addAll(allSecurityGroups);
+ return ans;
+ }
+
+ @Override
+ public boolean addNeutronSecurityGroup(NeutronSecurityGroup input) {
+ if (neutronSecurityGroupExists(input.getID())) {
+ return false;
+ }
+ addMd(input);
+ return true;
+ }
+
+ @Override
+ public boolean removeNeutronSecurityGroup(String uuid) {
+ if (!neutronSecurityGroupExists(uuid)) {
+ return false;
+ }
+ removeMd(toMd(uuid));
+ return true;
+ }
+
+ @Override
+ public boolean updateNeutronSecurityGroup(String uuid, NeutronSecurityGroup delta) {
+ if (!neutronSecurityGroupExists(uuid)) {
+ return false;
+ }
+ updateMd(delta);
+ return true;
+ }
+
+ @Override
+ public boolean neutronSecurityGroupInUse(String securityGroupUUID) {
+ return !neutronSecurityGroupExists(securityGroupUUID);
+ }
+
+ protected NeutronSecurityGroup fromMd(SecurityGroup group) {
+ NeutronSecurityGroup answer = new NeutronSecurityGroup();
+ if (group.getName() != null) {
+ answer.setSecurityGroupName(group.getName());
+ }
+ if (group.getDescription() != null) {
+ answer.setSecurityGroupDescription(group.getDescription());
+ }
+ if (group.getTenantId() != null) {
+ answer.setSecurityGroupTenantID(group.getTenantId().getValue().replace("-",""));
+ }
+ if (group.getSecurityRules() != null) {
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronSecurityRuleCRUD(this);
+ INeutronSecurityRuleCRUD srCrud = interfaces.getSecurityRuleInterface();
+
+ List<NeutronSecurityRule> rules = new ArrayList<NeutronSecurityRule>();
+ for (Uuid uuid: group.getSecurityRules()) {
+ rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
+ }
+ answer.setSecurityRules(rules);
+ }
+ if (group.getUuid() != null) {
+ answer.setID(group.getUuid().getValue());
+ }
+ return answer;
+ }
+
+ @Override
+ protected SecurityGroup toMd(NeutronSecurityGroup securityGroup) {
+ SecurityGroupBuilder securityGroupBuilder = new SecurityGroupBuilder();
+ if (securityGroup.getSecurityGroupName() != null) {
+ securityGroupBuilder.setName(securityGroup.getSecurityGroupName());
+ }
+ if (securityGroup.getSecurityGroupDescription() != null) {
+ securityGroupBuilder.setDescription(securityGroup.getSecurityGroupDescription());
+ }
+ if (securityGroup.getSecurityGroupTenantID() != null) {
+ securityGroupBuilder.setTenantId(toUuid(securityGroup.getSecurityGroupTenantID()));
+ }
+ if (securityGroup.getSecurityRules() != null) {
+ List<Uuid> neutronSecurityRule = new ArrayList<Uuid>();
+ for (NeutronSecurityRule securityRule : securityGroup.getSecurityRules()) {
+ if (securityRule.getID() != null) {
+ neutronSecurityRule.add(toUuid(securityRule.getID()));
+ }
+ }
+ securityGroupBuilder.setSecurityRules(neutronSecurityRule);
+ }
+ if (securityGroup.getID() != null) {
+ securityGroupBuilder.setUuid(toUuid(securityGroup.getID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron securityGroup without UUID");
+ }
+
+ return securityGroupBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<SecurityGroup> createInstanceIdentifier(SecurityGroup securityGroup) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(SecurityGroups.class).child(SecurityGroup.class,
+ securityGroup.getKey());
+ }
+
+ protected InstanceIdentifier<SecurityGroups> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(SecurityGroups.class);
+ }
+
+ @Override
+ protected SecurityGroup toMd(String uuid) {
+ SecurityGroupBuilder securityGroupBuilder = new SecurityGroupBuilder();
+ securityGroupBuilder.setUuid(toUuid(uuid));
+ return securityGroupBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronSecurityGroupInterface neutronSecurityGroupInterface = new NeutronSecurityGroupInterface(providerContext);
+ ServiceRegistration<INeutronSecurityGroupCRUD> neutronSecurityGroupInterfaceRegistration = context.registerService(INeutronSecurityGroupCRUD.class, neutronSecurityGroupInterface, null);
+ if(neutronSecurityGroupInterfaceRegistration != null) {
+ registrations.add(neutronSecurityGroupInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionEgress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionIngress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmpV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolUdp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
+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 com.google.common.collect.ImmutableBiMap;
+
+
+public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<SecurityRule, NeutronSecurityRule> implements INeutronSecurityRuleCRUD {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSecurityRuleInterface.class);
+
+ private static final ImmutableBiMap<Class<? extends DirectionBase>,String> DIRECTION_MAP
+ = new ImmutableBiMap.Builder<Class<? extends DirectionBase>,String>()
+ .put(DirectionEgress.class,"egress")
+ .put(DirectionIngress.class,"ingress")
+ .build();
+ private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
+ = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
+ .put(ProtocolIcmp.class,"icmp")
+ .put(ProtocolTcp.class,"tcp")
+ .put(ProtocolUdp.class,"udp")
+ .put(ProtocolIcmpV6.class,"icmpv6")
+ .build();
+ private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP
+ = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>,String>()
+ .put(EthertypeV4.class,"IPv4")
+ .put(EthertypeV6.class,"IPv6")
+ .build();
+
+ NeutronSecurityRuleInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ private void updateSecGroupRuleInSecurityGroup(NeutronSecurityRule input) {
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronSecurityGroupCRUD(this);
+ INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
+ NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
+ if(sg != null && sg.getSecurityRules() != null) {
+ for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
+ if(sgr != null && sgr.getID() != null && sgr.getID().equals(input.getID())) {
+ int index = sg.getSecurityRules().indexOf(sgr);
+ sg.getSecurityRules().set(index, input);
+ }
+ }
+ }
+ if (sg != null) {
+ sg.getSecurityRules().add(input);
+ }
+ }
+
+ private void removeSecGroupRuleFromSecurityGroup(NeutronSecurityRule input) {
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronSecurityGroupCRUD(this);
+ INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
+ NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
+ if(sg != null && sg.getSecurityRules() != null) {
+ List<NeutronSecurityRule> toRemove = new ArrayList<NeutronSecurityRule>();
+ for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
+ if(sgr.getID() != null && sgr.getID().equals(input.getID())) {
+ toRemove.add(sgr);
+ }
+ }
+ sg.getSecurityRules().removeAll(toRemove);
+ }
+ }
+
+ @Override
+ public boolean neutronSecurityRuleExists(String uuid) {
+ SecurityRule rule = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (rule == null) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public NeutronSecurityRule getNeutronSecurityRule(String uuid) {
+ SecurityRule rule = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (rule == null) {
+ return null;
+ }
+ return fromMd(rule);
+ }
+
+ @Override
+ public List<NeutronSecurityRule> getAllNeutronSecurityRules() {
+ Set<NeutronSecurityRule> allSecurityRules = new HashSet<NeutronSecurityRule>();
+ SecurityRules rules = readMd(createInstanceIdentifier());
+ if (rules != null) {
+ for (SecurityRule rule: rules.getSecurityRule()) {
+ allSecurityRules.add(fromMd(rule));
+ }
+ }
+ LOGGER.debug("Exiting getSecurityRule, Found {} OpenStackSecurityRule", allSecurityRules.size());
+ List<NeutronSecurityRule> ans = new ArrayList<NeutronSecurityRule>();
+ ans.addAll(allSecurityRules);
+ return ans;
+ }
+
+ @Override
+ public boolean addNeutronSecurityRule(NeutronSecurityRule input) {
+ if (neutronSecurityRuleExists(input.getID())) {
+ return false;
+ }
+ updateSecGroupRuleInSecurityGroup(input);
+ addMd(input);
+ return true;
+ }
+
+ @Override
+ public boolean removeNeutronSecurityRule(String uuid) {
+ if (!neutronSecurityRuleExists(uuid)) {
+ return false;
+ }
+ removeSecGroupRuleFromSecurityGroup(getNeutronSecurityRule(uuid));
+ removeMd(toMd(uuid));
+ return true;
+ }
+
+ @Override
+ public boolean updateNeutronSecurityRule(String uuid, NeutronSecurityRule delta) {
+ if (!neutronSecurityRuleExists(uuid)) {
+ return false;
+ }
+ updateSecGroupRuleInSecurityGroup(delta);
+ updateMd(delta);
+ return true;
+ }
+
+ @Override
+ public boolean neutronSecurityRuleInUse(String securityRuleUUID) {
+ return !neutronSecurityRuleExists(securityRuleUUID);
+ }
+
+ protected NeutronSecurityRule fromMd(SecurityRule rule) {
+ NeutronSecurityRule answer = new NeutronSecurityRule();
+ if (rule.getTenantId() != null) {
+ answer.setSecurityRuleTenantID(rule.getTenantId().getValue().replace("-",""));
+ }
+ if (rule.getDirection() != null) {
+ answer.setSecurityRuleDirection(DIRECTION_MAP.get(rule.getDirection()));
+ }
+ if (rule.getSecurityGroupId() != null) {
+ answer.setSecurityRuleGroupID(rule.getSecurityGroupId().getValue());
+ }
+ if (rule.getRemoteGroupId() != null) {
+ answer.setSecurityRemoteGroupID(rule.getRemoteGroupId().getValue());
+ }
+ if (rule.getRemoteIpPrefix() != null) {
+ answer.setSecurityRuleRemoteIpPrefix(rule.getRemoteIpPrefix().getIpv4Prefix() != null?
+ rule.getRemoteIpPrefix().getIpv4Prefix().getValue():rule.getRemoteIpPrefix().getIpv6Prefix().getValue());
+ }
+ if (rule.getProtocol() != null) {
+ answer.setSecurityRuleProtocol(PROTOCOL_MAP.get(rule.getProtocol()));
+ }
+ if (rule.getEthertype() != null) {
+ answer.setSecurityRuleEthertype(ETHERTYPE_MAP.get(rule.getEthertype()));
+ }
+ if (rule.getPortRangeMin() != null) {
+ answer.setSecurityRulePortMin(Integer.valueOf(rule.getPortRangeMin()));
+ }
+ if (rule.getPortRangeMax() != null) {
+ answer.setSecurityRulePortMax(Integer.valueOf(rule.getPortRangeMax()));
+ }
+ if (rule.getId() != null) {
+ answer.setID(rule.getId().getValue());
+ }
+ return answer;
+ }
+
+ @Override
+ protected SecurityRule toMd(NeutronSecurityRule securityRule) {
+ SecurityRuleBuilder securityRuleBuilder = new SecurityRuleBuilder();
+
+ if (securityRule.getSecurityRuleTenantID() != null) {
+ securityRuleBuilder.setTenantId(toUuid(securityRule.getSecurityRuleTenantID()));
+ }
+ if (securityRule.getSecurityRuleDirection() != null) {
+ ImmutableBiMap<String, Class<? extends DirectionBase>> mapper =
+ DIRECTION_MAP.inverse();
+ securityRuleBuilder.setDirection((Class<? extends DirectionBase>) mapper.get(securityRule.getSecurityRuleDirection()));
+ }
+ if (securityRule.getSecurityRuleGroupID() != null) {
+ securityRuleBuilder.setSecurityGroupId(toUuid(securityRule.getSecurityRuleGroupID()));
+ }
+ if (securityRule.getSecurityRemoteGroupID() != null) {
+ securityRuleBuilder.setRemoteGroupId(toUuid(securityRule.getSecurityRemoteGroupID()));
+ }
+ if (securityRule.getSecurityRuleRemoteIpPrefix() != null) {
+ securityRuleBuilder.setRemoteIpPrefix(new IpPrefix(securityRule.getSecurityRuleRemoteIpPrefix().toCharArray()));
+ }
+ if (securityRule.getSecurityRuleProtocol() != null) {
+ ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
+ PROTOCOL_MAP.inverse();
+ securityRuleBuilder.setProtocol((Class<? extends ProtocolBase>) mapper.get(securityRule.getSecurityRuleProtocol()));
+ }
+ if (securityRule.getSecurityRuleEthertype() != null) {
+ ImmutableBiMap<String, Class<? extends EthertypeBase>> mapper =
+ ETHERTYPE_MAP.inverse();
+ securityRuleBuilder.setEthertype((Class<? extends EthertypeBase>) mapper.get(securityRule.getSecurityRuleEthertype()));
+ }
+ if (securityRule.getSecurityRulePortMin() != null) {
+ securityRuleBuilder.setPortRangeMin(Integer.valueOf(securityRule.getSecurityRulePortMin()));
+ }
+ if (securityRule.getSecurityRulePortMax() != null) {
+ securityRuleBuilder.setPortRangeMax(Integer.valueOf(securityRule.getSecurityRulePortMax()));
+ }
+ if (securityRule.getID() != null) {
+ securityRuleBuilder.setId(toUuid(securityRule.getID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron securityRule without UUID");
+ }
+ return securityRuleBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<SecurityRule> createInstanceIdentifier(SecurityRule securityRule) {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(SecurityRules.class).child(SecurityRule.class,
+ securityRule.getKey());
+ }
+
+ protected InstanceIdentifier<SecurityRules> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(SecurityRules.class);
+ }
+
+ @Override
+ protected SecurityRule toMd(String uuid) {
+ SecurityRuleBuilder securityRuleBuilder = new SecurityRuleBuilder();
+ securityRuleBuilder.setId(toUuid(uuid));
+ return securityRuleBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronSecurityRuleInterface neutronSecurityRuleInterface = new NeutronSecurityRuleInterface(providerContext);
+ ServiceRegistration<INeutronSecurityRuleCRUD> neutronSecurityRuleInterfaceRegistration = context.registerService(INeutronSecurityRuleCRUD.class, neutronSecurityRuleInterface, null);
+ if(neutronSecurityRuleInterfaceRegistration != null) {
+ registrations.add(neutronSecurityRuleInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.crud.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnetIPAllocationPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Base;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Off;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Slaac;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Stateless;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.AllocationPools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.AllocationPoolsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetBuilder;
+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 com.google.common.collect.ImmutableBiMap;
+
+public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, NeutronSubnet> implements INeutronSubnetCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSubnetInterface.class);
+
+ private static final ImmutableBiMap<Class<? extends IpVersionBase>,Integer> IPV_MAP
+ = new ImmutableBiMap.Builder<Class<? extends IpVersionBase>,Integer>()
+ .put(IpVersionV4.class,Integer.valueOf(4))
+ .put(IpVersionV6.class,Integer.valueOf(6))
+ .build();
+
+ private static final ImmutableBiMap<Class<? extends Dhcpv6Base>,String> DHCPV6_MAP
+ = new ImmutableBiMap.Builder<Class<? extends Dhcpv6Base>,String>()
+ .put(Dhcpv6Off.class,"off")
+ .put(Dhcpv6Stateful.class,"dhcpv6-stateful")
+ .put(Dhcpv6Slaac.class,"slaac")
+ .put(Dhcpv6Stateless.class,"dhcpv6-stateless")
+ .build();
+
+ NeutronSubnetInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ // IfNBSubnetCRUD methods
+
+ @Override
+ public boolean subnetExists(String uuid) {
+ Subnet subnet = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (subnet == null) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public NeutronSubnet getSubnet(String uuid) {
+ Subnet subnet = readMd(createInstanceIdentifier(toMd(uuid)));
+ if (subnet == null) {
+ return null;
+ }
+ return fromMd(subnet);
+ }
+
+ @Override
+ public List<NeutronSubnet> getAllSubnets() {
+ Set<NeutronSubnet> allSubnets = new HashSet<NeutronSubnet>();
+ Subnets subnets = readMd(createInstanceIdentifier());
+ if (subnets != null) {
+ for (Subnet subnet: subnets.getSubnet()) {
+ allSubnets.add(fromMd(subnet));
+ }
+ }
+ LOGGER.debug("Exiting getAllSubnets, Found {} OpenStackSubnets", allSubnets.size());
+ List<NeutronSubnet> ans = new ArrayList<NeutronSubnet>();
+ ans.addAll(allSubnets);
+ return ans;
+ }
+
+ @Override
+ public boolean addSubnet(NeutronSubnet input) {
+ String id = input.getID();
+ if (subnetExists(id)) {
+ return false;
+ }
+ addMd(input);
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronNetworkCRUD(this);
+ INeutronNetworkCRUD networkIf = interfaces.getNetworkInterface();
+
+ NeutronNetwork targetNet = networkIf.getNetwork(input.getNetworkUUID());
+ targetNet.addSubnet(id);
+ return true;
+ }
+
+ @Override
+ public boolean removeSubnet(String uuid) {
+ NeutronSubnet target = getSubnet(uuid);
+ if (target == null) {
+ return false;
+ }
+ removeMd(toMd(uuid));
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronNetworkCRUD(this);
+ INeutronNetworkCRUD networkIf = interfaces.getNetworkInterface();
+
+ NeutronNetwork targetNet = networkIf.getNetwork(target.getNetworkUUID());
+ targetNet.removeSubnet(uuid);
+ return true;
+ }
+
+ @Override
+ public boolean updateSubnet(String uuid, NeutronSubnet delta) {
+ if (!subnetExists(uuid)) {
+ return false;
+ }
+/* note: because what we get is *not* a delta but (at this point) the updated
+ * object, this is much simpler - just replace the value and update the mdsal
+ * with it */
+ updateMd(delta);
+ return true;
+ }
+
+// note: this is being set to false in preparation for deprecation and removal
+ @Override
+ public boolean subnetInUse(String subnetUUID) {
+ return false;
+ }
+
+ protected NeutronSubnet fromMd(Subnet subnet) {
+ NeutronSubnet result = new NeutronSubnet();
+ result.setName(subnet.getName());
+ result.setTenantID(String.valueOf(subnet.getTenantId().getValue()).replace("-",""));
+ result.setNetworkUUID(subnet.getNetworkId().getValue());
+ result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
+ result.setCidr(subnet.getCidr());
+ result.setGatewayIP(String.valueOf(subnet.getGatewayIp().getValue()));
+ result.setIpV6RaMode(DHCPV6_MAP.get(subnet.getIpv6RaMode()));
+ result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
+ result.setEnableDHCP(subnet.isEnableDhcp());
+ if (subnet.getAllocationPools() != null) {
+ List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ for (AllocationPools allocationPool : subnet.getAllocationPools()) {
+ NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
+ pool.setPoolStart(allocationPool.getStart());
+ pool.setPoolEnd(allocationPool.getEnd());
+ allocationPools.add(pool);
+ }
+ result.setAllocationPools(allocationPools);
+ }
+ if (subnet.getDnsNameservers() != null) {
+ List<String> dnsNameServers = new ArrayList<String>();
+ for (IpAddress dnsNameServer : subnet.getDnsNameservers()) {
+ dnsNameServers.add(String.valueOf(dnsNameServer.getValue()));
+ }
+ result.setDnsNameservers(dnsNameServers);
+ }
+ result.setID(subnet.getUuid().getValue());
+// read through the ports and put the ones in this subnet into the internal
+// myPorts object.
+// @deprecated and will be removed in Boron
+ Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronPortCRUD(this);
+ INeutronPortCRUD portIf = interfaces.getPortInterface();
+ for (NeutronPort port : portIf.getAllPorts()) {
+ if (port.getFixedIPs() != null) {
+ for (Neutron_IPs ip : port.getFixedIPs()) {
+ if (ip.getSubnetUUID().equals(result.getID())) {
+ allPorts.add(port);
+ }
+ }
+ }
+ }
+ List<NeutronPort> ports = new ArrayList<NeutronPort>();
+ ports.addAll(allPorts);
+ result.setPorts(ports);
+ return result;
+ }
+
+ protected Subnet toMd(NeutronSubnet subnet) {
+ SubnetBuilder subnetBuilder = new SubnetBuilder();
+ if (subnet.getName() != null) {
+ subnetBuilder.setName(subnet.getName());
+ }
+ if (subnet.getTenantID() != null) {
+ subnetBuilder.setTenantId(toUuid(subnet.getTenantID()));
+ }
+ if (subnet.getNetworkUUID() != null) {
+ subnetBuilder.setNetworkId(toUuid(subnet.getNetworkUUID()));
+ }
+ if (subnet.getIpVersion() != null) {
+ ImmutableBiMap<Integer, Class<? extends IpVersionBase>> mapper =
+ IPV_MAP.inverse();
+ subnetBuilder.setIpVersion((Class<? extends IpVersionBase>) mapper.get(subnet
+ .getIpVersion()));
+ }
+ if (subnet.getCidr() != null) {
+ subnetBuilder.setCidr(subnet.getCidr());
+ }
+ if (subnet.getGatewayIP() != null) {
+ IpAddress ipAddress = new IpAddress(subnet.getGatewayIP()
+ .toCharArray());
+ subnetBuilder.setGatewayIp(ipAddress);
+ }
+ if (subnet.getIpV6RaMode() != null) {
+ ImmutableBiMap<String, Class<? extends Dhcpv6Base>> mapper =
+ DHCPV6_MAP.inverse();
+ subnetBuilder.setIpv6RaMode((Class<? extends Dhcpv6Base>) mapper.get(subnet.getIpV6RaMode()));
+ }
+ if (subnet.getIpV6AddressMode() != null) {
+ ImmutableBiMap<String, Class<? extends Dhcpv6Base>> mapper =
+ DHCPV6_MAP.inverse();
+ subnetBuilder.setIpv6AddressMode((Class<? extends Dhcpv6Base>) mapper.get(subnet.getIpV6AddressMode()));
+ }
+ subnetBuilder.setEnableDhcp(subnet.getEnableDHCP());
+ if (subnet.getAllocationPools() != null) {
+ List<AllocationPools> allocationPools = new ArrayList<AllocationPools>();
+ for (NeutronSubnetIPAllocationPool allocationPool : subnet
+ .getAllocationPools()) {
+ AllocationPoolsBuilder builder = new AllocationPoolsBuilder();
+ builder.setStart(allocationPool.getPoolStart());
+ builder.setEnd(allocationPool.getPoolEnd());
+ AllocationPools temp = builder.build();
+ allocationPools.add(temp);
+ }
+ subnetBuilder.setAllocationPools(allocationPools);
+ }
+ if (subnet.getDnsNameservers() != null) {
+ List<IpAddress> dnsNameServers = new ArrayList<IpAddress>();
+ for (String dnsNameServer : subnet.getDnsNameservers()) {
+ IpAddress ipAddress = new IpAddress(dnsNameServer.toCharArray());
+ dnsNameServers.add(ipAddress);
+ }
+ subnetBuilder.setDnsNameservers(dnsNameServers);
+ }
+ if (subnet.getID() != null) {
+ subnetBuilder.setUuid(toUuid(subnet.getID()));
+ } else {
+ LOGGER.warn("Attempting to write neutron subnet without UUID");
+ }
+ return subnetBuilder.build();
+ }
+
+ @Override
+ protected InstanceIdentifier<Subnet> createInstanceIdentifier(Subnet subnet) {
+ return InstanceIdentifier.create(Neutron.class).child(Subnets.class)
+ .child(Subnet.class, subnet.getKey());
+ }
+
+ protected InstanceIdentifier<Subnets> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class)
+ .child(Subnets.class);
+ }
+
+ @Override
+ protected Subnet toMd(String uuid) {
+ SubnetBuilder subnetBuilder = new SubnetBuilder();
+ subnetBuilder.setUuid(toUuid(uuid));
+ return subnetBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronSubnetInterface neutronSubnetInterface = new NeutronSubnetInterface(providerContext);
+ ServiceRegistration<INeutronSubnetCRUD> neutronSubnetInterfaceRegistration = context.registerService(INeutronSubnetCRUD.class, neutronSubnetInterface, null);
+ if(neutronSubnetInterfaceRegistration != null) {
+ registrations.add(neutronSubnetInterfaceRegistration);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewall;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Firewall Rules needs to implement
+ *
+ */
+
+public interface INeutronFirewallAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified firewall can be created
+ *
+ * @param firewall
+ * instance of proposed new Firewall object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronFirewall(NeutronFirewall firewall);
+
+ /**
+ * Services provide this interface method for taking action after a firewall has been created
+ *
+ * @param firewall
+ * instance of new Firewall object
+ */
+ void neutronFirewallCreated(NeutronFirewall firewall);
+
+ /**
+ * Services provide this interface method to indicate if the specified firewall can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the firewall object using patch semantics
+ * @param original
+ * instance of the Firewall object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronFirewall(NeutronFirewall delta, NeutronFirewall original);
+
+ /**
+ * Services provide this interface method for taking action after a firewall has been updated
+ *
+ * @param firewall
+ * instance of modified Firewall object
+ */
+ void neutronFirewallUpdated(NeutronFirewall firewall);
+
+ /**
+ * Services provide this interface method to indicate if the specified firewall can be deleted
+ *
+ * @param firewall
+ * instance of the Firewall object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronFirewall(NeutronFirewall firewall);
+
+ /**
+ * Services provide this interface method for taking action after a firewall has been deleted
+ *
+ * @param firewall
+ * instance of deleted Firewall object
+ */
+ void neutronFirewallDeleted(NeutronFirewall firewall);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallPolicy;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Firewall Policys needs to implement
+ *
+ */
+
+public interface INeutronFirewallPolicyAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified firewallPolicy can be created
+ *
+ * @param firewallPolicy
+ * instance of proposed new Firewall Policy object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronFirewallPolicy(NeutronFirewallPolicy firewallPolicy);
+
+ /**
+ * Services provide this interface method for taking action after a firewallPolicy has been created
+ *
+ * @param firewallPolicy
+ * instance of new Firewall Policy object
+ */
+ void neutronFirewallPolicyCreated(NeutronFirewallPolicy firewallPolicy);
+
+ /**
+ * Services provide this interface method to indicate if the specified firewallPolicy can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the firewallPolicy object using patch semantics
+ * @param original
+ * instance of the Firewall Policy object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronFirewallPolicy(NeutronFirewallPolicy delta, NeutronFirewallPolicy original);
+
+ /**
+ * Services provide this interface method for taking action after a firewallPolicy has been updated
+ *
+ * @param firewallPolicy
+ * instance of modified Firewall Policy object
+ */
+ void neutronFirewallPolicyUpdated(NeutronFirewallPolicy firewallPolicy);
+
+ /**
+ * Services provide this interface method to indicate if the specified firewallPolicy can be deleted
+ *
+ * @param firewallPolicy
+ * instance of the Firewall Policy object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronFirewallPolicy(NeutronFirewallPolicy firewallPolicy);
+
+ /**
+ * Services provide this interface method for taking action after a firewallPolicy has been deleted
+ *
+ * @param firewallPolicy
+ * instance of deleted Firewall Policy object
+ */
+ void neutronFirewallPolicyDeleted(NeutronFirewallPolicy firewallPolicy);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallRule;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Firewall Rules needs to implement
+ *
+ */
+
+public interface INeutronFirewallRuleAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified firewallRule can be created
+ *
+ * @param firewallRule
+ * instance of proposed new Firewall Rule object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronFirewallRule(NeutronFirewallRule firewallRule);
+
+ /**
+ * Services provide this interface method for taking action after a firewallRule has been created
+ *
+ * @param firewallRule
+ * instance of new Firewall Rule object
+ */
+ void neutronFirewallRuleCreated(NeutronFirewallRule firewallRule);
+
+ /**
+ * Services provide this interface method to indicate if the specified firewallRule can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the firewallRule object using patch semantics
+ * @param original
+ * instance of the Firewall Rule object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronFirewallRule(NeutronFirewallRule delta, NeutronFirewallRule original);
+
+ /**
+ * Services provide this interface method for taking action after a firewallRule has been updated
+ *
+ * @param firewallRule
+ * instance of modified Firewall Rule object
+ */
+ void neutronFirewallRuleUpdated(NeutronFirewallRule firewallRule);
+
+ /**
+ * Services provide this interface method to indicate if the specified firewallRule can be deleted
+ *
+ * @param firewallRule
+ * instance of the Firewall Rule object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronFirewallRule(NeutronFirewallRule firewallRule);
+
+ /**
+ * Services provide this interface method for taking action after a firewallRule has been deleted
+ *
+ * @param firewallRule
+ * instance of deleted Firewall Rule object
+ */
+ void neutronFirewallRuleDeleted(NeutronFirewallRule firewallRule);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Neutron FloatingIPs needs to implement
+ *
+ */
+
+public interface INeutronFloatingIPAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified floatingIP can be created
+ *
+ * @param floatingIP
+ * instance of proposed new Neutron FloatingIP object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateFloatingIP(NeutronFloatingIP floatingIP);
+
+ /**
+ * Services provide this interface method for taking action after a floatingIP has been created
+ *
+ * @param floatingIP
+ * instance of new Neutron FloatingIP object
+ */
+ void neutronFloatingIPCreated(NeutronFloatingIP floatingIP);
+
+ /**
+ * Services provide this interface method to indicate if the specified floatingIP can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the floatingIP object using patch semantics
+ * @param original
+ * instance of the Neutron FloatingIP object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateFloatingIP(NeutronFloatingIP delta, NeutronFloatingIP original);
+
+ /**
+ * Services provide this interface method for taking action after a floatingIP has been updated
+ *
+ * @param floatingIP
+ * instance of modified Neutron FloatingIP object
+ */
+ void neutronFloatingIPUpdated(NeutronFloatingIP floatingIP);
+
+ /**
+ * Services provide this interface method to indicate if the specified floatingIP can be deleted
+ *
+ * @param floatingIP
+ * instance of the Neutron FloatingIP object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteFloatingIP(NeutronFloatingIP floatingIP);
+
+ /**
+ * Services provide this interface method for taking action after a floatingIP has been deleted
+ *
+ * @param floatingIP
+ * instance of deleted Neutron FloatingIP object
+ */
+ void neutronFloatingIPDeleted(NeutronFloatingIP floatingIP);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of LoadBalancer Rules needs to implement
+ *
+ */
+
+public interface INeutronLoadBalancerAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancer can be created
+ *
+ * @param loadBalancer
+ * instance of proposed new LoadBalancer object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronLoadBalancer(NeutronLoadBalancer loadBalancer);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancer has been created
+ *
+ * @param loadBalancer
+ * instance of new LoadBalancer object
+ */
+ void neutronLoadBalancerCreated(NeutronLoadBalancer loadBalancer);
+
+ /**
+ * Services provide this interface method to indicate if the
+ * specified loadBalancer can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the loadBalancer object using patch semantics
+ * @param original
+ * instance of the LoadBalancer object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronLoadBalancer(NeutronLoadBalancer delta, NeutronLoadBalancer original);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancer has been updated
+ *
+ * @param loadBalancer
+ * instance of modified LoadBalancer object
+ */
+ void neutronLoadBalancerUpdated(NeutronLoadBalancer loadBalancer);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancer can be deleted
+ *
+ * @param loadBalancer
+ * instance of the LoadBalancer object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronLoadBalancer(NeutronLoadBalancer loadBalancer);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancer has been deleted
+ *
+ * @param loadBalancer
+ * instance of deleted LoadBalancer object
+ */
+ void neutronLoadBalancerDeleted(NeutronLoadBalancer loadBalancer);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerHealthMonitor;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of LoadBalancerHealthMonitor Rules needs to implement
+ *
+ */
+
+public interface INeutronLoadBalancerHealthMonitorAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerHealthMonitor can be created
+ *
+ * @param loadBalancerHealthMonitor
+ * instance of proposed new LoadBalancerHealthMonitor object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronLoadBalancerHealthMonitor(NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerHealthMonitor has been created
+ *
+ * @param loadBalancerHealthMonitor
+ * instance of new LoadBalancerHealthMonitor object
+ */
+ void neutronLoadBalancerHealthMonitorCreated(NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerHealthMonitor can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the loadBalancerHealthMonitor object using patch semantics
+ * @param original
+ * instance of the LoadBalancerHealthMonitor object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronLoadBalancerHealthMonitor(NeutronLoadBalancerHealthMonitor delta,
+ NeutronLoadBalancerHealthMonitor original);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerHealthMonitor has been updated
+ *
+ * @param loadBalancerHealthMonitor
+ * instance of modified LoadBalancerHealthMonitor object
+ */
+ void neutronLoadBalancerHealthMonitorUpdated(NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerHealthMonitor can be deleted
+ *
+ * @param loadBalancerHealthMonitor
+ * instance of the LoadBalancerHealthMonitor object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronLoadBalancerHealthMonitor(NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerHealthMonitor has been deleted
+ *
+ * @param loadBalancerHealthMonitor
+ * instance of deleted LoadBalancerHealthMonitor object
+ */
+ void neutronLoadBalancerHealthMonitorDeleted(NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerListener;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of LoadBalancerListener Rules needs to implement
+ *
+ */
+
+public interface INeutronLoadBalancerListenerAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerListener can be created
+ *
+ * @param loadBalancerListener
+ * instance of proposed new LoadBalancerListener object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronLoadBalancerListener(NeutronLoadBalancerListener loadBalancerListener);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerListener has been created
+ *
+ * @param loadBalancerListener
+ * instance of new LoadBalancerListener object
+ */
+ void neutronLoadBalancerListenerCreated(NeutronLoadBalancerListener loadBalancerListener);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerListener can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the loadBalancerListener object using patch semantics
+ * @param original
+ * instance of the LoadBalancerListener object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronLoadBalancerListener(NeutronLoadBalancerListener delta,
+ NeutronLoadBalancerListener original);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerListener has been updated
+ *
+ * @param loadBalancerListener
+ * instance of modified LoadBalancerListener object
+ */
+ void neutronLoadBalancerListenerUpdated(NeutronLoadBalancerListener loadBalancerListener);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerListener can be deleted
+ *
+ * @param loadBalancerListener
+ * instance of the LoadBalancerListener object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronLoadBalancerListener(NeutronLoadBalancerListener loadBalancerListener);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerListener has been deleted
+ *
+ * @param loadBalancerListener
+ * instance of deleted LoadBalancerListener object
+ */
+ void neutronLoadBalancerListenerDeleted(NeutronLoadBalancerListener loadBalancerListener);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of LoadBalancerPool Rules needs to implement
+ *
+ */
+
+public interface INeutronLoadBalancerPoolAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerPool can be created
+ *
+ * @param loadBalancerPool
+ * instance of proposed new LoadBalancerPool object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronLoadBalancerPool(NeutronLoadBalancerPool loadBalancerPool);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerPool has been created
+ *
+ * @param loadBalancerPool
+ * instance of new LoadBalancerPool object
+ */
+ void neutronLoadBalancerPoolCreated(NeutronLoadBalancerPool loadBalancerPool);
+
+ /**
+ * Services provide this interface method to indicate if the
+ * specified loadBalancerPool can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the loadBalancerPool object using patch semantics
+ * @param original
+ * instance of the LoadBalancerPool object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronLoadBalancerPool(NeutronLoadBalancerPool delta, NeutronLoadBalancerPool original);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerPool has been updated
+ *
+ * @param loadBalancerPool
+ * instance of modified LoadBalancerPool object
+ */
+ void neutronLoadBalancerPoolUpdated(NeutronLoadBalancerPool loadBalancerPool);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerPool can be deleted
+ *
+ * @param loadBalancerPool
+ * instance of the LoadBalancerPool object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronLoadBalancerPool(NeutronLoadBalancerPool loadBalancerPool);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerPool has been deleted
+ *
+ * @param loadBalancerPool
+ * instance of deleted LoadBalancerPool object
+ */
+ void neutronLoadBalancerPoolDeleted(NeutronLoadBalancerPool loadBalancerPool);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+
+public interface INeutronLoadBalancerPoolMemberAware {
+
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerPoolMember can be created
+ *
+ * @param loadBalancerPoolMember
+ * instance of proposed new LoadBalancerPool object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerPoolMember has been created
+ *
+ * @param loadBalancerPoolMember
+ * instance of new LoadBalancerPool object
+ */
+ void neutronLoadBalancerPoolMemberCreated(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerPoolMember can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the loadBalancerPoolMember object using patch semantics
+ * @param original
+ * instance of the LoadBalancerPool object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember delta,
+ NeutronLoadBalancerPoolMember original);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerPoolMember has been updated
+ *
+ * @param loadBalancerPoolMember
+ * instance of modified LoadBalancerPool object
+ */
+ void neutronLoadBalancerPoolMemberUpdated(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
+
+ /**
+ * Services provide this interface method to indicate if the specified loadBalancerPoolMember can be deleted
+ *
+ * @param loadBalancerPoolMember
+ * instance of the LoadBalancerPool object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
+
+ /**
+ * Services provide this interface method for taking action after a loadBalancerPoolMember has been deleted
+ *
+ * @param loadBalancerPoolMember
+ * instance of deleted LoadBalancerPool object
+ */
+ void neutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Neutron Networks needs to implement
+ *
+ */
+
+public interface INeutronNetworkAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified network can be created
+ *
+ * @param network
+ * instance of proposed new Neutron Network object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNetwork(NeutronNetwork network);
+
+ /**
+ * Services provide this interface method for taking action after a network has been created
+ *
+ * @param network
+ * instance of new Neutron Network object
+ */
+ void neutronNetworkCreated(NeutronNetwork network);
+
+ /**
+ * Services provide this interface method to indicate if the specified network can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the network object using patch semantics
+ * @param original
+ * instance of the Neutron Network object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNetwork(NeutronNetwork delta, NeutronNetwork original);
+
+ /**
+ * Services provide this interface method for taking action after a network has been updated
+ *
+ * @param network
+ * instance of modified Neutron Network object
+ */
+ void neutronNetworkUpdated(NeutronNetwork network);
+
+ /**
+ * Services provide this interface method to indicate if the specified network can be deleted
+ *
+ * @param network
+ * instance of the Neutron Network object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNetwork(NeutronNetwork network);
+
+ /**
+ * Services provide this interface method for taking action after a network has been deleted
+ *
+ * @param network
+ * instance of deleted Neutron Network object
+ */
+ void neutronNetworkDeleted(NeutronNetwork network);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Neutron Ports needs to implement
+ *
+ */
+
+public interface INeutronPortAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified port can be created
+ *
+ * @param port
+ * instance of proposed new Neutron Port object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreatePort(NeutronPort port);
+
+ /**
+ * Services provide this interface method for taking action after a port has been created
+ *
+ * @param port
+ * instance of new Neutron Port object
+ */
+ void neutronPortCreated(NeutronPort port);
+
+ /**
+ * Services provide this interface method to indicate if the specified port can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the port object using patch semantics
+ * @param original
+ * instance of the Neutron Port object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdatePort(NeutronPort delta, NeutronPort original);
+
+ /**
+ * Services provide this interface method for taking action after a port has been updated
+ *
+ * @param port
+ * instance of modified Neutron Port object
+ */
+ void neutronPortUpdated(NeutronPort port);
+
+ /**
+ * Services provide this interface method to indicate if the specified port can be deleted
+ *
+ * @param port
+ * instance of the Neutron Port object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeletePort(NeutronPort port);
+
+ /**
+ * Services provide this interface method for taking action after a port has been deleted
+ *
+ * @param port
+ * instance of deleted Port Network object
+ */
+ void neutronPortDeleted(NeutronPort port);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Neutron Routers needs to implement
+ *
+ */
+
+public interface INeutronRouterAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified router can be created
+ *
+ * @param router
+ * instance of proposed new Neutron Router object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateRouter(NeutronRouter router);
+
+ /**
+ * Services provide this interface method for taking action after a router has been created
+ *
+ * @param router
+ * instance of new Neutron Router object
+ */
+ void neutronRouterCreated(NeutronRouter router);
+
+ /**
+ * Services provide this interface method to indicate if the specified router can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the router object using patch semantics
+ * @param original
+ * instance of the Neutron Router object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateRouter(NeutronRouter delta, NeutronRouter original);
+
+ /**
+ * Services provide this interface method for taking action after a router has been updated
+ *
+ * @param router
+ * instance of modified Neutron Router object
+ */
+ void neutronRouterUpdated(NeutronRouter router);
+
+ /**
+ * Services provide this interface method to indicate if the specified router can be deleted
+ *
+ * @param router
+ * instance of the Neutron Router object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteRouter(NeutronRouter router);
+
+ /**
+ * Services provide this interface method for taking action after a router has been deleted
+ *
+ * @param router
+ * instance of deleted Router Network object
+ */
+ void neutronRouterDeleted(NeutronRouter router);
+
+ /**
+ * Services provide this interface method to indicate if the
+ * specified interface can be attached to the specified router
+ *
+ * @param router
+ * instance of the base Neutron Router object
+ * @param routerInterface
+ * instance of the NeutronRouter_Interface to be attached to the router
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the attach operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canAttachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface);
+
+ /**
+ * Services provide this interface method for taking action
+ * after an interface has been added to a router
+ *
+ * @param router
+ * instance of the base Neutron Router object
+ * @param routerInterface
+ * instance of the NeutronRouter_Interface being attached to the router
+ */
+ void neutronRouterInterfaceAttached(NeutronRouter router, NeutronRouter_Interface routerInterface);
+
+ /**
+ * Services provide this interface method to indicate if the
+ * specified interface can be detached from the specified router
+ *
+ * @param router
+ * instance of the base Neutron Router object
+ * @param routerInterface
+ * instance of the NeutronRouter_Interface to be detached to the router
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the detach operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDetachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface);
+
+ /**
+ * Services provide this interface method for taking action after an interface has been removed from a router
+ *
+ * @param router
+ * instance of the base Neutron Router object
+ * @param routerInterface
+ * instance of the NeutronRouter_Interface being detached from the router
+ */
+ void neutronRouterInterfaceDetached(NeutronRouter router, NeutronRouter_Interface routerInterface);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Neutron Security Groups needs to implement
+ */
+
+public interface INeutronSecurityGroupAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified security group can be created
+ *
+ * @param securityGroup instance of proposed new Neutron Security Group object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronSecurityGroup(NeutronSecurityGroup securityGroup);
+
+ /**
+ * Services provide this interface method for taking action after a security group has been created
+ *
+ * @param securityGroup instance of new Neutron Security Group object
+ */
+ void neutronSecurityGroupCreated(NeutronSecurityGroup securityGroup);
+
+ /**
+ * Services provide this interface method to indicate if the specified security group can be changed using the specified
+ * delta
+ *
+ * @param delta updates to the security group object using patch semantics
+ * @param original instance of the Neutron Security Group object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronSecurityGroup(NeutronSecurityGroup delta, NeutronSecurityGroup original);
+
+ /**
+ * Services provide this interface method for taking action after a security group has been updated
+ *
+ * @param securityGroup instance of modified Neutron Security Group object
+ */
+ void neutronSecurityGroupUpdated(NeutronSecurityGroup securityGroup);
+
+ /**
+ * Services provide this interface method to indicate if the specified security group can be deleted
+ *
+ * @param securityGroup instance of the Neutron Security Group object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronSecurityGroup(NeutronSecurityGroup securityGroup);
+
+ /**
+ * Services provide this interface method for taking action after a security group has been deleted
+ *
+ * @param securityGroup instance of deleted Neutron Security Group object
+ */
+ void neutronSecurityGroupDeleted(NeutronSecurityGroup securityGroup);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+
+/**
+ * This interface defines the methods required to be aware of Neutron Security Rules
+ */
+
+public interface INeutronSecurityRuleAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified security rule can be created
+ *
+ * @param securityRule instance of proposed new Neutron Security Rule object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateNeutronSecurityRule(NeutronSecurityRule securityRule);
+
+ /**
+ * Services provide this interface method for taking action after a security rule has been created
+ *
+ * @param securityRule instance of new Neutron Security Rule object
+ */
+ void neutronSecurityRuleCreated(NeutronSecurityRule securityRule);
+
+ /**
+ * Services provide this interface method to indicate if the specified security rule can be changed using the specified
+ * delta
+ *
+ * @param delta updates to the security rule object using patch semantics
+ * @param original instance of the Neutron Security Rule object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateNeutronSecurityRule(NeutronSecurityRule delta, NeutronSecurityRule original);
+
+ /**
+ * Services provide this interface method for taking action after a security rule has been updated
+ *
+ * @param securityRule instance of modified Neutron Security Rule object
+ */
+ void neutronSecurityRuleUpdated(NeutronSecurityRule securityRule);
+
+ /**
+ * Services provide this interface method to indicate if the specified security rule can be deleted
+ *
+ * @param securityRule instance of the Neutron Security Rule object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteNeutronSecurityRule(NeutronSecurityRule securityRule);
+
+ /**
+ * Services provide this interface method for taking action after a security rule has been deleted
+ *
+ * @param securityRule instance of deleted Neutron Security Rule object
+ */
+ void neutronSecurityRuleDeleted(NeutronSecurityRule securityRule);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware;
+
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+
+/**
+ * This interface defines the methods a service that wishes to be aware of Neutron Subnets needs to implement
+ *
+ */
+
+public interface INeutronSubnetAware {
+
+ /**
+ * Services provide this interface method to indicate if the specified subnet can be created
+ *
+ * @param subnet
+ * instance of proposed new Neutron Subnet object
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the create operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canCreateSubnet(NeutronSubnet subnet);
+
+ /**
+ * Services provide this interface method for taking action after a subnet has been created
+ *
+ * @param subnet
+ * instance of new Neutron Subnet object
+ */
+ void neutronSubnetCreated(NeutronSubnet subnet);
+
+ /**
+ * Services provide this interface method to indicate if the specified subnet can be changed using the specified
+ * delta
+ *
+ * @param delta
+ * updates to the subnet object using patch semantics
+ * @param original
+ * instance of the Neutron Subnet object to be updated
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the update operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canUpdateSubnet(NeutronSubnet delta, NeutronSubnet original);
+
+ /**
+ * Services provide this interface method for taking action after a subnet has been updated
+ *
+ * @param subnet
+ * instance of modified Neutron Subnet object
+ */
+ void neutronSubnetUpdated(NeutronSubnet subnet);
+
+ /**
+ * Services provide this interface method to indicate if the specified subnet can be deleted
+ *
+ * @param subnet
+ * instance of the Subnet Router object to be deleted
+ * @return integer
+ * the return value is understood to be a HTTP status code. A return value outside of 200 through 299
+ * results in the delete operation being interrupted and the returned status value reflected in the
+ * HTTP response.
+ */
+ int canDeleteSubnet(NeutronSubnet subnet);
+
+ /**
+ * Services provide this interface method for taking action after a subnet has been deleted
+ *
+ * @param subnet
+ * instance of deleted Router Subnet object
+ */
+ void neutronSubnetDeleted(NeutronSubnet subnet);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronFloatingIPAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.Floatingips;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.floatingips.Floatingip;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronFloatingIPChangeListener implements DataChangeListener, AutoCloseable{
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronFloatingIPChangeListener.class);
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronFloatingIPChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Floatingip> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Floatingips.class)
+ .child(Floatingip.class);
+ LOG.debug("Register listener for Neutron FloatingIp model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this, DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}",changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronFloatingIPAware.class, this);
+ createFloatingIP(changes, subscribers);
+ updateFloatingIP(changes, subscribers);
+ deleteFloatingIP(changes, subscribers);
+ }
+
+ private void createFloatingIP(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newFloatingIP : changes.getCreatedData().entrySet()) {
+ if(newFloatingIP.getValue() instanceof Floatingip){
+ NeutronFloatingIP floatingip= fromMd((Floatingip)newFloatingIP.getValue());
+ for(Object entry: subscribers){
+ INeutronFloatingIPAware subscriber = (INeutronFloatingIPAware)entry;
+ subscriber.neutronFloatingIPCreated(floatingip);
+ }
+ }
+ }
+ }
+
+ private void updateFloatingIP(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updateFloatingIP : changes.getUpdatedData().entrySet()) {
+ if(updateFloatingIP.getValue() instanceof Floatingip){
+ NeutronFloatingIP floatingip = fromMd((Floatingip)updateFloatingIP.getValue());
+ for(Object entry: subscribers){
+ INeutronFloatingIPAware subscriber = (INeutronFloatingIPAware)entry;
+ subscriber.neutronFloatingIPUpdated(floatingip);
+ }
+ }
+ }
+ }
+
+ private void deleteFloatingIP(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedFloatingIPPath : changes.getRemovedPaths()) {
+ if(deletedFloatingIPPath.getTargetType().equals(Floatingip.class)){
+ NeutronFloatingIP floatingip = fromMd((Floatingip)changes.getOriginalData().get(deletedFloatingIPPath));
+ for(Object entry: subscribers){
+ INeutronFloatingIPAware subscriber = (INeutronFloatingIPAware)entry;
+ subscriber.neutronFloatingIPDeleted(floatingip);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronFloatingIPInterface.java class of Neutron Northbound class.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronFloatingIP fromMd(Floatingip fip) {
+ NeutronFloatingIP result = new NeutronFloatingIP();
+ result.setID(String.valueOf(fip.getUuid().getValue()));
+ if (fip.getFloatingNetworkId() != null) {
+ result.setFloatingNetworkUUID(String.valueOf(fip.getFloatingNetworkId().getValue()));
+ }
+ if (fip.getPortId() != null) {
+ result.setPortUUID(String.valueOf(fip.getPortId().getValue()));
+ }
+ if (fip.getFixedIpAddress() != null ) {
+ result.setFixedIPAddress(String.valueOf(fip.getFixedIpAddress().getValue()));
+ }
+ if (fip.getFloatingIpAddress() != null) {
+ result.setFloatingIPAddress(String.valueOf(fip.getFloatingIpAddress().getValue()));
+ }
+ if (fip.getTenantId() != null) {
+ result.setTenantUUID(String.valueOf(fip.getTenantId().getValue()));
+ }
+ if (fip.getRouterId() != null) {
+ result.setRouterUUID(String.valueOf(fip.getRouterId().getValue()));
+ }
+ result.setStatus(fip.getStatus());
+ return result;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronIAwareUtil {
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(NeutronIAwareUtil.class);
+
+ private NeutronIAwareUtil() {
+ }
+
+ public static Object[] getInstances(Class<?> clazz,Object bundle) {
+ Object instances[] = null;
+ try {
+ BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
+ .getBundleContext();
+
+ ServiceReference<?>[] services = null;
+ services = bCtx.getServiceReferences(clazz.getName(),
+ null);
+ if (services != null) {
+ instances = new Object[services.length];
+ for (int i = 0; i < services.length; i++) {
+ instances[i] = bCtx.getService(services[i]);
+ }
+ }
+ } catch (Exception e) {
+ LOGGER.error("Instance reference is NULL", e);
+ }
+ return instances;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer_SessionPersistence;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_ID;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolAware;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.Pools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.Pool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.pool.members.Member;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableBiMap;
+
+public class NeutronLoadBalancerPoolChangeListener implements DataChangeListener, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronLoadBalancerPoolChangeListener.class);
+
+ private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
+ = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
+ .put(ProtocolHttp.class, "HTTP")
+ .put(ProtocolHttps.class, "HTTPS")
+ .put(ProtocolIcmp.class, "ICMP")
+ .put(ProtocolTcp.class,"TCP")
+ .build();
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronLoadBalancerPoolChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Pool> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Pools.class)
+ .child(Pool.class);
+ LOG.debug("Register listener for Neutron Load Balancer Pool model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this, AsyncDataBroker.DataChangeScope.ONE);
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+
+ @Override
+ public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}", changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
+ createPool(changes, subscribers);
+ updatePool(changes, subscribers);
+ deletePool(changes, subscribers);
+ }
+
+ private void createPool(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newPool : changes.getCreatedData().entrySet()) {
+ if(newPool.getValue() instanceof Pool){
+ NeutronLoadBalancerPool loadBalancerPool = fromMd((Pool) newPool.getValue());
+ for (Object entry : subscribers) {
+ INeutronLoadBalancerPoolAware subscriber = (INeutronLoadBalancerPoolAware) entry;
+ subscriber.neutronLoadBalancerPoolCreated(loadBalancerPool);
+ }
+ }
+ }
+ }
+ private void updatePool(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updatePool : changes.getUpdatedData().entrySet()) {
+ if(updatePool.getValue() instanceof Pool){
+ NeutronLoadBalancerPool loadBalancerPool = fromMd((Pool)updatePool.getValue());
+ for(Object entry: subscribers){
+ INeutronLoadBalancerPoolAware subscriber = (INeutronLoadBalancerPoolAware) entry;
+ subscriber.neutronLoadBalancerPoolUpdated(loadBalancerPool);
+ }
+ }
+ }
+ }
+ private void deletePool(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedPoolPath : changes.getRemovedPaths()) {
+ if(deletedPoolPath.getTargetType().equals(Pool.class)){
+ NeutronLoadBalancerPool loadBalancerPool = fromMd((Pool)changes.getOriginalData().get(deletedPoolPath));
+ for(Object entry: subscribers){
+ INeutronLoadBalancerPoolAware subscriber = (INeutronLoadBalancerPoolAware) entry;
+ subscriber.neutronLoadBalancerPoolDeleted(loadBalancerPool);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronLoadBalancerPool.java class of Neutron Northbound class.
+ * in the original location, this method is called extractFields.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronLoadBalancerPool fromMd(Pool pool) {
+ NeutronLoadBalancerPool result = new NeutronLoadBalancerPool();
+
+ result.setID(pool.getUuid().getValue());
+ result.setLoadBalancerPoolTenantID(pool.getTenantId().getValue());
+ result.setLoadBalancerPoolName(pool.getName());
+ result.setLoadBalancerPoolDescription(pool.getDescr());
+ result.setLoadBalancerPoolProtocol(PROTOCOL_MAP.get(pool.getProtocol()));
+ result.setLoadBalancerPoolLbAlgorithm(pool.getLbAlgorithm());
+
+ // TODO: setNeutronLoadBalancerPoolHealthMonitorID is a list? Fill in, when its needed.
+ if (pool.getHealthmonitorId() != null) {
+ result.setNeutronLoadBalancerPoolHealthMonitorID(pool.getHealthmonitorId().getValue());
+ }
+
+ result.setLoadBalancerPoolAdminStateIsUp(pool.isAdminStateUp());
+
+ List<Neutron_ID> listeners = new ArrayList();
+ if (pool.getListeners() != null) {
+ for (Uuid listenerUuid : pool.getListeners()) {
+ listeners.add(new Neutron_ID(listenerUuid.getValue()));
+ }
+ }
+ result.setLoadBalancerPoolListeners(listeners);
+
+ if (pool.getSessionPersistence() != null) {
+ NeutronLoadBalancer_SessionPersistence sessionPersistence = new NeutronLoadBalancer_SessionPersistence();
+ sessionPersistence.setCookieName(pool.getSessionPersistence().getCookieName());
+ sessionPersistence.setType(pool.getSessionPersistence().getType());
+ result.setLoadBalancerSessionPersistence(sessionPersistence);
+ }
+
+ List<NeutronLoadBalancerPoolMember> loadBalancerPoolMembers = new ArrayList();
+ if (pool.getMembers() != null) {
+ for (Member member : pool.getMembers().getMember()) {
+ NeutronLoadBalancerPoolMember neutronMember = new NeutronLoadBalancerPoolMember();
+
+ neutronMember.setPoolID(pool.getUuid().getValue());
+ neutronMember.setPoolMemberID(member.getUuid().getValue());
+
+ // TODO: locate and populate remainder attributes, when its needed
+ // member.setPoolMemberAddress(xxx);
+ // member.setPoolMemberAdminStateIsUp(xxx);
+ // member.setPoolMemberProtoPort(xxx);
+ // member.setPoolMemberSubnetID(xxx);
+ // member.setPoolMemberTenantID(xxx);
+ // member.setPoolMemberWeight(xxx);
+
+ loadBalancerPoolMembers.add(neutronMember);
+ }
+ }
+ result.setLoadBalancerPoolMembers(loadBalancerPoolMembers);
+
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 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
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolMemberAware;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.Pools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.Pool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.PoolKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.pool.Members;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.lbaasv2.rev150712.lbaas.attributes.pools.pool.members.Member;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronLoadBalancerPoolMemberChangeListener implements DataChangeListener, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronLoadBalancerPoolMemberChangeListener.class);
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronLoadBalancerPoolMemberChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Member> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Pools.class)
+ .child(Pool.class)
+ .child(Members.class)
+ .child(Member.class);
+ LOG.debug("Register listener for Neutron Load Balancer Pool Member model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this,
+ AsyncDataBroker.DataChangeScope.ONE);
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+
+ @Override
+ public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}", changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
+ createPoolMember(changes, subscribers);
+ updatePoolMember(changes, subscribers);
+ deletePoolMember(changes, subscribers);
+ }
+
+ private void createPoolMember(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newPoolMember : changes.getCreatedData().entrySet()) {
+ if(newPoolMember.getValue() instanceof Member){
+ NeutronLoadBalancerPoolMember neutronLBPoolMember = fromMd(newPoolMember.getKey(), (Member) newPoolMember.getValue());
+ for (Object entry : subscribers) {
+ INeutronLoadBalancerPoolMemberAware subscriber = (INeutronLoadBalancerPoolMemberAware) entry;
+ subscriber.neutronLoadBalancerPoolMemberCreated(neutronLBPoolMember);
+ }
+ }
+ }
+ }
+ private void updatePoolMember(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updatePoolMember : changes.getUpdatedData().entrySet()) {
+ if(updatePoolMember.getValue() instanceof Member){
+ NeutronLoadBalancerPoolMember neutronLBPoolMember =
+ fromMd(updatePoolMember.getKey(), (Member) updatePoolMember.getValue());
+ for(Object entry: subscribers){
+ INeutronLoadBalancerPoolMemberAware subscriber = (INeutronLoadBalancerPoolMemberAware) entry;
+ subscriber.neutronLoadBalancerPoolMemberUpdated(neutronLBPoolMember);
+ }
+ }
+ }
+ }
+ private void deletePoolMember(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedPoolMemberPath : changes.getRemovedPaths()) {
+ if(deletedPoolMemberPath.getTargetType().equals(Member.class)){
+ NeutronLoadBalancerPoolMember neutronLBPoolMember =
+ fromMd(deletedPoolMemberPath, (Member) changes.getOriginalData().get(deletedPoolMemberPath));
+ for(Object entry: subscribers){
+ INeutronLoadBalancerPoolMemberAware subscriber = (INeutronLoadBalancerPoolMemberAware) entry;
+ subscriber.neutronLoadBalancerPoolMemberDeleted(neutronLBPoolMember);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronLoadBalancerPoolMember.java class of Neutron Northbound class.
+ * in the original location, this method is called extractFields.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronLoadBalancerPoolMember fromMd(InstanceIdentifier<?> iid, Member member) {
+ NeutronLoadBalancerPoolMember result = new NeutronLoadBalancerPoolMember();
+
+ final PoolKey poolsKey = iid.firstKeyOf(Pool.class, PoolKey.class);
+ if (poolsKey != null) {
+ result.setPoolID(poolsKey.getUuid().getValue());
+ }
+
+ result.setID(member.getUuid().getValue());
+ result.setPoolMemberAdminStateIsUp(member.isAdminStateUp());
+
+ final IpAddress memberIpAddress = member.getAddress();
+ if (memberIpAddress != null) {
+ if (memberIpAddress.getIpv4Address() != null) {
+ result.setPoolMemberAddress(memberIpAddress.getIpv4Address().getValue());
+ } else if (memberIpAddress.getIpv6Address() != null) {
+ result.setPoolMemberAddress(memberIpAddress.getIpv6Address().getValue());
+ }
+ }
+
+ result.setPoolMemberProtoPort(member.getProtocolPort());
+ result.setPoolMemberSubnetID(member.getSubnetId().getValue());
+ result.setPoolMemberTenantID(member.getTenantId().getValue());
+ result.setPoolMemberWeight(member.getWeight());
+
+ return result;
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork_Segment;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronNetworkAware;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.ext.rev150712.NetworkL3Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeFlat;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableBiMap;
+
+public class NeutronNetworkChangeListener implements DataChangeListener, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronNetworkChangeListener.class);
+
+ private static final ImmutableBiMap<Class<? extends NetworkTypeBase>,String> NETWORK_MAP
+ = new ImmutableBiMap.Builder<Class<? extends NetworkTypeBase>,String>()
+ .put(NetworkTypeFlat.class,"flat")
+ .put(NetworkTypeGre.class,"gre")
+ .put(NetworkTypeVlan.class,"vlan")
+ .put(NetworkTypeVxlan.class,"vxlan")
+ .build();
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronNetworkChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Network> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Networks.class)
+ .child(Network.class);
+ LOG.debug("Register listener for Neutron Network model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this, DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}",changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronNetworkAware.class, this);
+ createNetwork(changes, subscribers);
+ updateNetwork(changes, subscribers);
+ deleteNetwork(changes, subscribers);
+ }
+
+ private void createNetwork(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newNetwork : changes.getCreatedData().entrySet()) {
+ if(newNetwork.getValue() instanceof Network){
+ NeutronNetwork network = fromMd((Network)newNetwork.getValue());
+ for(Object entry: subscribers){
+ INeutronNetworkAware subscriber = (INeutronNetworkAware)entry;
+ subscriber.neutronNetworkCreated(network);
+ }
+ }
+ }
+ }
+
+ private void updateNetwork(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updateNetwork : changes.getUpdatedData().entrySet()) {
+ if(updateNetwork.getValue() instanceof Network){
+ NeutronNetwork network = fromMd((Network)updateNetwork.getValue());
+ for(Object entry: subscribers){
+ INeutronNetworkAware subscriber = (INeutronNetworkAware)entry;
+ subscriber.neutronNetworkUpdated(network);
+ }
+ }
+ }
+ }
+
+ private void deleteNetwork(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedNetworkPath : changes.getRemovedPaths()) {
+ if(deletedNetworkPath.getTargetType().equals(Network.class)){
+ NeutronNetwork network = fromMd((Network)changes.getOriginalData().get(deletedNetworkPath));
+ for(Object entry: subscribers){
+ INeutronNetworkAware subscriber = (INeutronNetworkAware)entry;
+ subscriber.neutronNetworkDeleted(network);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronNetworkInterface.java class of Neutron Northbound class.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronNetwork fromMd(Network network) {
+ NeutronNetwork result = new NeutronNetwork();
+ result.setAdminStateUp(network.isAdminStateUp());
+ result.setNetworkName(network.getName());
+ result.setShared(network.isShared());
+ result.setStatus(network.getStatus());
+ if (network.getSubnets() != null) {
+ List<String> neutronSubnets = new ArrayList<String>();
+ for( Uuid subnet : network.getSubnets()) {
+ neutronSubnets.add(subnet.getValue());
+ }
+ result.setSubnets(neutronSubnets);
+ }
+
+ // todo remove '-' chars as tenant id doesn't use them
+ result.setTenantID(network.getTenantId().getValue());
+ result.setID(network.getUuid().getValue());
+
+ NetworkL3Extension l3Extension = network.getAugmentation(NetworkL3Extension.class);
+ result.setRouterExternal(l3Extension.isExternal());
+
+ NetworkProviderExtension providerExtension = network.getAugmentation(NetworkProviderExtension.class);
+ result.setProviderPhysicalNetwork(providerExtension.getPhysicalNetwork());
+ result.setProviderSegmentationID(providerExtension.getSegmentationId());
+ result.setProviderNetworkType(NETWORK_MAP.get(providerExtension.getNetworkType()));
+ List<NeutronNetwork_Segment> segments = new ArrayList<NeutronNetwork_Segment>();
+ if (providerExtension.getSegments() != null) {
+ for (Segments segment: providerExtension.getSegments()) {
+ NeutronNetwork_Segment neutronSegment = new NeutronNetwork_Segment();
+ neutronSegment.setProviderPhysicalNetwork(segment.getPhysicalNetwork());
+ neutronSegment.setProviderSegmentationID(segment.getSegmentationId());
+ neutronSegment.setProviderNetworkType(NETWORK_MAP.get(segment.getNetworkType()));
+ segments.add(neutronSegment);
+ }
+ }
+ result.setSegments(segments);
+ return result;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort_AllowedAddressPairs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort_ExtraDHCPOption;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort_VIFDetail;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronPortAware;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.binding.attributes.VifDetails;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.AllowedAddressPairs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.ExtraDhcpOpts;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronPortChangeListener implements DataChangeListener, AutoCloseable{
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronPortChangeListener.class);
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronPortChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Port> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Ports.class)
+ .child(Port.class);
+ LOG.debug("Register listener for Neutron Port model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this, DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}",changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronPortAware.class, this);
+ createPort(changes, subscribers);
+ updatePort(changes, subscribers);
+ deletePort(changes, subscribers);
+ }
+
+ private void createPort(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newPort : changes.getCreatedData().entrySet()) {
+ if(newPort.getValue() instanceof Port){
+ NeutronPort port = fromMd((Port)newPort.getValue());
+ for(Object entry: subscribers){
+ INeutronPortAware subscriber = (INeutronPortAware)entry;
+ subscriber.neutronPortCreated(port);
+ }
+ }
+ }
+ }
+
+ private void updatePort(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ Map<String, NeutronPort> originalPortMap = getChangedPorts(changes.getOriginalData());
+ for (Entry<InstanceIdentifier<?>, DataObject> updatePort : changes.getUpdatedData().entrySet()) {
+ if (updatePort.getValue() instanceof Port) {
+ NeutronPort port = fromMd((Port)updatePort.getValue());
+ NeutronPort originalPort = originalPortMap.get(port.getID());
+ if (originalPort != null) {
+ port.setOriginalPort(originalPort);
+ } else {
+ LOG.warn("Original Port data is missing");
+ }
+ for (Object entry: subscribers) {
+ INeutronPortAware subscriber = (INeutronPortAware)entry;
+ subscriber.neutronPortUpdated(port);
+ }
+ }
+ }
+ }
+
+ private void deletePort(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedPortPath : changes.getRemovedPaths()) {
+ if(deletedPortPath.getTargetType().equals(Port.class)){
+ NeutronPort port = fromMd((Port)changes.getOriginalData().get(deletedPortPath));
+ for(Object entry: subscribers){
+ INeutronPortAware subscriber = (INeutronPortAware)entry;
+ subscriber.neutronPortDeleted(port);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronPortInterface.java class of Neutron Northbound class.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronPort fromMd(Port port) {
+
+ NeutronPort result = new NeutronPort();
+ result.setAdminStateUp(port.isAdminStateUp());
+ if (port.getAllowedAddressPairs() != null) {
+ List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
+ for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
+ NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
+ pair.setIpAddress(mdPair.getIpAddress());
+ pair.setMacAddress(mdPair.getMacAddress());
+ pair.setPortID(mdPair.getPortId());
+ pairs.add(pair);
+ }
+ result.setAllowedAddressPairs(pairs);
+ }
+ result.setDeviceID(port.getDeviceId());
+ result.setDeviceOwner(port.getDeviceOwner());
+ if (port.getExtraDhcpOpts() != null) {
+ List<NeutronPort_ExtraDHCPOption> options = new ArrayList<NeutronPort_ExtraDHCPOption>();
+ for (ExtraDhcpOpts opt : port.getExtraDhcpOpts()) {
+ NeutronPort_ExtraDHCPOption arg = new NeutronPort_ExtraDHCPOption();
+ arg.setName(opt.getOptName());
+ arg.setValue(opt.getOptValue());
+ options.add(arg);
+ }
+ result.setExtraDHCPOptions(options);
+ }
+ if (port.getFixedIps() != null) {
+ List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ for (FixedIps mdIP : port.getFixedIps()) {
+ Neutron_IPs ip = new Neutron_IPs();
+ ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
+ ip.setSubnetUUID(mdIP.getSubnetId().getValue());
+ ips.add(ip);
+ }
+ result.setFixedIPs(ips);
+ }
+ result.setMacAddress(port.getMacAddress());
+ result.setName(port.getName());
+ result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
+ if (port.getSecurityGroups() != null) {
+ Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>();
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
+ INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface();
+ for (Uuid sgUuid : port.getSecurityGroups()) {
+ allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
+ }
+ List<NeutronSecurityGroup> groups = new ArrayList<NeutronSecurityGroup>();
+ groups.addAll(allGroups);
+ result.setSecurityGroups(groups);
+ }
+ result.setStatus(port.getStatus());
+ if (port.getTenantId() != null) {
+ result.setTenantID(String.valueOf(port.getTenantId().getValue()).replace("-", ""));
+ }
+ result.setPortUUID(String.valueOf(port.getUuid().getValue()));
+ addExtensions(port, result);
+ return result;
+ }
+
+ protected void addExtensions(Port port, NeutronPort result) {
+ PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
+ result.setBindinghostID(binding.getHostId());
+ if (binding.getVifDetails() != null) {
+ List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+ for (VifDetails vifDetail : binding.getVifDetails()) {
+ NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
+ detail.setPortFilter(vifDetail.isPortFilter());
+ detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
+ details.add(detail);
+ }
+ result.setVIFDetail(details);
+ }
+ result.setBindingvifType(binding.getVifType());
+ result.setBindingvnicType(binding.getVnicType());
+ }
+
+ private Map<String,NeutronPort> getChangedPorts(Map<InstanceIdentifier<?>, DataObject> changedData) {
+ LOG.trace("getChangedPorts:" + changedData);
+ Map<String,NeutronPort> portMap = new HashMap<String,NeutronPort>();
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> changed : changedData.entrySet()) {
+ if (changed.getValue() instanceof Port) {
+ NeutronPort port = fromMd((Port)changed.getValue());
+ portMap.put(port.getID(), port);
+ }
+ }
+ return portMap;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_NetworkReference;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronRouterAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronRouterChangeListener implements DataChangeListener, AutoCloseable{
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronRouterChangeListener.class);
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronRouterChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Router> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Routers.class)
+ .child(Router.class);
+ LOG.debug("Register listener for Neutron Router model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this, DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}",changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronRouterAware.class, this);
+ createRouter(changes, subscribers);
+ updateRouter(changes, subscribers);
+ deleteRouter(changes, subscribers);
+ }
+
+ private void createRouter(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newRouter : changes.getCreatedData().entrySet()) {
+ if(newRouter.getValue() instanceof Router){
+ NeutronRouter router = fromMd((Router)newRouter.getValue());
+ for(Object entry: subscribers){
+ INeutronRouterAware subscriber = (INeutronRouterAware)entry;
+ subscriber.neutronRouterCreated(router);
+ }
+ }
+ }
+
+ }
+
+ private void updateRouter(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updateRouter : changes.getUpdatedData().entrySet()) {
+ if(updateRouter.getValue() instanceof Router){
+ NeutronRouter router = fromMd((Router)updateRouter.getValue());
+ for(Object entry: subscribers){
+ INeutronRouterAware subscriber = (INeutronRouterAware)entry;
+ subscriber.neutronRouterUpdated(router);
+ }
+ }
+ }
+ }
+
+ private void deleteRouter(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedRouterPath : changes.getRemovedPaths()) {
+ if(deletedRouterPath.getTargetType().equals(Router.class)){
+ NeutronRouter router = fromMd((Router)changes.getOriginalData().get(deletedRouterPath));
+ for(Object entry: subscribers){
+ INeutronRouterAware subscriber = (INeutronRouterAware)entry;
+ subscriber.neutronRouterDeleted(router);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronRouterInterface.java class of Neutron Northbound class.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronRouter fromMd(Router router) {
+ NeutronRouter result = new NeutronRouter();
+ result.setID(String.valueOf(router.getUuid().getValue()));
+ result.setName(router.getName());
+ result.setTenantID(String.valueOf(router.getTenantId().getValue()));
+ result.setAdminStateUp(router.isAdminStateUp());
+ result.setStatus(router.getStatus());
+ result.setDistributed(router.isDistributed());
+ if (router.getGatewayPortId() != null) {
+ result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
+ }
+ if (router.getRoutes() != null) {
+ List<String> routes = new ArrayList<String>();
+ for (String route : router.getRoutes()) {
+ routes.add(route);
+ }
+ result.setRoutes(routes);
+ }
+
+ if (router.getExternalGatewayInfo() != null) {
+ NeutronRouter_NetworkReference extGwInfo = new NeutronRouter_NetworkReference();
+ extGwInfo.setNetworkID(String.valueOf(router.getExternalGatewayInfo().getExternalNetworkId().getValue()));
+ extGwInfo.setEnableSNAT(router.getExternalGatewayInfo().isEnableSnat());
+ if (router.getExternalGatewayInfo().getExternalFixedIps() != null) {
+ List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
+ for (ExternalFixedIps mdFixedIP : router.getExternalGatewayInfo().getExternalFixedIps()) {
+ Neutron_IPs fixedIP = new Neutron_IPs();
+ fixedIP.setSubnetUUID(String.valueOf(mdFixedIP.getSubnetId().getValue()));
+ fixedIP.setIpAddress(String.valueOf(mdFixedIP.getIpAddress().getValue()));
+ fixedIPs.add(fixedIP);
+ }
+ extGwInfo.setExternalFixedIPs(fixedIPs);
+ }
+ result.setExternalGatewayInfo(extGwInfo);
+ }
+
+ if (router.getInterfaces() != null) {
+ Map<String, NeutronRouter_Interface> interfaces = new HashMap<String, NeutronRouter_Interface>();
+ for (Interfaces mdInterface : router.getInterfaces()) {
+ NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
+ String id = String.valueOf(mdInterface.getUuid().getValue());
+ pojoInterface.setID(id);
+ pojoInterface.setTenantID(String.valueOf(mdInterface.getTenantId().getValue()));
+ pojoInterface.setSubnetUUID(String.valueOf(mdInterface.getSubnetId().getValue()));
+ pojoInterface.setPortUUID(String.valueOf(mdInterface.getPortId().getValue()));
+ interfaces.put(id, pojoInterface);
+ }
+ result.setInterfaces(interfaces);
+ }
+ return result;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityGroupAware;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.SecurityGroups;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronSecurityGroupDataChangeListener implements
+ DataChangeListener, AutoCloseable {
+ private static final Logger LOG = LoggerFactory
+ .getLogger(NeutronSecurityGroupDataChangeListener.class);
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronSecurityGroupDataChangeListener(DataBroker db) {
+ this.db = db;
+ InstanceIdentifier<SecurityGroup> path = InstanceIdentifier
+ .create(Neutron.class).child(SecurityGroups.class)
+ .child(SecurityGroup.class);
+ LOG.debug("Register listener for Neutron Secutiry group model data changes");
+ registration = this.db.registerDataChangeListener(
+ LogicalDatastoreType.CONFIGURATION, path, this,
+ DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}", changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(
+ INeutronSecurityGroupAware.class, this);
+ createSecurityGroup(changes, subscribers);
+ updateSecurityGroup(changes, subscribers);
+ deleteSecurityGroup(changes, subscribers);
+ }
+
+ private void createSecurityGroup(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newSecutiryGroup : changes
+ .getCreatedData().entrySet()) {
+ if (newSecutiryGroup.getValue() instanceof SecurityGroup) {
+ NeutronSecurityGroup secutiryGroup = fromMd((SecurityGroup) newSecutiryGroup
+ .getValue());
+ for (Object entry : subscribers) {
+ INeutronSecurityGroupAware subscriber = (INeutronSecurityGroupAware) entry;
+ subscriber.neutronSecurityGroupCreated(secutiryGroup);
+ }
+ }
+ }
+
+ }
+
+ private void updateSecurityGroup(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updateSecurityGroup : changes
+ .getUpdatedData().entrySet()) {
+ if (updateSecurityGroup.getValue() instanceof SecurityGroup) {
+ NeutronSecurityGroup securityGroup = fromMd((SecurityGroup) updateSecurityGroup
+ .getValue());
+ for (Object entry : subscribers) {
+ INeutronSecurityGroupAware subscriber = (INeutronSecurityGroupAware) entry;
+ subscriber.neutronSecurityGroupUpdated(securityGroup);
+ }
+ }
+ }
+ }
+
+ private void deleteSecurityGroup(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedSecurityGroup : changes
+ .getRemovedPaths()) {
+ if (deletedSecurityGroup.getTargetType()
+ .equals(SecurityGroup.class)) {
+ NeutronSecurityGroup securityGroup = fromMd((SecurityGroup) changes
+ .getOriginalData().get(deletedSecurityGroup));
+ for (Object entry : subscribers) {
+ INeutronSecurityGroupAware subscriber = (INeutronSecurityGroupAware) entry;
+ subscriber.neutronSecurityGroupDeleted(securityGroup);
+ }
+ }
+ }
+ }
+
+ private NeutronSecurityGroup fromMd(SecurityGroup group) {
+ NeutronSecurityGroup answer = new NeutronSecurityGroup();
+ if (group.getName() != null) {
+ answer.setSecurityGroupName(group.getName());
+ }
+ if (group.getDescription() != null) {
+ answer.setSecurityGroupDescription(group.getDescription());
+ }
+ if (group.getTenantId() != null) {
+ answer.setSecurityGroupTenantID(group.getTenantId().getValue()
+ .replace("-", ""));
+ }
+ if (group.getSecurityRules() != null) {
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronSecurityRuleCRUD(this);
+ INeutronSecurityRuleCRUD srCrud = interfaces
+ .getSecurityRuleInterface();
+
+ List<NeutronSecurityRule> rules = new ArrayList<NeutronSecurityRule>();
+ for (Uuid uuid : group.getSecurityRules()) {
+ rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
+ }
+ answer.setSecurityRules(rules);
+ }
+ if (group.getUuid() != null) {
+ answer.setID(group.getUuid().getValue());
+ }
+ return answer;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSecurityRuleAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionEgress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionIngress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolHttps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableBiMap;
+
+public class NeutronSecurityRuleDataChangeListener implements DataChangeListener, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleDataChangeListener.class);
+
+ private static final ImmutableBiMap<Class<? extends DirectionBase>, String> DIRECTION_MAP
+ = new ImmutableBiMap.Builder<Class<? extends DirectionBase>, String>()
+ .put(DirectionEgress.class, "egress")
+ .put(DirectionIngress.class, "ingress").build();
+ private static final ImmutableBiMap<Class<? extends ProtocolBase>, String> PROTOCOL_MAP
+ = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>, String>()
+ .put(ProtocolHttp.class, "HTTP")
+ .put(ProtocolHttps.class, "HTTPS")
+ .put(ProtocolIcmp.class, "ICMP")
+ .put(ProtocolTcp.class, "TCP")
+ .build();
+ private static final ImmutableBiMap<Class<? extends EthertypeBase>, String> ETHERTYPE_MAP
+ = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>, String>()
+ .put(EthertypeV4.class, "v4")
+ .put(EthertypeV6.class, "v6")
+ .build();
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronSecurityRuleDataChangeListener(DataBroker db) {
+ this.db = db;
+ InstanceIdentifier<SecurityRule> path = InstanceIdentifier
+ .create(Neutron.class).child(SecurityRules.class)
+ .child(SecurityRule.class);
+ LOG.debug("Register listener for Neutron Secutiry rules model data changes");
+ registration = this.db.registerDataChangeListener(
+ LogicalDatastoreType.CONFIGURATION, path, this,
+ DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}", changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(
+ INeutronSecurityRuleAware.class, this);
+ createSecurityRule(changes, subscribers);
+ updateSecurityRule(changes, subscribers);
+ deleteSecurityRule(changes, subscribers);
+ }
+
+ private void createSecurityRule(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newSecutiryRule : changes
+ .getCreatedData().entrySet()) {
+ if (newSecutiryRule.getValue() instanceof SecurityRule) {
+ NeutronSecurityRule secutiryRule = fromMd((SecurityRule) newSecutiryRule
+ .getValue());
+ for (Object entry : subscribers) {
+ INeutronSecurityRuleAware subscriber = (INeutronSecurityRuleAware) entry;
+ subscriber.neutronSecurityRuleCreated(secutiryRule);
+ }
+ }
+ }
+
+ }
+
+ private void updateSecurityRule(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updateSecurityRule : changes
+ .getUpdatedData().entrySet()) {
+ if (updateSecurityRule.getValue() instanceof SecurityRule) {
+ NeutronSecurityRule securityRule = fromMd((SecurityRule) updateSecurityRule
+ .getValue());
+ for (Object entry : subscribers) {
+ INeutronSecurityRuleAware subscriber = (INeutronSecurityRuleAware) entry;
+ subscriber.neutronSecurityRuleUpdated(securityRule);
+ }
+ }
+ }
+ }
+
+ private void deleteSecurityRule(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedSecurityRule : changes
+ .getRemovedPaths()) {
+ if (deletedSecurityRule.getTargetType().equals(SecurityRule.class)) {
+ NeutronSecurityRule securityRule = fromMd((SecurityRule) changes
+ .getOriginalData().get(deletedSecurityRule));
+ for (Object entry : subscribers) {
+ INeutronSecurityRuleAware subscriber = (INeutronSecurityRuleAware) entry;
+ subscriber.neutronSecurityRuleDeleted(securityRule);
+ }
+ }
+ }
+ }
+
+ private NeutronSecurityRule fromMd(SecurityRule rule) {
+ NeutronSecurityRule answer = new NeutronSecurityRule();
+ if (rule.getTenantId() != null) {
+ answer.setSecurityRuleTenantID(rule.getTenantId().getValue()
+ .replace("-", ""));
+ }
+ if (rule.getDirection() != null) {
+ answer.setSecurityRuleDirection(DIRECTION_MAP.get(rule
+ .getDirection()));
+ }
+ if (rule.getSecurityGroupId() != null) {
+ answer.setSecurityRuleGroupID(rule.getSecurityGroupId().getValue());
+ }
+ if (rule.getRemoteGroupId() != null) {
+ answer.setSecurityRemoteGroupID(rule.getRemoteGroupId().getValue());
+ }
+ if (rule.getRemoteIpPrefix() != null) {
+ answer.setSecurityRuleRemoteIpPrefix(rule.getRemoteIpPrefix().getIpv4Prefix()!= null?
+ rule.getRemoteIpPrefix().getIpv4Prefix().getValue():rule.getRemoteIpPrefix().getIpv6Prefix().getValue());
+ }
+ if (rule.getProtocol() != null) {
+ answer.setSecurityRuleProtocol(PROTOCOL_MAP.get(rule.getProtocol()));
+ }
+ if (rule.getEthertype() != null) {
+ answer.setSecurityRuleEthertype(ETHERTYPE_MAP.get(rule
+ .getEthertype()));
+ }
+ if (rule.getPortRangeMin() != null) {
+ answer.setSecurityRulePortMin(Integer.valueOf(rule
+ .getPortRangeMin()));
+ }
+ if (rule.getPortRangeMax() != null) {
+ answer.setSecurityRulePortMax(Integer.valueOf(rule
+ .getPortRangeMax()));
+ }
+ if (rule.getId() != null) {
+ answer.setID(rule.getId().getValue());
+ }
+ return answer;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, 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
+ */
+package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnetIPAllocationPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronSubnetAware;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Base;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Off;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Slaac;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Stateless;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.AllocationPools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableBiMap;
+
+public class NeutronSubnetChangeListener implements DataChangeListener, AutoCloseable{
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronSubnetChangeListener.class);
+
+ private static final ImmutableBiMap<Class<? extends IpVersionBase>,Integer> IPV_MAP
+ = new ImmutableBiMap.Builder<Class<? extends IpVersionBase>,Integer>()
+ .put(IpVersionV4.class,Integer.valueOf(4))
+ .put(IpVersionV6.class,Integer.valueOf(6))
+ .build();
+
+ private static final ImmutableBiMap<Class<? extends Dhcpv6Base>,String> DHCPV6_MAP
+ = new ImmutableBiMap.Builder<Class<? extends Dhcpv6Base>,String>()
+ .put(Dhcpv6Off.class,"off")
+ .put(Dhcpv6Stateful.class,"dhcpv6-stateful")
+ .put(Dhcpv6Slaac.class,"slaac")
+ .put(Dhcpv6Stateless.class,"dhcpv6-stateless")
+ .build();
+
+ private ListenerRegistration<DataChangeListener> registration;
+ private DataBroker db;
+
+ public NeutronSubnetChangeListener(DataBroker db){
+ this.db = db;
+ InstanceIdentifier<Subnet> path = InstanceIdentifier
+ .create(Neutron.class)
+ .child(Subnets.class)
+ .child(Subnet.class);
+ LOG.debug("Register listener for Neutron Subnet model data changes");
+ registration =
+ this.db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, this, DataChangeScope.ONE);
+
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ LOG.trace("Data changes : {}",changes);
+
+ Object[] subscribers = NeutronIAwareUtil.getInstances(INeutronSubnetAware.class, this);
+ createSubnet(changes, subscribers);
+ updateSubnet(changes, subscribers);
+ deleteSubnet(changes, subscribers);
+ }
+
+ private void createSubnet(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> newSubnet : changes.getCreatedData().entrySet()) {
+ if(newSubnet.getValue() instanceof Subnet){
+ NeutronSubnet subnet = fromMd((Subnet)newSubnet.getValue());
+ for(Object entry: subscribers){
+ INeutronSubnetAware subscriber = (INeutronSubnetAware)entry;
+ subscriber.neutronSubnetCreated(subnet);
+ }
+ }
+ }
+ }
+
+ private void updateSubnet(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (Entry<InstanceIdentifier<?>, DataObject> updateSubnet : changes.getUpdatedData().entrySet()) {
+ if(updateSubnet.getValue() instanceof Subnet){
+ NeutronSubnet subnet = fromMd((Subnet)updateSubnet.getValue());
+ for(Object entry: subscribers){
+ INeutronSubnetAware subscriber = (INeutronSubnetAware)entry;
+ subscriber.neutronSubnetUpdated(subnet);
+ }
+ }
+ }
+ }
+
+ private void deleteSubnet(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes,
+ Object[] subscribers) {
+ for (InstanceIdentifier<?> deletedSubnetPath : changes.getRemovedPaths()) {
+ if(deletedSubnetPath.getTargetType().equals(Subnet.class)){
+ NeutronSubnet subnet = fromMd((Subnet)changes.getOriginalData().get(deletedSubnetPath));
+ for(Object entry: subscribers){
+ INeutronSubnetAware subscriber = (INeutronSubnetAware)entry;
+ subscriber.neutronSubnetDeleted(subnet);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is borrowed from NeutronSubnetInterface.java class of Neutron Northbound class.
+ * We will be utilizing similar code from other classes from the same package of neutron project.
+ */
+ private NeutronSubnet fromMd(Subnet subnet) {
+ NeutronSubnet result = new NeutronSubnet();
+ result.setName(subnet.getName());
+ result.setTenantID(String.valueOf(subnet.getTenantId().getValue()).replace("-",""));
+ result.setNetworkUUID(subnet.getNetworkId().getValue());
+ result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
+ result.setCidr(subnet.getCidr());
+ result.setGatewayIP(String.valueOf(subnet.getGatewayIp().getValue()));
+ result.setIpV6RaMode(DHCPV6_MAP.get(subnet.getIpv6RaMode()));
+ result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
+ result.setEnableDHCP(subnet.isEnableDhcp());
+ if (subnet.getAllocationPools() != null) {
+ List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ for (AllocationPools allocationPool : subnet.getAllocationPools()) {
+ NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
+ pool.setPoolStart(allocationPool.getStart());
+ pool.setPoolEnd(allocationPool.getEnd());
+ allocationPools.add(pool);
+ }
+ result.setAllocationPools(allocationPools);
+ }
+ if (subnet.getDnsNameservers() != null) {
+ List<String> dnsNameServers = new ArrayList<String>();
+ for (IpAddress dnsNameServer : subnet.getDnsNameservers()) {
+ dnsNameServers.add(String.valueOf(dnsNameServer.getValue()));
+ }
+ result.setDnsNameservers(dnsNameServers);
+ }
+ result.setID(subnet.getUuid().getValue());
+
+ // read through the ports and put the ones in this subnet into the internal
+ // myPorts object.
+ Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
+ .fetchINeutronPortCRUD(this);
+ INeutronPortCRUD portIf = interfaces.getPortInterface();
+ for (NeutronPort port : portIf.getAllPorts()) {
+ if (port.getFixedIPs() != null) {
+ for (Neutron_IPs ip : port.getFixedIPs()) {
+ if (ip.getSubnetUUID().equals(result.getID())) {
+ allPorts.add(port);
+ }
+ }
+ }
+ }
+ List<NeutronPort> ports = new ArrayList<NeutronPort>();
+ ports.addAll(allPorts);
+ result.setPorts(ports);
+ return result;
+ }
+
+ @Override
+ public void close() throws Exception {
+ registration.close();
+ }
+
+}
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.NeutronFirewall;
-import org.opendaylight.neutron.spi.NeutronFirewallPolicy;
-import org.opendaylight.neutron.spi.NeutronFirewallRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewall;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallPolicy;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFirewallRule;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.osgi.framework.ServiceReference;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.opendaylight.neutron.spi.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSubnet;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.powermock.modules.junit4.PowerMockRunner;
/**
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
-import org.opendaylight.neutron.spi.NeutronSecurityRule;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.osgi.framework.ServiceReference;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.opendaylight.neutron.spi.NeutronRouter;
-import org.opendaylight.neutron.spi.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.SouthboundEvent.Type;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronFloatingIP;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronRouter;
-import org.opendaylight.neutron.spi.NeutronRouter_Interface;
-import org.opendaylight.neutron.spi.NeutronSubnet;
-import org.opendaylight.neutron.spi.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronRouter_Interface;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSubnet;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.ArpProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.NeutronPort;
-import org.opendaylight.neutron.spi.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.NeutronNetwork;
-import org.opendaylight.neutron.spi.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronPort;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
import org.opendaylight.ovsdb.openstack.netvirt.api.VlanConfigurationCache;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronNetwork;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
/*
-* Copyright (C) 2014 Red Hat, Inc.
+* Copyright (C) 2014 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,
/*
-* Copyright (C) 2014 Red Hat, Inc.
+* Copyright (C) 2014 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,
/*
- * Copyright (C) 2015 Red Hat, Inc.
+ * Copyright (C) 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,
/*
- * Copyright (C) 2014 Red Hat, Inc.
+ * Copyright (C) 2014 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,
/*
- * Copyright (C) 2015 Red Hat, Inc.
+ * Copyright (C) 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,