Prefer Regions to Zones

This commit is contained in:
Jeremy Daggett 2014-07-25 09:23:35 -07:00
parent 03c900fba6
commit 5ed8620d37
22 changed files with 171 additions and 64 deletions

View File

@ -70,7 +70,20 @@ public interface NeutronApi extends Closeable {
/**
* Provides synchronous access to Router features.
*
* <h3>NOTE</h3>
* This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type
* to determine if it is present.
*/
@Delegate
Optional<? extends RouterApi> getRouterApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
/**
* Provides synchronous access to Router features.
* @deprecated Please use {@link #getRouterApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
Optional<? extends RouterApi> getRouterExtensionApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
}

View File

@ -16,8 +16,19 @@
*/
package org.jclouds.openstack.neutron.v2.extensions;
import com.google.common.annotations.Beta;
import org.jclouds.Fallbacks;
import javax.inject.Named;
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.core.MediaType;
import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.collect.PagedIterable;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
@ -38,15 +49,7 @@ import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.annotations.WrapWith;
import javax.inject.Named;
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.core.MediaType;
import com.google.common.annotations.Beta;
/**
* Provides synchronous access to Router operations on the OpenStack Neutron API.
@ -73,7 +76,7 @@ public interface RouterApi {
@GET
@Transform(RouterToPagedIterable.class)
@ResponseParser(ParseRouters.class)
@Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class)
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
PagedIterable<Router> list();
/**
@ -95,7 +98,7 @@ public interface RouterApi {
@GET
@Path("/{id}")
@SelectJson("router")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Router get(@PathParam("id") String id);
@ -121,7 +124,7 @@ public interface RouterApi {
@PUT
@Path("/{id}")
@SelectJson("router")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Router update(@PathParam("id") String id, @WrapWith("router") Router.UpdateOptions router);
@ -134,7 +137,7 @@ public interface RouterApi {
@Named("router:delete")
@DELETE
@Path("/{id}")
@Fallback(Fallbacks.FalseOnNotFoundOr404.class)
@Fallback(FalseOnNotFoundOr404.class)
boolean delete(@PathParam("id") String id);
/**
@ -148,7 +151,7 @@ public interface RouterApi {
@PUT
@Path("/{id}/add_router_interface")
@MapBinder(EmptyOptions.class)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
RouterInterface addInterfaceForSubnet(@PathParam("id") String routerId, @PayloadParam("subnet_id") String subnetId);
@ -163,7 +166,7 @@ public interface RouterApi {
@PUT
@Path("/{id}/add_router_interface")
@MapBinder(EmptyOptions.class)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
RouterInterface addInterfaceForPort(@PathParam("id") String routerId, @PayloadParam("port_id") String portId);
@ -177,7 +180,7 @@ public interface RouterApi {
@PUT
@Path("/{id}/remove_router_interface")
@MapBinder(EmptyOptions.class)
@Fallback(Fallbacks.FalseOnNotFoundOr404.class)
@Fallback(FalseOnNotFoundOr404.class)
boolean removeInterfaceForSubnet(@PathParam("id") String routerId, @PayloadParam("subnet_id") String subnetId);
/**
@ -190,6 +193,6 @@ public interface RouterApi {
@PUT
@Path("/{id}/remove_router_interface")
@MapBinder(EmptyOptions.class)
@Fallback(Fallbacks.FalseOnNotFoundOr404.class)
@Fallback(FalseOnNotFoundOr404.class)
boolean removeInterfaceForPort(@PathParam("id") String routerId, @PayloadParam("port_id") String portId);
}

View File

@ -17,10 +17,13 @@
package org.jclouds.openstack.neutron.v2_0;
import com.google.common.base.Optional;
import com.google.inject.Provides;
import java.io.Closeable;
import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Region;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.RegionToEndpoint;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.openstack.neutron.v2_0.extensions.RouterApi;
import org.jclouds.openstack.neutron.v2_0.features.NetworkApi;
@ -30,53 +33,104 @@ import org.jclouds.openstack.v2_0.features.ExtensionApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import java.io.Closeable;
import java.util.Set;
import com.google.common.base.Optional;
import com.google.inject.Provides;
/**
* Provides synchronous access to Neutron.
* <p/>
*
* @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/">api doc</a>
* @deprecated Use v2 instead of v2_0
* @deprecated Please use {@link org.jclouds.openstack.neutron.v2.NeutronApi} as this
* interface will be removed in jclouds 3.0.
*/
@Deprecated
public interface NeutronApi extends Closeable {
/**
* @return the Region codes configured
*/
@Provides
@Region
Set<String> getConfiguredRegions();
/**
* Provides synchronous access to Extension features.
*/
@Delegate
ExtensionApi getExtensionApi(
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
/**
* Provides synchronous access to Network features.
*/
@Delegate
NetworkApi getNetworkApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
/**
* Provides synchronous access to Subnet features
*/
@Delegate
SubnetApi getSubnetApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
/**
* Provides synchronous access to Port features.
*/
@Delegate
PortApi getPortApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
/**
* Provides synchronous access to Router features.
*/
@Delegate
Optional<? extends RouterApi> getRouterApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
/**
* @return the Zone codes configured
* @deprecated Please use {@link #getConfiguredRegions()} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Provides
@Zone
Set<String> getConfiguredZones();
/**
* Provides synchronous access to Extension features.
* @deprecated Please use {@link #getExtensionApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
ExtensionApi getExtensionApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Network features.
* @deprecated Please use {@link #getNetworkApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
NetworkApi getNetworkApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Subnet features
* Provides synchronous access to Subnet features.
* @deprecated Please use {@link #getSubnetApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
SubnetApi getSubnetApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Port features.
* @deprecated Please use {@link #getPortApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
PortApi getPortApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Router features.
* @deprecated Please use {@link #getRouterApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
Optional<? extends RouterApi> getRouterExtensionForZone(@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
}

View File

@ -17,8 +17,12 @@
package org.jclouds.openstack.neutron.v2_0;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
@ -28,11 +32,8 @@ import org.jclouds.openstack.neutron.v2_0.config.NeutronHttpApiModule;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.internal.BaseHttpApiMetadata;
import java.net.URI;
import java.util.Properties;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/**
* Implementation of {@link org.jclouds.apis.ApiMetadata} for Neutron 2.0 API

View File

@ -16,12 +16,11 @@
*/
package org.jclouds.openstack.neutron.v2_0.config;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.Provides;
import java.net.URI;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
@ -35,27 +34,26 @@ import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamesp
import org.jclouds.rest.ConfiguresHttpApi;
import org.jclouds.rest.config.HttpApiModule;
import org.jclouds.rest.functions.ImplicitOptionalConverter;
import javax.inject.Provider;
import javax.inject.Singleton;
import java.net.URI;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.Provides;
/**
* Configures the Neutron connection.
*/
@Deprecated
@ConfiguresHttpApi
public class NeutronHttpApiModule extends HttpApiModule<NeutronApi> {
@Override
protected void configure() {
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
super.configure();
}
@Provides
@Singleton
public Multimap<URI, URI> aliases() {
@ -74,7 +72,7 @@ public class NeutronHttpApiModule extends HttpApiModule<NeutronApi> {
}
});
}
@Override
protected void bindErrorHandlers() {
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(NeutronErrorHandler.class);

View File

@ -17,9 +17,20 @@
package org.jclouds.openstack.neutron.v2_0.extensions;
import javax.inject.Named;
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.core.MediaType;
import org.jclouds.Fallbacks;
import org.jclouds.collect.PagedIterable;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
import org.jclouds.openstack.neutron.v2_0.domain.Router;
@ -39,27 +50,14 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.Transform;
import javax.inject.Named;
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.core.MediaType;
import static org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
/**
* Provides synchronous access to Router operations on the OpenStack Neutron API.
* <p/>
* A logical entity for forwarding packets across internal subnets and NATting them on external
* networks through an appropriate external gateway.
*
* @see <a href=
* "http://docs.openstack.org/api/openstack-network/2.0/content/router_ext.html">api doc</a>
* @deprecated Use v2 instead of v2_0
* @deprecated Please use {@link org.jclouds.openstack.neutron.v2.extensions.RouterApi} as this
* interface will be removed in jclouds 3.0.
*/
@Deprecated
@Path("/v2.0/routers")

View File

@ -38,6 +38,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParseNetworkDetails extends ParseJson<Networks> {

View File

@ -38,6 +38,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParseNetworks extends ParseJson<Networks> {

View File

@ -39,6 +39,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParsePortDetails extends ParseJson<Ports> {

View File

@ -38,6 +38,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParsePorts extends ParseJson<Ports> {

View File

@ -39,6 +39,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParseRouterDetails extends ParseJson<Routers> {

View File

@ -39,6 +39,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParseRouters extends ParseJson<Routers> {

View File

@ -38,6 +38,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParseSubnetDetails extends ParseJson<Subnets> {

View File

@ -38,6 +38,9 @@ import java.beans.ConstructorProperties;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Nick Livens
*/
@Beta
@Singleton
public class ParseSubnets extends ParseJson<Subnets> {

View File

@ -42,6 +42,8 @@ import static org.testng.Assert.assertTrue;
/**
* Tests parsing and Guice wiring of RouterApi
*
* @author Nick Livens
*/
@Test(groups = "unit", testName = "RouterApiExpectTest")
public class RouterApiExpectTest extends BaseNeutronApiExpectTest {

View File

@ -42,6 +42,8 @@ import static org.testng.Assert.assertTrue;
/**
* Tests parsing and Guice wiring of RouterApi
*
* @author Nick Livens
*/
@Test(groups = "live", testName = "RouterApiLiveTest")
public class RouterApiLiveTest extends BaseNeutronApiLiveTest {

View File

@ -42,6 +42,8 @@ import static org.testng.Assert.assertTrue;
/**
* Tests parsing and Guice wiring of NetworkApi
*
* @author Nick Livens
*/
@Test(groups = "unit", testName = "NetworkApiExpectTest")
public class NetworkApiExpectTest extends BaseNeutronApiExpectTest {

View File

@ -38,6 +38,8 @@ import static org.testng.Assert.assertTrue;
/**
* Tests parsing and Guice wiring of NetworkApi
*
* @author Nick Livens
*/
@Test(groups = "live", testName = "NetworkApiLiveTest")
public class NetworkApiLiveTest extends BaseNeutronApiLiveTest {

View File

@ -41,6 +41,8 @@ import static org.testng.Assert.assertTrue;
/**
* Tests parsing and Guice wiring of PortApi
*
* @author Nick Livens
*/
@Test(groups = "unit", testName = "PortApiExpectTest")
public class PortApiExpectTest extends BaseNeutronApiExpectTest {

View File

@ -43,6 +43,8 @@ import com.google.common.collect.Sets;
/**
* Tests PortApi in combination with the Network & SubnetApi
*
* @author Nick Livens
*/
@Test(groups = "live", testName = "PortApiLiveTest")
public class PortApiLiveTest extends BaseNeutronApiLiveTest {

View File

@ -40,6 +40,8 @@ import static org.testng.Assert.assertTrue;
/**
* Tests parsing and Guice wiring of SubnetApi
*
* @author Nick Livens
*/
@Test(groups = "unit", testName = "SubnetApiExpectTest")
public class SubnetApiExpectTest extends BaseNeutronApiExpectTest {

View File

@ -43,6 +43,8 @@ import com.google.common.collect.Sets;
/**
* Tests subnet api in combination with the network api
*
* @author Nick Livens
*/
@Test(groups = "live", testName = "SubnetApiLiveTest")
public class SubnetApiLiveTest extends BaseNeutronApiLiveTest {