<groupId>org.opendaylight.controller</groupId>
<artifactId>usermanager.northbound</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>networkconfig.neutron.northbound</artifactId>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</fileset>
<mapper>
<regexpmapper from="^(.*)/([^/]+)/*/target/enunciate/generate/swagger/ui/(.*Northbound).*$$" to="\3"></regexpmapper>
- <regexpmapper from="^(.*)/neutron/([^/]+)/*/target/enunciate/generate/swagger/ui/(.*resource-list.json)$$" to="neutron-\3"></regexpmapper>
<regexpmapper from="^(.*)/([^/]+)/*/target/enunciate/generate/swagger/ui/(.*resource-list.json)$$" to="\2-\3"></regexpmapper>
</mapper>
</copy>
<path>
<fileset dir="${api.dir}">
<include name="**/*resource-list.json"></include>
- <exclude name="**/neutron*"></exclude>
</fileset>
</path>
<sequential>
<var name="jsoncontent" unset="true"></var>
</sequential>
</for>
- <sequential>
- <loadfile property="jsoncontent" srcfile="${api.dir}/neutron-resource-list.json">
- <filterchain>
- <headfilter lines="46"></headfilter>
- <tailfilter lines="42"></tailfilter>
- </filterchain>
- </loadfile>
- <echo append="true" file="${resource.dir}/apilist.json" message="${jsoncontent},"></echo>
- <var name="jsoncontent" unset="true"></var>
- </sequential>
<echo append="true" file="${resource.dir}/apilist.json">{ }
]
}</echo>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>
- </parent>
- <artifactId>features-neutron</artifactId>
- <version>${networkconfig.neutron.version}</version>
- <packaging>jar</packaging>
-
- <properties>
- <features.file>features.xml</features.file>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.aaa</groupId>
- <artifactId>features-aaa</artifactId>
- <version>${aaa.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>networkconfig.neutron</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-servlet</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.moxy</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>networkconfig.neutron</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-net</groupId>
- <artifactId>commons-net</artifactId>
- </dependency>
- <!-- test to validate features.xml -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>features-test</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <filtering>true</filtering>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>filter</id>
- <goals>
- <goal>resources</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/${features.file}</file>
- <type>xml</type>
- <classifier>features</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
- <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>
- </systemPropertyVariables>
- <dependenciesToScan>
- <dependency>org.opendaylight.yangtools:features-test</dependency>
- </dependenciesToScan>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-
-<features name="odl-neutron-${networkconfig.neutron.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <repository>mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features</repository>
- <feature name='odl-neutron-all' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: API">
- <feature version='${networkconfig.neutron.version}'>odl-neutron-api</feature>
- <feature version='${networkconfig.neutron.version}'>odl-neutron-northbound</feature>
- <feature version='${networkconfig.neutron.version}'>odl-neutron-implementation</feature>
- </feature>
- <feature name='odl-neutron-northbound' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: Northbound">
- <feature version='${aaa.version}'>odl-aaa-authn</feature>
- <feature>war</feature>
- <feature version='${networkconfig.neutron.version}'>odl-neutron-api</feature>
- <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version}</bundle>
- <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version}</bundle>
- <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/${eclipse.persistence.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/networkconfig.neutron.northbound/${networkconfig.neutron.northbound.version}</bundle>
- <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
- <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
- <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
- <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
- </feature>
-
- <feature name='odl-neutron-api' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: API">
- <bundle>mvn:org.opendaylight.controller/networkconfig.neutron/${networkconfig.neutron.version}</bundle>
- <bundle>mvn:commons-net/commons-net/${commons.net.version}</bundle>
- <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
- </feature>
- <feature name='odl-neutron-implementation' version='${networkconfig.neutron.version}' description="OpenDaylight :: Neutron :: Implementation">
- <feature version='${networkconfig.neutron.version}'>odl-neutron-api</feature>
- <feature>war</feature>
- <bundle>mvn:org.opendaylight.controller/networkconfig.neutron.implementation/${networkconfig.neutron.implementation.version}</bundle>
- <bundle>mvn:org.osgi/org.osgi.core/${osgi.core.version}</bundle>
- </feature>
-</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
- </parent>
- <artifactId>networkconfig.neutron.implementation</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>networkconfig.neutron</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>*</Import-Package>
- <Bundle-Activator>org.opendaylight.controller.networkconfig.neutron.implementation.Activator</Bundle-Activator>
- </instructions>
- <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
- </scm>
-
- <distributionManagement>
- <!-- OpenDayLight Released artifact -->
- <repository>
- <id>opendaylight-release</id>
- <url>${nexusproxy}/repositories/${nexus.repository.release}/</url>
- </repository>
- <!-- OpenDayLight Snapshot artifact -->
- <snapshotRepository>
- <id>opendaylight-snapshot</id>
- <url>${nexusproxy}/repositories/${nexus.repository.snapshot}/</url>
- </snapshotRepository>
- <!-- Site deployment -->
- <site>
- <id>website</id>
- <url>${sitedeploy}</url>
- </site>
- </distributionManagement>
-</project>
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.implementation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Activator implements BundleActivator {
- protected static final Logger logger = LoggerFactory
- .getLogger(Activator.class);
- private List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
-
- @Override
- public void start(BundleContext context) throws Exception {
- NeutronRouterInterface neutronRouterInterface = new NeutronRouterInterface();
- ServiceRegistration<INeutronRouterCRUD> neutronRouterInterfaceRegistration = context.registerService(INeutronRouterCRUD.class, neutronRouterInterface, null);
- if(neutronRouterInterfaceRegistration != null) {
- registrations.add(neutronRouterInterfaceRegistration);
- }
- NeutronPortInterface neutronPortInterface = new NeutronPortInterface();
- ServiceRegistration<INeutronPortCRUD> neutronPortInterfaceRegistration = context.registerService(INeutronPortCRUD.class, neutronPortInterface, null);
- if(neutronPortInterfaceRegistration != null) {
- registrations.add(neutronPortInterfaceRegistration);
- }
-
- NeutronSubnetInterface neutronSubnetInterface = new NeutronSubnetInterface();
- ServiceRegistration<INeutronSubnetCRUD> neutronSubnetInterfaceRegistration = context.registerService(INeutronSubnetCRUD.class, neutronSubnetInterface, null);
- if(neutronSubnetInterfaceRegistration != null) {
- registrations.add(neutronSubnetInterfaceRegistration);
- }
-
- NeutronNetworkInterface neutronNetworkInterface = new NeutronNetworkInterface();
- ServiceRegistration<INeutronNetworkCRUD> neutronNetworkInterfaceRegistration = context.registerService(INeutronNetworkCRUD.class, neutronNetworkInterface, null);
- if(neutronNetworkInterfaceRegistration != null) {
- registrations.add(neutronNetworkInterfaceRegistration);
- }
-
- NeutronSecurityGroupInterface neutronSecurityGroupInterface = new NeutronSecurityGroupInterface();
- ServiceRegistration<INeutronSecurityGroupCRUD> neutronSecurityGroupInterfaceRegistration = context.registerService(INeutronSecurityGroupCRUD.class, neutronSecurityGroupInterface, null);
- if(neutronSecurityGroupInterfaceRegistration != null) {
- registrations.add(neutronSecurityGroupInterfaceRegistration);
- }
-
- NeutronSecurityRuleInterface neutronSecurityRuleInterface = new NeutronSecurityRuleInterface();
- ServiceRegistration<INeutronSecurityRuleCRUD> neutronSecurityRuleInterfaceRegistration = context.registerService(INeutronSecurityRuleCRUD.class, neutronSecurityRuleInterface, null);
- if(neutronSecurityRuleInterfaceRegistration != null) {
- registrations.add(neutronSecurityRuleInterfaceRegistration);
- }
-
- NeutronFirewallInterface neutronFirewallInterface = new NeutronFirewallInterface();
- ServiceRegistration<INeutronFirewallCRUD> neutronFirewallInterfaceRegistration = context.registerService(INeutronFirewallCRUD.class, neutronFirewallInterface, null);
- if(neutronFirewallInterfaceRegistration != null) {
- registrations.add(neutronFirewallInterfaceRegistration);
- }
-
- NeutronFirewallPolicyInterface neutronFirewallPolicyInterface = new NeutronFirewallPolicyInterface();
- ServiceRegistration<INeutronFirewallPolicyCRUD> neutronFirewallPolicyInterfaceRegistration = context.registerService(INeutronFirewallPolicyCRUD.class, neutronFirewallPolicyInterface, null);
- if(neutronFirewallPolicyInterfaceRegistration != null) {
- registrations.add(neutronFirewallPolicyInterfaceRegistration);
- }
-
- NeutronFirewallRuleInterface neutronFirewallRuleInterface = new NeutronFirewallRuleInterface();
- ServiceRegistration<INeutronFirewallRuleCRUD> neutronFirewallRuleInterfaceRegistration = context.registerService(INeutronFirewallRuleCRUD.class, neutronFirewallRuleInterface, null);
- if(neutronFirewallRuleInterfaceRegistration != null) {
- registrations.add(neutronFirewallRuleInterfaceRegistration);
- }
-
- NeutronLoadBalancerInterface neutronLoadBalancerInterface = new NeutronLoadBalancerInterface();
- ServiceRegistration<INeutronLoadBalancerCRUD> neutronLoadBalancerInterfaceRegistration = context.registerService(INeutronLoadBalancerCRUD.class, neutronLoadBalancerInterface, null);
- if(neutronFirewallInterfaceRegistration != null) {
- registrations.add(neutronLoadBalancerInterfaceRegistration);
- }
-
- NeutronLoadBalancerPoolInterface neutronLoadBalancerPoolInterface = new NeutronLoadBalancerPoolInterface();
- ServiceRegistration<INeutronLoadBalancerPoolCRUD> neutronLoadBalancerPoolInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolCRUD.class, neutronLoadBalancerPoolInterface, null);
- if(neutronLoadBalancerPoolInterfaceRegistration != null) {
- registrations.add(neutronLoadBalancerPoolInterfaceRegistration);
- }
-
- NeutronLoadBalancerListenerInterface neutronLoadBalancerListenerInterface = new NeutronLoadBalancerListenerInterface();
- ServiceRegistration<INeutronLoadBalancerListenerCRUD> neutronLoadBalancerListenerInterfaceRegistration = context.registerService(INeutronLoadBalancerListenerCRUD.class, neutronLoadBalancerListenerInterface, null);
- if(neutronLoadBalancerListenerInterfaceRegistration != null) {
- registrations.add(neutronLoadBalancerListenerInterfaceRegistration);
- }
-
- NeutronLoadBalancerHealthMonitorInterface neutronLoadBalancerHealthMonitorInterface = new NeutronLoadBalancerHealthMonitorInterface();
- ServiceRegistration<INeutronLoadBalancerHealthMonitorCRUD> neutronLoadBalancerHealthMonitorInterfaceRegistration = context.registerService(INeutronLoadBalancerHealthMonitorCRUD.class, neutronLoadBalancerHealthMonitorInterface, null);
- if(neutronLoadBalancerHealthMonitorInterfaceRegistration != null) {
- registrations.add(neutronLoadBalancerHealthMonitorInterfaceRegistration);
- }
-
- NeutronLoadBalancerPoolMemberInterface neutronLoadBalancerPoolMemberInterface = new NeutronLoadBalancerPoolMemberInterface();
- ServiceRegistration<INeutronLoadBalancerPoolMemberCRUD> neutronLoadBalancerPoolMemberInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolMemberCRUD.class, neutronLoadBalancerPoolMemberInterface, null);
- if(neutronLoadBalancerPoolMemberInterfaceRegistration != null) {
- registrations.add(neutronLoadBalancerPoolMemberInterfaceRegistration);
- }
-
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- for(ServiceRegistration registration : registrations) {
- if(registration != null) {
- registration.unregister();
- }
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewall;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronFirewallInterface implements INeutronFirewallCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallInterface.class);
-
- private ConcurrentMap<String, NeutronFirewall> firewallDB = new ConcurrentHashMap<String, NeutronFirewall>();
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronFirewallExists(String uuid) {
- return firewallDB.containsKey(uuid);
- }
-
- @Override
- public NeutronFirewall getNeutronFirewall(String uuid) {
- if (!neutronFirewallExists(uuid)) {
- logger.debug("No Firewall Have Been Defined");
- return null;
- }
- return firewallDB.get(uuid);
- }
-
- @Override
- public List<NeutronFirewall> getAllNeutronFirewalls() {
- Set<NeutronFirewall> allFirewalls = new HashSet<NeutronFirewall>();
- for (Entry<String, NeutronFirewall> entry : firewallDB.entrySet()) {
- NeutronFirewall firewall = entry.getValue();
- allFirewalls.add(firewall);
- }
- logger.debug("Exiting getFirewalls, Found {} OpenStackFirewall", allFirewalls.size());
- List<NeutronFirewall> ans = new ArrayList<NeutronFirewall>();
- ans.addAll(allFirewalls);
- return ans;
- }
-
- @Override
- public boolean addNeutronFirewall(NeutronFirewall input) {
- if (neutronFirewallExists(input.getFirewallUUID())) {
- return false;
- }
- firewallDB.putIfAbsent(input.getFirewallUUID(), input);
- return true;
- }
-
- @Override
- public boolean removeNeutronFirewall(String uuid) {
- if (!neutronFirewallExists(uuid)) {
- return false;
- }
- firewallDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateNeutronFirewall(String uuid, NeutronFirewall delta) {
- if (!neutronFirewallExists(uuid)) {
- return false;
- }
- NeutronFirewall target = firewallDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronFirewallInUse(String firewallUUID) {
- return !neutronFirewallExists(firewallUUID);
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronFirewallPolicyInterface implements INeutronFirewallPolicyCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallPolicyInterface.class);
-
- private ConcurrentMap<String, NeutronFirewallPolicy> firewallPolicyDB = new ConcurrentHashMap<String, NeutronFirewallPolicy>();
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronFirewallPolicyExists(String uuid) {
- return firewallPolicyDB.containsKey(uuid);
- }
-
- @Override
- public NeutronFirewallPolicy getNeutronFirewallPolicy(String uuid) {
- if (!neutronFirewallPolicyExists(uuid)) {
- logger.debug("No Firewall Rule Have Been Defined");
- return null;
- }
- return firewallPolicyDB.get(uuid);
- }
-
- @Override
- public List<NeutronFirewallPolicy> getAllNeutronFirewallPolicies() {
- Set<NeutronFirewallPolicy> allFirewallPolicies = new HashSet<NeutronFirewallPolicy>();
- for (Entry<String, NeutronFirewallPolicy> entry : firewallPolicyDB.entrySet()) {
- NeutronFirewallPolicy firewallPolicy = entry.getValue();
- allFirewallPolicies.add(firewallPolicy);
- }
- logger.debug("Exiting getFirewallPolicies, Found {} OpenStackFirewallPolicy", allFirewallPolicies.size());
- List<NeutronFirewallPolicy> ans = new ArrayList<NeutronFirewallPolicy>();
- ans.addAll(allFirewallPolicies);
- return ans;
- }
-
- @Override
- public boolean addNeutronFirewallPolicy(NeutronFirewallPolicy input) {
- if (neutronFirewallPolicyExists(input.getFirewallPolicyUUID())) {
- return false;
- }
- firewallPolicyDB.putIfAbsent(input.getFirewallPolicyUUID(), input);
- return true;
- }
-
- @Override
- public boolean removeNeutronFirewallPolicy(String uuid) {
- if (!neutronFirewallPolicyExists(uuid)) {
- return false;
- }
- firewallPolicyDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateNeutronFirewallPolicy(String uuid, NeutronFirewallPolicy delta) {
- if (!neutronFirewallPolicyExists(uuid)) {
- return false;
- }
- NeutronFirewallPolicy target = firewallPolicyDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronFirewallPolicyInUse(String firewallPolicyUUID) {
- return !neutronFirewallPolicyExists(firewallPolicyUUID);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronFirewallRuleInterface implements INeutronFirewallRuleCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronFirewallRuleInterface.class);
-
- private ConcurrentMap<String, NeutronFirewallRule> firewallRuleDB = new ConcurrentHashMap<String, NeutronFirewallRule>();
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronFirewallRuleExists(String uuid) {
- return firewallRuleDB.containsKey(uuid);
- }
-
- @Override
- public NeutronFirewallRule getNeutronFirewallRule(String uuid) {
- if (!neutronFirewallRuleExists(uuid)) {
- logger.debug("No Firewall Rule Have Been Defined");
- return null;
- }
- return firewallRuleDB.get(uuid);
- }
-
- @Override
- public List<NeutronFirewallRule> getAllNeutronFirewallRules() {
- Set<NeutronFirewallRule> allFirewallRules = new HashSet<NeutronFirewallRule>();
- for (Entry<String, NeutronFirewallRule> entry : firewallRuleDB.entrySet()) {
- NeutronFirewallRule firewallRule = entry.getValue();
- allFirewallRules.add(firewallRule);
- }
- logger.debug("Exiting getFirewallRules, Found {} OpenStackFirewallRule", allFirewallRules.size());
- List<NeutronFirewallRule> ans = new ArrayList<NeutronFirewallRule>();
- ans.addAll(allFirewallRules);
- return ans;
- }
-
- @Override
- public boolean addNeutronFirewallRule(NeutronFirewallRule input) {
- if (neutronFirewallRuleExists(input.getFirewallRuleUUID())) {
- return false;
- }
- firewallRuleDB.putIfAbsent(input.getFirewallRuleUUID(), input);
- return true;
- }
-
- @Override
- public boolean removeNeutronFirewallRule(String uuid) {
- if (!neutronFirewallRuleExists(uuid)) {
- return false;
- }
- firewallRuleDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateNeutronFirewallRule(String uuid, NeutronFirewallRule delta) {
- if (!neutronFirewallRuleExists(uuid)) {
- return false;
- }
- NeutronFirewallRule target = firewallRuleDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronFirewallRuleInUse(String firewallRuleUUID) {
- return !neutronFirewallRuleExists(firewallRuleUUID);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-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.networkconfig.neutron.INeutronFloatingIPCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronFloatingIPInterface.class);
-
- private ConcurrentMap<String, NeutronFloatingIP> floatingIPDB = new ConcurrentHashMap<String, NeutronFloatingIP>();
-
- // this method uses reflection to update an object from it's delta.
-
- @SuppressWarnings("unused")
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- // IfNBFloatingIPCRUD interface methods
-
- @Override
- public boolean floatingIPExists(String uuid) {
- return floatingIPDB.containsKey(uuid);
- }
-
- @Override
- public NeutronFloatingIP getFloatingIP(String uuid) {
- if (!floatingIPExists(uuid)) {
- return null;
- }
- return floatingIPDB.get(uuid);
- }
-
- @Override
- public List<NeutronFloatingIP> getAllFloatingIPs() {
- Set<NeutronFloatingIP> allIPs = new HashSet<NeutronFloatingIP>();
- for (Entry<String, NeutronFloatingIP> entry : floatingIPDB.entrySet()) {
- NeutronFloatingIP floatingip = entry.getValue();
- allIPs.add(floatingip);
- }
- 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) {
- INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
- INeutronSubnetCRUD subnetCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- INeutronPortCRUD portCRUD = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
-
- if (floatingIPExists(input.getID())) {
- return false;
- }
- //if floating_ip_address isn't there, allocate from the subnet pool
- NeutronSubnet subnet = subnetCRUD.getSubnet(networkCRUD.getNetwork(input.getFloatingNetworkUUID()).getSubnets().get(0));
- if (input.getFloatingIPAddress() == null) {
- input.setFloatingIPAddress(subnet.getLowAddr());
- }
- subnet.allocateIP(input.getFloatingIPAddress());
-
- //if port_id is there, bind port to this floating ip
- if (input.getPortUUID() != null) {
- NeutronPort port = portCRUD.getPort(input.getPortUUID());
- port.addFloatingIP(input.getFixedIPAddress(), input);
- }
-
- floatingIPDB.putIfAbsent(input.getID(), input);
- return true;
- }
-
- @Override
- public boolean removeFloatingIP(String uuid) {
- INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
- INeutronSubnetCRUD subnetCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- INeutronPortCRUD portCRUD = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
-
- if (!floatingIPExists(uuid)) {
- return false;
- }
- NeutronFloatingIP floatIP = getFloatingIP(uuid);
- //if floating_ip_address isn't there, allocate from the subnet pool
- NeutronSubnet subnet = subnetCRUD.getSubnet(networkCRUD.getNetwork(floatIP.getFloatingNetworkUUID()).getSubnets().get(0));
- subnet.releaseIP(floatIP.getFloatingIPAddress());
- if (floatIP.getPortUUID() != null) {
- NeutronPort port = portCRUD.getPort(floatIP.getPortUUID());
- port.removeFloatingIP(floatIP.getFixedIPAddress());
- }
- floatingIPDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateFloatingIP(String uuid, NeutronFloatingIP delta) {
- INeutronPortCRUD portCRUD = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
-
- if (!floatingIPExists(uuid)) {
- return false;
- }
- NeutronFloatingIP target = floatingIPDB.get(uuid);
- if (target.getPortUUID() != null) {
- NeutronPort port = portCRUD.getPort(target.getPortUUID());
- port.removeFloatingIP(target.getFixedIPAddress());
- }
-
- //if port_id is there, bind port to this floating ip
- if (delta.getPortUUID() != null) {
- NeutronPort port = portCRUD.getPort(delta.getPortUUID());
- port.addFloatingIP(delta.getFixedIPAddress(), delta);
- }
-
- target.setPortUUID(delta.getPortUUID());
- target.setFixedIPAddress(delta.getFixedIPAddress());
- return true;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerHealthMonitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronLoadBalancerHealthMonitorInterface implements INeutronLoadBalancerHealthMonitorCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerHealthMonitorInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancerHealthMonitor> loadBalancerHealthMonitorDB = new ConcurrentHashMap<String, NeutronLoadBalancerHealthMonitor>();
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronLoadBalancerHealthMonitorExists(String uuid) {
- return loadBalancerHealthMonitorDB.containsKey(uuid);
- }
-
- @Override
- public NeutronLoadBalancerHealthMonitor getNeutronLoadBalancerHealthMonitor(String uuid) {
- if (!neutronLoadBalancerHealthMonitorExists(uuid)) {
- logger.debug("No LoadBalancerHealthMonitor has Been Defined");
- return null;
- }
- return loadBalancerHealthMonitorDB.get(uuid);
- }
-
- @Override
- public List<NeutronLoadBalancerHealthMonitor> getAllNeutronLoadBalancerHealthMonitors() {
- Set<NeutronLoadBalancerHealthMonitor> allLoadBalancerHealthMonitors = new HashSet<NeutronLoadBalancerHealthMonitor>();
- for (Entry<String, NeutronLoadBalancerHealthMonitor> entry : loadBalancerHealthMonitorDB.entrySet()) {
- NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor = entry.getValue();
- allLoadBalancerHealthMonitors.add(loadBalancerHealthMonitor);
- }
- logger.debug("Exiting getLoadBalancerHealthMonitors, Found {} OpenStackLoadBalancerHealthMonitor", allLoadBalancerHealthMonitors.size());
- List<NeutronLoadBalancerHealthMonitor> ans = new ArrayList<NeutronLoadBalancerHealthMonitor>();
- ans.addAll(allLoadBalancerHealthMonitors);
- return ans;
- }
-
- @Override
- public boolean addNeutronLoadBalancerHealthMonitor(NeutronLoadBalancerHealthMonitor input) {
- if (neutronLoadBalancerHealthMonitorExists(input.getLoadBalancerHealthMonitorID())) {
- return false;
- }
- loadBalancerHealthMonitorDB.putIfAbsent(input.getLoadBalancerHealthMonitorID(), input);
- //TODO: add code to find INeutronLoadBalancerHealthMonitorAware services and call newtorkCreated on them
- return true;
- }
-
- @Override
- public boolean removeNeutronLoadBalancerHealthMonitor(String uuid) {
- if (!neutronLoadBalancerHealthMonitorExists(uuid)) {
- return false;
- }
- loadBalancerHealthMonitorDB.remove(uuid);
- //TODO: add code to find INeutronLoadBalancerHealthMonitorAware services and call newtorkDeleted on them
- return true;
- }
-
- @Override
- public boolean updateNeutronLoadBalancerHealthMonitor(String uuid, NeutronLoadBalancerHealthMonitor delta) {
- if (!neutronLoadBalancerHealthMonitorExists(uuid)) {
- return false;
- }
- NeutronLoadBalancerHealthMonitor target = loadBalancerHealthMonitorDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronLoadBalancerHealthMonitorInUse(String loadBalancerHealthMonitorUUID) {
- return !neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorUUID);
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronLoadBalancerInterface implements INeutronLoadBalancerCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<String, NeutronLoadBalancer>();
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @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.getLoadBalancerID())) {
- return false;
- }
- loadBalancerDB.putIfAbsent(input.getLoadBalancerID(), 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);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronLoadBalancerListenerInterface implements INeutronLoadBalancerListenerCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerListenerInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancerListener> loadBalancerListenerDB = new ConcurrentHashMap<String, NeutronLoadBalancerListener>();
-
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronLoadBalancerListenerExists(String uuid) {
- return loadBalancerListenerDB.containsKey(uuid);
- }
-
- @Override
- public NeutronLoadBalancerListener getNeutronLoadBalancerListener(String uuid) {
- if (!neutronLoadBalancerListenerExists(uuid)) {
- logger.debug("No LoadBalancerListener Have Been Defined");
- return null;
- }
- return loadBalancerListenerDB.get(uuid);
- }
-
- @Override
- public List<NeutronLoadBalancerListener> getAllNeutronLoadBalancerListeners() {
- Set<NeutronLoadBalancerListener> allLoadBalancerListeners = new HashSet<NeutronLoadBalancerListener>();
- for (Entry<String, NeutronLoadBalancerListener> entry : loadBalancerListenerDB.entrySet()) {
- NeutronLoadBalancerListener loadBalancerListener = entry.getValue();
- allLoadBalancerListeners.add(loadBalancerListener);
- }
- logger.debug("Exiting getLoadBalancerListeners, Found {} OpenStackLoadBalancerListener", allLoadBalancerListeners.size());
- List<NeutronLoadBalancerListener> ans = new ArrayList<NeutronLoadBalancerListener>();
- ans.addAll(allLoadBalancerListeners);
- return ans;
- }
-
- @Override
- public boolean addNeutronLoadBalancerListener(NeutronLoadBalancerListener input) {
- if (neutronLoadBalancerListenerExists(input.getLoadBalancerListenerID())) {
- return false;
- }
- loadBalancerListenerDB.putIfAbsent(input.getLoadBalancerListenerID(), input);
- //TODO: add code to find INeutronLoadBalancerListenerAware services and call newtorkCreated on them
- return true;
- }
-
- @Override
- public boolean removeNeutronLoadBalancerListener(String uuid) {
- if (!neutronLoadBalancerListenerExists(uuid)) {
- return false;
- }
- loadBalancerListenerDB.remove(uuid);
- //TODO: add code to find INeutronLoadBalancerListenerAware services and call newtorkDeleted on them
- return true;
- }
-
- @Override
- public boolean updateNeutronLoadBalancerListener(String uuid, NeutronLoadBalancerListener delta) {
- if (!neutronLoadBalancerListenerExists(uuid)) {
- return false;
- }
- NeutronLoadBalancerListener target = loadBalancerListenerDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronLoadBalancerListenerInUse(String loadBalancerListenerUUID) {
- return !neutronLoadBalancerListenerExists(loadBalancerListenerUUID);
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronLoadBalancerPoolInterface implements INeutronLoadBalancerPoolCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerPoolInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<String, NeutronLoadBalancerPool>();
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @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.getLoadBalancerPoolID())) {
- return false;
- }
- loadBalancerPoolDB.putIfAbsent(input.getLoadBalancerPoolID(), 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);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class NeutronLoadBalancerPoolMemberInterface
- implements INeutronLoadBalancerPoolMemberCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancerPoolMemberInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancerPoolMember> loadBalancerPoolMemberDB = new ConcurrentHashMap<String, NeutronLoadBalancerPoolMember>();
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronLoadBalancerPoolMemberExists(String uuid) {
- return loadBalancerPoolMemberDB.containsKey(uuid);
- }
-
- @Override
- public NeutronLoadBalancerPoolMember getNeutronLoadBalancerPoolMember(String uuid) {
- if (!neutronLoadBalancerPoolMemberExists(uuid)) {
- logger.debug("No LoadBalancerPoolMember Have Been Defined");
- return null;
- }
- return loadBalancerPoolMemberDB.get(uuid);
- }
-
- @Override
- public List<NeutronLoadBalancerPoolMember> getAllNeutronLoadBalancerPoolMembers() {
- Set<NeutronLoadBalancerPoolMember> allLoadBalancerPoolMembers = new HashSet<NeutronLoadBalancerPoolMember>();
- for (Map.Entry<String, NeutronLoadBalancerPoolMember> entry : loadBalancerPoolMemberDB.entrySet()) {
- NeutronLoadBalancerPoolMember loadBalancerPoolMember = entry.getValue();
- allLoadBalancerPoolMembers.add(loadBalancerPoolMember);
- }
- logger.debug("Exiting getLoadBalancerPoolMembers, Found {} OpenStackLoadBalancerPoolMember",
- allLoadBalancerPoolMembers.size());
- List<NeutronLoadBalancerPoolMember> ans = new ArrayList<NeutronLoadBalancerPoolMember>();
- ans.addAll(allLoadBalancerPoolMembers);
- return ans;
- }
-
- @Override
- public boolean addNeutronLoadBalancerPoolMember(NeutronLoadBalancerPoolMember input) {
- if (neutronLoadBalancerPoolMemberExists(input.getPoolMemberID())) {
- return false;
- }
- loadBalancerPoolMemberDB.putIfAbsent(input.getPoolMemberID(), input);
- return true;
- }
-
- @Override
- public boolean removeNeutronLoadBalancerPoolMember(String uuid) {
- if (!neutronLoadBalancerPoolMemberExists(uuid)) {
- return false;
- }
- loadBalancerPoolMemberDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateNeutronLoadBalancerPoolMember(String uuid, NeutronLoadBalancerPoolMember delta) {
- if (!neutronLoadBalancerPoolMemberExists(uuid)) {
- return false;
- }
- NeutronLoadBalancerPoolMember target = loadBalancerPoolMemberDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronLoadBalancerPoolMemberInUse(String loadBalancerPoolMemberID) {
- return !neutronLoadBalancerPoolMemberExists(loadBalancerPoolMemberID);
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-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.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NeutronNetworkInterface implements INeutronNetworkCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronNetworkInterface.class);
- private ConcurrentMap<String, NeutronNetwork> networkDB = new ConcurrentHashMap<String, NeutronNetwork>();
-
-
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- // IfNBNetworkCRUD methods
-
- @Override
- public boolean networkExists(String uuid) {
- return networkDB.containsKey(uuid);
- }
-
- @Override
- public NeutronNetwork getNetwork(String uuid) {
- if (!networkExists(uuid)) {
- return null;
- }
- return networkDB.get(uuid);
- }
-
- @Override
- public List<NeutronNetwork> getAllNetworks() {
- Set<NeutronNetwork> allNetworks = new HashSet<NeutronNetwork>();
- for (Entry<String, NeutronNetwork> entry : networkDB.entrySet()) {
- NeutronNetwork network = entry.getValue();
- allNetworks.add(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;
- }
- networkDB.putIfAbsent(input.getID(), input);
- //TODO: add code to find INeutronNetworkAware services and call newtorkCreated on them
- return true;
- }
-
- @Override
- public boolean removeNetwork(String uuid) {
- if (!networkExists(uuid)) {
- return false;
- }
- networkDB.remove(uuid);
- //TODO: add code to find INeutronNetworkAware services and call newtorkDeleted on them
- return true;
- }
-
- @Override
- public boolean updateNetwork(String uuid, NeutronNetwork delta) {
- if (!networkExists(uuid)) {
- return false;
- }
- NeutronNetwork target = networkDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean networkInUse(String netUUID) {
- if (!networkExists(netUUID)) {
- return true;
- }
- NeutronNetwork target = networkDB.get(netUUID);
- if (target.getPortsOnNetwork().size() > 0) {
- return true;
- }
- return false;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-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.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NeutronPortInterface implements INeutronPortCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronPortInterface.class);
- private ConcurrentMap<String, NeutronPort> portDB = new ConcurrentHashMap<String, NeutronPort>();
-
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- // IfNBPortCRUD methods
-
- @Override
- public boolean portExists(String uuid) {
- return portDB.containsKey(uuid);
- }
-
- @Override
- public NeutronPort getPort(String uuid) {
- if (!portExists(uuid)) {
- return null;
- }
- return portDB.get(uuid);
- }
-
- @Override
- public List<NeutronPort> getAllPorts() {
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
- for (Entry<String, NeutronPort> entry : portDB.entrySet()) {
- NeutronPort port = entry.getValue();
- allPorts.add(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;
- }
- portDB.putIfAbsent(input.getID(), input);
- // if there are no fixed IPs, allocate one for each subnet in the network
- INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- if (input.getFixedIPs() == null){
- input.setFixedIPs(new ArrayList<Neutron_IPs>());
- }
- if (input.getFixedIPs().size() == 0) {
- List<Neutron_IPs> list = input.getFixedIPs();
- Iterator<NeutronSubnet> subnetIterator = systemCRUD.getAllSubnets().iterator();
- while (subnetIterator.hasNext()) {
- NeutronSubnet subnet = subnetIterator.next();
- if (subnet.getNetworkUUID().equals(input.getNetworkUUID())) {
- list.add(new Neutron_IPs(subnet.getID()));
- }
- }
- }
- Iterator<Neutron_IPs> fixedIPIterator = input.getFixedIPs().iterator();
- while (fixedIPIterator.hasNext()) {
- Neutron_IPs ip = fixedIPIterator.next();
- NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());
- if (ip.getIpAddress() == null) {
- ip.setIpAddress(subnet.getLowAddr());
- }
- if (!ip.getIpAddress().equals(subnet.getGatewayIP())) {
- subnet.allocateIP(ip.getIpAddress());
- }
- else {
- subnet.setGatewayIPAllocated();
- }
- subnet.addPort(input);
- }
- INeutronNetworkCRUD networkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
-
- NeutronNetwork network = networkIf.getNetwork(input.getNetworkUUID());
- network.addPort(input);
- return true;
- }
-
- @Override
- public boolean removePort(String uuid) {
- if (!portExists(uuid)) {
- return false;
- }
- NeutronPort port = getPort(uuid);
- portDB.remove(uuid);
- INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
- INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
-
- NeutronNetwork network = networkCRUD.getNetwork(port.getNetworkUUID());
- network.removePort(port);
- Iterator<Neutron_IPs> fixedIPIterator = port.getFixedIPs().iterator();
- while (fixedIPIterator.hasNext()) {
- Neutron_IPs ip = fixedIPIterator.next();
- NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());
- if (!ip.getIpAddress().equals(subnet.getGatewayIP())) {
- subnet.releaseIP(ip.getIpAddress());
- }
- else {
- subnet.resetGatewayIPAllocated();
- }
- subnet.removePort(port);
- }
- return true;
- }
-
- @Override
- public boolean updatePort(String uuid, NeutronPort delta) {
- if (!portExists(uuid)) {
- return false;
- }
- NeutronPort target = portDB.get(uuid);
- // remove old Fixed_IPs
- if (delta.getFixedIPs() != null) {
- NeutronPort port = getPort(uuid);
- INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- for (Neutron_IPs ip: port.getFixedIPs()) {
- NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());
- subnet.releaseIP(ip.getIpAddress());
- }
-
- // allocate new Fixed_IPs
- for (Neutron_IPs ip: delta.getFixedIPs()) {
- NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());
- if (ip.getIpAddress() == null) {
- ip.setIpAddress(subnet.getLowAddr());
- }
- subnet.allocateIP(ip.getIpAddress());
- }
- }
- return overwrite(target, delta);
- }
-
- @Override
- public boolean macInUse(String macAddress) {
- List<NeutronPort> ports = getAllPorts();
- Iterator<NeutronPort> portIterator = ports.iterator();
- while (portIterator.hasNext()) {
- NeutronPort port = portIterator.next();
- if (macAddress.equalsIgnoreCase(port.getMacAddress())) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public NeutronPort getGatewayPort(String subnetUUID) {
- INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- NeutronSubnet subnet = systemCRUD.getSubnet(subnetUUID);
- Iterator<NeutronPort> portIterator = getAllPorts().iterator();
- while (portIterator.hasNext()) {
- NeutronPort port = portIterator.next();
- List<Neutron_IPs> fixedIPs = port.getFixedIPs();
- if (fixedIPs.size() == 1) {
- if (subnet.getGatewayIP().equals(fixedIPs.get(0).getIpAddress())) {
- return port;
- }
- }
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-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.networkconfig.neutron.INeutronRouterCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NeutronRouterInterface implements INeutronRouterCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronRouterInterface.class);
- private ConcurrentMap<String, NeutronRouter> routerDB = new ConcurrentHashMap<String, NeutronRouter>();
- // methods needed for creating caches
-
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
-
- // IfNBRouterCRUD Interface methods
-
- @Override
- public boolean routerExists(String uuid) {
- return routerDB.containsKey(uuid);
- }
-
- @Override
- public NeutronRouter getRouter(String uuid) {
- if (!routerExists(uuid)) {
- return null;
- }
- return routerDB.get(uuid);
- }
-
- @Override
- public List<NeutronRouter> getAllRouters() {
- Set<NeutronRouter> allRouters = new HashSet<NeutronRouter>();
- for (Entry<String, NeutronRouter> entry : routerDB.entrySet()) {
- NeutronRouter router = entry.getValue();
- allRouters.add(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;
- }
- routerDB.putIfAbsent(input.getID(), input);
- return true;
- }
-
- @Override
- public boolean removeRouter(String uuid) {
- if (!routerExists(uuid)) {
- return false;
- }
- routerDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateRouter(String uuid, NeutronRouter delta) {
- if (!routerExists(uuid)) {
- return false;
- }
- NeutronRouter target = routerDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean routerInUse(String routerUUID) {
- if (!routerExists(routerUUID)) {
- return true;
- }
- NeutronRouter target = routerDB.get(routerUUID);
- return (target.getInterfaces().size() > 0);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Map.Entry;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class NeutronSecurityGroupInterface implements INeutronSecurityGroupCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronSecurityGroupInterface.class);
- private ConcurrentMap<String, NeutronSecurityGroup> securityGroupDB = new ConcurrentHashMap<String, NeutronSecurityGroup>();
-
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronSecurityGroupExists(String uuid) {
- return securityGroupDB.containsKey(uuid);
- }
-
- @Override
- public NeutronSecurityGroup getNeutronSecurityGroup(String uuid) {
- if (!neutronSecurityGroupExists(uuid)) {
- logger.debug("No Security Groups Have Been Defined");
- return null;
- }
- return securityGroupDB.get(uuid);
- }
-
- @Override
- public List<NeutronSecurityGroup> getAllNeutronSecurityGroups() {
- Set<NeutronSecurityGroup> allSecurityGroups = new HashSet<NeutronSecurityGroup>();
- for (Entry<String, NeutronSecurityGroup> entry : securityGroupDB.entrySet()) {
- NeutronSecurityGroup securityGroup = entry.getValue();
- allSecurityGroups.add(securityGroup);
- }
- 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.getSecurityGroupUUID())) {
- return false;
- }
- securityGroupDB.putIfAbsent(input.getSecurityGroupUUID(), input);
- return true;
- }
-
- @Override
- public boolean removeNeutronSecurityGroup(String uuid) {
- if (!neutronSecurityGroupExists(uuid)) {
- return false;
- }
- securityGroupDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateNeutronSecurityGroup(String uuid, NeutronSecurityGroup delta) {
- if (!neutronSecurityGroupExists(uuid)) {
- return false;
- }
- NeutronSecurityGroup target = securityGroupDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronSecurityGroupInUse(String securityGroupUUID) {
- return !neutronSecurityGroupExists(securityGroupUUID);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Map.Entry;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class NeutronSecurityRuleInterface implements INeutronSecurityRuleCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronSecurityRuleInterface.class);
- private ConcurrentMap<String, NeutronSecurityRule> securityRuleDB = new ConcurrentHashMap<String, NeutronSecurityRule>();
-
- // this method uses reflection to update an object from it's delta.
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for (Method toMethod : methods) {
- if (toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")) {
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[]) null);
- if (value != null) {
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean neutronSecurityRuleExists(String uuid) {
- return securityRuleDB.containsKey(uuid);
- }
-
- @Override
- public NeutronSecurityRule getNeutronSecurityRule(String uuid) {
- if (!neutronSecurityRuleExists(uuid)) {
- logger.debug("No Security Rules Have Been Defined");
- return null;
- }
- return securityRuleDB.get(uuid);
- }
-
- @Override
- public List<NeutronSecurityRule> getAllNeutronSecurityRules() {
- Set<NeutronSecurityRule> allSecurityRules = new HashSet<NeutronSecurityRule>();
- for (Entry<String, NeutronSecurityRule> entry : securityRuleDB.entrySet()) {
- NeutronSecurityRule securityRule = entry.getValue();
- allSecurityRules.add(securityRule);
- }
- 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.getSecurityRuleUUID())) {
- return false;
- }
- securityRuleDB.putIfAbsent(input.getSecurityRuleUUID(), input);
- return true;
- }
-
- @Override
- public boolean removeNeutronSecurityRule(String uuid) {
- if (!neutronSecurityRuleExists(uuid)) {
- return false;
- }
- securityRuleDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateNeutronSecurityRule(String uuid, NeutronSecurityRule delta) {
- if (!neutronSecurityRuleExists(uuid)) {
- return false;
- }
- NeutronSecurityRule target = securityRuleDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean neutronSecurityRuleInUse(String securityRuleUUID) {
- return !neutronSecurityRuleExists(securityRuleUUID);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.implementation;
-
-import java.lang.reflect.Method;
-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.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NeutronSubnetInterface implements INeutronSubnetCRUD {
- private static final Logger logger = LoggerFactory.getLogger(NeutronSubnetInterface.class);
- private ConcurrentMap<String, NeutronSubnet> subnetDB = new ConcurrentHashMap<String, NeutronSubnet>();
-
-
-
- // this method uses reflection to update an object from it's delta.
-
- private boolean overwrite(Object target, Object delta) {
- Method[] methods = target.getClass().getMethods();
-
- for(Method toMethod: methods){
- if(toMethod.getDeclaringClass().equals(target.getClass())
- && toMethod.getName().startsWith("set")){
-
- String toName = toMethod.getName();
- String fromName = toName.replace("set", "get");
-
- try {
- Method fromMethod = delta.getClass().getMethod(fromName);
- Object value = fromMethod.invoke(delta, (Object[])null);
- if(value != null){
- toMethod.invoke(target, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- return true;
- }
-
-
- // IfNBSubnetCRUD methods
-
- @Override
- public boolean subnetExists(String uuid) {
- return subnetDB.containsKey(uuid);
- }
-
- @Override
- public NeutronSubnet getSubnet(String uuid) {
- if (!subnetExists(uuid)) {
- return null;
- }
- return subnetDB.get(uuid);
- }
-
- @Override
- public List<NeutronSubnet> getAllSubnets() {
- Set<NeutronSubnet> allSubnets = new HashSet<NeutronSubnet>();
- for (Entry<String, NeutronSubnet> entry : subnetDB.entrySet()) {
- NeutronSubnet subnet = entry.getValue();
- allSubnets.add(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;
- }
- subnetDB.putIfAbsent(id, input);
- INeutronNetworkCRUD networkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
-
- NeutronNetwork targetNet = networkIf.getNetwork(input.getNetworkUUID());
- targetNet.addSubnet(id);
- return true;
- }
-
- @Override
- public boolean removeSubnet(String uuid) {
- if (!subnetExists(uuid)) {
- return false;
- }
- NeutronSubnet target = subnetDB.get(uuid);
- INeutronNetworkCRUD networkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
-
- NeutronNetwork targetNet = networkIf.getNetwork(target.getNetworkUUID());
- targetNet.removeSubnet(uuid);
- subnetDB.remove(uuid);
- return true;
- }
-
- @Override
- public boolean updateSubnet(String uuid, NeutronSubnet delta) {
- if (!subnetExists(uuid)) {
- return false;
- }
- NeutronSubnet target = subnetDB.get(uuid);
- return overwrite(target, delta);
- }
-
- @Override
- public boolean subnetInUse(String subnetUUID) {
- if (!subnetExists(subnetUUID)) {
- return true;
- }
- NeutronSubnet target = subnetDB.get(subnetUUID);
- return (target.getPortsInSubnet().size() > 0);
- }
-}
+++ /dev/null
-<?xml version="1.0"?>
-<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd">
-
- <services>
- <rest defaultRestSubcontext="/controller/nb/v2/neutron"/>
- </services>
-
- <modules>
- <docs docsDir="rest" title="OpenStack Neutron REST API" includeExampleXml="false" includeExampleJson="true"/>
- </modules>
-</enunciate>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>enunciate-parent</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/enunciate-parent</relativePath>
- </parent>
- <artifactId>networkconfig.neutron.northbound</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <dependencies>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-servlet</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.enunciate</groupId>
- <artifactId>enunciate-core-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.moxy</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>networkconfig.neutron</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>org.opendaylight.controller.networkconfig.neutron,
- org.eclipse.persistence.jaxb.rs,
- com.sun.jersey.spi.container.servlet,
- javax.ws.rs,
- javax.ws.rs.ext,
- javax.ws.rs.core,
- javax.xml.bind.annotation,
- javax.xml.bind,
- org.slf4j,
- org.osgi.framework,
- !org.codehaus.enunciate.jaxrs</Import-Package>
- <Web-ContextPath>/controller/nb/v2/neutron</Web-ContextPath>
- </instructions>
- <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
- </scm>
-
- <distributionManagement>
- <!-- OpenDayLight Released artifact -->
- <repository>
- <id>opendaylight-release</id>
- <url>${nexusproxy}/repositories/${nexus.repository.release}/</url>
- </repository>
- <!-- OpenDayLight Snapshot artifact -->
- <snapshotRepository>
- <id>opendaylight-snapshot</id>
- <url>${nexusproxy}/repositories/${nexus.repository.snapshot}/</url>
- </snapshotRepository>
- <!-- Site deployment -->
- <site>
- <id>website</id>
- <url>${sitedeploy}</url>
- </site>
- </distributionManagement>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-/**
- * Status Code 400 (Bad Request)
- *
- * The request could not be understood by the server due to malformed syntax.
- * The client SHOULD NOT repeat the request without modifications.
- */
-public class BadRequestException extends WebApplicationException {
- private static final long serialVersionUID = 1L;
-
- public BadRequestException(String string) {
- super(Response.status(Response.Status.BAD_REQUEST).entity(string).type(MediaType.TEXT_PLAIN).build());
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Dave Tucker
- */
-
-package org.opendaylight.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronObject;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for Neutron Requests
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.northbound.api.INeutronRequest}
- */
-@Deprecated
-public interface INeutronRequest<T extends INeutronObject> {
- public T getSingleton();
- public boolean isSingleton();
- public List<T> getBulk();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.MediaType;
-
-/**
- * Status Code 500 (Internal Server Error)
- *
- * The server encountered an unexpected condition which prevented
- * it from fulfilling the request.
- *
- *
- *
- */
-public class InternalServerErrorException extends WebApplicationException {
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the INTERNAL_SERVER_ERROR custom handler
- *
- * @param string Error message to specify further the
- * INTERNAL_SERVER_ERROR response
- *
- */
- public InternalServerErrorException(String string) {
- super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- string).type(MediaType.TEXT_PLAIN).build());
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewall;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Neutron Northbound REST APIs for Firewall.<br>
- * This class provides REST APIs for managing neutron Firewall
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-@Path("/fw/firewalls")
-public class NeutronFirewallNorthbound {
-
- private NeutronFirewall extractFields(NeutronFirewall o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Firewalls */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-
- public Response listGroups(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack firewall attributes
- @QueryParam("id") String queryFirewallUUID,
- @QueryParam("tenant_id") String queryFirewallTenantID,
- @QueryParam("name") String queryFirewallName,
- @QueryParam("description") String queryFirewallDescription,
- @QueryParam("shared") Boolean queryFirewallAdminStateIsUp,
- @QueryParam("status") String queryFirewallStatus,
- @QueryParam("shared") Boolean queryFirewallIsShared,
- @QueryParam("firewall_policy_id") String queryFirewallPolicyID,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronFirewallCRUD firewallInterface = NeutronCRUDInterfaces.getINeutronFirewallCRUD(this);
- INeutronFirewallRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronFirewallRuleCRUD(this);
-
- if (firewallInterface == null) {
- throw new ServiceUnavailableException("Firewall CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronFirewall> allFirewalls = firewallInterface.getAllNeutronFirewalls();
- List<NeutronFirewall> ans = new ArrayList<NeutronFirewall>();
- Iterator<NeutronFirewall> i = allFirewalls.iterator();
- while (i.hasNext()) {
- NeutronFirewall nsg = i.next();
- if ((queryFirewallUUID == null ||
- queryFirewallUUID.equals(nsg.getFirewallUUID())) &&
- (queryFirewallTenantID == null ||
- queryFirewallTenantID.equals(nsg.getFirewallTenantID())) &&
- (queryFirewallName == null ||
- queryFirewallName.equals(nsg.getFirewallName())) &&
- (queryFirewallDescription == null ||
- queryFirewallDescription.equals(nsg.getFirewallDescription())) &&
- (queryFirewallAdminStateIsUp == null ||
- queryFirewallAdminStateIsUp.equals(nsg.getFirewallAdminStateIsUp())) &&
- (queryFirewallStatus == null ||
- queryFirewallStatus.equals(nsg.getFirewallStatus())) &&
- (queryFirewallIsShared == null ||
- queryFirewallIsShared.equals(nsg.getFirewallIsShared())) &&
- (queryFirewallPolicyID == null ||
- queryFirewallPolicyID.equals(nsg.getFirewallPolicyID()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg,fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- //TODO: apply pagination to results
- return Response.status(200).entity(
- new NeutronFirewallRequest(ans)).build();
- }
-
- /**
- * Returns a specific Firewall */
-
- @Path("{firewallUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showFirewall(@PathParam("firewallUUID") String firewallUUID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronFirewallCRUD firewallInterface = NeutronCRUDInterfaces.getINeutronFirewallCRUD(this);
- if (firewallInterface == null) {
- throw new ServiceUnavailableException("Firewall CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!firewallInterface.neutronFirewallExists(firewallUUID)) {
- throw new ResourceNotFoundException("Firewall UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronFirewall ans = firewallInterface.getNeutronFirewall(firewallUUID);
- return Response.status(200).entity(
- new NeutronFirewallRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronFirewallRequest(firewallInterface.getNeutronFirewall(firewallUUID))).build();
- }
- }
-
- /**
- * Creates new Firewall */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createFirewalls(final NeutronFirewallRequest input) {
- INeutronFirewallCRUD firewallInterface = NeutronCRUDInterfaces.getINeutronFirewallCRUD(this);
- if (firewallInterface == null) {
- throw new ServiceUnavailableException("Firewall CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronFirewall singleton = input.getSingleton();
-
- /*
- * Verify that the Firewall doesn't already exist.
- */
- if (firewallInterface.neutronFirewallExists(singleton.getFirewallUUID())) {
- throw new BadRequestException("Firewall UUID already exists");
- }
- firewallInterface.addNeutronFirewall(singleton);
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- int status = service.canCreateNeutronFirewall(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- firewallInterface.addNeutronFirewall(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- service.neutronFirewallCreated(singleton);
- }
- }
- } else {
- List<NeutronFirewall> bulk = input.getBulk();
- Iterator<NeutronFirewall> i = bulk.iterator();
- HashMap<String, NeutronFirewall> testMap = new HashMap<String, NeutronFirewall>();
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
- while (i.hasNext()) {
- NeutronFirewall test = i.next();
-
- /*
- * Verify that the secruity group doesn't already exist
- */
- if (firewallInterface.neutronFirewallExists(test.getFirewallUUID())) {
- throw new BadRequestException("Firewall UUID already is already created");
- }
- if (testMap.containsKey(test.getFirewallUUID())) {
- throw new BadRequestException("Firewall UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- int status = service.canCreateNeutronFirewall(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
-
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronFirewall test = i.next();
- firewallInterface.addNeutronFirewall(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- service.neutronFirewallCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Firewall */
-
- @Path("{firewallUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateFirewall(
- @PathParam("firewallUUID") String firewallUUID, final NeutronFirewallRequest input) {
- INeutronFirewallCRUD firewallInterface = NeutronCRUDInterfaces.getINeutronFirewallCRUD(this);
- if (firewallInterface == null) {
- throw new ServiceUnavailableException("Firewall CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Firewall exists and there is only one delta provided
- */
- if (!firewallInterface.neutronFirewallExists(firewallUUID)) {
- throw new ResourceNotFoundException("Firewall UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronFirewall delta = input.getSingleton();
- NeutronFirewall original = firewallInterface.getNeutronFirewall(firewallUUID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getFirewallUUID() != null ||
- delta.getFirewallTenantID() != null ||
- delta.getFirewallName() != null ||
- delta.getFirewallDescription() != null ||
- delta.getFirewallAdminStateIsUp() != null ||
- delta.getFirewallStatus() != null ||
- delta.getFirewallIsShared() != null ||
- delta.getFirewallPolicyID() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- int status = service.canUpdateNeutronFirewall(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- firewallInterface.updateNeutronFirewall(firewallUUID, delta);
- NeutronFirewall updatedFirewall = firewallInterface.getNeutronFirewall(firewallUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- service.neutronFirewallUpdated(updatedFirewall);
- }
- }
- return Response.status(200).entity(new NeutronFirewallRequest(firewallInterface.getNeutronFirewall(firewallUUID))).build();
- }
-
- /**
- * Deletes a Firewall */
-
- @Path("{firewallUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteFirewall(
- @PathParam("firewallUUID") String firewallUUID) {
- INeutronFirewallCRUD firewallInterface = NeutronCRUDInterfaces.getINeutronFirewallCRUD(this);
- if (firewallInterface == null) {
- throw new ServiceUnavailableException("Firewall CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Firewall exists and it isn't currently in use
- */
- if (!firewallInterface.neutronFirewallExists(firewallUUID)) {
- throw new ResourceNotFoundException("Firewall UUID does not exist.");
- }
- if (firewallInterface.neutronFirewallInUse(firewallUUID)) {
- return Response.status(409).build();
- }
- NeutronFirewall singleton = firewallInterface.getNeutronFirewall(firewallUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- int status = service.canDeleteNeutronFirewall(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * remove it and return 204 status
- */
- firewallInterface.removeNeutronFirewall(firewallUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallAware service = (INeutronFirewallAware) instance;
- service.neutronFirewallDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallPolicy;
-
-/**
- * Neutron Northbound REST APIs for Firewall Policies.<br>
- * This class provides REST APIs for managing neutron Firewall Policies
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-@Path("/fw/firewalls_policies")
-public class NeutronFirewallPolicyNorthbound {
-
- private NeutronFirewallPolicy extractFields(NeutronFirewallPolicy o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Firewall Policies */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-
- public Response listGroups(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack Firewall Policy attributes
- @QueryParam("id") String queryFirewallPolicyUUID,
- @QueryParam("tenant_id") String queryFirewallPolicyTenantID,
- @QueryParam("name") String queryFirewallPolicyName,
- @QueryParam("description") String querySecurityPolicyDescription,
- @QueryParam("shared") String querySecurityPolicyIsShared,
- @QueryParam("firewall_rules") List<String> querySecurityPolicyFirewallRules,
- @QueryParam("audited") Boolean querySecurityPolicyIsAudited,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronFirewallPolicyCRUD firewallPolicyInterface = NeutronCRUDInterfaces.getINeutronFirewallPolicyCRUD(this);
-
- if (firewallPolicyInterface == null) {
- throw new ServiceUnavailableException("Firewall Policy CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronFirewallPolicy> allFirewallPolicies = firewallPolicyInterface.getAllNeutronFirewallPolicies();
- List<NeutronFirewallPolicy> ans = new ArrayList<NeutronFirewallPolicy>();
- Iterator<NeutronFirewallPolicy> i = allFirewallPolicies.iterator();
- while (i.hasNext()) {
- NeutronFirewallPolicy nsg = i.next();
- if ((queryFirewallPolicyUUID == null ||
- queryFirewallPolicyUUID.equals(nsg.getFirewallPolicyUUID())) &&
- (queryFirewallPolicyTenantID == null ||
- queryFirewallPolicyTenantID.equals(nsg.getFirewallPolicyTenantID())) &&
- (queryFirewallPolicyName == null ||
- queryFirewallPolicyName.equals(nsg.getFirewallPolicyName())) &&
- (querySecurityPolicyDescription == null ||
- querySecurityPolicyDescription.equals(nsg.getFirewallPolicyDescription())) &&
- (querySecurityPolicyIsShared == null ||
- querySecurityPolicyIsShared.equals(nsg.getFirewallPolicyIsShared())) &&
- (querySecurityPolicyFirewallRules.size() == 0 ||
- querySecurityPolicyFirewallRules.equals(nsg.getFirewallPolicyRules())) &&
- (querySecurityPolicyIsAudited == null ||
- querySecurityPolicyIsAudited.equals(nsg.getFirewallPolicyIsAudited()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg,fields));
- } else {
- ans.add(nsg);
- }
- }
- } // ans.add((NeutronFirewallPolicy) rules);
- //TODO: apply pagination to results
- return Response.status(200).entity(
- new NeutronFirewallPolicyRequest(ans)).build();
- }
-
- /**
- * Returns a specific Firewall Policy */
-
- @Path("{firewallPolicyUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showFirewallPolicy(@PathParam("firewallPolicyUUID") String firewallPolicyUUID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronFirewallPolicyCRUD firewallPolicyInterface = NeutronCRUDInterfaces.getINeutronFirewallPolicyCRUD(this);
- if (firewallPolicyInterface == null) {
- throw new ServiceUnavailableException("Firewall Policy CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!firewallPolicyInterface.neutronFirewallPolicyExists(firewallPolicyUUID)) {
- throw new ResourceNotFoundException("Firewall Policy UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronFirewallPolicy ans = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID);
- return Response.status(200).entity(
- new NeutronFirewallPolicyRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronFirewallPolicyRequest(firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID))).build();
- }
- }
-
- /**
- * Creates new Firewall Policy
- * */
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createFirewallPolicies(final NeutronFirewallPolicyRequest input) {
- INeutronFirewallPolicyCRUD firewallPolicyInterface = NeutronCRUDInterfaces.getINeutronFirewallPolicyCRUD(this);
- if (firewallPolicyInterface == null) {
- throw new ServiceUnavailableException("Firewall Policy CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronFirewallPolicy singleton = input.getSingleton();
-
- /*
- * Verify that the Firewall Policy doesn't already exist.
- */
- if (firewallPolicyInterface.neutronFirewallPolicyExists(singleton.getFirewallPolicyUUID())) {
- throw new BadRequestException("Firewall Policy UUID already exists");
- }
- firewallPolicyInterface.addNeutronFirewallPolicy(singleton);
-
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- int status = service.canCreateNeutronFirewallPolicy(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- firewallPolicyInterface.addNeutronFirewallPolicy(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- service.neutronFirewallPolicyCreated(singleton);
- }
- }
- } else {
- List<NeutronFirewallPolicy> bulk = input.getBulk();
- Iterator<NeutronFirewallPolicy> i = bulk.iterator();
- HashMap<String, NeutronFirewallPolicy> testMap = new HashMap<String, NeutronFirewallPolicy>();
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
- while (i.hasNext()) {
- NeutronFirewallPolicy test = i.next();
-
- /*
- * Verify that the firewall policy doesn't already exist
- */
-
- if (firewallPolicyInterface.neutronFirewallPolicyExists(test.getFirewallPolicyUUID())) {
- throw new BadRequestException("Firewall Policy UUID already is already created");
- }
- if (testMap.containsKey(test.getFirewallPolicyUUID())) {
- throw new BadRequestException("Firewall Policy UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- int status = service.canCreateNeutronFirewallPolicy(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronFirewallPolicy test = i.next();
- firewallPolicyInterface.addNeutronFirewallPolicy(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- service.neutronFirewallPolicyCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Firewall Policy
- */
- @Path("{firewallPolicyUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackSubnets.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateFirewallPolicy(
- @PathParam("firewallPolicyUUID") String firewallPolicyUUID, final NeutronFirewallPolicyRequest input) {
- INeutronFirewallPolicyCRUD firewallPolicyInterface = NeutronCRUDInterfaces.getINeutronFirewallPolicyCRUD(this);
- if (firewallPolicyInterface == null) {
- throw new ServiceUnavailableException("Firewall Policy CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Firewall Policy exists and there is only one delta provided
- */
- if (!firewallPolicyInterface.neutronFirewallPolicyExists(firewallPolicyUUID)) {
- throw new ResourceNotFoundException("Firewall Policy UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronFirewallPolicy delta = input.getSingleton();
- NeutronFirewallPolicy original = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getFirewallPolicyUUID() != null ||
- delta.getFirewallPolicyTenantID() != null ||
- delta.getFirewallPolicyName() != null ||
- delta.getFirewallPolicyDescription() != null ||
- delta.getFirewallPolicyIsShared() != null ||
- delta.getFirewallPolicyRules().size() > 0 ||
- delta.getFirewallPolicyIsAudited() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- int status = service.canUpdateNeutronFirewallPolicy(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- firewallPolicyInterface.updateNeutronFirewallPolicy(firewallPolicyUUID, delta);
- NeutronFirewallPolicy updatedFirewallPolicy = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- service.neutronFirewallPolicyUpdated(updatedFirewallPolicy);
- }
- }
- return Response.status(200).entity(new NeutronFirewallPolicyRequest(firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID))).build();
- }
-
- /**
- * Deletes a Firewall Policy */
-
- @Path("{firewallPolicyUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteFirewallPolicy(
- @PathParam("firewallPolicyUUID") String firewallPolicyUUID) {
- INeutronFirewallPolicyCRUD firewallPolicyInterface = NeutronCRUDInterfaces.getINeutronFirewallPolicyCRUD(this);
- if (firewallPolicyInterface == null) {
- throw new ServiceUnavailableException("Firewall Policy CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Firewall Policy exists and it isn't currently in use
- */
- if (!firewallPolicyInterface.neutronFirewallPolicyExists(firewallPolicyUUID)) {
- throw new ResourceNotFoundException("Firewall Policy UUID does not exist.");
- }
- if (firewallPolicyInterface.neutronFirewallPolicyInUse(firewallPolicyUUID)) {
- return Response.status(409).build();
- }
- NeutronFirewallPolicy singleton = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- int status = service.canDeleteNeutronFirewallPolicy(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- firewallPolicyInterface.removeNeutronFirewallPolicy(firewallPolicyUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallPolicyAware service = (INeutronFirewallPolicyAware) instance;
- service.neutronFirewallPolicyDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallPolicy;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronFirewallPolicyRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="firewall_policy")
- NeutronFirewallPolicy singletonFirewallPolicy;
-
- @XmlElement(name="firewall_policies")
- List<NeutronFirewallPolicy> bulkRequest;
-
- NeutronFirewallPolicyRequest() {
- }
-
- NeutronFirewallPolicyRequest(List<NeutronFirewallPolicy> bulk) {
- bulkRequest = bulk;
- singletonFirewallPolicy = null;
- }
-
- NeutronFirewallPolicyRequest(NeutronFirewallPolicy group) {
- singletonFirewallPolicy = group;
- }
-
- public List<NeutronFirewallPolicy> getBulk() {
- return bulkRequest;
- }
-
- public NeutronFirewallPolicy getSingleton() {
- return singletonFirewallPolicy;
- }
-
- public boolean isSingleton() {
- return (singletonFirewallPolicy != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewall;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronFirewallRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="firewall")
- NeutronFirewall singletonFirewall;
-
- @XmlElement(name="firewalls")
- List<NeutronFirewall> bulkRequest;
-
- NeutronFirewallRequest() {
- }
-
- NeutronFirewallRequest(List<NeutronFirewall> bulk) {
- bulkRequest = bulk;
- singletonFirewall = null;
- }
-
- NeutronFirewallRequest(NeutronFirewall group) {
- singletonFirewall = group;
- }
-
- public List<NeutronFirewall> getBulk() {
- return bulkRequest;
- }
-
- public NeutronFirewall getSingleton() {
- return singletonFirewall;
- }
-
- public boolean isSingleton() {
- return (singletonFirewall != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallRule;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronFirewallRuleRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="firewall_rule")
- NeutronFirewallRule singletonFirewallRule;
-
- @XmlElement(name="firewall_rules")
- List<NeutronFirewallRule> bulkRequest;
-
- NeutronFirewallRuleRequest() {
- }
-
- NeutronFirewallRuleRequest(List<NeutronFirewallRule> bulk) {
- bulkRequest = bulk;
- singletonFirewallRule = null;
- }
-
- NeutronFirewallRuleRequest(NeutronFirewallRule group) {
- singletonFirewallRule = group;
- }
-
- public List<NeutronFirewallRule> getBulk() {
- return bulkRequest;
- }
-
- public NeutronFirewallRule getSingleton() {
- return singletonFirewallRule;
- }
-
- public boolean isSingleton() {
- return (singletonFirewallRule != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFirewallRule;
-
-/**
- * Neutron Northbound REST APIs for Firewall Rule.<br>
- * This class provides REST APIs for managing neutron Firewall Rule
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- */
-
-@Path("fw/firewalls_rules")
-public class NeutronFirewallRulesNorthbound {
-
- private NeutronFirewallRule extractFields(NeutronFirewallRule o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Firewall Rules
- */
- @GET
- @Produces({MediaType.APPLICATION_JSON})
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
- public Response listRules(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack firewall rule attributes
- @QueryParam("id") String queryFirewallRuleUUID,
- @QueryParam("tenant_id") String queryFirewallRuleTenantID,
- @QueryParam("name") String queryFirewallRuleName,
- @QueryParam("description") String queryFirewallRuleDescription,
- @QueryParam("admin_state_up") Boolean queryFirewallRuleAdminStateIsUp,
- @QueryParam("status") String queryFirewallRuleStatus,
- @QueryParam("shared") Boolean queryFirewallRuleIsShared,
- @QueryParam("firewall_policy_id") String queryFirewallRulePolicyID,
- @QueryParam("protocol") String queryFirewallRuleProtocol,
- @QueryParam("ip_version") Integer queryFirewallRuleIpVer,
- @QueryParam("source_ip_address") String queryFirewallRuleSrcIpAddr,
- @QueryParam("destination_ip_address") String queryFirewallRuleDstIpAddr,
- @QueryParam("source_port") Integer queryFirewallRuleSrcPort,
- @QueryParam("destination_port") Integer queryFirewallRuleDstPort,
- @QueryParam("position") Integer queryFirewallRulePosition,
- @QueryParam("action") String queryFirewallRuleAction,
- @QueryParam("enabled") Boolean queryFirewallRuleIsEnabled,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronFirewallRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronFirewallRuleCRUD(this);
- if (firewallRuleInterface == null) {
- throw new ServiceUnavailableException("Firewall Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronFirewallRule> allFirewallRules = firewallRuleInterface.getAllNeutronFirewallRules();
- List<NeutronFirewallRule> ans = new ArrayList<NeutronFirewallRule>();
- Iterator<NeutronFirewallRule> i = allFirewallRules.iterator();
- while (i.hasNext()) {
- NeutronFirewallRule nsr = i.next();
- if ((queryFirewallRuleUUID == null ||
- queryFirewallRuleUUID.equals(nsr.getFirewallRuleUUID())) &&
- (queryFirewallRuleTenantID == null ||
- queryFirewallRuleTenantID.equals(nsr.getFirewallRuleTenantID())) &&
- (queryFirewallRuleName == null ||
- queryFirewallRuleName.equals(nsr.getFirewallRuleName())) &&
- (queryFirewallRuleDescription == null ||
- queryFirewallRuleDescription.equals(nsr.getFirewallRuleDescription())) &&
- (queryFirewallRuleAdminStateIsUp == null ||
- queryFirewallRuleAdminStateIsUp.equals(nsr.getFirewallRuleAdminStateIsUp())) &&
- (queryFirewallRuleStatus == null ||
- queryFirewallRuleStatus.equals(nsr.getFirewallRuleStatus())) &&
- (queryFirewallRuleIsShared == null ||
- queryFirewallRuleIsShared.equals(nsr.getFirewallRuleIsShared())) &&
- (queryFirewallRulePolicyID == null ||
- queryFirewallRulePolicyID.equals(nsr.getFirewallRulePolicyID())) &&
- (queryFirewallRuleProtocol == null ||
- queryFirewallRuleProtocol.equals(nsr.getFirewallRuleProtocol())) &&
- (queryFirewallRuleIpVer == null ||
- queryFirewallRuleIpVer.equals(nsr.getFirewallRuleIpVer())) &&
- (queryFirewallRuleSrcIpAddr == null ||
- queryFirewallRuleSrcIpAddr.equals(nsr.getFirewallRuleSrcIpAddr())) &&
- (queryFirewallRuleDstIpAddr == null ||
- queryFirewallRuleDstIpAddr.equals(nsr.getFirewallRuleDstIpAddr())) &&
- (queryFirewallRuleSrcPort == null ||
- queryFirewallRuleSrcPort.equals(nsr.getFirewallRuleSrcPort())) &&
- (queryFirewallRuleDstPort == null ||
- queryFirewallRuleDstPort.equals(nsr.getFirewallRuleDstPort())) &&
- (queryFirewallRulePosition == null ||
- queryFirewallRulePosition.equals(nsr.getFirewallRulePosition())) &&
- (queryFirewallRuleAction == null ||
- queryFirewallRuleAction.equals(nsr.getFirewallRuleAction())) &&
- (queryFirewallRuleIsEnabled == null ||
- queryFirewallRuleIsEnabled.equals(nsr.getFirewallRuleIsEnabled()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsr, fields));
- } else {
- ans.add(nsr);
- }
- }
- }
- //TODO: apply pagination to results
- return Response.status(200).entity(
- new NeutronFirewallRuleRequest(ans)).build();
- }
-
- /**
- * Returns a specific Firewall Rule
- */
-
- @Path("{firewallRuleUUID}")
- @GET
- @Produces({MediaType.APPLICATION_JSON})
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
- public Response showFirewallRule(@PathParam("firewallRuleUUID") String firewallRuleUUID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronFirewallRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronFirewallRuleCRUD(this);
- if (firewallRuleInterface == null) {
- throw new ServiceUnavailableException("Firewall Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!firewallRuleInterface.neutronFirewallRuleExists(firewallRuleUUID)) {
- throw new ResourceNotFoundException("Firewall Rule UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronFirewallRule ans = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID);
- return Response.status(200).entity(
- new NeutronFirewallRuleRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200)
- .entity(new NeutronFirewallRuleRequest(
- firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID)))
- .build();
- }
- }
-
- /**
- * Creates new Firewall Rule
- */
-
- @POST
- @Produces({MediaType.APPLICATION_JSON})
- @Consumes({MediaType.APPLICATION_JSON})
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
- public Response createFirewallRules(final NeutronFirewallRuleRequest input) {
- INeutronFirewallRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronFirewallRuleCRUD(this);
- if (firewallRuleInterface == null) {
- throw new ServiceUnavailableException("Firewall Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronFirewallPolicyCRUD firewallPolicyInterface = NeutronCRUDInterfaces.getINeutronFirewallPolicyCRUD(this);
- if (firewallPolicyInterface == null) {
- throw new ServiceUnavailableException("Firewall Policy CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- if (input.isSingleton()) {
- NeutronFirewallRule singleton = input.getSingleton();
- if (firewallRuleInterface.neutronFirewallRuleExists(singleton.getFirewallRuleUUID())) {
- throw new BadRequestException("Firewall Rule UUID already exists");
- }
- firewallRuleInterface.addNeutronFirewallRule(singleton);
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- int status = service.canCreateNeutronFirewallRule(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- // add rule to cache
- singleton.initDefaults();
- firewallRuleInterface.addNeutronFirewallRule(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- service.neutronFirewallRuleCreated(singleton);
- }
- }
- } else {
- List<NeutronFirewallRule> bulk = input.getBulk();
- Iterator<NeutronFirewallRule> i = bulk.iterator();
- HashMap<String, NeutronFirewallRule> testMap = new HashMap<String, NeutronFirewallRule>();
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
- while (i.hasNext()) {
- NeutronFirewallRule test = i.next();
-
- /*
- * Verify that the Firewall rule doesn't already exist
- */
-
- if (firewallRuleInterface.neutronFirewallRuleExists(test.getFirewallRuleUUID())) {
- throw new BadRequestException("Firewall Rule UUID already exists");
- }
- if (testMap.containsKey(test.getFirewallRuleUUID())) {
- throw new BadRequestException("Firewall Rule UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- int status = service.canCreateNeutronFirewallRule(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronFirewallRule test = i.next();
- firewallRuleInterface.addNeutronFirewallRule(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- service.neutronFirewallRuleCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Firewall Rule
- */
- @Path("{firewallRuleUUID}")
- @PUT
- @Produces({MediaType.APPLICATION_JSON})
- @Consumes({MediaType.APPLICATION_JSON})
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
- public Response updateFirewallRule(
- @PathParam("firewallRuleUUID") String firewallRuleUUID, final NeutronFirewallRuleRequest input) {
- INeutronFirewallRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronFirewallRuleCRUD(this);
- if (firewallRuleInterface == null) {
- throw new ServiceUnavailableException("Firewall Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- /*
- * verify the Firewall Rule exists
- */
- if (!firewallRuleInterface.neutronFirewallRuleExists(firewallRuleUUID)) {
- throw new ResourceNotFoundException("Firewall Rule UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronFirewallRule delta = input.getSingleton();
- NeutronFirewallRule original = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID);
-
- /*
- * updates restricted by Neutron
- *
- */
- if (delta.getFirewallRuleUUID() != null ||
- delta.getFirewallRuleTenantID() != null ||
- delta.getFirewallRuleName() != null ||
- delta.getFirewallRuleDescription() != null ||
- delta.getFirewallRuleAdminStateIsUp() != null ||
- delta.getFirewallRuleStatus() != null ||
- delta.getFirewallRuleIsShared() != null ||
- delta.getFirewallRulePolicyID() != null ||
- delta.getFirewallRuleProtocol() != null ||
- delta.getFirewallRuleIpVer() != null ||
- delta.getFirewallRuleSrcIpAddr() != null ||
- delta.getFirewallRuleDstIpAddr() != null ||
- delta.getFirewallRuleSrcPort() != null ||
- delta.getFirewallRuleDstPort() != null ||
- delta.getFirewallRulePosition() != null ||
- delta.getFirewallRuleAction() != null ||
- delta.getFirewallRuleIsEnabled() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- int status = service.canUpdateNeutronFirewallRule(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- firewallRuleInterface.updateNeutronFirewallRule(firewallRuleUUID, delta);
- NeutronFirewallRule updatedFirewallRule = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- service.neutronFirewallRuleUpdated(updatedFirewallRule);
- }
- }
- return Response.status(200)
- .entity(new NeutronFirewallRuleRequest(firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID)))
- .build();
- }
-
- /**
- * Deletes a Firewall Rule
- */
-
- @Path("{firewallRuleUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
- public Response deleteFirewallRule(
- @PathParam("firewallRuleUUID") String firewallRuleUUID) {
- INeutronFirewallRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronFirewallRuleCRUD(this);
- if (firewallRuleInterface == null) {
- throw new ServiceUnavailableException("Firewall Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Firewall Rule exists and it isn't currently in use
- */
- if (!firewallRuleInterface.neutronFirewallRuleExists(firewallRuleUUID)) {
- throw new ResourceNotFoundException("Firewall Rule UUID does not exist.");
- }
- if (firewallRuleInterface.neutronFirewallRuleInUse(firewallRuleUUID)) {
- return Response.status(409).build();
- }
- NeutronFirewallRule singleton = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- int status = service.canDeleteNeutronFirewallRule(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * remove it and return 204 status
- */
- firewallRuleInterface.removeNeutronFirewallRule(firewallRuleUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFirewallRuleAware service = (INeutronFirewallRuleAware) instance;
- service.neutronFirewallRuleDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-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.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronFloatingIPRequest {
- // See OpenStack Network API v2.0 Reference for description of
- // annotated attributes
-
- @XmlElement(name="floatingip")
- NeutronFloatingIP singletonFloatingIP;
-
- @XmlElement(name="floatingips")
- List<NeutronFloatingIP> bulkRequest;
-
- NeutronFloatingIPRequest() {
- }
-
- NeutronFloatingIPRequest(List<NeutronFloatingIP> bulk) {
- bulkRequest = bulk;
- singletonFloatingIP = null;
- }
-
- NeutronFloatingIPRequest(NeutronFloatingIP singleton) {
- bulkRequest = null;
- singletonFloatingIP = singleton;
- }
-
- public NeutronFloatingIP getSingleton() {
- return singletonFloatingIP;
- }
-
- public boolean isSingleton() {
- return (singletonFloatingIP != null);
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-
-/**
- * Neutron Northbound REST APIs.<br>
- * This class provides REST APIs for managing Neutron Floating IPs
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-
-@Path("/floatingips")
-public class NeutronFloatingIPsNorthbound {
-
- private NeutronFloatingIP extractFields(NeutronFloatingIP o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all FloatingIPs */
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response listFloatingIPs(
- // return fields
- @QueryParam("fields") List<String> fields,
- // note: openstack isn't clear about filtering on lists, so we aren't handling them
- @QueryParam("id") String queryID,
- @QueryParam("floating_network_id") String queryFloatingNetworkId,
- @QueryParam("port_id") String queryPortId,
- @QueryParam("fixed_ip_address") String queryFixedIPAddress,
- @QueryParam("floating_ip_address") String queryFloatingIPAddress,
- @QueryParam("tenant_id") String queryTenantID,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronFloatingIPCRUD floatingIPInterface = NeutronCRUDInterfaces.getINeutronFloatingIPCRUD(this);
- if (floatingIPInterface == null) {
- throw new ServiceUnavailableException("Floating IP CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronFloatingIP> allFloatingIPs = floatingIPInterface.getAllFloatingIPs();
- List<NeutronFloatingIP> ans = new ArrayList<NeutronFloatingIP>();
- Iterator<NeutronFloatingIP> i = allFloatingIPs.iterator();
- while (i.hasNext()) {
- NeutronFloatingIP oSS = i.next();
- //match filters: TODO provider extension and router extension
- if ((queryID == null || queryID.equals(oSS.getID())) &&
- (queryFloatingNetworkId == null || queryFloatingNetworkId.equals(oSS.getFloatingNetworkUUID())) &&
- (queryPortId == null || queryPortId.equals(oSS.getPortUUID())) &&
- (queryFixedIPAddress == null || queryFixedIPAddress.equals(oSS.getFixedIPAddress())) &&
- (queryFloatingIPAddress == null || queryFloatingIPAddress.equals(oSS.getFloatingIPAddress())) &&
- (queryTenantID == null || queryTenantID.equals(oSS.getTenantUUID()))) {
- if (fields.size() > 0)
- ans.add(extractFields(oSS,fields));
- else
- ans.add(oSS);
- }
- }
- //TODO: apply pagination to results
- return Response.status(200).entity(
- new NeutronFloatingIPRequest(ans)).build();
- }
-
- /**
- * Returns a specific FloatingIP */
-
- @Path("{floatingipUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showFloatingIP(
- @PathParam("floatingipUUID") String floatingipUUID,
- // return fields
- @QueryParam("fields") List<String> fields ) {
- INeutronFloatingIPCRUD floatingIPInterface = NeutronCRUDInterfaces.getINeutronFloatingIPCRUD(this);
- if (floatingIPInterface == null) {
- throw new ServiceUnavailableException("Floating IP CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!floatingIPInterface.floatingIPExists(floatingipUUID))
- throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
- if (fields.size() > 0) {
- NeutronFloatingIP ans = floatingIPInterface.getFloatingIP(floatingipUUID);
- return Response.status(200).entity(
- new NeutronFloatingIPRequest(extractFields(ans, fields))).build();
- } else
- return Response.status(200).entity(
- new NeutronFloatingIPRequest(floatingIPInterface.getFloatingIP(floatingipUUID))).build();
-
- }
-
- /**
- * Creates new FloatingIPs */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createFloatingIPs(final NeutronFloatingIPRequest input) {
- INeutronFloatingIPCRUD floatingIPInterface = NeutronCRUDInterfaces.getINeutronFloatingIPCRUD(this);
- if (floatingIPInterface == null) {
- throw new ServiceUnavailableException("Floating IP CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD( this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronFloatingIP singleton = input.getSingleton();
- // check existence of id in cache and return badrequest if exists
- if (floatingIPInterface.floatingIPExists(singleton.getID()))
- throw new BadRequestException("Floating IP UUID already exists.");
- // check if the external network is specified, exists, and is an external network
- String externalNetworkUUID = singleton.getFloatingNetworkUUID();
- if (externalNetworkUUID == null)
- throw new BadRequestException("external network UUID doesn't exist.");
- if (!networkInterface.networkExists(externalNetworkUUID))
- throw new BadRequestException("external network UUID doesn't exist.");
- NeutronNetwork externNetwork = networkInterface.getNetwork(externalNetworkUUID);
- if (!externNetwork.isRouterExternal())
- throw new BadRequestException("external network isn't marked router:external");
- // if floating IP is specified, make sure it can come from the network
- String floatingIP = singleton.getFloatingIPAddress();
- if (floatingIP != null) {
- if (externNetwork.getSubnets().size() != 1)
- throw new BadRequestException("external network doesn't have a subnet");
- NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0));
- if (!externSubnet.isValidIP(floatingIP))
- throw new BadRequestException("external IP isn't valid for the specified subnet.");
- if (externSubnet.isIPInUse(floatingIP))
- throw new ResourceConflictException("floating IP is in use.");
- }
- // if port_id is specified, then check that the port exists and has at least one IP
- String port_id = singleton.getPortUUID();
- if (port_id != null) {
- String fixedIP = null; // used for the fixedIP calculation
- if (!portInterface.portExists(port_id))
- throw new ResourceNotFoundException("Port UUID doesn't exist.");
- NeutronPort port = portInterface.getPort(port_id);
- if (port.getFixedIPs().size() < 1)
- throw new BadRequestException("port UUID doesn't have an IP address.");
- // if there is more than one fixed IP then check for fixed_ip_address
- // and that it is in the list of port addresses
- if (port.getFixedIPs().size() > 1) {
- fixedIP = singleton.getFixedIPAddress();
- if (fixedIP == null)
- throw new BadRequestException("fixed IP address doesn't exist.");
- Iterator<Neutron_IPs> i = port.getFixedIPs().iterator();
- boolean validFixedIP = false;
- while (i.hasNext() && !validFixedIP) {
- Neutron_IPs ip = i.next();
- if (ip.getIpAddress().equals(fixedIP))
- validFixedIP = true;
- }
- if (!validFixedIP)
- throw new BadRequestException("can't find a valid fixed IP address");
- } else {
- fixedIP = port.getFixedIPs().get(0).getIpAddress();
- if (singleton.getFixedIPAddress() != null && !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress()))
- throw new BadRequestException("mismatched fixed IP address in request");
- }
- //lastly check that this fixed IP address isn't already used
- if (port.isBoundToFloatingIP(fixedIP))
- throw new ResourceConflictException("fixed IP is in use.");
- singleton.setFixedIPAddress(fixedIP);
- }
- Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- int status = service.canCreateFloatingIP(singleton);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- floatingIPInterface.addFloatingIP(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- service.neutronFloatingIPCreated(singleton);
- }
- }
- } else {
- throw new BadRequestException("only singleton requests allowed.");
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a FloatingIP */
-
- @Path("{floatingipUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateFloatingIP(
- @PathParam("floatingipUUID") String floatingipUUID,
- NeutronFloatingIPRequest input
- ) {
- INeutronFloatingIPCRUD floatingIPInterface = NeutronCRUDInterfaces.getINeutronFloatingIPCRUD(this);
- if (floatingIPInterface == null) {
- throw new ServiceUnavailableException("Floating IP CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD( this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!floatingIPInterface.floatingIPExists(floatingipUUID))
- throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
-
- NeutronFloatingIP sourceFloatingIP = floatingIPInterface.getFloatingIP(floatingipUUID);
- if (!input.isSingleton())
- throw new BadRequestException("only singleton requests allowed.");
- NeutronFloatingIP singleton = input.getSingleton();
- if (singleton.getID() == null)
- throw new BadRequestException("singleton UUID doesn't exist.");
-
- NeutronNetwork externNetwork = networkInterface.getNetwork(
- sourceFloatingIP.getFloatingNetworkUUID());
-
- // if floating IP is specified, make sure it can come from the network
- String floatingIP = singleton.getFloatingIPAddress();
- if (floatingIP != null) {
- if (externNetwork.getSubnets().size() != 1)
- throw new BadRequestException("external network doesn't have a subnet.");
- NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0));
- if (!externSubnet.isValidIP(floatingIP))
- throw new BadRequestException("floating IP not valid for external subnet");
- if (externSubnet.isIPInUse(floatingIP))
- throw new ResourceConflictException("floating IP is in use.");
- }
-
- // if port_id is specified, then check that the port exists and has at least one IP
- String port_id = singleton.getPortUUID();
- if (port_id != null) {
- String fixedIP = null; // used for the fixedIP calculation
- if (!portInterface.portExists(port_id))
- throw new ResourceNotFoundException("Port UUID doesn't exist.");
- NeutronPort port = portInterface.getPort(port_id);
- if (port.getFixedIPs().size() < 1)
- throw new BadRequestException("port ID doesn't have a fixed IP address.");
- // if there is more than one fixed IP then check for fixed_ip_address
- // and that it is in the list of port addresses
- if (port.getFixedIPs().size() > 1) {
- fixedIP = singleton.getFixedIPAddress();
- if (fixedIP == null)
- throw new BadRequestException("request doesn't have a fixed IP address");
- Iterator<Neutron_IPs> i = port.getFixedIPs().iterator();
- boolean validFixedIP = false;
- while (i.hasNext() && !validFixedIP) {
- Neutron_IPs ip = i.next();
- if (ip.getIpAddress().equals(fixedIP))
- validFixedIP = true;
- }
- if (!validFixedIP)
- throw new BadRequestException("couldn't find a valid fixed IP address");
- } else {
- fixedIP = port.getFixedIPs().get(0).getIpAddress();
- if (singleton.getFixedIPAddress() != null &&
- !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress()))
- throw new BadRequestException("mismatch in fixed IP addresses");
- }
- //lastly check that this fixed IP address isn't already used
- if (port.isBoundToFloatingIP(fixedIP))
- throw new ResourceConflictException("fixed IP is in use.");
- singleton.setFixedIPAddress(fixedIP);
- }
- NeutronFloatingIP target = floatingIPInterface.getFloatingIP(floatingipUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- int status = service.canUpdateFloatingIP(singleton, target);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- floatingIPInterface.updateFloatingIP(floatingipUUID, singleton);
- target = floatingIPInterface.getFloatingIP(floatingipUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- service.neutronFloatingIPUpdated(target);
- }
- }
- return Response.status(200).entity(
- new NeutronFloatingIPRequest(target)).build();
-
- }
-
- /**
- * Deletes a FloatingIP */
-
- @Path("{floatingipUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteFloatingIP(
- @PathParam("floatingipUUID") String floatingipUUID) {
- INeutronFloatingIPCRUD floatingIPInterface = NeutronCRUDInterfaces.getINeutronFloatingIPCRUD(this);
- if (floatingIPInterface == null) {
- throw new ServiceUnavailableException("Floating IP CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!floatingIPInterface.floatingIPExists(floatingipUUID))
- throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
- // TODO: need to undo port association if it exists
- NeutronFloatingIP singleton = floatingIPInterface.getFloatingIP(floatingipUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- int status = service.canDeleteFloatingIP(singleton);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- floatingIPInterface.removeFloatingIP(floatingipUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- service.neutronFloatingIPDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerHealthMonitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Neutron Northbound REST APIs for Load Balancer HealthMonitor.<br>
- * This class provides REST APIs for managing neutron LoadBalancerHealthMonitor
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-@Path("/healthmonitors")
-public class NeutronLoadBalancerHealthMonitorNorthbound {
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancer.class);
-
- private NeutronLoadBalancerHealthMonitor extractFields(NeutronLoadBalancerHealthMonitor o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all LoadBalancerHealthMonitor */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-
- public Response listGroups(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack LoadBalancerHealthMonitor attributes
- @QueryParam("id") String queryLoadBalancerHealthMonitorID,
- @QueryParam("tenant_id") String queryLoadBalancerHealthMonitorTenantID,
- // TODO "type" is being a property by the JSON parser.
- @QueryParam("type") String queryLoadBalancerHealthMonitorType,
- @QueryParam("delay") Integer queryLoadBalancerHealthMonitorDelay,
- @QueryParam("timeout") Integer queryLoadBalancerHealthMonitorTimeout,
- @QueryParam("max_retries") Integer queryLoadBalancerHealthMonitorMaxRetries,
- @QueryParam("http_method") String queryLoadBalancerHealthMonitorHttpMethod,
- @QueryParam("url_path") String queryLoadBalancerHealthMonitorUrlPath,
- @QueryParam("expected_codes") String queryLoadBalancerHealthMonitorExpectedCodes,
- @QueryParam("admin_state_up") Boolean queryLoadBalancerHealthMonitorIsAdminStateUp,
- @QueryParam("status") String queryLoadBalancerHealthMonitorStatus,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = NeutronCRUDInterfaces
- .getINeutronLoadBalancerHealthMonitorCRUD(this);
- if (loadBalancerHealthMonitorInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerHealthMonitor CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronLoadBalancerHealthMonitor> allLoadBalancerHealthMonitors = loadBalancerHealthMonitorInterface.getAllNeutronLoadBalancerHealthMonitors();
- List<NeutronLoadBalancerHealthMonitor> ans = new ArrayList<NeutronLoadBalancerHealthMonitor>();
- Iterator<NeutronLoadBalancerHealthMonitor> i = allLoadBalancerHealthMonitors.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerHealthMonitor nsg = i.next();
- if ((queryLoadBalancerHealthMonitorID == null ||
- queryLoadBalancerHealthMonitorID.equals(nsg.getLoadBalancerHealthMonitorID())) &&
- (queryLoadBalancerHealthMonitorTenantID == null ||
- queryLoadBalancerHealthMonitorTenantID.equals
- (nsg.getLoadBalancerHealthMonitorTenantID())) &&
- (queryLoadBalancerHealthMonitorType == null ||
- queryLoadBalancerHealthMonitorType.equals
- (nsg.getLoadBalancerHealthMonitorType())) &&
- (queryLoadBalancerHealthMonitorDelay == null ||
- queryLoadBalancerHealthMonitorDelay.equals
- (nsg.getLoadBalancerHealthMonitorDelay())) &&
- (queryLoadBalancerHealthMonitorTimeout == null ||
- queryLoadBalancerHealthMonitorTimeout.equals
- (nsg.getLoadBalancerHealthMonitorTimeout())) &&
- (queryLoadBalancerHealthMonitorMaxRetries == null ||
- queryLoadBalancerHealthMonitorMaxRetries.equals
- (nsg.getLoadBalancerHealthMonitorMaxRetries())) &&
- (queryLoadBalancerHealthMonitorHttpMethod == null ||
- queryLoadBalancerHealthMonitorHttpMethod.equals
- (nsg.getLoadBalancerHealthMonitorHttpMethod())) &&
- (queryLoadBalancerHealthMonitorUrlPath == null ||
- queryLoadBalancerHealthMonitorUrlPath.equals
- (nsg.getLoadBalancerHealthMonitorUrlPath())) &&
- (queryLoadBalancerHealthMonitorExpectedCodes == null ||
- queryLoadBalancerHealthMonitorExpectedCodes.equals
- (nsg.getLoadBalancerHealthMonitorExpectedCodes())) &&
- (queryLoadBalancerHealthMonitorIsAdminStateUp == null ||
- queryLoadBalancerHealthMonitorIsAdminStateUp.equals
- (nsg.getLoadBalancerHealthMonitorAdminStateIsUp())) &&
- (queryLoadBalancerHealthMonitorStatus == null ||
- queryLoadBalancerHealthMonitorStatus.equals
- (nsg.getLoadBalancerHealthMonitorStatus()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg,fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronLoadBalancerHealthMonitorRequest(ans)).build();
- }
-
- /**
- * Returns a specific LoadBalancerHealthMonitor */
-
- @Path("{loadBalancerHealthMonitorID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showLoadBalancerHealthMonitor(@PathParam("loadBalancerHealthMonitorID") String loadBalancerHealthMonitorID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerHealthMonitorCRUD(this);
- if (loadBalancerHealthMonitorInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerHealthMonitor CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorID)) {
- throw new ResourceNotFoundException("LoadBalancerHealthMonitor UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronLoadBalancerHealthMonitor ans = loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID);
- return Response.status(200).entity(
- new NeutronLoadBalancerHealthMonitorRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronLoadBalancerHealthMonitorRequest(loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID))).build();
- }
- }
-
- /**
- * Creates new LoadBalancerHealthMonitor */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createLoadBalancerHealthMonitors(final NeutronLoadBalancerHealthMonitorRequest input) {
- INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerHealthMonitorCRUD(this);
- if (loadBalancerHealthMonitorInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerHealthMonitor CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronLoadBalancerHealthMonitor singleton = input.getSingleton();
-
- /*
- * Verify that the LoadBalancerHealthMonitor doesn't already exist.
- */
- if (loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(singleton.getLoadBalancerHealthMonitorID())) {
- throw new BadRequestException("LoadBalancerHealthMonitor UUID already exists");
- }
- loadBalancerHealthMonitorInterface.addNeutronLoadBalancerHealthMonitor(singleton);
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- int status = service.canCreateNeutronLoadBalancerHealthMonitor(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- loadBalancerHealthMonitorInterface.addNeutronLoadBalancerHealthMonitor(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- service.neutronLoadBalancerHealthMonitorCreated(singleton);
- }
- }
- } else {
- List<NeutronLoadBalancerHealthMonitor> bulk = input.getBulk();
- Iterator<NeutronLoadBalancerHealthMonitor> i = bulk.iterator();
- HashMap<String, NeutronLoadBalancerHealthMonitor> testMap = new HashMap<String, NeutronLoadBalancerHealthMonitor>();
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
- while (i.hasNext()) {
- NeutronLoadBalancerHealthMonitor test = i.next();
-
- /*
- * Verify that the firewall policy doesn't already exist
- */
-
- if (loadBalancerHealthMonitorInterface
- .neutronLoadBalancerHealthMonitorExists(test.getLoadBalancerHealthMonitorID())) {
- throw new BadRequestException("LoadBalancerHealthMonitor UUID already is already created");
- }
- if (testMap.containsKey(test.getLoadBalancerHealthMonitorID())) {
- throw new BadRequestException("LoadBalancerHealthMonitor UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- int status = service.canCreateNeutronLoadBalancerHealthMonitor(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerHealthMonitor test = i.next();
- loadBalancerHealthMonitorInterface.addNeutronLoadBalancerHealthMonitor(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- service.neutronLoadBalancerHealthMonitorCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a LoadBalancerHealthMonitor Policy
- */
- @Path("{loadBalancerHealthMonitorID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateLoadBalancerHealthMonitor(
- @PathParam("loadBalancerHealthMonitorID") String loadBalancerHealthMonitorID,
- final NeutronLoadBalancerHealthMonitorRequest input) {
- INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = NeutronCRUDInterfaces
- .getINeutronLoadBalancerHealthMonitorCRUD(this);
- if (loadBalancerHealthMonitorInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerHealthMonitor CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancerHealthMonitor exists and there is only one delta provided
- */
- if (!loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorID)) {
- throw new ResourceNotFoundException("LoadBalancerHealthMonitor UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronLoadBalancerHealthMonitor delta = input.getSingleton();
- NeutronLoadBalancerHealthMonitor original = loadBalancerHealthMonitorInterface
- .getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getLoadBalancerHealthMonitorID() != null ||
- delta.getLoadBalancerHealthMonitorTenantID() != null ||
- delta.getLoadBalancerHealthMonitorType() != null ||
- delta.getLoadBalancerHealthMonitorDelay() != null ||
- delta.getLoadBalancerHealthMonitorTimeout() != null ||
- delta.getLoadBalancerHealthMonitorMaxRetries() != null ||
- delta.getLoadBalancerHealthMonitorHttpMethod() != null ||
- delta.getLoadBalancerHealthMonitorUrlPath() != null ||
- delta.getLoadBalancerHealthMonitorExpectedCodes() != null ||
- delta.getLoadBalancerHealthMonitorAdminStateIsUp() != null ||
- delta.getLoadBalancerHealthMonitorStatus() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- int status = service.canUpdateNeutronLoadBalancerHealthMonitor(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- loadBalancerHealthMonitorInterface.updateNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID, delta);
- NeutronLoadBalancerHealthMonitor updatedLoadBalancerHealthMonitor = loadBalancerHealthMonitorInterface
- .getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- service.neutronLoadBalancerHealthMonitorUpdated(updatedLoadBalancerHealthMonitor);
- }
- }
- return Response.status(200).entity(new NeutronLoadBalancerHealthMonitorRequest
- (loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor
- (loadBalancerHealthMonitorID))).build();
- }
-
-
-
- /**
- * Deletes a LoadBalancerHealthMonitor
- * */
- @Path("{loadBalancerHealthMonitorID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteLoadBalancerHealthMonitor(
- @PathParam("loadBalancerHealthMonitorID") String loadBalancerHealthMonitorID) {
- INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerHealthMonitorCRUD(this);
- if (loadBalancerHealthMonitorInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerHealthMonitor CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- /*
- * verify the LoadBalancerHealthMonitor exists and it isn't currently in use
- */
- if (!loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorID)) {
- throw new ResourceNotFoundException("LoadBalancerHealthMonitor UUID does not exist.");
- }
- if (loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorInUse(loadBalancerHealthMonitorID)) {
- return Response.status(409).build();
- }
- NeutronLoadBalancerHealthMonitor singleton = loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID);
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- int status = service.canDeleteNeutronLoadBalancerHealthMonitor(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- loadBalancerHealthMonitorInterface.removeNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerHealthMonitorAware service = (INeutronLoadBalancerHealthMonitorAware) instance;
- service.neutronLoadBalancerHealthMonitorDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerHealthMonitor;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronLoadBalancerHealthMonitorRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="healthmonitor")
- NeutronLoadBalancerHealthMonitor singletonLoadBalancerHealthMonitor;
-
- @XmlElement(name="healthmonitors")
- List<NeutronLoadBalancerHealthMonitor> bulkRequest;
-
- NeutronLoadBalancerHealthMonitorRequest() {
- }
-
- NeutronLoadBalancerHealthMonitorRequest(List<NeutronLoadBalancerHealthMonitor> bulk) {
- bulkRequest = bulk;
- singletonLoadBalancerHealthMonitor = null;
- }
-
- NeutronLoadBalancerHealthMonitorRequest(NeutronLoadBalancerHealthMonitor group) {
- singletonLoadBalancerHealthMonitor = group;
- }
-
- public List<NeutronLoadBalancerHealthMonitor> getBulk() {
- return bulkRequest;
- }
-
- public NeutronLoadBalancerHealthMonitor getSingleton() {
- return singletonLoadBalancerHealthMonitor;
- }
-
- public boolean isSingleton() {
- return (singletonLoadBalancerHealthMonitor != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener;
-
-/**
- * Neutron Northbound REST APIs for LoadBalancerListener Policies.<br>
- * This class provides REST APIs for managing neutron LoadBalancerListener Policies
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-@Path("/listeners")
-public class NeutronLoadBalancerListenerNorthbound {
-
- private NeutronLoadBalancerListener extractFields(NeutronLoadBalancerListener o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all LoadBalancerListener */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-
- public Response listGroups(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack LoadBalancerListener attributes
- @QueryParam("id") String queryLoadBalancerListenerID,
- @QueryParam("default_pool_id") String queryLoadBalancerListenerDefaultPoolID,
- @QueryParam("tenant_id") String queryLoadBalancerListenerTenantID,
- @QueryParam("name") String queryLoadBalancerListenerName,
- @QueryParam("description") String queryLoadBalancerListenerDescription,
- @QueryParam("shared") String queryLoadBalancerListenerIsShared,
- @QueryParam("protocol") String queryLoadBalancerListenerProtocol,
- @QueryParam("protocol_port") String queryLoadBalancerListenerProtocolPort,
- @QueryParam("load_balancer_id") String queryLoadBalancerListenerLoadBalancerID,
- @QueryParam("admin_state_up") String queryLoadBalancerListenerAdminIsUp,
- @QueryParam("status") String queryLoadBalancerListenerStatus,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerListenerCRUD(this);
- // INeutronLoadBalancerListenerRuleCRUD firewallRuleInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerListenerRuleCRUD(this);
-
- if (loadBalancerListenerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerListener CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronLoadBalancerListener> allLoadBalancerListeners = loadBalancerListenerInterface.getAllNeutronLoadBalancerListeners();
- // List<NeutronLoadBalancerListenerRule> allLoadBalancerListenerRules = firewallRuleInterface.getAllNeutronLoadBalancerListenerRules();
- List<NeutronLoadBalancerListener> ans = new ArrayList<NeutronLoadBalancerListener>();
- // List<NeutronLoadBalancerListenerRule> rules = new ArrayList<NeutronLoadBalancerListenerRule>();
- Iterator<NeutronLoadBalancerListener> i = allLoadBalancerListeners.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerListener nsg = i.next();
- if ((queryLoadBalancerListenerID == null ||
- queryLoadBalancerListenerID.equals(nsg.getLoadBalancerListenerID())) &&
- (queryLoadBalancerListenerDefaultPoolID == null ||
- queryLoadBalancerListenerDefaultPoolID.equals(nsg.getNeutronLoadBalancerListenerDefaultPoolID())) &&
- (queryLoadBalancerListenerTenantID == null ||
- queryLoadBalancerListenerTenantID.equals(nsg.getLoadBalancerListenerTenantID())) &&
- (queryLoadBalancerListenerName == null ||
- queryLoadBalancerListenerName.equals(nsg.getLoadBalancerListenerName())) &&
- (queryLoadBalancerListenerDescription == null ||
- queryLoadBalancerListenerDescription.equals(nsg.getLoadBalancerListenerDescription())) &&
- (queryLoadBalancerListenerIsShared == null ||
- queryLoadBalancerListenerIsShared.equals(nsg.getLoadBalancerListenerIsShared())) &&
- (queryLoadBalancerListenerProtocol == null ||
- queryLoadBalancerListenerProtocol.equals(nsg.getNeutronLoadBalancerListenerProtocol())) &&
- (queryLoadBalancerListenerProtocolPort == null ||
- queryLoadBalancerListenerProtocolPort.equals(nsg.getNeutronLoadBalancerListenerProtocolPort())) &&
- (queryLoadBalancerListenerLoadBalancerID == null ||
- queryLoadBalancerListenerLoadBalancerID.equals(nsg.getNeutronLoadBalancerListenerLoadBalancerID())) &&
- (queryLoadBalancerListenerAdminIsUp == null ||
- queryLoadBalancerListenerAdminIsUp.equals(nsg.getLoadBalancerListenerAdminStateIsUp())) &&
- (queryLoadBalancerListenerStatus == null ||
- queryLoadBalancerListenerStatus.equals(nsg.getLoadBalancerListenerStatus()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg,fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronLoadBalancerListenerRequest(ans)).build();
- }
-
- /**
- * Returns a specific LoadBalancerListener */
-
- @Path("{loadBalancerListenerID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showLoadBalancerListener(@PathParam("loadBalancerListenerID") String loadBalancerListenerID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerListenerCRUD(this);
- if (loadBalancerListenerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerListener CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!loadBalancerListenerInterface.neutronLoadBalancerListenerExists(loadBalancerListenerID)) {
- throw new ResourceNotFoundException("LoadBalancerListener UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronLoadBalancerListener ans = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID);
- return Response.status(200).entity(
- new NeutronLoadBalancerListenerRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronLoadBalancerListenerRequest(loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID))).build();
- }
- }
-
- /**
- * Creates new LoadBalancerListener */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createLoadBalancerListeners(final NeutronLoadBalancerListenerRequest input) {
- INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerListenerCRUD(this);
- if (loadBalancerListenerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerListener CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronLoadBalancerListener singleton = input.getSingleton();
-
- /*
- * Verify that the LoadBalancerListener doesn't already exist.
- */
- if (loadBalancerListenerInterface.neutronLoadBalancerListenerExists(singleton.getLoadBalancerListenerID())) {
- throw new BadRequestException("LoadBalancerListener UUID already exists");
- }
- loadBalancerListenerInterface.addNeutronLoadBalancerListener(singleton);
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- int status = service.canCreateNeutronLoadBalancerListener(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- loadBalancerListenerInterface.addNeutronLoadBalancerListener(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- service.neutronLoadBalancerListenerCreated(singleton);
- }
- }
- } else {
- List<NeutronLoadBalancerListener> bulk = input.getBulk();
- Iterator<NeutronLoadBalancerListener> i = bulk.iterator();
- HashMap<String, NeutronLoadBalancerListener> testMap = new HashMap<String, NeutronLoadBalancerListener>();
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
- while (i.hasNext()) {
- NeutronLoadBalancerListener test = i.next();
-
- /*
- * Verify that the firewall policy doesn't already exist
- */
-
- if (loadBalancerListenerInterface.neutronLoadBalancerListenerExists(test.getLoadBalancerListenerID())) {
- throw new BadRequestException("LoadBalancerListener UUID already is already created");
- }
- if (testMap.containsKey(test.getLoadBalancerListenerID())) {
- throw new BadRequestException("LoadBalancerListener UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- int status = service.canCreateNeutronLoadBalancerListener(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerListener test = i.next();
- loadBalancerListenerInterface.addNeutronLoadBalancerListener(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- service.neutronLoadBalancerListenerCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a LoadBalancerListener Policy
- */
- @Path("{loadBalancerListenerID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateLoadBalancerListener(
- @PathParam("loadBalancerListenerID") String loadBalancerListenerID, final NeutronLoadBalancerListenerRequest input) {
- INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerListenerCRUD(this);
- if (loadBalancerListenerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerListener CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancerListener exists and there is only one delta provided
- */
- if (!loadBalancerListenerInterface.neutronLoadBalancerListenerExists(loadBalancerListenerID)) {
- throw new ResourceNotFoundException("LoadBalancerListener UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronLoadBalancerListener delta = input.getSingleton();
- NeutronLoadBalancerListener original = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getLoadBalancerListenerID() != null ||
- delta.getNeutronLoadBalancerListenerDefaultPoolID() != null ||
- delta.getLoadBalancerListenerTenantID() != null ||
- delta.getLoadBalancerListenerName() != null ||
- delta.getLoadBalancerListenerDescription() != null ||
- delta.getLoadBalancerListenerIsShared() != null ||
- delta.getNeutronLoadBalancerListenerProtocol() != null ||
- delta.getNeutronLoadBalancerListenerProtocolPort() != null ||
- delta.getNeutronLoadBalancerListenerLoadBalancerID() != null ||
- delta.getLoadBalancerListenerAdminStateIsUp() != null ||
- delta.getLoadBalancerListenerStatus() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- int status = service.canUpdateNeutronLoadBalancerListener(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- loadBalancerListenerInterface.updateNeutronLoadBalancerListener(loadBalancerListenerID, delta);
- NeutronLoadBalancerListener updatedLoadBalancerListener = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- service.neutronLoadBalancerListenerUpdated(updatedLoadBalancerListener);
- }
- }
- return Response.status(200).entity(new NeutronLoadBalancerListenerRequest(loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID))).build();
- }
-
- /**
- * Deletes a LoadBalancerListener */
-
- @Path("{loadBalancerListenerID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteLoadBalancerListener(
- @PathParam("loadBalancerListenerID") String loadBalancerListenerID) {
- INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerListenerCRUD(this);
- if (loadBalancerListenerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerListener CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancerListener exists and it isn't currently in use
- */
- if (!loadBalancerListenerInterface.neutronLoadBalancerListenerExists(loadBalancerListenerID)) {
- throw new ResourceNotFoundException("LoadBalancerListener UUID does not exist.");
- }
- if (loadBalancerListenerInterface.neutronLoadBalancerListenerInUse(loadBalancerListenerID)) {
- return Response.status(409).build();
- }
- NeutronLoadBalancerListener singleton = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID);
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- int status = service.canDeleteNeutronLoadBalancerListener(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- loadBalancerListenerInterface.removeNeutronLoadBalancerListener(loadBalancerListenerID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance;
- service.neutronLoadBalancerListenerDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronLoadBalancerListenerRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="listener")
- NeutronLoadBalancerListener singletonLoadBalancerListener;
-
- @XmlElement(name="listeners")
- List<NeutronLoadBalancerListener> bulkRequest;
-
- NeutronLoadBalancerListenerRequest() {
- }
-
- NeutronLoadBalancerListenerRequest(List<NeutronLoadBalancerListener> bulk) {
- bulkRequest = bulk;
- singletonLoadBalancerListener = null;
- }
-
- NeutronLoadBalancerListenerRequest(NeutronLoadBalancerListener group) {
- singletonLoadBalancerListener = group;
- }
-
- public List<NeutronLoadBalancerListener> getBulk() {
- return bulkRequest;
- }
-
- public NeutronLoadBalancerListener getSingleton() {
- return singletonLoadBalancerListener;
- }
-
- public boolean isSingleton() {
- return (singletonLoadBalancerListener != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-
-/**
- * Neutron Northbound REST APIs for LoadBalancers.<br>
- * This class provides REST APIs for managing neutron LoadBalancers
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-@Path("/loadbalancers")
-public class NeutronLoadBalancerNorthbound {
-
- private NeutronLoadBalancer extractFields(NeutronLoadBalancer o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all LoadBalancer */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-
- public Response listGroups(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack LoadBalancer attributes
- @QueryParam("id") String queryLoadBalancerID,
- @QueryParam("tenant_id") String queryLoadBalancerTenantID,
- @QueryParam("name") String queryLoadBalancerName,
- @QueryParam("description") String queryLoadBalancerDescription,
- @QueryParam("status") String queryLoadBalancerStatus,
- @QueryParam("vip_address") String queryLoadBalancerVipAddress,
- @QueryParam("vip_subnet") String queryLoadBalancerVipSubnet,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronLoadBalancerCRUD loadBalancerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerCRUD(this);
-
- if (loadBalancerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancer CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronLoadBalancer> allLoadBalancers = loadBalancerInterface.getAllNeutronLoadBalancers();
- // List<NeutronLoadBalancerRule> allLoadBalancerRules = firewallRuleInterface.getAllNeutronLoadBalancerRules();
- List<NeutronLoadBalancer> ans = new ArrayList<NeutronLoadBalancer>();
- // List<NeutronLoadBalancerRule> rules = new ArrayList<NeutronLoadBalancerRule>();
- Iterator<NeutronLoadBalancer> i = allLoadBalancers.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancer nsg = i.next();
- if ((queryLoadBalancerID == null ||
- queryLoadBalancerID.equals(nsg.getLoadBalancerID())) &&
- (queryLoadBalancerTenantID == null ||
- queryLoadBalancerTenantID.equals(nsg.getLoadBalancerTenantID())) &&
- (queryLoadBalancerName == null ||
- queryLoadBalancerName.equals(nsg.getLoadBalancerName())) &&
- (queryLoadBalancerDescription == null ||
- queryLoadBalancerDescription.equals(nsg.getLoadBalancerDescription())) &&
- (queryLoadBalancerVipAddress == null ||
- queryLoadBalancerVipAddress.equals(nsg.getLoadBalancerVipAddress())) &&
- (queryLoadBalancerVipSubnet == null ||
- queryLoadBalancerVipSubnet.equals(nsg.getLoadBalancerVipSubnetID()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg,fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronLoadBalancerRequest(ans)).build();
- }
-
- /**
- * Returns a specific LoadBalancer */
-
- @Path("{loadBalancerID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
-
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showLoadBalancer(@PathParam("loadBalancerID") String loadBalancerID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronLoadBalancerCRUD loadBalancerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerCRUD(
- this);
- if (loadBalancerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancer CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!loadBalancerInterface.neutronLoadBalancerExists(loadBalancerID)) {
- throw new ResourceNotFoundException("LoadBalancer UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronLoadBalancer ans = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID);
- return Response.status(200).entity(
- new NeutronLoadBalancerRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronLoadBalancerRequest(loadBalancerInterface.getNeutronLoadBalancer(
- loadBalancerID))).build();
- }
- }
-
- /**
- * Creates new LoadBalancer */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
-
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createLoadBalancers(final NeutronLoadBalancerRequest input) {
- INeutronLoadBalancerCRUD loadBalancerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerCRUD(
- this);
- if (loadBalancerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancer CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronLoadBalancer singleton = input.getSingleton();
-
- /*
- * Verify that the LoadBalancer doesn't already exist.
- */
- if (loadBalancerInterface.neutronLoadBalancerExists(singleton.getLoadBalancerID())) {
- throw new BadRequestException("LoadBalancer UUID already exists");
- }
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- int status = service.canCreateNeutronLoadBalancer(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- loadBalancerInterface.addNeutronLoadBalancer(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- service.neutronLoadBalancerCreated(singleton);
- }
- }
- } else {
- List<NeutronLoadBalancer> bulk = input.getBulk();
- Iterator<NeutronLoadBalancer> i = bulk.iterator();
- HashMap<String, NeutronLoadBalancer> testMap = new HashMap<String, NeutronLoadBalancer>();
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
- while (i.hasNext()) {
- NeutronLoadBalancer test = i.next();
-
- /*
- * Verify that the loadbalancer doesn't already exist
- */
-
- if (loadBalancerInterface.neutronLoadBalancerExists(test.getLoadBalancerID())) {
- throw new BadRequestException("Load Balancer Pool UUID already is already created");
- }
- if (testMap.containsKey(test.getLoadBalancerID())) {
- throw new BadRequestException("Load Balancer Pool UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- int status = service.canCreateNeutronLoadBalancer(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancer test = i.next();
- loadBalancerInterface.addNeutronLoadBalancer(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- service.neutronLoadBalancerCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a LoadBalancer Policy
- */
- @Path("{loadBalancerID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
-
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateLoadBalancer(
- @PathParam("loadBalancerID") String loadBalancerID, final NeutronLoadBalancerRequest input) {
- INeutronLoadBalancerCRUD loadBalancerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerCRUD(
- this);
- if (loadBalancerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancer CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancer exists and there is only one delta provided
- */
- if (!loadBalancerInterface.neutronLoadBalancerExists(loadBalancerID)) {
- throw new ResourceNotFoundException("LoadBalancer UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronLoadBalancer delta = input.getSingleton();
- NeutronLoadBalancer original = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getLoadBalancerID() != null ||
- delta.getLoadBalancerTenantID() != null ||
- delta.getLoadBalancerName() != null ||
- delta.getLoadBalancerDescription() != null ||
- delta.getLoadBalancerStatus() != null ||
- delta.getLoadBalancerVipAddress() != null ||
- delta.getLoadBalancerVipSubnetID() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- int status = service.canUpdateNeutronLoadBalancer(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- loadBalancerInterface.updateNeutronLoadBalancer(loadBalancerID, delta);
- NeutronLoadBalancer updatedLoadBalancer = loadBalancerInterface.getNeutronLoadBalancer(
- loadBalancerID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- service.neutronLoadBalancerUpdated(updatedLoadBalancer);
- }
- }
- return Response.status(200).entity(new NeutronLoadBalancerRequest(loadBalancerInterface.getNeutronLoadBalancer(
- loadBalancerID))).build();
- }
-
- /**
- * Deletes a LoadBalancer */
-
- @Path("{loadBalancerID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteLoadBalancer(
- @PathParam("loadBalancerID") String loadBalancerID) {
- INeutronLoadBalancerCRUD loadBalancerInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerCRUD(
- this);
- if (loadBalancerInterface == null) {
- throw new ServiceUnavailableException("LoadBalancer CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancer exists and it isn't currently in use
- */
- if (!loadBalancerInterface.neutronLoadBalancerExists(loadBalancerID)) {
- throw new ResourceNotFoundException("LoadBalancer UUID does not exist.");
- }
- if (loadBalancerInterface.neutronLoadBalancerInUse(loadBalancerID)) {
- return Response.status(409).build();
- }
- NeutronLoadBalancer singleton = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID);
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- int status = service.canDeleteNeutronLoadBalancer(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
-
- loadBalancerInterface.removeNeutronLoadBalancer(loadBalancerID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance;
- service.neutronLoadBalancerDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-
-import javax.xml.bind.annotation.XmlElement;
-import java.util.List;
-
-public class NeutronLoadBalancerPoolMemberRequest {
-
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="member")
- NeutronLoadBalancerPoolMember singletonLoadBalancerPoolMember;
-
- @XmlElement(name="members")
- List<NeutronLoadBalancerPoolMember> bulkRequest;
-
- NeutronLoadBalancerPoolMemberRequest() {
- }
-
- NeutronLoadBalancerPoolMemberRequest(List<NeutronLoadBalancerPoolMember> bulk) {
- bulkRequest = bulk;
- singletonLoadBalancerPoolMember = null;
- }
-
- NeutronLoadBalancerPoolMemberRequest(NeutronLoadBalancerPoolMember group) {
- singletonLoadBalancerPoolMember = group;
- }
-
- public List<NeutronLoadBalancerPoolMember> getBulk() {
- return bulkRequest;
- }
-
- public NeutronLoadBalancerPoolMember getSingleton() {
- return singletonLoadBalancerPoolMember;
- }
-
- public boolean isSingleton() {
- return (singletonLoadBalancerPoolMember != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 SDN Hub, LLC.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Srini Seetharaman
- */
-
-package org.opendaylight.controller.networkconfig.neutron.northbound;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberAware;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-
-@Path("/pools/{loadBalancerPoolUUID}/members")
-public class NeutronLoadBalancerPoolMembersNorthbound {
- private NeutronLoadBalancerPoolMember extractFields(NeutronLoadBalancerPoolMember o, List<String> fields) {
- return o.extractFields(fields);
- }
-/**
- * Returns a list of all LoadBalancerPoolMembers in specified pool
- */
-@GET
-@Produces({MediaType.APPLICATION_JSON})
-@StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
-
-public Response listMembers(
- //Path param
- @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID,
-
- // return fields
- @QueryParam("fields") List<String> fields,
-
- // OpenStack LoadBalancerPool attributes
- @QueryParam("id") String queryLoadBalancerPoolMemberID,
- @QueryParam("tenant_id") String queryLoadBalancerPoolMemberTenantID,
- @QueryParam("address") String queryLoadBalancerPoolMemberAddress,
- @QueryParam("protocol_port") String queryLoadBalancerPoolMemberProtoPort,
- @QueryParam("admin_state_up") String queryLoadBalancerPoolMemberAdminStateUp,
- @QueryParam("weight") String queryLoadBalancerPoolMemberWeight,
- @QueryParam("subnet_id") String queryLoadBalancerPoolMemberSubnetID,
- @QueryParam("status") String queryLoadBalancerPoolMemberStatus,
-
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
-) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces
- .getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) {
- throw new ResourceNotFoundException("loadBalancerPool UUID does not exist.");
- }
- List<NeutronLoadBalancerPoolMember> members =
- loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID).getLoadBalancerPoolMembers();
- List<NeutronLoadBalancerPoolMember> ans = new ArrayList<NeutronLoadBalancerPoolMember>();
- Iterator<NeutronLoadBalancerPoolMember> i = members.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerPoolMember nsg = i.next();
- if ((queryLoadBalancerPoolMemberID == null ||
- queryLoadBalancerPoolMemberID.equals(nsg.getPoolMemberID())) &&
- loadBalancerPoolUUID.equals(nsg.getPoolID()) &&
- (queryLoadBalancerPoolMemberTenantID == null ||
- queryLoadBalancerPoolMemberTenantID.equals(nsg.getPoolMemberTenantID())) &&
- (queryLoadBalancerPoolMemberAddress == null ||
- queryLoadBalancerPoolMemberAddress.equals(nsg.getPoolMemberAddress())) &&
- (queryLoadBalancerPoolMemberAdminStateUp == null ||
- queryLoadBalancerPoolMemberAdminStateUp.equals(nsg.getPoolMemberAdminStateIsUp())) &&
- (queryLoadBalancerPoolMemberWeight == null ||
- queryLoadBalancerPoolMemberWeight.equals(nsg.getPoolMemberWeight())) &&
- (queryLoadBalancerPoolMemberSubnetID == null ||
- queryLoadBalancerPoolMemberSubnetID.equals(nsg.getPoolMemberSubnetID())) &&
- (queryLoadBalancerPoolMemberStatus == null ||
- queryLoadBalancerPoolMemberStatus.equals(nsg.getPoolMemberStatus()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg, fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronLoadBalancerPoolMemberRequest(ans)).build();
-}
-
-/**
- * Returns a specific LoadBalancerPoolMember
- */
-
-@Path("{loadBalancerPoolMemberUUID}")
-@GET
-@Produces({ MediaType.APPLICATION_JSON })
-//@TypeHint(OpenStackLoadBalancerPoolMembers.class)
-@StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-public Response showLoadBalancerPoolMember(
- @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID,
- @PathParam("loadBalancerPoolMemberUUID") String loadBalancerPoolMemberUUID,
- // return fields
- @QueryParam("fields") List<String> fields ) {
-
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces
- .getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) {
- throw new ResourceNotFoundException("loadBalancerPool UUID does not exist.");
- }
- List<NeutronLoadBalancerPoolMember> members =
- loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID).getLoadBalancerPoolMembers();
- for (NeutronLoadBalancerPoolMember ans: members) {
- if (!ans.getPoolMemberID().equals(loadBalancerPoolMemberUUID))
- continue;
-
- if (fields.size() > 0) {
- return Response.status(200).entity(
- new NeutronLoadBalancerPoolMemberRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(
- new NeutronLoadBalancerPoolMemberRequest(ans)).build();
- }
- }
- return Response.status(204).build();
-}
-
-/**
- * Adds a Member to an LBaaS Pool member
- */
-@PUT
-@Produces({MediaType.APPLICATION_JSON})
-@Consumes({MediaType.APPLICATION_JSON})
-@StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented")})
-public Response createLoadBalancerPoolMember(
- @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID,
- final NeutronLoadBalancerPoolMemberRequest input) {
-
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- // Verify that the loadBalancerPool exists, for the member to be added to its cache
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) {
- throw new ResourceNotFoundException("loadBalancerPool UUID does not exist.");
- }
- NeutronLoadBalancerPool singletonPool = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID);
-
- if (input.isSingleton()) {
- NeutronLoadBalancerPoolMember singleton = input.getSingleton();
- singleton.setPoolID(loadBalancerPoolUUID);
- String loadBalancerPoolMemberUUID = singleton.getPoolMemberID();
-
- /*
- * Verify that the LoadBalancerPoolMember doesn't already exist.
- */
- List<NeutronLoadBalancerPoolMember> members = singletonPool.getLoadBalancerPoolMembers();
- for (NeutronLoadBalancerPoolMember member: members) {
- if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID))
- throw new BadRequestException("LoadBalancerPoolMember UUID already exists");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
- int status = service.canCreateNeutronLoadBalancerPoolMember(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
- service.neutronLoadBalancerPoolMemberCreated(singleton);
- }
- }
-
- /**
- * Add the member from the neutron load balancer pool as well
- */
- singletonPool.addLoadBalancerPoolMember(singleton);
-
- } else {
- List<NeutronLoadBalancerPoolMember> bulk = input.getBulk();
- Iterator<NeutronLoadBalancerPoolMember> i = bulk.iterator();
- HashMap<String, NeutronLoadBalancerPoolMember> testMap = new HashMap<String, NeutronLoadBalancerPoolMember>();
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
- while (i.hasNext()) {
- NeutronLoadBalancerPoolMember test = i.next();
- String loadBalancerPoolMemberUUID = test.getPoolMemberID();
-
- /*
- * Verify that the LoadBalancerPoolMember doesn't already exist.
- */
- List<NeutronLoadBalancerPoolMember> members = singletonPool.getLoadBalancerPoolMembers();
- for (NeutronLoadBalancerPoolMember member: members) {
- if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID))
- throw new BadRequestException("LoadBalancerPoolMember UUID already exists");
- }
-
- if (testMap.containsKey(test.getPoolMemberID())) {
- throw new BadRequestException("Load Balancer PoolMember UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
- int status = service.canCreateNeutronLoadBalancerPoolMember(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerPoolMember test = i.next();
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
- service.neutronLoadBalancerPoolMemberCreated(test);
- }
- }
- singletonPool.addLoadBalancerPoolMember(test);
- }
- }
- return Response.status(201).entity(input).build();
-}
-
-/**
- * Updates a LB member pool
- */
-
-@Path("{loadBalancerPoolMemberUUID}")
-@PUT
-@Produces({ MediaType.APPLICATION_JSON })
-@Consumes({ MediaType.APPLICATION_JSON })
-@StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-public Response updateLoadBalancerPoolMember(
- @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID,
- @PathParam("loadBalancerPoolMemberUUID") String loadBalancerPoolMemberUUID,
- final NeutronLoadBalancerPoolMemberRequest input) {
-
- //TODO: Implement update LB member pool
- return Response.status(501).entity(input).build();
-}
-
-/**
- * Deletes a LoadBalancerPoolMember
- */
-
-@Path("{loadBalancerPoolMemberUUID}")
-@DELETE
-@StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-public Response deleteLoadBalancerPoolMember(
- @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID,
- @PathParam("loadBalancerPoolMemberUUID") String loadBalancerPoolMemberUUID) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- // Verify that the loadBalancerPool exists, for the member to be removed from its cache
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) {
- throw new ResourceNotFoundException("loadBalancerPool UUID does not exist.");
- }
-
- //Verify that the LB pool member exists
- NeutronLoadBalancerPoolMember singleton = null;
- List<NeutronLoadBalancerPoolMember> members =
- loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID).getLoadBalancerPoolMembers();
- for (NeutronLoadBalancerPoolMember member: members) {
- if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID)) {
- singleton = member;
- break;
- }
- }
- if (singleton == null)
- throw new BadRequestException("LoadBalancerPoolMember UUID does not exist.");
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
- int status = service.canDeleteNeutronLoadBalancerPoolMember(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance;
- service.neutronLoadBalancerPoolMemberDeleted(singleton);
- }
- }
-
- /**
- * Remove the member from the neutron load balancer pool
- */
- NeutronLoadBalancerPool singletonPool = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID);
- singletonPool.removeLoadBalancerPoolMember(singleton);
-
- return Response.status(204).build();
-}
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 SDN Hub, LLC.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Srini Seetharaman
- */
-
-package org.opendaylight.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
-
-/**
- * Neutron Northbound REST APIs for LoadBalancerPool Policies.<br>
- * This class provides REST APIs for managing neutron LoadBalancerPool Policies
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-
-/**
- * For now, the LB pool member data is maintained with the INeutronLoadBalancerPoolCRUD,
- * and not duplicated within the INeutronLoadBalancerPoolMemberCRUD's cache.
- */
-
-@Path("/pools")
-public class NeutronLoadBalancerPoolNorthbound {
-
- private NeutronLoadBalancerPool extractFields(NeutronLoadBalancerPool o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all LoadBalancerPool
- * */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
-
- public Response listGroups(
- // return fields
- @QueryParam("fields") List<String> fields,
- // OpenStack LoadBalancerPool attributes
- @QueryParam("id") String queryLoadBalancerPoolID,
- @QueryParam("tenant_id") String queryLoadBalancerPoolTenantID,
- @QueryParam("name") String queryLoadBalancerPoolName,
- @QueryParam("description") String queryLoadBalancerDescription,
- @QueryParam("protocol") String queryLoadBalancerProtocol,
- @QueryParam("lb_algorithm") String queryLoadBalancerPoolLbAlgorithm,
- @QueryParam("healthmonitor_id") String queryLoadBalancerPoolHealthMonitorID,
- @QueryParam("admin_state_up") String queryLoadBalancerIsAdminStateUp,
- @QueryParam("status") String queryLoadBalancerPoolStatus,
- @QueryParam("members") List<NeutronLoadBalancerPoolMember> queryLoadBalancerPoolMembers,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronLoadBalancerPool> allLoadBalancerPools = loadBalancerPoolInterface.getAllNeutronLoadBalancerPools();
- List<NeutronLoadBalancerPool> ans = new ArrayList<NeutronLoadBalancerPool>();
- Iterator<NeutronLoadBalancerPool> i = allLoadBalancerPools.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerPool nsg = i.next();
- if ((queryLoadBalancerPoolID == null ||
- queryLoadBalancerPoolID.equals(nsg.getLoadBalancerPoolID())) &&
- (queryLoadBalancerPoolTenantID == null ||
- queryLoadBalancerPoolTenantID.equals(nsg.getLoadBalancerPoolTenantID())) &&
- (queryLoadBalancerPoolName == null ||
- queryLoadBalancerPoolName.equals(nsg.getLoadBalancerPoolName())) &&
- (queryLoadBalancerDescription == null ||
- queryLoadBalancerDescription.equals(nsg.getLoadBalancerPoolDescription())) &&
- (queryLoadBalancerPoolLbAlgorithm == null ||
- queryLoadBalancerPoolLbAlgorithm.equals(nsg.getLoadBalancerPoolLbAlgorithm())) &&
- (queryLoadBalancerPoolHealthMonitorID == null ||
- queryLoadBalancerPoolHealthMonitorID.equals(nsg.getNeutronLoadBalancerPoolHealthMonitorID())) &&
- (queryLoadBalancerIsAdminStateUp == null ||
- queryLoadBalancerIsAdminStateUp.equals(nsg.getLoadBalancerPoolAdminIsStateIsUp())) &&
- (queryLoadBalancerPoolStatus == null ||
- queryLoadBalancerPoolStatus.equals(nsg.getLoadBalancerPoolStatus())) &&
- (queryLoadBalancerPoolMembers.size() == 0 ||
- queryLoadBalancerPoolMembers.equals(nsg.getLoadBalancerPoolMembers()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg,fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronLoadBalancerPoolRequest(ans)).build();
- }
-
- /**
- * Returns a specific LoadBalancerPool */
-
- @Path("{loadBalancerPoolID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showLoadBalancerPool(@PathParam("loadBalancerPoolID") String loadBalancerPoolID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolID)) {
- throw new ResourceNotFoundException("LoadBalancerPool UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronLoadBalancerPool ans = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID);
- return Response.status(200).entity(
- new NeutronLoadBalancerPoolRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronLoadBalancerPoolRequest(loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID))).build();
- }
- }
-
- /**
- * Creates new LoadBalancerPool */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createLoadBalancerPools(final NeutronLoadBalancerPoolRequest input) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronLoadBalancerPool singleton = input.getSingleton();
-
- /*
- * Verify that the LoadBalancerPool doesn't already exist.
- */
- if (loadBalancerPoolInterface.neutronLoadBalancerPoolExists(singleton.getLoadBalancerPoolID())) {
- throw new BadRequestException("LoadBalancerPool UUID already exists");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- int status = service.canCreateNeutronLoadBalancerPool(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- loadBalancerPoolInterface.addNeutronLoadBalancerPool(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- service.neutronLoadBalancerPoolCreated(singleton);
- }
- }
- } else {
- List<NeutronLoadBalancerPool> bulk = input.getBulk();
- Iterator<NeutronLoadBalancerPool> i = bulk.iterator();
- HashMap<String, NeutronLoadBalancerPool> testMap = new HashMap<String, NeutronLoadBalancerPool>();
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
- while (i.hasNext()) {
- NeutronLoadBalancerPool test = i.next();
-
- /*
- * Verify that the loadBalancerPool doesn't already exist
- */
-
- if (loadBalancerPoolInterface.neutronLoadBalancerPoolExists(test.getLoadBalancerPoolID())) {
- throw new BadRequestException("Load Balancer Pool UUID already is already created");
- }
- if (testMap.containsKey(test.getLoadBalancerPoolID())) {
- throw new BadRequestException("Load Balancer Pool UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- int status = service.canCreateNeutronLoadBalancerPool(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronLoadBalancerPool test = i.next();
- loadBalancerPoolInterface.addNeutronLoadBalancerPool(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- service.neutronLoadBalancerPoolCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a LoadBalancerPool Policy
- */
- @Path("{loadBalancerPoolID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateLoadBalancerPool(
- @PathParam("loadBalancerPoolID") String loadBalancerPoolID, final NeutronLoadBalancerPoolRequest input) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancerPool exists and there is only one delta provided
- */
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolID)) {
- throw new ResourceNotFoundException("LoadBalancerPool UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronLoadBalancerPool delta = input.getSingleton();
- NeutronLoadBalancerPool original = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getLoadBalancerPoolID() != null ||
- delta.getLoadBalancerPoolTenantID() != null ||
- delta.getLoadBalancerPoolName() != null ||
- delta.getLoadBalancerPoolDescription() != null ||
- delta.getLoadBalancerPoolProtocol() != null ||
- delta.getLoadBalancerPoolLbAlgorithm() != null ||
- delta.getNeutronLoadBalancerPoolHealthMonitorID() != null ||
- delta.getLoadBalancerPoolAdminIsStateIsUp() != null ||
- delta.getLoadBalancerPoolStatus() != null ||
- delta.getLoadBalancerPoolMembers() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- int status = service.canUpdateNeutronLoadBalancerPool(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- loadBalancerPoolInterface.updateNeutronLoadBalancerPool(loadBalancerPoolID, delta);
- NeutronLoadBalancerPool updatedLoadBalancerPool = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- service.neutronLoadBalancerPoolUpdated(updatedLoadBalancerPool);
- }
- }
- return Response.status(200).entity(new NeutronLoadBalancerPoolRequest(loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID))).build();
- }
-
- /**
- * Deletes a LoadBalancerPool
- */
-
- @Path("{loadBalancerPoolUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteLoadBalancerPool(
- @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID) {
- INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = NeutronCRUDInterfaces.getINeutronLoadBalancerPoolCRUD(this);
- if (loadBalancerPoolInterface == null) {
- throw new ServiceUnavailableException("LoadBalancerPool CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the LoadBalancerPool exists and it isn't currently in use
- */
- if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) {
- throw new ResourceNotFoundException("LoadBalancerPool UUID does not exist.");
- }
- if (loadBalancerPoolInterface.neutronLoadBalancerPoolInUse(loadBalancerPoolUUID)) {
- return Response.status(409).build();
- }
- NeutronLoadBalancerPool singleton = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- int status = service.canDeleteNeutronLoadBalancerPool(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * remove it and return 204 status
- */
- loadBalancerPoolInterface.removeNeutronLoadBalancerPool(loadBalancerPoolUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronLoadBalancerPoolAware service = (INeutronLoadBalancerPoolAware) instance;
- service.neutronLoadBalancerPoolDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronLoadBalancerPoolRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="pool")
- NeutronLoadBalancerPool singletonLoadBalancerPool;
-
- @XmlElement(name="pools")
- List<NeutronLoadBalancerPool> bulkRequest;
-
- NeutronLoadBalancerPoolRequest() {
- }
-
- NeutronLoadBalancerPoolRequest(List<NeutronLoadBalancerPool> bulk) {
- bulkRequest = bulk;
- singletonLoadBalancerPool = null;
- }
-
- NeutronLoadBalancerPoolRequest(NeutronLoadBalancerPool group) {
- singletonLoadBalancerPool = group;
- }
-
- public List<NeutronLoadBalancerPool> getBulk() {
- return bulkRequest;
- }
-
- public NeutronLoadBalancerPool getSingleton() {
- return singletonLoadBalancerPool;
- }
-
- public boolean isSingleton() {
- return (singletonLoadBalancerPool != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronLoadBalancerRequest {
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="loadbalancer")
- NeutronLoadBalancer singletonLoadBalancer;
-
- @XmlElement(name="loadbalancers")
- List<NeutronLoadBalancer> bulkRequest;
-
- NeutronLoadBalancerRequest() {
- }
-
- NeutronLoadBalancerRequest(List<NeutronLoadBalancer> bulk) {
- bulkRequest = bulk;
- singletonLoadBalancer = null;
- }
-
- NeutronLoadBalancerRequest(NeutronLoadBalancer group) {
- singletonLoadBalancer = group;
- }
-
- public List<NeutronLoadBalancer> getBulk() {
- return bulkRequest;
- }
-
- public NeutronLoadBalancer getSingleton() {
- return singletonLoadBalancer;
- }
-
- public boolean isSingleton() {
- return (singletonLoadBalancer != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-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.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronNetworkRequest implements INeutronRequest<NeutronNetwork> {
- // See OpenStack Network API v2.0 Reference for description of
- // annotated attributes
-
- @XmlElement(name="network")
- NeutronNetwork singletonNetwork;
-
- @XmlElement(name="networks")
- List<NeutronNetwork> bulkRequest;
-
- @XmlElement(name="networks_links")
- List<NeutronPageLink> links;
-
- NeutronNetworkRequest() {
- }
-
- NeutronNetworkRequest(List<NeutronNetwork> bulkRequest, List<NeutronPageLink> links) {
- this.bulkRequest = bulkRequest;
- this.links = links;
- this.singletonNetwork = null;
- }
-
- NeutronNetworkRequest(List<NeutronNetwork> bulk) {
- bulkRequest = bulk;
- singletonNetwork = null;
- }
-
- NeutronNetworkRequest(NeutronNetwork net) {
- singletonNetwork = net;
- }
-
- @Override
- public NeutronNetwork getSingleton() {
- return singletonNetwork;
- }
-
- @Override
- public boolean isSingleton() {
- return (singletonNetwork != null);
- }
-
- @Override
- public List<NeutronNetwork> getBulk() {
- return bulkRequest;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.codehaus.enunciate.jaxrs.TypeHint;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-
-/**
- * Neutron Northbound REST APIs for Network.<br>
- * This class provides REST APIs for managing neutron Networks
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-
-@Path("/networks")
-public class NeutronNetworksNorthbound {
-
- @Context
- UriInfo uriInfo;
-
- private NeutronNetwork extractFields(NeutronNetwork o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Networks */
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackNetworks.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized")})
- public Response listNetworks(
- // return fields
- @QueryParam("fields") List<String> fields,
- // note: openstack isn't clear about filtering on lists, so we aren't handling them
- @QueryParam("id") String queryID,
- @QueryParam("name") String queryName,
- @QueryParam("admin_state_up") String queryAdminStateUp,
- @QueryParam("status") String queryStatus,
- @QueryParam("shared") String queryShared,
- @QueryParam("tenant_id") String queryTenantID,
- @QueryParam("router_external") String queryRouterExternal,
- @QueryParam("provider_network_type") String queryProviderNetworkType,
- @QueryParam("provider_physical_network") String queryProviderPhysicalNetwork,
- @QueryParam("provider_segmentation_id") String queryProviderSegmentationID,
- // linkTitle
- @QueryParam("limit") Integer limit,
- @QueryParam("marker") String marker,
- @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
- // sorting not supported
- ) {
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronNetwork> allNetworks = networkInterface.getAllNetworks();
- List<NeutronNetwork> ans = new ArrayList<NeutronNetwork>();
- Iterator<NeutronNetwork> i = allNetworks.iterator();
- while (i.hasNext()) {
- NeutronNetwork oSN = i.next();
- //match filters: TODO provider extension
- Boolean bAdminStateUp = null;
- Boolean bShared = null;
- Boolean bRouterExternal = null;
- if (queryAdminStateUp != null) {
- bAdminStateUp = Boolean.valueOf(queryAdminStateUp);
- }
- if (queryShared != null) {
- bShared = Boolean.valueOf(queryShared);
- }
- if (queryRouterExternal != null) {
- bRouterExternal = Boolean.valueOf(queryRouterExternal);
- }
- if ((queryID == null || queryID.equals(oSN.getID())) &&
- (queryName == null || queryName.equals(oSN.getNetworkName())) &&
- (bAdminStateUp == null || bAdminStateUp.booleanValue() == oSN.isAdminStateUp()) &&
- (queryStatus == null || queryStatus.equals(oSN.getStatus())) &&
- (bShared == null || bShared.booleanValue() == oSN.isShared()) &&
- (bRouterExternal == null || bRouterExternal.booleanValue() == oSN.isRouterExternal()) &&
- (queryTenantID == null || queryTenantID.equals(oSN.getTenantID()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(oSN,fields));
- } else {
- ans.add(oSN);
- }
- }
- }
-
- if (limit != null && ans.size() > 1) {
- // Return a paginated request
- NeutronNetworkRequest request = (NeutronNetworkRequest) PaginatedRequestFactory.createRequest(limit,
- marker, pageReverse, uriInfo, ans, NeutronNetwork.class);
- return Response.status(200).entity(request).build();
- }
-
- return Response.status(200).entity(new NeutronNetworkRequest(ans)).build();
-
- }
-
- /**
- * Returns a specific Network */
-
- @Path("{netUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackNetworks.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found") })
- public Response showNetwork(
- @PathParam("netUUID") String netUUID,
- // return fields
- @QueryParam("fields") List<String> fields
- ) {
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!networkInterface.networkExists(netUUID)) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronNetwork ans = networkInterface.getNetwork(netUUID);
- return Response.status(200).entity(
- new NeutronNetworkRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(
- new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
- }
- }
-
- /**
- * Creates new Networks */
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- @TypeHint(NeutronNetwork.class)
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized") })
- public Response createNetworks(final NeutronNetworkRequest input) {
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronNetwork singleton = input.getSingleton();
-
- /*
- * network ID can't already exist
- */
- if (networkInterface.networkExists(singleton.getID())) {
- throw new BadRequestException("network UUID already exists");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- int status = service.canCreateNetwork(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- // add network to cache
- singleton.initDefaults();
- networkInterface.addNetwork(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- service.neutronNetworkCreated(singleton);
- }
- }
-
- } else {
- List<NeutronNetwork> bulk = input.getBulk();
- Iterator<NeutronNetwork> i = bulk.iterator();
- HashMap<String, NeutronNetwork> testMap = new HashMap<String, NeutronNetwork>();
- Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
- while (i.hasNext()) {
- NeutronNetwork test = i.next();
-
- /*
- * network ID can't already exist, nor can there be an entry for this UUID
- * already in this bulk request
- */
- if (networkInterface.networkExists(test.getID())) {
- throw new BadRequestException("network UUID already exists");
- }
- if (testMap.containsKey(test.getID())) {
- throw new BadRequestException("network UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance: instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- int status = service.canCreateNetwork(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- testMap.put(test.getID(),test);
- }
-
- // now that everything passed, add items to the cache
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronNetwork test = i.next();
- test.initDefaults();
- networkInterface.addNetwork(test);
- if (instances != null) {
- for (Object instance: instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- service.neutronNetworkCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Network */
- @Path("{netUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackNetworks.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"), })
- public Response updateNetwork(
- @PathParam("netUUID") String netUUID, final NeutronNetworkRequest input
- ) {
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * network has to exist and only a single delta is supported
- */
- if (!networkInterface.networkExists(netUUID)) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("only singleton edits supported");
- }
- NeutronNetwork delta = input.getSingleton();
-
- /*
- * transitions forbidden by Neutron
- */
- if (delta.getID() != null || delta.getTenantID() != null ||
- delta.getStatus() != null) {
- throw new BadRequestException("attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- NeutronNetwork original = networkInterface.getNetwork(netUUID);
- int status = service.canUpdateNetwork(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- // update network object and return the modified object
- networkInterface.updateNetwork(netUUID, delta);
- NeutronNetwork updatedSingleton = networkInterface.getNetwork(netUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- service.neutronNetworkUpdated(updatedSingleton);
- }
- }
- return Response.status(200).entity(
- new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
- }
-
- /**
- * Deletes a Network */
-
- @Path("{netUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Network In Use") })
- public Response deleteNetwork(
- @PathParam("netUUID") String netUUID) {
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * network has to exist and not be in use before it can be removed
- */
- if (!networkInterface.networkExists(netUUID)) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (networkInterface.networkInUse(netUUID)) {
- throw new ResourceConflictException("Network ID in use");
- }
-
- NeutronNetwork singleton = networkInterface.getNetwork(netUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- int status = service.canDeleteNetwork(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- networkInterface.removeNetwork(netUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- service.neutronNetworkDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;
-
-import javax.ws.rs.core.Application;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * This class is an instance of javax.ws.rs.core.Application and is used to return the classes
- * that will be instantiated for JAXRS processing. This is necessary
- * because package scanning in jersey doesn't yet work in OSGi environment.
- *
- */
-public class NeutronNorthboundRSApplication extends Application {
- @Override
- public Set<Class<?>> getClasses() {
- Set<Class<?>> classes = new HashSet<Class<?>>();
-// northbound URIs
- classes.add(NeutronNetworksNorthbound.class);
- classes.add(NeutronSubnetsNorthbound.class);
- classes.add(NeutronPortsNorthbound.class);
- classes.add(NeutronRoutersNorthbound.class);
- classes.add(NeutronFloatingIPsNorthbound.class);
- classes.add(NeutronSecurityGroupsNorthbound.class);
- classes.add(NeutronSecurityRulesNorthbound.class);
- classes.add(NeutronFirewallNorthbound.class);
- classes.add(NeutronFirewallPolicyNorthbound.class);
- classes.add(NeutronFirewallRulesNorthbound.class);
- classes.add(NeutronLoadBalancerNorthbound.class);
- classes.add(NeutronLoadBalancerListenerNorthbound.class);
- classes.add(NeutronLoadBalancerPoolNorthbound.class);
- classes.add(NeutronLoadBalancerHealthMonitorNorthbound.class);
- classes.add(NeutronLoadBalancerPoolMembersNorthbound.class);
- classes.add(MOXyJsonProvider.class);
- return classes;
- }
-
- @Override
- public Set<Object> getSingletons() {
- MOXyJsonProvider moxyJsonProvider = new MOXyJsonProvider();
-
- moxyJsonProvider.setAttributePrefix("@");
- moxyJsonProvider.setFormattedOutput(true);
- moxyJsonProvider.setIncludeRoot(false);
- moxyJsonProvider.setMarshalEmptyCollections(true);
- moxyJsonProvider.setValueWrapper("$");
-
- Map<String, String> namespacePrefixMapper = new HashMap<String, String>(3);
- namespacePrefixMapper.put("router", "router"); // FIXME: fill in with XSD
- namespacePrefixMapper.put("provider", "provider"); // FIXME: fill in with XSD
- namespacePrefixMapper.put("binding", "binding");
- moxyJsonProvider.setNamespacePrefixMapper(namespacePrefixMapper);
- moxyJsonProvider.setNamespaceSeparator(':');
-
- HashSet<Object> set = new HashSet<Object>(1);
- set.add(moxyJsonProvider);
- return set;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Hewlett-Packard Development Company L.P
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Dave Tucker
- */
-
-package org.opendaylight.controller.networkconfig.neutron.northbound;
-
-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 NeutronPageLink {
-
- @XmlElement(name="ref")
- String ref;
-
- @XmlElement (name="href")
- String href;
-
- public String getRef() {
- return ref;
- }
-
- public void setRef(String ref) {
- this.ref = ref;
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(String href) {
- this.href = href;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-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.opendaylight.controller.networkconfig.neutron.NeutronPort;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronPortRequest implements INeutronRequest<NeutronPort> {
- // See OpenStack Network API v2.0 Reference for description of
- // annotated attributes
-
- @XmlElement(name="port")
- NeutronPort singletonPort;
-
- @XmlElement(name="ports")
- List<NeutronPort> bulkRequest;
-
- @XmlElement(name="ports_links")
- List<NeutronPageLink> links;
-
- NeutronPortRequest() {
- }
-
- public NeutronPortRequest(List<NeutronPort> bulkRequest, List<NeutronPageLink> links) {
- this.bulkRequest = bulkRequest;
- this.links = links;
- this.singletonPort = null;
- }
-
- NeutronPortRequest(List<NeutronPort> bulk) {
- bulkRequest = bulk;
- singletonPort = null;
- }
-
- NeutronPortRequest(NeutronPort port) {
- singletonPort = port;
- }
-
- @Override
- public NeutronPort getSingleton() {
- return singletonPort;
- }
-
- @Override
- public boolean isSingleton() {
- return (singletonPort != null);
- }
-
- @Override
- public List<NeutronPort> getBulk() {
- return bulkRequest;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-
-/**
- * Neutron Northbound REST APIs.<br>
- * This class provides REST APIs for managing neutron port objects
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-
-@Path("/ports")
-public class NeutronPortsNorthbound {
-
- final String mac_regex="^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$";
-
- private NeutronPort extractFields(NeutronPort o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- @Context
- UriInfo uriInfo;
-
- /**
- * Returns a list of all Ports */
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackPorts.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response listPorts(
- // return fields
- @QueryParam("fields") List<String> fields,
- // note: openstack isn't clear about filtering on lists, so we aren't handling them
- @QueryParam("id") String queryID,
- @QueryParam("network_id") String queryNetworkID,
- @QueryParam("name") String queryName,
- @QueryParam("admin_state_up") String queryAdminStateUp,
- @QueryParam("status") String queryStatus,
- @QueryParam("mac_address") String queryMACAddress,
- @QueryParam("device_id") String queryDeviceID,
- @QueryParam("device_owner") String queryDeviceOwner,
- @QueryParam("tenant_id") String queryTenantID,
- // linkTitle
- @QueryParam("limit") Integer limit,
- @QueryParam("marker") String marker,
- @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
- // sorting not supported
- ) {
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronPort> allPorts = portInterface.getAllPorts();
- List<NeutronPort> ans = new ArrayList<NeutronPort>();
- Iterator<NeutronPort> i = allPorts.iterator();
- while (i.hasNext()) {
- NeutronPort oSS = i.next();
- if ((queryID == null || queryID.equals(oSS.getID())) &&
- (queryNetworkID == null || queryNetworkID.equals(oSS.getNetworkUUID())) &&
- (queryName == null || queryName.equals(oSS.getName())) &&
- (queryAdminStateUp == null || queryAdminStateUp.equals(oSS.getAdminStateUp())) &&
- (queryStatus == null || queryStatus.equals(oSS.getStatus())) &&
- (queryMACAddress == null || queryMACAddress.equals(oSS.getMacAddress())) &&
- (queryDeviceID == null || queryDeviceID.equals(oSS.getDeviceID())) &&
- (queryDeviceOwner == null || queryDeviceOwner.equals(oSS.getDeviceOwner())) &&
- (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(oSS,fields));
- } else {
- ans.add(oSS);
- }
- }
- }
-
- if (limit != null && ans.size() > 1) {
- // Return a paginated request
- NeutronPortRequest request = (NeutronPortRequest) PaginatedRequestFactory.createRequest(limit,
- marker, pageReverse, uriInfo, ans, NeutronPort.class);
- return Response.status(200).entity(request).build();
- }
-
- return Response.status(200).entity(
- new NeutronPortRequest(ans)).build();
- }
-
- /**
- * Returns a specific Port */
-
- @Path("{portUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackPorts.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showPort(
- @PathParam("portUUID") String portUUID,
- // return fields
- @QueryParam("fields") List<String> fields ) {
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!portInterface.portExists(portUUID)) {
- throw new ResourceNotFoundException("port UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronPort ans = portInterface.getPort(portUUID);
- return Response.status(200).entity(
- new NeutronPortRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(
- new NeutronPortRequest(portInterface.getPort(portUUID))).build();
- }
- }
-
- /**
- * Creates new Ports */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackPorts.class)
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented"),
- @ResponseCode(code = 503, condition = "MAC generation failure") })
- public Response createPorts(final NeutronPortRequest input) {
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronPort singleton = input.getSingleton();
-
- /*
- * the port must be part of an existing network, must not already exist,
- * have a valid MAC and the MAC not be in use
- */
- if (singleton.getNetworkUUID() == null) {
- throw new BadRequestException("network UUID musy be specified");
- }
- if (portInterface.portExists(singleton.getID())) {
- throw new BadRequestException("port UUID already exists");
- }
- if (!networkInterface.networkExists(singleton.getNetworkUUID())) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (singleton.getMacAddress() == null ||
- !singleton.getMacAddress().matches(mac_regex)) {
- throw new BadRequestException("MAC address not properly formatted");
- }
- if (portInterface.macInUse(singleton.getMacAddress())) {
- throw new ResourceConflictException("MAC Address is in use.");
- }
- /*
- * if fixed IPs are specified, each one has to have an existing subnet ID
- * that is in the same scoping network as the port. In addition, if an IP
- * address is specified it has to be a valid address for the subnet and not
- * already in use
- */
- List<Neutron_IPs> fixedIPs = singleton.getFixedIPs();
- if (fixedIPs != null && fixedIPs.size() > 0) {
- Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
- while (fixedIPIterator.hasNext()) {
- Neutron_IPs ip = fixedIPIterator.next();
- if (ip.getSubnetUUID() == null) {
- throw new BadRequestException("subnet UUID not specified");
- }
- if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
- throw new BadRequestException("subnet UUID must exists");
- }
- NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
- if (!singleton.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
- throw new BadRequestException("network UUID must match that of subnet");
- }
- if (ip.getIpAddress() != null) {
- if (!subnet.isValidIP(ip.getIpAddress())) {
- throw new BadRequestException("IP address is not valid");
- }
- if (subnet.isIPInUse(ip.getIpAddress())) {
- throw new ResourceConflictException("IP address is in use.");
- }
- }
- }
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canCreatePort(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- // add the port to the cache
- portInterface.addPort(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- service.neutronPortCreated(singleton);
- }
- }
- } else {
- List<NeutronPort> bulk = input.getBulk();
- Iterator<NeutronPort> i = bulk.iterator();
- HashMap<String, NeutronPort> testMap = new HashMap<String, NeutronPort>();
- Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
- while (i.hasNext()) {
- NeutronPort test = i.next();
-
- /*
- * the port must be part of an existing network, must not already exist,
- * have a valid MAC and the MAC not be in use. Further the bulk request
- * can't already contain a new port with the same UUID
- */
- if (portInterface.portExists(test.getID())) {
- throw new BadRequestException("port UUID already exists");
- }
- if (testMap.containsKey(test.getID())) {
- throw new BadRequestException("port UUID already exists");
- }
- for (NeutronPort check : testMap.values()) {
- if (test.getMacAddress().equalsIgnoreCase(check.getMacAddress())) {
- throw new ResourceConflictException("MAC address already allocated");
- }
- for (Neutron_IPs test_fixedIP : test.getFixedIPs()) {
- for (Neutron_IPs check_fixedIP : check.getFixedIPs()) {
- if (test_fixedIP.getIpAddress().equals(check_fixedIP.getIpAddress())) {
- throw new ResourceConflictException("IP address already allocated");
- }
- }
- }
- }
- testMap.put(test.getID(), test);
- if (!networkInterface.networkExists(test.getNetworkUUID())) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (!test.getMacAddress().matches(mac_regex)) {
- throw new BadRequestException("MAC address not properly formatted");
- }
- if (portInterface.macInUse(test.getMacAddress())) {
- throw new ResourceConflictException("MAC address in use");
- }
-
- /*
- * if fixed IPs are specified, each one has to have an existing subnet ID
- * that is in the same scoping network as the port. In addition, if an IP
- * address is specified it has to be a valid address for the subnet and not
- * already in use (or be the gateway IP address of the subnet)
- */
- List<Neutron_IPs> fixedIPs = test.getFixedIPs();
- if (fixedIPs != null && fixedIPs.size() > 0) {
- Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
- while (fixedIPIterator.hasNext()) {
- Neutron_IPs ip = fixedIPIterator.next();
- if (ip.getSubnetUUID() == null) {
- throw new BadRequestException("subnet UUID must be specified");
- }
- if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
- throw new BadRequestException("subnet UUID doesn't exists");
- }
- NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
- if (!test.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
- throw new BadRequestException("network UUID must match that of subnet");
- }
- if (ip.getIpAddress() != null) {
- if (!subnet.isValidIP(ip.getIpAddress())) {
- throw new BadRequestException("ip address not valid");
- }
- //TODO: need to add consideration for a fixed IP being assigned the same address as a allocated IP in the
- //same bulk create
- if (subnet.isIPInUse(ip.getIpAddress())) {
- throw new ResourceConflictException("IP address in use");
- }
- }
- }
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canCreatePort(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
-
- //once everything has passed, then we can add to the cache
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronPort test = i.next();
- portInterface.addPort(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- service.neutronPortCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Port */
-
- @Path("{portUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackPorts.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updatePort(
- @PathParam("portUUID") String portUUID,
- NeutronPortRequest input
- ) {
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- // port has to exist and only a single delta is supported
- if (!portInterface.portExists(portUUID)) {
- throw new ResourceNotFoundException("port UUID does not exist.");
- }
- NeutronPort target = portInterface.getPort(portUUID);
- if (!input.isSingleton()) {
- throw new BadRequestException("only singleton edit suported");
- }
- NeutronPort singleton = input.getSingleton();
- NeutronPort original = portInterface.getPort(portUUID);
-
- // deltas restricted by Neutron
- if (singleton.getID() != null || singleton.getTenantID() != null ||
- singleton.getStatus() != null) {
- throw new BadRequestException("attribute change blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canUpdatePort(singleton, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- // Verify the new fixed ips are valid
- List<Neutron_IPs> fixedIPs = singleton.getFixedIPs();
- if (fixedIPs != null && fixedIPs.size() > 0) {
- Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
- while (fixedIPIterator.hasNext()) {
- Neutron_IPs ip = fixedIPIterator.next();
- if (ip.getSubnetUUID() == null) {
- throw new BadRequestException("subnet UUID must be specified");
- }
- if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
- throw new BadRequestException("subnet UUID doesn't exist.");
- }
- NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
- if (!target.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
- throw new BadRequestException("network UUID must match that of subnet");
- }
- if (ip.getIpAddress() != null) {
- if (!subnet.isValidIP(ip.getIpAddress())) {
- throw new BadRequestException("invalid IP address");
- }
- if (subnet.isIPInUse(ip.getIpAddress())) {
- throw new ResourceConflictException("IP address in use");
- }
- }
- }
- }
-
- // TODO: Support change of security groups
- // update the port and return the modified object
- portInterface.updatePort(portUUID, singleton);
- NeutronPort updatedPort = portInterface.getPort(portUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- service.neutronPortUpdated(updatedPort);
- }
- }
- return Response.status(200).entity(
- new NeutronPortRequest(updatedPort)).build();
-
- }
-
- /**
- * Deletes a Port */
-
- @Path("{portUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deletePort(
- @PathParam("portUUID") String portUUID) {
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- // port has to exist and not be owned by anyone. then it can be removed from the cache
- if (!portInterface.portExists(portUUID)) {
- throw new ResourceNotFoundException("port UUID does not exist.");
- }
- NeutronPort port = portInterface.getPort(portUUID);
- if (port.getDeviceID() != null ||
- port.getDeviceOwner() != null) {
- Response.status(403).build();
- }
- NeutronPort singleton = portInterface.getPort(portUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canDeletePort(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- portInterface.removePort(portUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- service.neutronPortDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-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.opendaylight.controller.networkconfig.neutron.NeutronRouter;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronRouterRequest {
- // See OpenStack Network API v2.0 Reference for description of
- // annotated attributes
-
- @XmlElement(name="router")
- NeutronRouter singletonRouter;
-
- @XmlElement(name="routers")
- List<NeutronRouter> bulkRequest;
-
- NeutronRouterRequest() {
- }
-
- NeutronRouterRequest(List<NeutronRouter> bulk) {
- bulkRequest = bulk;
- singletonRouter = null;
- }
-
- NeutronRouterRequest(NeutronRouter router) {
- singletonRouter = router;
- }
-
- public List<NeutronRouter> getBulk() {
- return bulkRequest;
- }
-
- public NeutronRouter getSingleton() {
- return singletonRouter;
- }
-
- public boolean isSingleton() {
- return (singletonRouter != null);
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronRouterAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
-import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-
-
-/**
- * Neutron Northbound REST APIs.<br>
- * This class provides REST APIs for managing neutron routers
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-
-@Path("/routers")
-public class NeutronRoutersNorthbound {
-
- private NeutronRouter extractFields(NeutronRouter o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Routers */
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackRouters.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response listRouters(
- // return fields
- @QueryParam("fields") List<String> fields,
- // note: openstack isn't clear about filtering on lists, so we aren't handling them
- @QueryParam("id") String queryID,
- @QueryParam("name") String queryName,
- @QueryParam("admin_state_up") String queryAdminStateUp,
- @QueryParam("status") String queryStatus,
- @QueryParam("tenant_id") String queryTenantID,
- @QueryParam("external_gateway_info") String queryExternalGatewayInfo,
- // pagination
- @QueryParam("limit") String limit,
- @QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
- // sorting not supported
- ) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronRouter> allRouters = routerInterface.getAllRouters();
- List<NeutronRouter> ans = new ArrayList<NeutronRouter>();
- Iterator<NeutronRouter> i = allRouters.iterator();
- while (i.hasNext()) {
- NeutronRouter oSS = i.next();
- if ((queryID == null || queryID.equals(oSS.getID())) &&
- (queryName == null || queryName.equals(oSS.getName())) &&
- (queryAdminStateUp == null || queryAdminStateUp.equals(oSS.getAdminStateUp())) &&
- (queryStatus == null || queryStatus.equals(oSS.getStatus())) &&
- (queryExternalGatewayInfo == null || queryExternalGatewayInfo.equals(oSS.getExternalGatewayInfo())) &&
- (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
- if (fields.size() > 0)
- ans.add(extractFields(oSS,fields));
- else
- ans.add(oSS);
- }
- }
- //TODO: apply pagination to results
- return Response.status(200).entity(
- new NeutronRouterRequest(ans)).build();
- }
-
- /**
- * Returns a specific Router */
-
- @Path("{routerUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackRouters.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showRouter(
- @PathParam("routerUUID") String routerUUID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!routerInterface.routerExists(routerUUID)) {
- throw new ResourceNotFoundException("Router UUID not found");
- }
- if (fields.size() > 0) {
- NeutronRouter ans = routerInterface.getRouter(routerUUID);
- return Response.status(200).entity(
- new NeutronRouterRequest(extractFields(ans, fields))).build();
- } else
- return Response.status(200).entity(
- new NeutronRouterRequest(routerInterface.getRouter(routerUUID))).build();
- }
-
- /**
- * Creates new Routers */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackRouters.class)
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createRouters(final NeutronRouterRequest input) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronRouter singleton = input.getSingleton();
-
- /*
- * verify that the router doesn't already exist (issue: is deeper inspection necessary?)
- * if there is external gateway information provided, verify that the specified network
- * exists and has been designated as "router:external"
- */
- if (routerInterface.routerExists(singleton.getID()))
- throw new BadRequestException("router UUID already exists");
- if (singleton.getExternalGatewayInfo() != null) {
- String externNetworkPtr = singleton.getExternalGatewayInfo().getNetworkID();
- if (!networkInterface.networkExists(externNetworkPtr))
- throw new BadRequestException("External Network Pointer doesn't exist");
- NeutronNetwork externNetwork = networkInterface.getNetwork(externNetworkPtr);
- if (!externNetwork.isRouterExternal())
- throw new BadRequestException("External Network Pointer isn't marked as router:external");
- }
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canCreateRouter(singleton);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * add router to the cache
- */
- routerInterface.addRouter(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterCreated(singleton);
- }
- }
- } else {
-
- /*
- * only singleton router creates supported
- */
- throw new BadRequestException("Only singleton router creates supported");
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Router */
-
- @Path("{routerUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackRouters.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateRouter(
- @PathParam("routerUUID") String routerUUID,
- NeutronRouterRequest input
- ) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * router has to exist and only a single delta can be supplied
- */
- if (!routerInterface.routerExists(routerUUID))
- throw new ResourceNotFoundException("Router UUID not found");
- if (!input.isSingleton())
- throw new BadRequestException("Only single router deltas supported");
- NeutronRouter singleton = input.getSingleton();
- NeutronRouter original = routerInterface.getRouter(routerUUID);
-
- /*
- * attribute changes blocked by Neutron
- */
- if (singleton.getID() != null || singleton.getTenantID() != null ||
- singleton.getStatus() != null)
- throw new BadRequestException("Request attribute change not allowed");
-
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canUpdateRouter(singleton, original);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- /*
- * if the external gateway info is being changed, verify that the new network
- * exists and has been designated as an external network
- */
- if (singleton.getExternalGatewayInfo() != null) {
- String externNetworkPtr = singleton.getExternalGatewayInfo().getNetworkID();
- if (!networkInterface.networkExists(externNetworkPtr))
- throw new BadRequestException("External Network Pointer does not exist");
- NeutronNetwork externNetwork = networkInterface.getNetwork(externNetworkPtr);
- if (!externNetwork.isRouterExternal())
- throw new BadRequestException("External Network Pointer isn't marked as router:external");
- }
-
- /*
- * update the router entry and return the modified object
- */
- routerInterface.updateRouter(routerUUID, singleton);
- NeutronRouter updatedRouter = routerInterface.getRouter(routerUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterUpdated(updatedRouter);
- }
- }
- return Response.status(200).entity(
- new NeutronRouterRequest(routerInterface.getRouter(routerUUID))).build();
-
- }
-
- /**
- * Deletes a Router */
-
- @Path("{routerUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteRouter(
- @PathParam("routerUUID") String routerUUID) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify that the router exists and is not in use before removing it
- */
- if (!routerInterface.routerExists(routerUUID))
- throw new ResourceNotFoundException("Router UUID not found");
- if (routerInterface.routerInUse(routerUUID))
- throw new ResourceConflictException("Router UUID in Use");
- NeutronRouter singleton = routerInterface.getRouter(routerUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canDeleteRouter(singleton);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- routerInterface.removeRouter(routerUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-
- /**
- * Adds an interface to a router */
-
- @Path("{routerUUID}/add_router_interface")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackRouterInterfaces.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response addRouterInterface(
- @PathParam("routerUUID") String routerUUID,
- NeutronRouter_Interface input
- ) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * While the Neutron specification says that the router has to exist and the input can only specify either a subnet id
- * or a port id, but not both, this code assumes that the plugin has filled everything in for us and so both must be present
- */
- if (!routerInterface.routerExists(routerUUID))
- throw new BadRequestException("Router UUID doesn't exist");
- NeutronRouter target = routerInterface.getRouter(routerUUID);
- if (input.getSubnetUUID() == null ||
- input.getPortUUID() == null)
- throw new BadRequestException("Must specify at subnet id, port id or both");
-
- // check that the port is part of the subnet
- NeutronSubnet targetSubnet = subnetInterface.getSubnet(input.getSubnetUUID());
- if (targetSubnet == null)
- throw new BadRequestException("Subnet id doesn't exist");
- NeutronPort targetPort = portInterface.getPort(input.getPortUUID());
- if (targetPort == null)
- throw new BadRequestException("Port id doesn't exist");
- if (!targetSubnet.getPortsInSubnet().contains(targetPort))
- throw new BadRequestException("Port id not part of subnet id");
-
- if (targetPort.getFixedIPs().size() != 1)
- throw new BadRequestException("Port id must have a single fixedIP address");
- if (targetPort.getDeviceID() != null ||
- targetPort.getDeviceOwner() != null)
- throw new ResourceConflictException("Target Port already allocated");
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canAttachInterface(target, input);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- //mark the port device id and device owner fields
- targetPort.setDeviceOwner("network:router_interface");
- targetPort.setDeviceID(routerUUID);
-
- target.addInterface(input.getPortUUID(), input);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterInterfaceAttached(target, input);
- }
- }
-
- return Response.status(200).entity(input).build();
- }
-
- /**
- * Removes an interface to a router */
-
- @Path("{routerUUID}/remove_router_interface")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackRouterInterfaces.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response removeRouterInterface(
- @PathParam("routerUUID") String routerUUID,
- NeutronRouter_Interface input
- ) {
- INeutronRouterCRUD routerInterface = NeutronCRUDInterfaces.getINeutronRouterCRUD(this);
- if (routerInterface == null) {
- throw new ServiceUnavailableException("Router CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
- if (portInterface == null) {
- throw new ServiceUnavailableException("Port CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- // verify the router exists
- if (!routerInterface.routerExists(routerUUID))
- throw new BadRequestException("Router does not exist");
- NeutronRouter target = routerInterface.getRouter(routerUUID);
-
- /*
- * remove by subnet id. Collect information about the impacted router for the response and
- * remove the port corresponding to the gateway IP address of the subnet
- */
- if (input.getPortUUID() == null &&
- input.getSubnetUUID() != null) {
- NeutronPort port = portInterface.getGatewayPort(input.getSubnetUUID());
- if (port == null)
- throw new ResourceNotFoundException("Port UUID not found");
- input.setPortUUID(port.getID());
- input.setID(target.getID());
- input.setTenantID(target.getTenantID());
-
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canDetachInterface(target, input);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- // reset the port ownership
- port.setDeviceID(null);
- port.setDeviceOwner(null);
-
- target.removeInterface(input.getPortUUID());
- if (instances != null) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterInterfaceDetached(target, input);
- }
- }
- return Response.status(200).entity(input).build();
- }
-
- /*
- * remove by port id. collect information about the impacted router for the response
- * remove the interface and reset the port ownership
- */
- if (input.getPortUUID() != null &&
- input.getSubnetUUID() == null) {
- NeutronRouter_Interface targetInterface = target.getInterfaces().get(input.getPortUUID());
- if (targetInterface == null) {
- throw new ResourceNotFoundException("Router interface not found for given Port UUID");
- }
- input.setSubnetUUID(targetInterface.getSubnetUUID());
- input.setID(target.getID());
- input.setTenantID(target.getTenantID());
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canDetachInterface(target, input);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- NeutronPort port = portInterface.getPort(input.getPortUUID());
- port.setDeviceID(null);
- port.setDeviceOwner(null);
- target.removeInterface(input.getPortUUID());
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterInterfaceDetached(target, input);
- }
- return Response.status(200).entity(input).build();
- }
-
- /*
- * remove by both port and subnet ID. Verify that the first fixed IP of the port is a valid
- * IP address for the subnet, and then remove the interface, collecting information about the
- * impacted router for the response and reset port ownership
- */
- if (input.getPortUUID() != null &&
- input.getSubnetUUID() != null) {
- NeutronPort port = portInterface.getPort(input.getPortUUID());
- if (port == null) {
- throw new ResourceNotFoundException("Port UUID not found");
- }
- if (port.getFixedIPs() == null) {
- throw new ResourceNotFoundException("Port UUID has no fixed IPs");
- }
- NeutronSubnet subnet = subnetInterface.getSubnet(input.getSubnetUUID());
- if (subnet == null) {
- throw new ResourceNotFoundException("Subnet UUID not found");
- }
- if (!subnet.isValidIP(port.getFixedIPs().get(0).getIpAddress()))
- throw new ResourceConflictException("Target Port IP not in Target Subnet");
- Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- int status = service.canDetachInterface(target, input);
- if (status < 200 || status > 299)
- return Response.status(status).build();
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- input.setID(target.getID());
- input.setTenantID(target.getTenantID());
- port.setDeviceID(null);
- port.setDeviceOwner(null);
- target.removeInterface(input.getPortUUID());
- if (instances != null) {
- for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.canDetachInterface(target, input);
- }
- } for (Object instance : instances) {
- INeutronRouterAware service = (INeutronRouterAware) instance;
- service.neutronRouterInterfaceDetached(target, input);
- }
- return Response.status(200).entity(input).build();
- }
-
- // have to specify either a port ID or a subnet ID
- throw new BadRequestException("Must specify port id or subnet id or both");
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType (XmlAccessType.NONE)
-
-public class NeutronSecurityGroupRequest {
- /**
- * See OpenStack Network API v2.0 Reference for a
- * description of annotated attributes and operations
- */
-
- @XmlElement (name = "security_group")
- NeutronSecurityGroup singletonSecurityGroup;
-
- @XmlElement (name = "security_groups")
- List<NeutronSecurityGroup> bulkRequest;
-
- NeutronSecurityGroupRequest() {
- }
-
- NeutronSecurityGroupRequest(List<NeutronSecurityGroup> bulk) {
- bulkRequest = bulk;
- singletonSecurityGroup = null;
- }
-
- NeutronSecurityGroupRequest(NeutronSecurityGroup group) {
- singletonSecurityGroup = group;
- }
-
- public List<NeutronSecurityGroup> getBulk() {
- return bulkRequest;
- }
-
- public NeutronSecurityGroup getSingleton() {
- return singletonSecurityGroup;
- }
-
- public boolean isSingleton() {
- return (singletonSecurityGroup != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Neutron Northbound REST APIs for Security Group.<br>
- * This class provides REST APIs for managing neutron Security Group
- * <p/>
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- */
-@Path ("/security-groups")
-public class NeutronSecurityGroupsNorthbound {
- static final Logger logger = LoggerFactory.getLogger(NeutronSecurityGroupsNorthbound.class);
-
- private NeutronSecurityGroup extractFields(NeutronSecurityGroup o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Security Groups
- */
- @GET
- @Produces ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 200, condition = "Operation successful"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
-
- public Response listGroups(
- // return fields
- @QueryParam ("fields") List<String> fields,
- // OpenStack security group attributes
- @QueryParam ("id") String querySecurityGroupUUID,
- @QueryParam ("name") String querySecurityGroupName,
- @QueryParam ("description") String querySecurityDescription,
- @QueryParam ("tenant_id") String querySecurityTenantID,
- @QueryParam ("limit") String limit,
- @QueryParam ("marker") String marker,
- @QueryParam ("page_reverse") String pageReverse
- ) {
- INeutronSecurityGroupCRUD securityGroupInterface = NeutronCRUDInterfaces.getINeutronSecurityGroupCRUD(this);
-
- if (securityGroupInterface == null) {
- throw new ServiceUnavailableException("Security Group CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronSecurityGroup> allSecurityGroups = securityGroupInterface.getAllNeutronSecurityGroups();
- List<NeutronSecurityGroup> ans = new ArrayList<NeutronSecurityGroup>();
- Iterator<NeutronSecurityGroup> i = allSecurityGroups.iterator();
- while (i.hasNext()) {
- NeutronSecurityGroup nsg = i.next();
- if ((querySecurityGroupUUID == null ||
- querySecurityGroupUUID.equals(nsg.getSecurityGroupUUID())) &&
- (querySecurityGroupName == null ||
- querySecurityGroupName.equals(nsg.getSecurityGroupName())) &&
- (querySecurityDescription == null ||
- querySecurityDescription.equals(nsg.getSecurityGroupDescription())) &&
- (querySecurityTenantID == null ||
- querySecurityTenantID.equals(nsg.getSecurityGroupTenantID()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsg, fields));
- } else {
- ans.add(nsg);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronSecurityGroupRequest(ans)).build();
- }
-
- /**
- * Returns a specific Security Group
- */
-
- @Path ("{securityGroupUUID}")
- @GET
- @Produces ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 200, condition = "Operation successful"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response showSecurityGroup(@PathParam ("securityGroupUUID") String securityGroupUUID,
- // return fields
- @QueryParam ("fields") List<String> fields) {
- INeutronSecurityGroupCRUD securityGroupInterface = NeutronCRUDInterfaces.getINeutronSecurityGroupCRUD(this);
- if (securityGroupInterface == null) {
- throw new ServiceUnavailableException("Security Group CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!securityGroupInterface.neutronSecurityGroupExists(securityGroupUUID)) {
- throw new ResourceNotFoundException("Security Group UUID does not exist.");
- }
- if (!fields.isEmpty()) {
- NeutronSecurityGroup ans = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID);
- return Response.status(200).entity(
- new NeutronSecurityGroupRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronSecurityGroupRequest(securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID))).build();
- }
- }
-
- /**
- * Creates new Security Group
- */
-
- @POST
- @Produces ({MediaType.APPLICATION_JSON})
- @Consumes ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 201, condition = "Created"),
- @ResponseCode (code = 400, condition = "Bad Request"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 403, condition = "Forbidden"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 409, condition = "Conflict"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response createSecurityGroups(final NeutronSecurityGroupRequest input) {
- INeutronSecurityGroupCRUD securityGroupInterface = NeutronCRUDInterfaces.getINeutronSecurityGroupCRUD(this);
- if (securityGroupInterface == null) {
- throw new ServiceUnavailableException("Security Group CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- if (input.isSingleton()) {
- NeutronSecurityGroup singleton = input.getSingleton();
-
- /*
- * Verify that the Security Group doesn't already exist.
- */
- if (securityGroupInterface.neutronSecurityGroupExists(singleton.getSecurityGroupUUID())) {
- throw new BadRequestException("Security Group UUID already exists");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- int status = service.canCreateNeutronSecurityGroup(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- // Add to Neutron cache
- securityGroupInterface.addNeutronSecurityGroup(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- service.neutronSecurityGroupCreated(singleton);
- }
- }
- } else {
- List<NeutronSecurityGroup> bulk = input.getBulk();
- Iterator<NeutronSecurityGroup> i = bulk.iterator();
- HashMap<String, NeutronSecurityGroup> testMap = new HashMap<String, NeutronSecurityGroup>();
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
- while (i.hasNext()) {
- NeutronSecurityGroup test = i.next();
-
- /*
- * Verify that the security group doesn't already exist
- */
-
- if (securityGroupInterface.neutronSecurityGroupExists(test.getSecurityGroupUUID())) {
- throw new BadRequestException("Security Group UUID already is already created");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- int status = service.canCreateNeutronSecurityGroup(test);
- if ((status < 200) || (status > 299)) return Response.status(status).build();
- }
- } else {
- throw new BadRequestException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
-
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronSecurityGroup test = i.next();
- securityGroupInterface.addNeutronSecurityGroup(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- service.neutronSecurityGroupCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Security Group
- */
-
- @Path ("{securityGroupUUID}")
- @PUT
- @Produces ({MediaType.APPLICATION_JSON})
- @Consumes ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 200, condition = "Operation successful"),
- @ResponseCode (code = 400, condition = "Bad Request"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 403, condition = "Forbidden"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response updateSecurityGroup(
- @PathParam ("securityGroupUUID") String securityGroupUUID, final NeutronSecurityGroupRequest input) {
- INeutronSecurityGroupCRUD securityGroupInterface = NeutronCRUDInterfaces.getINeutronSecurityGroupCRUD(this);
- if (securityGroupInterface == null) {
- throw new ServiceUnavailableException("Security Group CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Security Group exists and there is only one delta provided
- */
- if (!securityGroupInterface.neutronSecurityGroupExists(securityGroupUUID)) {
- throw new ResourceNotFoundException("Security Group UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronSecurityGroup delta = input.getSingleton();
- NeutronSecurityGroup original = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID);
-
- if (delta.getSecurityGroupUUID() != null ||
- delta.getSecurityGroupTenantID() != null ||
- delta.getSecurityGroupName() != null ||
- delta.getSecurityGroupDescription() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- int status = service.canUpdateNeutronSecurityGroup(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- securityGroupInterface.updateNeutronSecurityGroup(securityGroupUUID, delta);
- NeutronSecurityGroup updatedSecurityGroup = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- service.neutronSecurityGroupUpdated(updatedSecurityGroup);
- }
- }
- return Response.status(200).entity(new NeutronSecurityGroupRequest(securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID))).build();
- }
-
- /**
- * Deletes a Security Group
- */
-
- @Path ("{securityGroupUUID}")
- @DELETE
- @StatusCodes ({
- @ResponseCode (code = 204, condition = "No Content"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 409, condition = "Conflict"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response deleteSecurityGroup(
- @PathParam ("securityGroupUUID") String securityGroupUUID) {
- INeutronSecurityGroupCRUD securityGroupInterface = NeutronCRUDInterfaces.getINeutronSecurityGroupCRUD(this);
- if (securityGroupInterface == null) {
- throw new ServiceUnavailableException("Security Group CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Security Group exists and it isn't currently in use
- */
- if (!securityGroupInterface.neutronSecurityGroupExists(securityGroupUUID)) {
- throw new ResourceNotFoundException("Security Group UUID does not exist.");
- }
- if (securityGroupInterface.neutronSecurityGroupInUse(securityGroupUUID)) {
- return Response.status(409).build();
- }
- NeutronSecurityGroup singleton = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- int status = service.canDeleteNeutronSecurityGroup(singleton);
- if ((status < 200) || (status > 299)) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * remove it and return 204 status
- */
- securityGroupInterface.removeNeutronSecurityGroup(securityGroupUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
- service.neutronSecurityGroupDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
-
-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.util.List;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronSecurityRuleRequest {
- /**
- * See OpenStack Network API v2.0 Reference for a
- * description of annotated attributes and operations
- */
-
- @XmlElement(name="security_group_rule")
- NeutronSecurityRule singletonSecurityRule;
-
- @XmlElement(name="security_group_rules")
- List<NeutronSecurityRule> bulkRequest;
-
- NeutronSecurityRuleRequest() {
- }
-
- NeutronSecurityRuleRequest(List<NeutronSecurityRule> bulk) {
- bulkRequest = bulk;
- singletonSecurityRule = null;
- }
-
- NeutronSecurityRuleRequest(NeutronSecurityRule rule) {
- singletonSecurityRule = rule;
- }
-
- public NeutronSecurityRule getSingleton() {
- return singletonSecurityRule;
- }
-
- public boolean isSingleton() {
- return (singletonSecurityRule != null);
- }
- public List<NeutronSecurityRule> getBulk() {
- return bulkRequest;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Neutron Northbound REST APIs for Security Rule.<br>
- * This class provides REST APIs for managing neutron Security Rule
- * <p/>
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- */
-
-@Path ("/security-group-rules")
-public class NeutronSecurityRulesNorthbound {
- static final Logger logger = LoggerFactory.getLogger(NeutronSecurityRulesNorthbound.class);
-
- private NeutronSecurityRule extractFields(NeutronSecurityRule o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- /**
- * Returns a list of all Security Rules
- */
- @GET
- @Produces ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 200, condition = "Operation successful"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response listRules(
- // return fields
- @QueryParam ("fields") List<String> fields,
- // OpenStack security rule attributes
- @QueryParam ("id") String querySecurityRuleUUID,
- @QueryParam ("direction") String querySecurityRuleDirection,
- @QueryParam ("protocol") String querySecurityRuleProtocol,
- @QueryParam ("port_range_min") Integer querySecurityRulePortMin,
- @QueryParam ("port_range_max") Integer querySecurityRulePortMax,
- @QueryParam ("ethertype") String querySecurityRuleEthertype,
- @QueryParam ("remote_ip_prefix") String querySecurityRuleIpPrefix,
- @QueryParam ("remote_group_id") String querySecurityRemoteGroupID,
- @QueryParam ("security_group_id") String querySecurityRuleGroupID,
- @QueryParam ("tenant_id") String querySecurityRuleTenantID,
- @QueryParam ("limit") String limit,
- @QueryParam ("marker") String marker,
- @QueryParam ("page_reverse") String pageReverse
- ) {
- INeutronSecurityRuleCRUD securityRuleInterface = NeutronCRUDInterfaces.getINeutronSecurityRuleCRUD(this);
- if (securityRuleInterface == null) {
- throw new ServiceUnavailableException("Security Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronSecurityRule> allSecurityRules = securityRuleInterface.getAllNeutronSecurityRules();
- List<NeutronSecurityRule> ans = new ArrayList<NeutronSecurityRule>();
- Iterator<NeutronSecurityRule> i = allSecurityRules.iterator();
- while (i.hasNext()) {
- NeutronSecurityRule nsr = i.next();
- if ((querySecurityRuleUUID == null ||
- querySecurityRuleUUID.equals(nsr.getSecurityRuleUUID())) &&
- (querySecurityRuleDirection == null ||
- querySecurityRuleDirection.equals(nsr.getSecurityRuleDirection())) &&
- (querySecurityRuleProtocol == null ||
- querySecurityRuleProtocol.equals(nsr.getSecurityRuleProtocol())) &&
- (querySecurityRulePortMin == null ||
- querySecurityRulePortMin.equals(nsr.getSecurityRulePortMin())) &&
- (querySecurityRulePortMax == null ||
- querySecurityRulePortMax.equals(nsr.getSecurityRulePortMax())) &&
- (querySecurityRuleEthertype == null ||
- querySecurityRuleEthertype.equals(nsr.getSecurityRuleEthertype())) &&
- (querySecurityRuleIpPrefix == null ||
- querySecurityRuleIpPrefix.equals(nsr.getSecurityRuleRemoteIpPrefix())) &&
- (querySecurityRuleGroupID == null ||
- querySecurityRuleGroupID.equals(nsr.getSecurityRuleGroupID())) &&
- (querySecurityRemoteGroupID == null ||
- querySecurityRemoteGroupID.equals(nsr.getSecurityRemoteGroupID())) &&
- (querySecurityRuleTenantID == null ||
- querySecurityRuleTenantID.equals(nsr.getSecurityRuleTenantID()))) {
- if (fields.size() > 0) {
- ans.add(extractFields(nsr, fields));
- } else {
- ans.add(nsr);
- }
- }
- }
- return Response.status(200).entity(
- new NeutronSecurityRuleRequest(ans)).build();
- }
-
- /**
- * Returns a specific Security Rule
- */
-
- @Path ("{securityRuleUUID}")
- @GET
- @Produces ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 200, condition = "Operation successful"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response showSecurityRule(@PathParam ("securityRuleUUID") String securityRuleUUID,
- // return fields
- @QueryParam ("fields") List<String> fields) {
- INeutronSecurityRuleCRUD securityRuleInterface = NeutronCRUDInterfaces.getINeutronSecurityRuleCRUD(this);
- if (securityRuleInterface == null) {
- throw new ServiceUnavailableException("Security Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!securityRuleInterface.neutronSecurityRuleExists(securityRuleUUID)) {
- throw new ResourceNotFoundException("Security Rule UUID does not exist.");
- }
- if (!fields.isEmpty()) {
- NeutronSecurityRule ans = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID);
- return Response.status(200).entity(
- new NeutronSecurityRuleRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(new NeutronSecurityRuleRequest(securityRuleInterface.getNeutronSecurityRule(securityRuleUUID))).build();
- }
- }
-
- /**
- * Creates new Security Rule
- */
-
- @POST
- @Produces ({MediaType.APPLICATION_JSON})
- @Consumes ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 201, condition = "Created"),
- @ResponseCode (code = 400, condition = "Bad Request"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 403, condition = "Forbidden"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 409, condition = "Conflict"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response createSecurityRules(final NeutronSecurityRuleRequest input) {
- INeutronSecurityRuleCRUD securityRuleInterface = NeutronCRUDInterfaces.getINeutronSecurityRuleCRUD(this);
- if (securityRuleInterface == null) {
- throw new ServiceUnavailableException("Security Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronSecurityGroupCRUD securityGroupInterface = NeutronCRUDInterfaces.getINeutronSecurityGroupCRUD(this);
- if (securityGroupInterface == null) {
- throw new ServiceUnavailableException("Security Group CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * Existing entry checks
- */
-
- if (input.isSingleton()) {
- NeutronSecurityRule singleton = input.getSingleton();
-
- if (securityRuleInterface.neutronSecurityRuleExists(singleton.getSecurityRuleUUID())) {
- throw new BadRequestException("Security Rule UUID already exists");
- }
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- int status = service.canCreateNeutronSecurityRule(singleton);
- if ((status < 200) || (status > 299)) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- // add rule to cache
- singleton.initDefaults();
- securityRuleInterface.addNeutronSecurityRule(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- service.neutronSecurityRuleCreated(singleton);
- }
- }
-
- securityRuleInterface.addNeutronSecurityRule(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- service.neutronSecurityRuleCreated(singleton);
- }
- }
- } else {
- List<NeutronSecurityRule> bulk = input.getBulk();
- Iterator<NeutronSecurityRule> i = bulk.iterator();
- HashMap<String, NeutronSecurityRule> testMap = new HashMap<String, NeutronSecurityRule>();
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
- while (i.hasNext()) {
- NeutronSecurityRule test = i.next();
-
- /*
- * Verify that the security rule doesn't already exist
- */
-
- if (securityRuleInterface.neutronSecurityRuleExists(test.getSecurityRuleUUID())) {
- throw new BadRequestException("Security Rule UUID already exists");
- }
- if (testMap.containsKey(test.getSecurityRuleUUID())) {
- throw new BadRequestException("Security Rule UUID already exists");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- int status = service.canCreateNeutronSecurityRule(test);
- if ((status < 200) || (status > 299)) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
-
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronSecurityRule test = i.next();
- securityRuleInterface.addNeutronSecurityRule(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- service.neutronSecurityRuleCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Security Rule
- */
-
- @Path ("{securityRuleUUID}")
- @PUT
- @Produces ({MediaType.APPLICATION_JSON})
- @Consumes ({MediaType.APPLICATION_JSON})
- @StatusCodes ({
- @ResponseCode (code = 200, condition = "Operation successful"),
- @ResponseCode (code = 400, condition = "Bad Request"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 403, condition = "Forbidden"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response updateSecurityRule(
- @PathParam ("securityRuleUUID") String securityRuleUUID, final NeutronSecurityRuleRequest input) {
- INeutronSecurityRuleCRUD securityRuleInterface = NeutronCRUDInterfaces.getINeutronSecurityRuleCRUD(this);
- if (securityRuleInterface == null) {
- throw new ServiceUnavailableException("Security Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Security Rule exists and there is only one delta provided
- */
- if (!securityRuleInterface.neutronSecurityRuleExists(securityRuleUUID)) {
- throw new ResourceNotFoundException("Security Rule UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronSecurityRule delta = input.getSingleton();
- NeutronSecurityRule original = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID);
-
- /*
- * updates restricted by Neutron
- *
- */
- if (delta.getSecurityRuleUUID() != null ||
- delta.getSecurityRuleDirection() != null ||
- delta.getSecurityRuleProtocol() != null ||
- delta.getSecurityRulePortMin() != null ||
- delta.getSecurityRulePortMax() != null ||
- delta.getSecurityRuleEthertype() != null ||
- delta.getSecurityRuleRemoteIpPrefix() != null ||
- delta.getSecurityRuleGroupID() != null ||
- delta.getSecurityRemoteGroupID() != null ||
- delta.getSecurityRuleTenantID() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- int status = service.canUpdateNeutronSecurityRule(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- securityRuleInterface.updateNeutronSecurityRule(securityRuleUUID, delta);
- NeutronSecurityRule updatedSecurityRule = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- service.neutronSecurityRuleUpdated(updatedSecurityRule);
- }
- }
- return Response.status(200).entity(new NeutronSecurityRuleRequest(securityRuleInterface.getNeutronSecurityRule(securityRuleUUID))).build();
- }
-
- /**
- * Deletes a Security Rule
- */
-
- @Path ("{securityRuleUUID}")
- @DELETE
- @StatusCodes ({
- @ResponseCode (code = 204, condition = "No Content"),
- @ResponseCode (code = 401, condition = "Unauthorized"),
- @ResponseCode (code = 404, condition = "Not Found"),
- @ResponseCode (code = 409, condition = "Conflict"),
- @ResponseCode (code = 501, condition = "Not Implemented")})
- public Response deleteSecurityRule(
- @PathParam ("securityRuleUUID") String securityRuleUUID) {
- INeutronSecurityRuleCRUD securityRuleInterface = NeutronCRUDInterfaces.getINeutronSecurityRuleCRUD(this);
- if (securityRuleInterface == null) {
- throw new ServiceUnavailableException("Security Rule CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the Security Rule exists and it isn't currently in use
- */
- if (!securityRuleInterface.neutronSecurityRuleExists(securityRuleUUID)) {
- throw new ResourceNotFoundException("Security Rule UUID does not exist.");
- }
- if (securityRuleInterface.neutronSecurityRuleInUse(securityRuleUUID)) {
- return Response.status(409).build();
- }
- NeutronSecurityRule singleton = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- int status = service.canDeleteNeutronSecurityRule(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
-
- /*
- * remove it and return 204 status
- */
- securityRuleInterface.removeNeutronSecurityRule(securityRuleUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSecurityRuleAware service = (INeutronSecurityRuleAware) instance;
- service.neutronSecurityRuleDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron.northbound;
-
-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.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronSubnetRequest implements INeutronRequest<NeutronSubnet> {
- // See OpenStack Network API v2.0 Reference for description of
- // annotated attributes
-
- @XmlElement(name="subnet")
- NeutronSubnet singletonSubnet;
-
- @XmlElement(name="subnets")
- List<NeutronSubnet> bulkRequest;
-
- @XmlElement(name="subnets_links")
- List<NeutronPageLink> links;
-
- NeutronSubnetRequest() {
- }
-
- public NeutronSubnetRequest(List<NeutronSubnet> bulkRequest, List<NeutronPageLink> links) {
- this.bulkRequest = bulkRequest;
- this.links = links;
- this.singletonSubnet = null;
- }
-
- NeutronSubnetRequest(List<NeutronSubnet> bulk) {
- bulkRequest = bulk;
- singletonSubnet = null;
- links = null;
- }
-
- NeutronSubnetRequest(NeutronSubnet subnet) {
- singletonSubnet = subnet;
- bulkRequest = null;
- links = null;
- }
-
- @Override
- public NeutronSubnet getSingleton() {
- return singletonSubnet;
- }
-
- @Override
- public List<NeutronSubnet> getBulk() {
- return bulkRequest;
- }
-
- @Override
- public boolean isSingleton() {
- return (singletonSubnet != null);
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation and others, 2013. 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.controller.networkconfig.neutron.northbound;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-
-/**
- * Neutron Northbound REST APIs for Subnets.<br>
- * This class provides REST APIs for managing neutron Subnets
- *
- * <br>
- * <br>
- * Authentication scheme : <b>HTTP Basic</b><br>
- * Authentication realm : <b>opendaylight</b><br>
- * Transport : <b>HTTP and HTTPS</b><br>
- * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
- *
- */
-
-@Path("/subnets")
-public class NeutronSubnetsNorthbound {
-
- private NeutronSubnet extractFields(NeutronSubnet o, List<String> fields) {
- return o.extractFields(fields);
- }
-
- @Context
- UriInfo uriInfo;
-
- /**
- * Returns a list of all Subnets */
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackSubnets.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response listSubnets(
- // return fields
- @QueryParam("fields") List<String> fields,
- // note: openstack isn't clear about filtering on lists, so we aren't handling them
- @QueryParam("id") String queryID,
- @QueryParam("network_id") String queryNetworkID,
- @QueryParam("name") String queryName,
- @QueryParam("ip_version") String queryIPVersion,
- @QueryParam("cidr") String queryCIDR,
- @QueryParam("gateway_ip") String queryGatewayIP,
- @QueryParam("enable_dhcp") String queryEnableDHCP,
- @QueryParam("tenant_id") String queryTenantID,
- @QueryParam("ipv6_address_mode") String queryIpV6AddressMode,
- @QueryParam("ipv6_ra_mode") String queryIpV6RaMode,
- // linkTitle
- @QueryParam("limit") Integer limit,
- @QueryParam("marker") String marker,
- @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
- // sorting not supported
- ) {
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- List<NeutronSubnet> allNetworks = subnetInterface.getAllSubnets();
- List<NeutronSubnet> ans = new ArrayList<NeutronSubnet>();
- Iterator<NeutronSubnet> i = allNetworks.iterator();
- while (i.hasNext()) {
- NeutronSubnet oSS = i.next();
- if ((queryID == null || queryID.equals(oSS.getID())) &&
- (queryNetworkID == null || queryNetworkID.equals(oSS.getNetworkUUID())) &&
- (queryName == null || queryName.equals(oSS.getName())) &&
- (queryIPVersion == null || queryIPVersion.equals(oSS.getIpVersion())) &&
- (queryCIDR == null || queryCIDR.equals(oSS.getCidr())) &&
- (queryGatewayIP == null || queryGatewayIP.equals(oSS.getGatewayIP())) &&
- (queryEnableDHCP == null || queryEnableDHCP.equals(oSS.getEnableDHCP())) &&
- (queryTenantID == null || queryTenantID.equals(oSS.getTenantID())) &&
- (queryIpV6AddressMode == null || queryIpV6AddressMode.equals(oSS.getIpV6AddressMode())) &&
- (queryIpV6RaMode == null || queryIpV6RaMode.equals(oSS.getIpV6RaMode()))){
- if (fields.size() > 0) {
- ans.add(extractFields(oSS,fields));
- } else {
- ans.add(oSS);
- }
- }
- }
-
- if (limit != null && ans.size() > 1) {
- // Return a paginated request
- NeutronSubnetRequest request = (NeutronSubnetRequest) PaginatedRequestFactory.createRequest(limit,
- marker, pageReverse, uriInfo, ans, NeutronSubnet.class);
- return Response.status(200).entity(request).build();
- }
-
- return Response.status(200).entity(
- new NeutronSubnetRequest(ans)).build();
- }
-
- /**
- * Returns a specific Subnet */
-
- @Path("{subnetUUID}")
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackSubnets.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response showSubnet(
- @PathParam("subnetUUID") String subnetUUID,
- // return fields
- @QueryParam("fields") List<String> fields) {
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (!subnetInterface.subnetExists(subnetUUID)) {
- throw new ResourceNotFoundException("subnet UUID does not exist.");
- }
- if (fields.size() > 0) {
- NeutronSubnet ans = subnetInterface.getSubnet(subnetUUID);
- return Response.status(200).entity(
- new NeutronSubnetRequest(extractFields(ans, fields))).build();
- } else {
- return Response.status(200).entity(
- new NeutronSubnetRequest(subnetInterface.getSubnet(subnetUUID))).build();
- }
- }
-
- /**
- * Creates new Subnets */
-
- @POST
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackSubnets.class)
- @StatusCodes({
- @ResponseCode(code = 201, condition = "Created"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response createSubnets(final NeutronSubnetRequest input) {
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
- if (networkInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
- if (input.isSingleton()) {
- NeutronSubnet singleton = input.getSingleton();
-
- /*
- * Verify that the subnet doesn't already exist (Issue: is a deeper check necessary?)
- * the specified network exists, the subnet has a valid network address,
- * and that the gateway IP doesn't overlap with the allocation pools
- * *then* add the subnet to the cache
- */
- if (subnetInterface.subnetExists(singleton.getID())) {
- throw new BadRequestException("subnet UUID already exists");
- }
- if (!networkInterface.networkExists(singleton.getNetworkUUID())) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (!singleton.isValidCIDR()) {
- throw new BadRequestException("invaild CIDR");
- }
- if (!singleton.initDefaults()) {
- throw new InternalServerErrorException("subnet object could not be initialized properly");
- }
- if (singleton.gatewayIP_Pool_overlap()) {
- throw new ResourceConflictException("IP pool overlaps with gateway");
- }
- Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- int status = service.canCreateSubnet(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- subnetInterface.addSubnet(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- service.neutronSubnetCreated(singleton);
- }
- }
- } else {
- List<NeutronSubnet> bulk = input.getBulk();
- Iterator<NeutronSubnet> i = bulk.iterator();
- HashMap<String, NeutronSubnet> testMap = new HashMap<String, NeutronSubnet>();
- Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
- while (i.hasNext()) {
- NeutronSubnet test = i.next();
-
- /*
- * Verify that the subnet doesn't already exist (Issue: is a deeper check necessary?)
- * the specified network exists, the subnet has a valid network address,
- * and that the gateway IP doesn't overlap with the allocation pools,
- * and that the bulk request doesn't already contain a subnet with this id
- */
-
- if (!test.initDefaults()) {
- throw new InternalServerErrorException("subnet object could not be initialized properly");
- }
- if (subnetInterface.subnetExists(test.getID())) {
- throw new BadRequestException("subnet UUID already exists");
- }
- if (testMap.containsKey(test.getID())) {
- throw new BadRequestException("subnet UUID already exists");
- }
- testMap.put(test.getID(), test);
- if (!networkInterface.networkExists(test.getNetworkUUID())) {
- throw new ResourceNotFoundException("network UUID does not exist.");
- }
- if (!test.isValidCIDR()) {
- throw new BadRequestException("Invalid CIDR");
- }
- if (test.gatewayIP_Pool_overlap()) {
- throw new ResourceConflictException("IP pool overlaps with gateway");
- }
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- int status = service.canCreateSubnet(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
- }
-
- /*
- * now, each element of the bulk request can be added to the cache
- */
- i = bulk.iterator();
- while (i.hasNext()) {
- NeutronSubnet test = i.next();
- subnetInterface.addSubnet(test);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- service.neutronSubnetCreated(test);
- }
- }
- }
- }
- return Response.status(201).entity(input).build();
- }
-
- /**
- * Updates a Subnet */
-
- @Path("{subnetUUID}")
- @PUT
- @Produces({ MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_JSON })
- //@TypeHint(OpenStackSubnets.class)
- @StatusCodes({
- @ResponseCode(code = 200, condition = "Operation successful"),
- @ResponseCode(code = 400, condition = "Bad Request"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 403, condition = "Forbidden"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response updateSubnet(
- @PathParam("subnetUUID") String subnetUUID, final NeutronSubnetRequest input
- ) {
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Subnet CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the subnet exists and there is only one delta provided
- */
- if (!subnetInterface.subnetExists(subnetUUID)) {
- throw new ResourceNotFoundException("subnet UUID does not exist.");
- }
- if (!input.isSingleton()) {
- throw new BadRequestException("Only singleton edit supported");
- }
- NeutronSubnet delta = input.getSingleton();
- NeutronSubnet original = subnetInterface.getSubnet(subnetUUID);
-
- /*
- * updates restricted by Neutron
- */
- if (delta.getID() != null || delta.getTenantID() != null ||
- delta.getIpVersion() != null || delta.getCidr() != null ||
- delta.getAllocationPools() != null) {
- throw new BadRequestException("Attribute edit blocked by Neutron");
- }
-
- Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- int status = service.canUpdateSubnet(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * update the object and return it
- */
- subnetInterface.updateSubnet(subnetUUID, delta);
- NeutronSubnet updatedSubnet = subnetInterface.getSubnet(subnetUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- service.neutronSubnetUpdated(updatedSubnet);
- }
- }
- return Response.status(200).entity(
- new NeutronSubnetRequest(subnetInterface.getSubnet(subnetUUID))).build();
- }
-
- /**
- * Deletes a Subnet */
-
- @Path("{subnetUUID}")
- @DELETE
- @StatusCodes({
- @ResponseCode(code = 204, condition = "No Content"),
- @ResponseCode(code = 401, condition = "Unauthorized"),
- @ResponseCode(code = 404, condition = "Not Found"),
- @ResponseCode(code = 409, condition = "Conflict"),
- @ResponseCode(code = 501, condition = "Not Implemented") })
- public Response deleteSubnet(
- @PathParam("subnetUUID") String subnetUUID) {
- INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
- if (subnetInterface == null) {
- throw new ServiceUnavailableException("Network CRUD Interface "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- /*
- * verify the subnet exists and it isn't currently in use
- */
- if (!subnetInterface.subnetExists(subnetUUID)) {
- throw new ResourceNotFoundException("subnet UUID does not exist.");
- }
- if (subnetInterface.subnetInUse(subnetUUID)) {
- return Response.status(409).build();
- }
- NeutronSubnet singleton = subnetInterface.getSubnet(subnetUUID);
- Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- int status = service.canDeleteSubnet(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- } else {
- throw new ServiceUnavailableException("No providers registered. Please try again later");
- }
- } else {
- throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
- }
-
- /*
- * remove it and return 204 status
- */
- subnetInterface.removeSubnet(subnetUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronSubnetAware service = (INeutronSubnetAware) instance;
- service.neutronSubnetDeleted(singleton);
- }
- }
- return Response.status(204).build();
- }
-}
+++ /dev/null
-package org.opendaylight.controller.networkconfig.neutron.northbound;
-
-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 NeutronUtil {
- private static final Logger logger = LoggerFactory
- .getLogger(NeutronUtil.class);
- 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");
- }
- return instances;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Dave Tucker
- */
-
-package org.opendaylight.controller.networkconfig.neutron.northbound;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import javax.ws.rs.core.UriInfo;
-
-import org.opendaylight.controller.networkconfig.neutron.INeutronObject;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-
-public class PaginatedRequestFactory {
- private static final Comparator<INeutronObject> NEUTRON_OBJECT_COMPARATOR = new Comparator<INeutronObject>() {
- @Override
- public int compare(INeutronObject o1, INeutronObject o2) {
- return o1.getID().compareTo(o2.getID());
- }
- };
-
- public static class PaginationResults<T extends INeutronObject> {
- List<T> collection;
- List<NeutronPageLink> links;
-
- public PaginationResults(List<T> collection, List<NeutronPageLink> links) {
- this.collection = collection;
- this.links = links;
- }
- }
-
- private static final class MarkerObject implements INeutronObject {
- private final String id;
-
- MarkerObject(String id) {
- this.id = id;
- }
-
- @Override
- public String getID() {
- return id;
- }
-
- @Override
- public void setID(String id) {
- throw new UnsupportedOperationException("Marker has constant ID");
- }
- }
-
- /*
- * SuppressWarnings is needed because the compiler does not understand that we
- * are actually safe here.
- *
- * FIXME: the only caller performs a cast back, so this is not actually necessary.
- */
- @SuppressWarnings("unchecked")
- public static <T extends INeutronObject> INeutronRequest<T> createRequest(Integer limit, String marker,
- Boolean pageReverse,
- UriInfo uriInfo,
- List<T> collection,
- Class<T> clazz) {
- PaginationResults<T> results = _paginate(limit, marker, pageReverse, uriInfo, collection);
-
- if (clazz.equals(NeutronNetwork.class)){
- return (INeutronRequest<T>) new NeutronNetworkRequest((List<NeutronNetwork>) results.collection, results.links);
- }
- if (clazz.equals(NeutronSubnet.class)){
- return (INeutronRequest<T>) new NeutronSubnetRequest((List<NeutronSubnet>) results.collection, results.links);
- }
- if (clazz.equals(NeutronPort.class)){
- return (INeutronRequest<T>) new NeutronPortRequest((List<NeutronPort>) results.collection, results.links);
- }
- return null;
- }
-
- private static <T extends INeutronObject> PaginationResults<T> _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List<T> collection) {
- List<NeutronPageLink> links = new ArrayList<>();
- final int startPos;
- String startMarker;
- String endMarker;
- Boolean firstPage = false;
- Boolean lastPage = false;
-
- Collections.sort(collection, NEUTRON_OBJECT_COMPARATOR);
-
- if (marker != null) {
- int offset = Collections.binarySearch(collection, new MarkerObject(marker), NEUTRON_OBJECT_COMPARATOR);
- if (offset < 0) {
- throw new ResourceNotFoundException("UUID for marker: " + marker + " could not be found");
- }
-
- if (!pageReverse) {
- startPos = offset + 1;
- }
- else {
- startPos = offset - limit;
- }
- }
- else {
- startPos = 0;
- }
-
- if (startPos == 0){
- firstPage = true;
- }
-
- if (startPos + limit >= collection.size()) {
- collection = collection.subList(startPos, collection.size());
- startMarker = collection.get(0).getID();
- endMarker = collection.get(collection.size() - 1).getID();
- lastPage = true;
- }
- else if (startPos < 0) {
- if (startPos + limit > 0) {
- collection = collection.subList(0, startPos + limit);
- startMarker = collection.get(0).getID();
- endMarker = collection.get(collection.size() - 1).getID();
- firstPage = true;
- }
- else {
- throw new BadRequestException("Requested page is out of bounds. Please check the supplied limit and marker");
- }
- }
- else {
- collection = collection.subList(startPos, startPos + limit);
- startMarker = collection.get(0).getID();
- endMarker = collection.get(limit-1).getID();
- }
-
- if (!lastPage) {
- NeutronPageLink next = new NeutronPageLink();
- next.setRef("next");
- next.setHref(uriInfo.getAbsolutePath().toString() + "?limit=" + limit.toString() + "&marker=" + endMarker);
- links.add(next);
- }
-
- if (!firstPage) {
- NeutronPageLink previous = new NeutronPageLink();
- previous.setRef("previous");
- previous.setHref(uriInfo.getAbsolutePath().toString() + "?limit=" + limit.toString() + "&marker=" + startMarker + "&page_reverse=True");
- links.add(previous);
- }
-
- return new PaginationResults<T>(collection, links);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.MediaType;
-
-/**
- * Status Code 409 (Conflict)
- *
- * The request could not be completed due to a conflict with the
- * current state of the resource. This code is only allowed in
- * situations where it is expected that the user might be able to
- * resolve the conflict and resubmit the request. The response body
- * SHOULD include enough information for the user to recognize the
- * source of the conflict. Ideally, the response entity would include
- * enough information for the user or user agent to fix the problem;
- * however, that might not be possible and is not required.
- *
- *
- *
- */
-public class ResourceConflictException extends WebApplicationException {
- private static final long serialVersionUID = 1L;
-
- public ResourceConflictException(String string) {
- super(Response.status(Response.Status.CONFLICT).entity(string).type(
- MediaType.TEXT_PLAIN).build());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.MediaType;
-
-/**
- * Status Code 404 (Not Found)
- *
- * The server has not found anything matching the Request-URI.
- * No indication is given of whether the condition is temporary or permanent.
- * The 410 (Gone) status code SHOULD be used if the server knows,
- * through some internally configurable mechanism, that an old resource
- * is permanently unavailable and has no forwarding address.
- * This status code is commonly used when the server does not wish to
- * reveal exactly why the request has been refused, or when no other
- * response is applicable.
- *
- *
- *
- */
-public class ResourceNotFoundException extends WebApplicationException {
- private static final long serialVersionUID = 1L;
-
- public ResourceNotFoundException(String string) {
- super(Response.status(Response.Status.NOT_FOUND).entity(string).type(
- MediaType.TEXT_PLAIN).build());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
-
-public enum RestMessages {
- SUCCESS("Success"), NOCONTAINER("Container does not exist"), NOSUBNET("Subnet does not exist"), NOSTATICROUTE(
- "Static Route does not exist"), NOHOST("Host does not exist"), NOFLOW("Flow does not exist"), NONODE(
- "Node does not exist"), NOPOLICY("Policy does not exist"), NORESOURCE("Resource does not exist"), RESOURCECONFLICT(
- "Operation failed due to Resource Conflict"), NODEFAULT("Container default is not a custom container"), DEFAULTDISABLED(
- "Container(s) are configured. Container default is not operational"), NOTALLOWEDONDEFAULT(
- "Container default is a static resource, no modification allowed on it"), UNKNOWNACTION("Unknown action"), INVALIDJSON(
- "JSON message is invalid"), INVALIDADDRESS("Invalid InetAddress"), AVAILABLESOON(
- "Resource is not implemented yet"), INTERNALERROR("Internal Error"), SERVICEUNAVAILABLE(
- "Service is not available. Could be down for maintanence"), INVALIDDATA(
- "Data is invalid or conflicts with URI");
-
- private String message;
-
- private RestMessages(String msg) {
- message = msg;
- }
-
- @Override
- public String toString() {
- return message;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.networkconfig.neutron.northbound;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.MediaType;
-
-/**
- * Status Code 503 (Service Unavailable Error)
- *
- * The server is currently unable to handle the request due to a temporary
- * overloading or maintenance of the server.
- * The implication is that this is a temporary condition which will be alleviated
- * after some delay.
- *
- *
- */
-public class ServiceUnavailableException extends WebApplicationException {
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the SERVICE_UNAVAILABLE custom handler
- *
- * @param string Error message to specify further the
- * SERVICE_UNAVAILABLE response
- *
- */
- public ServiceUnavailableException(String string) {
- super(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(
- string).type(MediaType.TEXT_PLAIN).build());
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>\r
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"\r
- version="3.0">\r
- <servlet>\r
- <servlet-name>JAXRSNeutron</servlet-name>\r
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>\r
- <init-param>\r
- <param-name>javax.ws.rs.Application</param-name>\r
- <param-value>org.opendaylight.controller.networkconfig.neutron.northbound.NeutronNorthboundRSApplication</param-value>\r
- </init-param>\r
- <!-- AAA Auth Filter -->\r
- <init-param>\r
- <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>\r
- <param-value> org.opendaylight.aaa.sts.TokenAuthFilter</param-value>\r
- </init-param>\r
- <load-on-startup>1</load-on-startup>\r
- </servlet>\r
-\r
- <servlet-mapping>\r
- <servlet-name>JAXRSNeutron</servlet-name>\r
- <url-pattern>/*</url-pattern>\r
- </servlet-mapping>\r
-\r
- <filter>\r
- <filter-name>cross-origin-restconf</filter-name>\r
- <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>\r
- <init-param>\r
- <param-name>allowedOrigins</param-name>\r
- <param-value>*</param-value>\r
- </init-param>\r
- <init-param>\r
- <param-name>allowedMethods</param-name>\r
- <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>\r
- </init-param>\r
- <init-param>\r
- <param-name>allowedHeaders</param-name>\r
- <param-value>origin, content-type, accept, authorization</param-value>\r
- </init-param>\r
- </filter>\r
- <filter-mapping>\r
- <filter-name>cross-origin-restconf</filter-name>\r
- <url-pattern>/*</url-pattern>\r
- </filter-mapping>\r
- <security-constraint>\r
- <web-resource-collection>\r
- <web-resource-name>NB api</web-resource-name>\r
- <url-pattern>/*</url-pattern>\r
- <http-method>POST</http-method>\r
- <http-method>GET</http-method>\r
- <http-method>PUT</http-method>\r
- <http-method>PATCH</http-method>\r
- <http-method>DELETE</http-method>\r
- <http-method>HEAD</http-method>\r
- </web-resource-collection>\r
- </security-constraint>\r
-</web-app>\r
+++ /dev/null
-javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
- </parent>
- <artifactId>networkconfig.neutron</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <dependencies>
- <dependency>
- <groupId>commons-net</groupId>
- <artifactId>commons-net</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>*</Import-Package>
- </instructions>
- <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
- </scm>
- <distributionManagement>
- <!-- OpenDayLight Released artifact -->
- <repository>
- <id>opendaylight-release</id>
- <url>${nexusproxy}/repositories/${nexus.repository.release}/</url>
- </repository>
- <!-- OpenDayLight Snapshot artifact -->
- <snapshotRepository>
- <id>opendaylight-snapshot</id>
- <url>${nexusproxy}/repositories/${nexus.repository.snapshot}/</url>
- </snapshotRepository>
- <!-- Site deployment -->
- <site>
- <id>website</id>
- <url>${sitedeploy}</url>
- </site>
- </distributionManagement>
-</project>
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Firewall Rules needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFirewallAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronFirewallDeleted(NeutronFirewall firewall);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack Firewall objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFirewallCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronFirewall}
- * OpenStackFirewall class
- */
-
- public NeutronFirewall getNeutronFirewall(String uuid);
-
- /**
- * Applications call this interface method to return all Firewall objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronFirewallInUse(String uuid);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Firewall Policys needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFirewallPolicyAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronFirewallPolicyDeleted(NeutronFirewallPolicy firewallPolicy);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack Firewall Policy objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFirewallPolicyCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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
- */
-
- public NeutronFirewallPolicy getNeutronFirewallPolicy(String uuid);
-
- /**
- * Applications call this interface method to return all Firewall Policy objects
- *
- * @return List of OpenStack Firewall Policy objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronFirewallPolicyInUse(String uuid);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Firewall Rules needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFirewallRuleAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronFirewallRuleDeleted(NeutronFirewallRule firewallRule);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack Firewall Rule objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFirewallRuleCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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
- */
-
- public NeutronFirewallRule getNeutronFirewallRule(String uuid);
-
- /**
- * Applications call this interface method to return all Firewall Rule objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronFirewallRuleInUse(String uuid);
-
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Neutron FloatingIPs needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFloatingIPAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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 floatingIP
- * 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronFloatingIPDeleted(NeutronFloatingIP floatingIP);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB FloatingIP objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronFloatingIPCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronFloatingIP.OpenStackFloatingIPs}
- * OpenStack FloatingIP class
- */
-
- public NeutronFloatingIP getFloatingIP(String uuid);
-
- /**
- * Applications call this interface method to return all FloatingIP objects
- *
- * @return a Set of OpenStackFloatingIPs objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean updateFloatingIP(String uuid, NeutronFloatingIP delta);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of LoadBalancer Rules needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronLoadBalancerDeleted(NeutronLoadBalancer loadBalancer);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack LoadBalancer objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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
- */
-
- public NeutronLoadBalancer getNeutronLoadBalancer(String uuid);
-
- /**
- * Applications call this interface method to return all LoadBalancer objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronLoadBalancerInUse(String uuid);
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of LoadBalancerHealthMonitor Rules needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerHealthMonitorAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronLoadBalancerHealthMonitorDeleted(NeutronLoadBalancerHealthMonitor loadBalancerHealthMonitor);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack LoadBalancerHealthMonitor objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerHealthMonitorCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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
- */
-
- public NeutronLoadBalancerHealthMonitor getNeutronLoadBalancerHealthMonitor(String uuid);
-
- /**
- * Applications call this interface method to return all LoadBalancerHealthMonitor objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronLoadBalancerHealthMonitorInUse(String uuid);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of LoadBalancerListener Rules needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerListenerAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronLoadBalancerListenerDeleted(NeutronLoadBalancerListener loadBalancerListener);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack LoadBalancerListener objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerListenerCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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
- */
-
- public NeutronLoadBalancerListener getNeutronLoadBalancerListener(String uuid);
-
- /**
- * Applications call this interface method to return all LoadBalancerListener objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronLoadBalancerListenerInUse(String uuid);
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of LoadBalancerPool Rules needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerPoolAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronLoadBalancerPoolDeleted(NeutronLoadBalancerPool loadBalancerPool);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack LoadBalancerPool objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerPoolCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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
- */
-
- public NeutronLoadBalancerPool getNeutronLoadBalancerPool(String uuid);
-
- /**
- * Applications call this interface method to return all LoadBalancerPool objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronLoadBalancerPoolInUse(String uuid);
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack INeutronLoadBalancerPoolMemberAware objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerPoolMemberAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack INeutronLoadBalancerPoolMemberCRUD objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronLoadBalancerPoolMemberCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember}
- * OpenStackNeutronLoadBalancerPoolMember class
- */
-
- public NeutronLoadBalancerPoolMember getNeutronLoadBalancerPoolMember(String uuid);
-
- /**
- * Applications call this interface method to return all NeutronLoadBalancerPoolMember objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronLoadBalancerPoolMemberInUse(String uuid);
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import javax.xml.bind.annotation.XmlElement;
-import java.util.List;
-
-public class INeutronLoadBalancerPoolMemberRequest {
-
- /**
- * See OpenStack Network API v2.0 Reference for description of
- * http://docs.openstack.org/api/openstack-network/2.0/content/
- */
-
- @XmlElement(name="member")
- NeutronLoadBalancerPoolMember singletonLoadBalancerPoolMember;
-
- @XmlElement(name="members")
- List<NeutronLoadBalancerPoolMember> bulkRequest;
-
- INeutronLoadBalancerPoolMemberRequest() {
- }
-
- public INeutronLoadBalancerPoolMemberRequest(List<NeutronLoadBalancerPoolMember> bulk) {
- bulkRequest = bulk;
- singletonLoadBalancerPoolMember = null;
- }
-
- INeutronLoadBalancerPoolMemberRequest(NeutronLoadBalancerPoolMember group) {
- singletonLoadBalancerPoolMember = group;
- }
-
- public List<NeutronLoadBalancerPoolMember> getBulk() {
- return bulkRequest;
- }
-
- public NeutronLoadBalancerPoolMember getSingleton() {
- return singletonLoadBalancerPoolMember;
- }
-
- public boolean isSingleton() {
- return (singletonLoadBalancerPoolMember != null);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Neutron Networks needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronNetworkAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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 network
- * 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronNetworkDeleted(NeutronNetwork network);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB network objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronNetworkCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronNetwork.OpenStackNetworks}
- * OpenStack Network class
- */
-
- public NeutronNetwork getNetwork(String uuid);
-
- /**
- * Applications call this interface method to return all Network objects
- *
- * @return List of OpenStackNetworks objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean networkInUse(String netUUID);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Dave Tucker
- */
-
-package org.opendaylight.controller.networkconfig.neutron;
-
-/**
- * This class contains behaviour common to Neutron configuration objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronObject}
- */
-@Deprecated
-public interface INeutronObject {
- public String getID();
- public void setID(String id);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Neutron Ports needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronPortAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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 port
- * 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronPortDeleted(NeutronPort port);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB Port objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronPortCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronPort.OpenStackPorts}
- * OpenStack Port class
- */
-
- public NeutronPort getPort(String uuid);
-
- /**
- * Applications call this interface method to return all Port objects
- *
- * @return List of OpenStackPorts objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public NeutronPort getGatewayPort(String subnetUUID);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Neutron Routers needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronRouterAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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 router
- * 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronRouterDeleted(NeutronRouter router);
-
- /**
- * Services provide this interface method to indicate if the specified interface can be attached to the specified route
- *
- * @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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronRouterInterfaceDetached(NeutronRouter router, NeutronRouter_Interface routerInterface);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB Router objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronRouterCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronRouter.OpenStackRouters}
- * OpenStack Router class
- */
-
- public NeutronRouter getRouter(String uuid);
-
- /**
- * Applications call this interface method to return all Router objects
- *
- * @return List of OpenStackRouters objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean updateRouter(String uuid, NeutronRouter delta);
-
- /**
- * Applications call this interface method to check if a router is in use
- *
- * @param uuid
- * identifier of the Router object
- * @return boolean on whether the router is in use or not
- */
-
- public boolean routerInUse(String routerUUID);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Neutron Security Groups needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronSecurityGroupAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronSecurityGroupDeleted(NeutronSecurityGroup securityGroup);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack Security Group objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronSecurityGroupCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronSecurityGroup.OpenStackSecurity Groups}
- * OpenStack Security Group class
- */
-
- public NeutronSecurityGroup getNeutronSecurityGroup(String uuid);
-
- /**
- * Applications call this interface method to return all Security Group objects
- *
- * @return List of OpenStackSecurity Groups objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronSecurityGroupInUse(String uuid);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods required to be aware of Neutron Security Rules
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronSecurityRuleAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronSecurityRuleDeleted(NeutronSecurityRule securityRule);
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB OpenStack Security Rule objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronSecurityRuleCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronSecurityRule.OpenStackNetworks}
- * OpenStackSecurity Rule class
- */
-
- public NeutronSecurityRule getNeutronSecurityRule(String uuid);
-
- /**
- * Applications call this interface method to return all Security Rule objects
- *
- * @return List of OpenStack SecurityRules objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean neutronSecurityRuleInUse(String uuid);
-
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-/**
- * This interface defines the methods a service that wishes to be aware of Neutron Subnets needs to implement
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronSubnetAware}
- */
-
-@Deprecated
-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.
- */
- public 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
- * @return void
- */
- public 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 subnet
- * 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.
- */
- public 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
- * @return void
- */
- public 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.
- */
- public 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
- * @return void
- */
- public void neutronSubnetDeleted(NeutronSubnet subnet);
-
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-import java.util.List;
-
-/**
- * This interface defines the methods for CRUD of NB Subnet objects
- *
- * @deprecated Replaced by {@link org.opendaylight.neutron.neutron.spi.INeutronSubnetCRUD}
- */
-
-@Deprecated
-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
- */
-
- public 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.controller.networkconfig.neutron.NeutronSubnet.OpenStackSubnets}
- * OpenStack Subnet class
- */
-
- public NeutronSubnet getSubnet(String uuid);
-
- /**
- * Applications call this interface method to return all Subnet objects
- *
- * @return List of OpenStackSubnets objects
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public 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
- */
-
- public boolean subnetInUse(String subnetUUID);
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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);
-
- public static INeutronNetworkCRUD getINeutronNetworkCRUD(Object o) {
- INeutronNetworkCRUD answer = (INeutronNetworkCRUD) getInstances(INeutronNetworkCRUD.class, o);
- return answer;
- }
-
- public static INeutronSubnetCRUD getINeutronSubnetCRUD(Object o) {
- INeutronSubnetCRUD answer = (INeutronSubnetCRUD) getInstances(INeutronSubnetCRUD.class, o);
- return answer;
- }
-
- public static INeutronPortCRUD getINeutronPortCRUD(Object o) {
- INeutronPortCRUD answer = (INeutronPortCRUD) getInstances(INeutronPortCRUD.class, o);
- return answer;
- }
-
- public static INeutronRouterCRUD getINeutronRouterCRUD(Object o) {
- INeutronRouterCRUD answer = (INeutronRouterCRUD) getInstances(INeutronRouterCRUD.class, o);
- return answer;
- }
-
- public static INeutronFloatingIPCRUD getINeutronFloatingIPCRUD(Object o) {
- INeutronFloatingIPCRUD answer = (INeutronFloatingIPCRUD) getInstances(INeutronFloatingIPCRUD.class, o);
- return answer;
- }
-
- public static INeutronSecurityGroupCRUD getINeutronSecurityGroupCRUD(Object o) {
- INeutronSecurityGroupCRUD answer = (INeutronSecurityGroupCRUD) getInstances(INeutronSecurityGroupCRUD.class, o);
- return answer;
- }
-
- public static INeutronSecurityRuleCRUD getINeutronSecurityRuleCRUD(Object o) {
- INeutronSecurityRuleCRUD answer = (INeutronSecurityRuleCRUD) getInstances(INeutronSecurityRuleCRUD.class, o);
- return answer;
- }
-
- public static INeutronFirewallCRUD getINeutronFirewallCRUD(Object o) {
- INeutronFirewallCRUD answer = (INeutronFirewallCRUD) getInstances(INeutronFirewallCRUD.class, o);
- return answer;
- }
-
- public static INeutronFirewallPolicyCRUD getINeutronFirewallPolicyCRUD(Object o) {
- INeutronFirewallPolicyCRUD answer = (INeutronFirewallPolicyCRUD) getInstances(INeutronFirewallPolicyCRUD.class, o);
- return answer;
- }
-
- public static INeutronFirewallRuleCRUD getINeutronFirewallRuleCRUD(Object o) {
- INeutronFirewallRuleCRUD answer = (INeutronFirewallRuleCRUD) getInstances(INeutronFirewallRuleCRUD.class, o);
- return answer;
- }
-
- public static INeutronLoadBalancerCRUD getINeutronLoadBalancerCRUD(Object o) {
- INeutronLoadBalancerCRUD answer = (INeutronLoadBalancerCRUD) getInstances(INeutronLoadBalancerCRUD.class, o);
- return answer;
- }
-
- public static INeutronLoadBalancerPoolCRUD getINeutronLoadBalancerPoolCRUD(Object o) {
- INeutronLoadBalancerPoolCRUD answer = (INeutronLoadBalancerPoolCRUD) getInstances(INeutronLoadBalancerPoolCRUD.class, o);
- return answer;
- }
-
- public static INeutronLoadBalancerListenerCRUD getINeutronLoadBalancerListenerCRUD(Object o) {
- INeutronLoadBalancerListenerCRUD answer = (INeutronLoadBalancerListenerCRUD) getInstances(INeutronLoadBalancerListenerCRUD.class, o);
- return answer;
- }
-
- public static INeutronLoadBalancerHealthMonitorCRUD getINeutronLoadBalancerHealthMonitorCRUD(Object o) {
- INeutronLoadBalancerHealthMonitorCRUD answer = (INeutronLoadBalancerHealthMonitorCRUD) getInstances(INeutronLoadBalancerHealthMonitorCRUD.class, o);
- return answer;
- }
-
- public static INeutronLoadBalancerPoolMemberCRUD getINeutronLoadBalancerPoolMemberCRUD(Object o) {
- INeutronLoadBalancerPoolMemberCRUD answer = (INeutronLoadBalancerPoolMemberCRUD) getInstances(INeutronLoadBalancerPoolMemberCRUD.class, o);
- return answer;
- }
-
- public static 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("Instance reference is NULL");
- }
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
- 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 getFirewallUUID() {
- return firewallUUID;
- }
-
- 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.setFirewallUUID(this.getFirewallUUID());
- }
- 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.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
- 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")
- String firewallPolicyIsAudited;
-
- public String getFirewallPolicyIsAudited() {
- return firewallPolicyIsAudited;
- }
-
- public void setFirewallPolicyIsAudited(String 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 getFirewallPolicyUUID() {
- return firewallPolicyUUID;
- }
-
- 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.setFirewallPolicyUUID(this.getFirewallPolicyUUID());
- }
- 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 + '\'' +
- '}';
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
- 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(defaultValue = "true", name = "admin_state_up")
- Boolean firewallRuleAdminStateIsUp;
-
- @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 Boolean getFirewallRuleAdminStateIsUp() {
- return firewallRuleAdminStateIsUp;
- }
-
- public void setFirewallRuleAdminStateIsUp(Boolean firewallRuleAdminStateIsUp) {
- this.firewallRuleAdminStateIsUp = firewallRuleAdminStateIsUp;
- }
-
- 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 getFirewallRuleUUID() {
- return firewallRuleUUID;
- }
-
- public void setFirewallRuleUUID(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.setFirewallRuleUUID(this.getFirewallRuleUUID());
- }
- 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("admin_state_up")) {
- ans.setFirewallRuleAdminStateIsUp(firewallRuleAdminStateIsUp);
- }
- 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 + '\'' +
- ", firewallRuleAdminStateIsUp=" + firewallRuleAdminStateIsUp +
- ", 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() {
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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 {
- 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;
-
- public NeutronFloatingIP() {
- }
-
- public String getID() { return floatingIPUUID; }
-
- public String getFloatingIPUUID() {
- return floatingIPUUID;
- }
-
- 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 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;
- }
-
- /**
- * 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.setFloatingIPUUID(this.getFloatingIPUUID());
- }
- 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());
- }
- }
- return ans;
- }
-
- public void initDefaults() {
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
- 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="vip_address")
- String loadBalancerVipAddress;
-
- @XmlElement (name="vip_subnet_id")
- String loadBalancerVipSubnetID;
-
- public String getLoadBalancerID() {
- return loadBalancerID;
- }
-
- 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 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.setLoadBalancerID(this.getLoadBalancerID());
- }
- 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());
- }
- }
- return ans;
- }
-
- @Override public String toString() {
- return "NeutronLoadBalancer{" +
- "loadBalancerID='" + loadBalancerID + '\'' +
- ", loadBalancerTenantID='" + loadBalancerTenantID + '\'' +
- ", loadBalancerName='" + loadBalancerName + '\'' +
- ", loadBalancerDescription='" + loadBalancerDescription + '\'' +
- ", loadBalancerStatus='" + loadBalancerStatus + '\'' +
- ", loadBalancerVipAddress='" + loadBalancerVipAddress + '\'' +
- ", loadBalancerVipSubnetID='" + loadBalancerVipSubnetID + '\'' +
- '}';
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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 {
- private static final long serialVersionUID = 1L;
- private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancer.class);
-
- @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="status")
- String loadBalancerHealthMonitorStatus;
-
- public String getLoadBalancerHealthMonitorID() {
- return loadBalancerHealthMonitorID;
- }
-
- 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 String getLoadBalancerHealthMonitorStatus() {
- return loadBalancerHealthMonitorStatus;
- }
-
- public void setLoadBalancerHealthMonitorStatus(String loadBalancerHealthMonitorStatus) {
- this.loadBalancerHealthMonitorStatus = loadBalancerHealthMonitorStatus;
- }
-
- 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.setLoadBalancerHealthMonitorID(this.getLoadBalancerHealthMonitorID());
- }
- 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);
- }
- if (s.equals("status")) {
- ans.setLoadBalancerHealthMonitorStatus(this.getLoadBalancerHealthMonitorStatus());
- }
- }
- 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 +
- ", loadBalancerHealthMonitorStatus='" + loadBalancerHealthMonitorStatus + '\'' +
- '}';
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
- private static final long serialVersionUID = 1L;
-
- @XmlElement(name="id")
- String loadBalancerListenerID;
-
- @XmlElement (name="default_pool_id")
- String neutronLoadBalancerListenerDefaultPoolID;
-
- @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="status")
- String loadBalancerListenerStatus;
-
- @XmlElement (defaultValue="false", name="shared")
- Boolean loadBalancerListenerIsShared;
-
- @XmlElement (name="protocol")
- String neutronLoadBalancerListenerProtocol;
-
- @XmlElement (name="protocol_port")
- String neutronLoadBalancerListenerProtocolPort;
-
- @XmlElement (name="load_balancer_id")
- String neutronLoadBalancerListenerLoadBalancerID;
-
-
- public String getLoadBalancerListenerID() {
- return loadBalancerListenerID;
- }
-
- 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 getLoadBalancerListenerStatus() {
- return loadBalancerListenerStatus;
- }
-
- public void setLoadBalancerListenerStatus(String loadBalancerListenerStatus) {
- this.loadBalancerListenerStatus = loadBalancerListenerStatus;
- }
-
- public Boolean getLoadBalancerListenerIsShared() {
- return loadBalancerListenerIsShared;
- }
-
- public void setLoadBalancerListenerIsShared(Boolean loadBalancerListenerIsShared) {
- this.loadBalancerListenerIsShared = loadBalancerListenerIsShared;
- }
-
- 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 String getNeutronLoadBalancerListenerLoadBalancerID() {
- return neutronLoadBalancerListenerLoadBalancerID;
- }
-
- public void setNeutronLoadBalancerListenerLoadBalancerID(String neutronLoadBalancerListenerLoadBalancerID) {
- this.neutronLoadBalancerListenerLoadBalancerID = neutronLoadBalancerListenerLoadBalancerID;
- }
-
- 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.setLoadBalancerListenerID(this.getLoadBalancerListenerID());
- }
- 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("shared")) {
- ans.setLoadBalancerListenerIsShared(loadBalancerListenerIsShared);
- }
- if (s.equals("protocol")) {
- ans.setNeutronLoadBalancerListenerProtocol(this.getNeutronLoadBalancerListenerProtocol());
- }
- if (s.equals("protocol_port")) {
- ans.setNeutronLoadBalancerListenerProtocolPort(this.getNeutronLoadBalancerListenerProtocolPort());
- }
- if (s.equals("load_balancer_id")) {
- ans.setNeutronLoadBalancerListenerLoadBalancerID(this.getNeutronLoadBalancerListenerLoadBalancerID());
- }
- if (s.equals("admin_state_up")) {
- ans.setLoadBalancerListenerAdminStateIsUp(loadBalancerListenerAdminStateIsUp);
- }
- if (s.equals("status")) {
- ans.setLoadBalancerListenerStatus(this.getLoadBalancerListenerStatus());
- }
- }
- return ans;
- }
-
- @Override public String toString() {
- return "NeutronLoadBalancerListener{" +
- "loadBalancerListenerID='" + loadBalancerListenerID + '\'' +
- ", neutronLoadBalancerListenerDefaultPoolID='" + neutronLoadBalancerListenerDefaultPoolID + '\'' +
- ", loadBalancerListenerTenantID='" + loadBalancerListenerTenantID + '\'' +
- ", loadBalancerListenerName='" + loadBalancerListenerName + '\'' +
- ", loadBalancerListenerDescription='" + loadBalancerListenerDescription + '\'' +
- ", loadBalancerListenerAdminStateIsUp=" + loadBalancerListenerAdminStateIsUp +
- ", loadBalancerListenerStatus='" + loadBalancerListenerStatus + '\'' +
- ", loadBalancerListenerIsShared=" + loadBalancerListenerIsShared +
- ", neutronLoadBalancerListenerProtocol='" + neutronLoadBalancerListenerProtocol + '\'' +
- ", neutronLoadBalancerListenerProtocolPort='" + neutronLoadBalancerListenerProtocolPort + '\'' +
- ", neutronLoadBalancerListenerLoadBalancerID='" + neutronLoadBalancerListenerLoadBalancerID + '\'' +
- '}';
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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.XmlElementWrapper;
-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 {
- 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="status")
- String loadBalancerPoolStatus;
-
- @XmlElement(name="members")
- List<NeutronLoadBalancerPoolMember> loadBalancerPoolMembers;
-
- public NeutronLoadBalancerPool() {
- }
-
- public String getLoadBalancerPoolID() {
- return loadBalancerPoolID;
- }
-
- 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 String getLoadBalancerPoolStatus() {
- return loadBalancerPoolStatus;
- }
-
- public void setLoadBalancerPoolStatus(String loadBalancerPoolStatus) {
- this.loadBalancerPoolStatus = loadBalancerPoolStatus;
- }
-
- public List<NeutronLoadBalancerPoolMember> getLoadBalancerPoolMembers() {
- /*
- * Update the pool_id of the member to that this.loadBalancerPoolID
- */
- for (NeutronLoadBalancerPoolMember member: loadBalancerPoolMembers)
- member.setPoolID(loadBalancerPoolID);
- 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.setLoadBalancerPoolID(this.getLoadBalancerPoolID());
- }
- 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("status")) {
- ans.setLoadBalancerPoolStatus(this.getLoadBalancerPoolStatus());
- }
- if (s.equals("members")) {
- ans.setLoadBalancerPoolMembers(getLoadBalancerPoolMembers());
- }
- }
- return ans;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
-
- 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;
-
- @XmlElement (name="status")
- String poolMemberStatus;
-
- String poolID;
-
- public NeutronLoadBalancerPoolMember() {
- }
-
- @XmlTransient
- public String getPoolID() {
- return poolID;
- }
-
- public void setPoolID(String poolID) {
- this.poolID = poolID;
- }
-
- public String getPoolMemberID() {
- return poolMemberID;
- }
-
- 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 String getPoolMemberStatus() {
- return poolMemberStatus;
- }
-
- public void setPoolMemberStatus(String poolMemberStatus) {
- this.poolMemberStatus = poolMemberStatus;
- }
-
- 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.setPoolMemberID(this.getPoolMemberID());
- }
- 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());
- }
- if (s.equals("status")) {
- ans.setPoolMemberStatus(this.getPoolMemberStatus());
- }
- }
- return ans;
- }
- @Override public String toString() {
- return "NeutronLoadBalancerPoolMember{" +
- "poolMemberID='" + poolMemberID + '\'' +
- ", poolID='" + poolID + '\'' +
- ", poolMemberTenantID='" + poolMemberTenantID + '\'' +
- ", poolMemberAddress='" + poolMemberAddress + '\'' +
- ", poolMemberProtoPort=" + poolMemberProtoPort +
- ", poolMemberAdminStateIsUp=" + poolMemberAdminStateIsUp +
- ", poolMemberWeight=" + poolMemberWeight +
- ", poolMemberSubnetID='" + poolMemberSubnetID + '\'' +
- ", poolMemberStatus='" + poolMemberStatus + '\'' +
- '}';
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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; // network UUID
-
- @XmlElement (name="name")
- String networkName; // name
-
- @XmlElement (defaultValue="true", name="admin_state_up")
- Boolean adminStateUp; // admin state up (true/false)
-
- @XmlElement (defaultValue="false", name="shared")
- Boolean shared; // shared network or not
-
- @XmlElement (name="tenant_id")
- String tenantID; // tenant for this network
-
- @XmlElement (defaultValue="false", namespace="router", name="external")
- Boolean routerExternal; // network external or not
-
- @XmlElement (defaultValue="flat", namespace="provider", name="network_type")
- String providerNetworkType; // provider network type (flat or vlan)
-
- @XmlElement (namespace="provider", name="physical_network")
- String providerPhysicalNetwork; // provider physical network (name)
-
- @XmlElement (namespace="provider", name="segmentation_id")
- String providerSegmentationID; // provide segmentation ID (vlan ID)
-
- @XmlElement (name="status")
- String status; // status (read-only)
-
- @XmlElement (name="subnets")
- List<String> subnets; // subnets (read-only)
-
- /* This attribute lists the ports associated with an instance
- * which is needed for determining if that instance can be deleted
- */
-
- List<NeutronPort> myPorts;
-
- public NeutronNetwork() {
- myPorts = new ArrayList<NeutronPort>();
- }
-
- 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 List<NeutronPort> getPortsOnNetwork() {
- return myPorts;
- }
-
- public void addPort(NeutronPort port) {
- myPorts.add(port);
- }
-
- public void removePort(NeutronPort port) {
- myPorts.remove(port);
- }
-
- /**
- * 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());
- }
- }
- 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 + ", myPorts=" + myPorts + "]";
- }
-}
-
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-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 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 (namespace= "binding", name="host_id")
- String bindinghostID;
-
- @XmlElement (namespace= "binding", name="vnic_type")
- String bindingvnicType;
-
- @XmlElement (namespace= "binding", name="vif_type")
- String bindingvifType;
-
-
- /* this attribute stores the floating IP address assigned to
- * each fixed IP address
- */
-
- HashMap<String, NeutronFloatingIP> floatingIPMap;
-
- public NeutronPort() {
- floatingIPMap = new HashMap<String, NeutronFloatingIP>();
- }
-
- 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 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 NeutronFloatingIP getFloatingIP(String key) {
- if (!floatingIPMap.containsKey(key)) {
- return null;
- }
- return floatingIPMap.get(key);
- }
-
- public void removeFloatingIP(String key) {
- floatingIPMap.remove(key);
- }
-
- public void addFloatingIP(String key, NeutronFloatingIP floatingIP) {
- if (!floatingIPMap.containsKey(key)) {
- floatingIPMap.put(key, floatingIP);
- }
- }
-
- /**
- * 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();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if (s.equals("id")) {
- ans.setPortUUID(this.getPortUUID());
- }
- if (s.equals("network_id")) {
- ans.setNetworkUUID(this.getNetworkUUID());
- }
- 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("mac_address")) {
- ans.setMacAddress(this.getMacAddress());
- }
- if (s.equals("fixed_ips")) {
- List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
- fixedIPs.addAll(this.getFixedIPs());
- ans.setFixedIPs(fixedIPs);
- }
- if (s.equals("device_id")) {
- ans.setDeviceID(this.getDeviceID());
- }
- if (s.equals("device_owner")) {
- ans.setDeviceOwner(this.getDeviceOwner());
- }
- if (s.equals("tenant_id")) {
- ans.setTenantID(this.getTenantID());
- }
- if (s.equals("security_groups")) {
- List<NeutronSecurityGroup> securityGroups = new ArrayList<NeutronSecurityGroup>();
- securityGroups.addAll(this.getSecurityGroups());
- ans.setSecurityGroups(securityGroups);
- }
- }
- return ans;
- }
-
- public void initDefaults() {
- adminStateUp = true;
- if (status == null) {
- status = "ACTIVE";
- }
- if (fixedIPs == null) {
- fixedIPs = new ArrayList<Neutron_IPs>();
- }
- }
-
- /**
- * This method checks to see if the port has a floating IPv4 address
- * associated with the supplied fixed IPv4 address
- *
- * @param fixedIP
- * fixed IPv4 address in dotted decimal format
- * @return a boolean indicating if there is a floating IPv4 address bound
- * to the fixed IPv4 address
- */
-
- public boolean isBoundToFloatingIP(String fixedIP) {
- return floatingIPMap.containsKey(fixedIP);
- }
-
- @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 + ", floatingIPMap=" + floatingIPMap + ", securityGroups=" + securityGroups
- + ", bindinghostID=" + bindinghostID + ", bindingvnicType=" + bindingvnicType
- + ", bindingvnicType=" + bindingvnicType + "]";
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-import java.io.Serializable;
-import java.util.HashMap;
-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 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
- */
- HashMap<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 HashMap<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;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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_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;
-
- public NeutronRouter_NetworkReference() {
- }
-
- public String getNetworkID() {
- return networkID;
- }
-
- public void setNetworkID(String networkID) {
- this.networkID = networkID;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 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 {
- 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;
-
- List<NeutronPort> neutronPorts;
-
- public NeutronSecurityGroup() {
- neutronPorts = new ArrayList<NeutronPort> ();
- List<NeutronSecurityRule> securityRules;
-
- }
-
- public String getSecurityGroupUUID() {
- return securityGroupUUID;
- }
-
- 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(NeutronSecurityRule neutronSecurityRule) {
- this.neutronSecurityRule = (List<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.setSecurityGroupUUID (this.getSecurityGroupUUID ());
- }
- 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 ((NeutronSecurityRule) 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.
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * 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.controller.networkconfig.neutron;
-
-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 {
- 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() {
- List<NeutronSecurityRule> securityRules;
- }
-
- public String getSecurityRuleUUID() {
- return securityRuleUUID;
- }
-
- 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.setSecurityRuleUUID(this.getSecurityRuleUUID());
- }
- 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.
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright IBM Corporation and others, 2013. 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.controller.networkconfig.neutron;
-
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.Inet6Address;
-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;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronSubnet 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 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<NeutronSubnet_IPAllocationPool> 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.
- */
- List<NeutronPort> myPorts;
-
- Boolean gatewayIPAssigned;
-
- public NeutronSubnet() {
- myPorts = new ArrayList<NeutronPort>();
- }
-
- 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<NeutronSubnet_IPAllocationPool> getAllocationPools() {
- return allocationPools;
- }
-
- public void setAllocationPools(List<NeutronSubnet_IPAllocationPool> 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<NeutronSubnet_IPAllocationPool> aPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
- 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;
- }
-
- /* 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 == 4) {
- try {
- SubnetUtils util = new SubnetUtils(cidr);
- SubnetInfo info = util.getInfo();
- if (!info.getNetworkAddress().equals(info.getAddress())) {
- return false;
- }
- } catch (Exception e) {
- return false;
- }
- return true;
- }
- if (ipVersion == 6) {
- // 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<128; i++) { // offset is to ensure proper comparison
- if (((((int) addrBytes[i/8]) & 0x000000FF) & (1 << (7-(i%8)))) != 0) {
- return(false);
- }
- }
- return(true);
- } catch (Exception 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<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnet_IPAllocationPool pool = i.next();
- if (pool.contains(gatewayIP)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean initDefaults() {
- if (enableDHCP == null) {
- enableDHCP = true;
- }
- if (ipVersion == null) {
- ipVersion = 4;
- }
- gatewayIPAssigned = false;
- dnsNameservers = new ArrayList<String>();
- if (hostRoutes == null) {
- hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
- }
- if (allocationPools == null) {
- allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
- try {
- SubnetUtils util = new SubnetUtils(cidr);
- SubnetInfo info = util.getInfo();
- if (gatewayIP == null || ("").equals(gatewayIP)) {
- gatewayIP = info.getLowAddress();
- }
- if (allocationPools.size() < 1) {
- NeutronSubnet_IPAllocationPool source =
- new NeutronSubnet_IPAllocationPool(info.getLowAddress(),
- info.getHighAddress());
- allocationPools = source.splitPool(gatewayIP);
- }
- } catch (Exception e) {
- return false;
- }
- }
- return true;
- }
-
- public List<NeutronPort> getPortsInSubnet() {
- return myPorts;
- }
-
- public void addPort(NeutronPort port) {
- myPorts.add(port);
- }
-
- public void removePort(NeutronPort port) {
- myPorts.remove(port);
- }
-
- /* this method tests to see if the supplied IPv4 address
- * is valid for this subnet or not
- */
- public boolean isValidIP(String ipAddress) {
- try {
- SubnetUtils util = new SubnetUtils(cidr);
- SubnetInfo info = util.getInfo();
- return info.isInRange(ipAddress);
- } catch (Exception e) {
- return false;
- }
- }
-
- /* test to see if the supplied IPv4 address is part of one of the
- * available allocation pools or not
- */
- public boolean isIPInUse(String ipAddress) {
- if (ipAddress.equals(gatewayIP) && !gatewayIPAssigned ) {
- return false;
- }
- Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnet_IPAllocationPool pool = i.next();
- if (pool.contains(ipAddress)) {
- return false;
- }
- }
- return true;
- }
-
- /* 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<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();
- while (i.hasNext()) {
- NeutronSubnet_IPAllocationPool pool = i.next();
- if (ans == null) {
- ans = pool.getPoolStart();
- }
- else
- if (NeutronSubnet_IPAllocationPool.convert(pool.getPoolStart()) <
- NeutronSubnet_IPAllocationPool.convert(ans)) {
- ans = pool.getPoolStart();
- }
- }
- return ans;
- }
-
- /*
- * allocate the parameter address. Because this uses an iterator to
- * check the instance's list of allocation pools and we want to modify
- * pools while the iterator is being used, it is necessary to
- * build a new list of allocation pools and replace the list when
- * finished (otherwise a split will cause undefined iterator behavior.
- */
- public void allocateIP(String ipAddress) {
- Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();
- List<NeutronSubnet_IPAllocationPool> newList = new ArrayList<NeutronSubnet_IPAllocationPool>(); // we have to modify a separate list
- while (i.hasNext()) {
- NeutronSubnet_IPAllocationPool pool = i.next();
- /* if the pool contains a single address element and we are allocating it
- * then we don't need to copy the pool over. Otherwise, we need to possibly
- * split the pool and add both pieces to the new list
- */
- if (!(pool.getPoolEnd().equalsIgnoreCase(ipAddress) &&
- pool.getPoolStart().equalsIgnoreCase(ipAddress))) {
- if (pool.contains(ipAddress)) {
- List<NeutronSubnet_IPAllocationPool> pools = pool.splitPool(ipAddress);
- newList.addAll(pools);
- } else {
- newList.add(pool);
- }
- }
- }
- allocationPools = newList;
- }
-
- /*
- * release an IP address back to the subnet. Although an iterator
- * is used, the list is not modified until the iterator is complete, so
- * an extra list is not necessary.
- */
- public void releaseIP(String ipAddress) {
- NeutronSubnet_IPAllocationPool lPool = null;
- NeutronSubnet_IPAllocationPool hPool = null;
- Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();
- long sIP = NeutronSubnet_IPAllocationPool.convert(ipAddress);
- //look for lPool where ipAddr - 1 is high address
- //look for hPool where ipAddr + 1 is low address
- while (i.hasNext()) {
- NeutronSubnet_IPAllocationPool pool = i.next();
- long lIP = NeutronSubnet_IPAllocationPool.convert(pool.getPoolStart());
- long hIP = NeutronSubnet_IPAllocationPool.convert(pool.getPoolEnd());
- if (sIP+1 == lIP) {
- hPool = pool;
- }
- if (sIP-1 == hIP) {
- lPool = pool;
- }
- }
- //if (lPool == NULL and hPool == NULL) create new pool where low = ip = high
- if (lPool == null && hPool == null) {
- allocationPools.add(new NeutronSubnet_IPAllocationPool(ipAddress,ipAddress));
- }
- //if (lPool == NULL and hPool != NULL) change low address of hPool to ipAddr
- if (lPool == null && hPool != null) {
- hPool.setPoolStart(ipAddress);
- }
- //if (lPool != NULL and hPool == NULL) change high address of lPool to ipAddr
- if (lPool != null && hPool == null) {
- lPool.setPoolEnd(ipAddress);
- }
- //if (lPool != NULL and hPool != NULL) remove lPool and hPool and create new pool
- // where low address = lPool.low address and high address = hPool.high Address
- if (lPool != null && hPool != null) {
- allocationPools.remove(lPool);
- allocationPools.remove(hPool);
- allocationPools.add(new NeutronSubnet_IPAllocationPool(
- lPool.getPoolStart(), hPool.getPoolEnd()));
- }
- }
-
- public void setGatewayIPAllocated() {
- gatewayIPAssigned = true;
- }
-
- public void resetGatewayIPAllocated() {
- gatewayIPAssigned = false;
- }
-
- public Boolean getGatewayIPAllocated() {
- return gatewayIPAssigned;
- }
-
- @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 + ", myPorts=" + myPorts
- + ", gatewayIPAssigned=" + gatewayIPAssigned + ", ipv6AddressMode=" + ipV6AddressMode
- + ", ipv6RaMode=" + ipV6RaMode + "]";
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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;
-
- public NeutronSubnet_HostRoute() { }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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 NeutronSubnet_IPAllocationPool implements Serializable {
- private static final long serialVersionUID = 1L;
-
- // See OpenStack Network API v2.0 Reference for description of
- // annotated attributes
-
- @XmlElement(name="start")
- String poolStart;
-
- @XmlElement(name="end")
- String poolEnd;
-
- public NeutronSubnet_IPAllocationPool() {
- }
-
- public NeutronSubnet_IPAllocationPool(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
- * @returns 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
- * @returns 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 <<= 8;
- ans |= Integer.parseInt(part);
- }
- }
- return ans;
- }
-
- /**
- * 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
- * @returns IPv4 address in dotted decimal format
- */
- static String longtoIP(long l) {
- int i;
- String[] parts = new String[4];
- for (i=0; i<4; i++) {
- parts[3-i] = String.valueOf(l & 255);
- l >>= 8;
- }
- return join(parts,".");
- }
-
- /*
- * helper routine used by longtoIP
- */
- public static String join(String r[],String d)
- {
- if (r.length == 0) {
- return "";
- }
- StringBuilder sb = new StringBuilder();
- int i;
- for(i=0;i<r.length-1;i++) {
- sb.append(r[i]+d);
- }
- 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<NeutronSubnet_IPAllocationPool> splitPool(String ipAddress) {
- List<NeutronSubnet_IPAllocationPool> ans = new ArrayList<NeutronSubnet_IPAllocationPool>();
- long gIP = NeutronSubnet_IPAllocationPool.convert(ipAddress);
- long sIP = NeutronSubnet_IPAllocationPool.convert(poolStart);
- long eIP = NeutronSubnet_IPAllocationPool.convert(poolEnd);
- long i;
- NeutronSubnet_IPAllocationPool p = new NeutronSubnet_IPAllocationPool();
- 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(NeutronSubnet_IPAllocationPool.longtoIP(i+1));
- }
- }
- if (i == eIP) {
- if (i != gIP) {
- p.setPoolEnd(poolEnd);
- } else {
- p.setPoolEnd(NeutronSubnet_IPAllocationPool.longtoIP(i-1));
- }
- ans.add(p);
- }
- if (i != sIP && i != eIP) {
- if (i != gIP) {
- if (!poolStarted) {
- p.setPoolStart(NeutronSubnet_IPAllocationPool.longtoIP(i));
- poolStarted = true;
- }
- } else {
- p.setPoolEnd(NeutronSubnet_IPAllocationPool.longtoIP(i-1));
- poolStarted = false;
- ans.add(p);
- p = new NeutronSubnet_IPAllocationPool();
- }
- }
- }
- return ans;
- }
-}
+++ /dev/null
-/*
- * Copyright IBM Corporation, 2013. 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.controller.networkconfig.neutron;
-
-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 + '\'' + "}";
- }
-}
<!-- adsal -->
<module>opendaylight/adsal</module>
- <!-- Neutron -->
- <module>opendaylight/networkconfiguration/neutron</module>
- <module>opendaylight/networkconfiguration/neutron/implementation</module>
- <module>opendaylight/networkconfiguration/neutron/northbound</module>
- <module>opendaylight/networkconfiguration/neutron/features</module>
-
<!-- Parents -->
<module>opendaylight/commons/concepts</module>
<module>opendaylight/commons/protocol-framework</module>