mirror of https://github.com/apache/jclouds.git
Prefer Regions to Zones in OpenStack APIs
This commit is contained in:
parent
9009bb5268
commit
744cd5d7eb
|
@ -18,65 +18,113 @@ package org.jclouds.openstack.cinder.v1;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.Zone;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.location.functions.ZoneToEndpoint;
|
import org.jclouds.location.functions.RegionToEndpoint;
|
||||||
|
import org.jclouds.openstack.cinder.v1.domain.Snapshot;
|
||||||
|
import org.jclouds.openstack.cinder.v1.domain.Volume;
|
||||||
|
import org.jclouds.openstack.cinder.v1.domain.VolumeType;
|
||||||
import org.jclouds.openstack.cinder.v1.features.QuotaApi;
|
import org.jclouds.openstack.cinder.v1.features.QuotaApi;
|
||||||
import org.jclouds.openstack.cinder.v1.features.SnapshotApi;
|
import org.jclouds.openstack.cinder.v1.features.SnapshotApi;
|
||||||
import org.jclouds.openstack.cinder.v1.features.VolumeApi;
|
import org.jclouds.openstack.cinder.v1.features.VolumeApi;
|
||||||
import org.jclouds.openstack.cinder.v1.features.VolumeTypeApi;
|
import org.jclouds.openstack.cinder.v1.features.VolumeTypeApi;
|
||||||
import org.jclouds.openstack.v2_0.features.ExtensionApi;
|
import org.jclouds.openstack.v2_0.features.ExtensionApi;
|
||||||
|
import org.jclouds.openstack.v2_0.services.Extension;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Cinder.
|
* Provides synchronous access to OpenStack Block Storage (Cinder) v1 API.
|
||||||
*
|
|
||||||
* @see <a href="http://api.openstack.org/">API Doc</a>
|
|
||||||
*/
|
*/
|
||||||
public interface CinderApi extends Closeable {
|
public interface CinderApi extends Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the Zone codes configured
|
* @return the Region codes configured
|
||||||
*/
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Zone
|
@Region
|
||||||
Set<String> getConfiguredZones();
|
Set<String> getConfiguredRegions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Extension features.
|
* Provides synchronous access to {@link Extension} features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
|
ExtensionApi getExtensionApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to {@link Volume} features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VolumeApi getVolumeApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to {@link VolumeType} features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VolumeTypeApi getVolumeTypeApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to {@link Snapshot} features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
SnapshotApi getSnapshotApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to quota features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
QuotaApi getQuotaApi(@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
|
||||||
|
@Region
|
||||||
|
Set<String> getConfiguredZones();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to Extension features.
|
||||||
|
* @deprecated Please use {@link #getExtensionApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
ExtensionApi getExtensionApiForZone(
|
ExtensionApi getExtensionApiForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Volume features.
|
* Provides synchronous access to Volume features.
|
||||||
|
* @deprecated Please use {@link #getVolumeApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Delegate
|
@Delegate
|
||||||
VolumeApi getVolumeApiForZone(
|
VolumeApi getVolumeApiForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to VolumeType features.
|
* Provides synchronous access to VolumeType features.
|
||||||
|
* @deprecated Please use {@link #getVolumeTypeApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Delegate
|
@Delegate
|
||||||
VolumeTypeApi getVolumeTypeApiForZone(
|
VolumeTypeApi getVolumeTypeApiForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Snapshot features.
|
* Provides synchronous access to Snapshot features.
|
||||||
|
* @deprecated Please use {@link #getSnapshotApi(String)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Delegate
|
@Delegate
|
||||||
SnapshotApi getSnapshotApiForZone(
|
SnapshotApi getSnapshotApiForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides synchronous access to quotas features.
|
|
||||||
*/
|
|
||||||
@Delegate
|
|
||||||
QuotaApi getQuotaApi(
|
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.jclouds.openstack.cinder.v1.config.CinderParserModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
|
import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule;
|
||||||
import org.jclouds.openstack.v2_0.ServiceType;
|
import org.jclouds.openstack.v2_0.ServiceType;
|
||||||
import org.jclouds.rest.internal.BaseHttpApiMetadata;
|
import org.jclouds.rest.internal.BaseHttpApiMetadata;
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Cinder v1 API
|
* Implementation of {@link org.jclouds.apis.ApiMetadata} for Cinder v1 API
|
||||||
*/
|
*/
|
||||||
public class CinderApiMetadata extends BaseHttpApiMetadata<CinderApi> {
|
public class CinderApiMetadata extends BaseHttpApiMetadata<CinderApi> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder toBuilder() {
|
public Builder toBuilder() {
|
||||||
return new Builder().fromApiMetadata(this);
|
return new Builder().fromApiMetadata(this);
|
||||||
|
@ -74,12 +74,12 @@ public class CinderApiMetadata extends BaseHttpApiMetadata<CinderApi> {
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(AuthenticationApiModule.class)
|
.add(AuthenticationApiModule.class)
|
||||||
.add(KeystoneAuthenticationModule.class)
|
.add(KeystoneAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(RegionModule.class)
|
||||||
.add(CinderParserModule.class)
|
.add(CinderParserModule.class)
|
||||||
.add(CinderHttpApiModule.class)
|
.add(CinderHttpApiModule.class)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CinderApiMetadata build() {
|
public CinderApiMetadata build() {
|
||||||
return new CinderApiMetadata(this);
|
return new CinderApiMetadata(this);
|
||||||
|
|
|
@ -16,7 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.cinder.v1.features;
|
package org.jclouds.openstack.cinder.v1.features;
|
||||||
|
|
||||||
import org.jclouds.Fallbacks;
|
import javax.inject.Named;
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.cinder.v1.domain.VolumeQuota;
|
import org.jclouds.openstack.cinder.v1.domain.VolumeQuota;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.rest.annotations.Fallback;
|
import org.jclouds.rest.annotations.Fallback;
|
||||||
|
@ -24,29 +32,22 @@ import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.jclouds.rest.annotations.SkipEncoding;
|
import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.PathParam;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Quota via their REST API.
|
* Provides access to the Quota API.
|
||||||
*
|
*
|
||||||
* @see QuotaApi
|
|
||||||
* @see <a href="http://api.openstack.org/">API Doc</a>
|
|
||||||
*/
|
*/
|
||||||
@SkipEncoding({'/', '='})
|
@SkipEncoding({'/', '='})
|
||||||
@RequestFilters(AuthenticateRequest.class)
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Path("/os-quota-sets")
|
@Path("/os-quota-sets")
|
||||||
public interface QuotaApi {
|
public interface QuotaApi {
|
||||||
|
|
||||||
|
@Named("quota:get")
|
||||||
@GET
|
@GET
|
||||||
@SelectJson("quota_set")
|
@SelectJson("quota_set")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Path("/{tenant_id}")
|
@Path("/{tenant_id}")
|
||||||
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
|
@Fallback(NullOnNotFoundOr404.class)
|
||||||
|
@Nullable
|
||||||
VolumeQuota getByTenant(@PathParam("tenant_id") String tenantId);
|
VolumeQuota getByTenant(@PathParam("tenant_id") String tenantId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.cinder.v1.domain.Snapshot;
|
import org.jclouds.openstack.cinder.v1.domain.Snapshot;
|
||||||
import org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions;
|
import org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
@ -42,12 +43,13 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Volume Snapshots via their REST API.
|
* Provides synchronous access to Volume Snapshots API.
|
||||||
*
|
*
|
||||||
* @see <a href="http://api.openstack.org/">API Doc</a>
|
|
||||||
*/
|
*/
|
||||||
@SkipEncoding({'/', '='})
|
@SkipEncoding({'/', '='})
|
||||||
@RequestFilters(AuthenticateRequest.class)
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/snapshots")
|
||||||
public interface SnapshotApi {
|
public interface SnapshotApi {
|
||||||
/**
|
/**
|
||||||
* Returns a summary list of Snapshots.
|
* Returns a summary list of Snapshots.
|
||||||
|
@ -56,10 +58,8 @@ public interface SnapshotApi {
|
||||||
*/
|
*/
|
||||||
@Named("snapshot:list")
|
@Named("snapshot:list")
|
||||||
@GET
|
@GET
|
||||||
@Path("/snapshots")
|
|
||||||
@SelectJson("snapshots")
|
@SelectJson("snapshots")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
|
||||||
FluentIterable<? extends Snapshot> list();
|
FluentIterable<? extends Snapshot> list();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,10 +69,9 @@ public interface SnapshotApi {
|
||||||
*/
|
*/
|
||||||
@Named("snapshot:list")
|
@Named("snapshot:list")
|
||||||
@GET
|
@GET
|
||||||
@Path("/snapshots/detail")
|
@Path("/detail")
|
||||||
@SelectJson("snapshots")
|
@SelectJson("snapshots")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
|
||||||
FluentIterable<? extends Snapshot> listInDetail();
|
FluentIterable<? extends Snapshot> listInDetail();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,26 +82,24 @@ public interface SnapshotApi {
|
||||||
*/
|
*/
|
||||||
@Named("snapshot:get")
|
@Named("snapshot:get")
|
||||||
@GET
|
@GET
|
||||||
@Path("/snapshots/{id}")
|
@Path("/{id}")
|
||||||
@SelectJson("snapshot")
|
@SelectJson("snapshot")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(NullOnNotFoundOr404.class)
|
||||||
@Fallback(NullOnNotFoundOr404.class)
|
@Nullable
|
||||||
Snapshot get(@PathParam("id") String snapshotId);
|
Snapshot get(@PathParam("id") String snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Snapshot. The Volume status must be Available.
|
* Creates a new Snapshot. The Volume status must be Available.
|
||||||
*
|
*
|
||||||
* @param volumeId The Volume Id from which to create the Snapshot
|
* @param volumeId The Volume Id from which to create the Snapshot
|
||||||
* @param options See CreateSnapshotOptions
|
* @param options See CreateSnapshotOptions
|
||||||
* @return The new Snapshot
|
* @return The new Snapshot
|
||||||
*/
|
*/
|
||||||
@Named("snapshot:create")
|
@Named("snapshot:create")
|
||||||
@POST
|
@POST
|
||||||
@Path("/snapshots")
|
|
||||||
@SelectJson("snapshot")
|
@SelectJson("snapshot")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@MapBinder(CreateSnapshotOptions.class)
|
@MapBinder(CreateSnapshotOptions.class)
|
||||||
Snapshot create(@PayloadParam("volume_id") String volumeId, CreateSnapshotOptions... options);
|
Snapshot create(@PayloadParam("volume_id") String volumeId, CreateSnapshotOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,8 +110,7 @@ public interface SnapshotApi {
|
||||||
*/
|
*/
|
||||||
@Named("snapshot:delete")
|
@Named("snapshot:delete")
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/snapshots/{id}")
|
@Path("/{id}")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(FalseOnNotFoundOr404.class)
|
||||||
@Fallback(FalseOnNotFoundOr404.class)
|
|
||||||
boolean delete(@PathParam("id") String snapshotId);
|
boolean delete(@PathParam("id") String snapshotId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.cinder.v1.domain.Volume;
|
import org.jclouds.openstack.cinder.v1.domain.Volume;
|
||||||
import org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions;
|
import org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
@ -42,16 +43,16 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Volumes.
|
* Provides synchronous access to the Volume API.
|
||||||
*
|
*
|
||||||
* This API strictly handles creating and managing Volumes. To attach a Volume to a Server you need to use the
|
* This API strictly handles creating and managing Volumes. To attach a Volume to a Server you need to use the
|
||||||
* @see VolumeAttachmentApi
|
* @see VolumeAttachmentApi
|
||||||
*
|
*
|
||||||
* @see VolumeAsyncApi
|
|
||||||
* @see <a href="http://api.openstack.org/">API Doc</a>
|
|
||||||
*/
|
*/
|
||||||
@SkipEncoding({'/', '='})
|
@SkipEncoding({'/', '='})
|
||||||
@RequestFilters(AuthenticateRequest.class)
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/volumes")
|
||||||
public interface VolumeApi {
|
public interface VolumeApi {
|
||||||
/**
|
/**
|
||||||
* Returns a summary list of Volumes.
|
* Returns a summary list of Volumes.
|
||||||
|
@ -60,9 +61,7 @@ public interface VolumeApi {
|
||||||
*/
|
*/
|
||||||
@Named("volume:list")
|
@Named("volume:list")
|
||||||
@GET
|
@GET
|
||||||
@Path("/volumes")
|
|
||||||
@SelectJson("volumes")
|
@SelectJson("volumes")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||||
FluentIterable<? extends Volume> list();
|
FluentIterable<? extends Volume> list();
|
||||||
|
|
||||||
|
@ -73,10 +72,9 @@ public interface VolumeApi {
|
||||||
*/
|
*/
|
||||||
@Named("volume:list")
|
@Named("volume:list")
|
||||||
@GET
|
@GET
|
||||||
@Path("/volumes/detail")
|
@Path("/detail")
|
||||||
@SelectJson("volumes")
|
@SelectJson("volumes")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
|
||||||
FluentIterable<? extends Volume> listInDetail();
|
FluentIterable<? extends Volume> listInDetail();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,24 +85,22 @@ public interface VolumeApi {
|
||||||
*/
|
*/
|
||||||
@Named("volume:get")
|
@Named("volume:get")
|
||||||
@GET
|
@GET
|
||||||
@Path("/volumes/{id}")
|
@Path("/{id}")
|
||||||
@SelectJson("volume")
|
@SelectJson("volume")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(NullOnNotFoundOr404.class)
|
||||||
@Fallback(NullOnNotFoundOr404.class)
|
@Nullable
|
||||||
Volume get(@PathParam("id") String volumeId);
|
Volume get(@PathParam("id") String volumeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Volume
|
* Creates a new Volume
|
||||||
*
|
*
|
||||||
* @param volumeId Id of the Volume
|
* @param volumeId Id of the Volume
|
||||||
* @param options See CreateVolumeOptions
|
* @param options See CreateVolumeOptions
|
||||||
* @return The new Volume
|
* @return The new Volume
|
||||||
*/
|
*/
|
||||||
@Named("volume:create")
|
@Named("volume:create")
|
||||||
@POST
|
@POST
|
||||||
@Path("/volumes")
|
|
||||||
@SelectJson("volume")
|
@SelectJson("volume")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@MapBinder(CreateVolumeOptions.class)
|
@MapBinder(CreateVolumeOptions.class)
|
||||||
Volume create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options);
|
Volume create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options);
|
||||||
|
@ -117,8 +113,7 @@ public interface VolumeApi {
|
||||||
*/
|
*/
|
||||||
@Named("volume:delete")
|
@Named("volume:delete")
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/volumes/{id}")
|
@Path("/{id}")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Fallback(FalseOnNotFoundOr404.class)
|
@Fallback(FalseOnNotFoundOr404.class)
|
||||||
boolean delete(@PathParam("id") String volumeId);
|
boolean delete(@PathParam("id") String volumeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.cinder.v1.domain.VolumeType;
|
import org.jclouds.openstack.cinder.v1.domain.VolumeType;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.rest.annotations.Fallback;
|
import org.jclouds.rest.annotations.Fallback;
|
||||||
|
@ -35,24 +36,22 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Volumes via their REST API.
|
* Provides synchronous access to the OpenStack Block Storage (Cinder) v1 Volume Types API.
|
||||||
*
|
*
|
||||||
* @see VolumeAsyncApi
|
|
||||||
* @see <a href="http://api.openstack.org/">API Doc</a>
|
|
||||||
*/
|
*/
|
||||||
@SkipEncoding({'/', '='})
|
@SkipEncoding({'/', '='})
|
||||||
@RequestFilters(AuthenticateRequest.class)
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/types")
|
||||||
public interface VolumeTypeApi {
|
public interface VolumeTypeApi {
|
||||||
/**
|
/**
|
||||||
* Returns a summary list of VolumeTypes.
|
* Returns a summary list of VolumeTypes.
|
||||||
*
|
*
|
||||||
* @return The list of VolumeTypes
|
* @return The list of VolumeTypes
|
||||||
*/
|
*/
|
||||||
@Named("volumetype:list")
|
@Named("volumeType:list")
|
||||||
@GET
|
@GET
|
||||||
@Path("/types")
|
|
||||||
@SelectJson("volume_types")
|
@SelectJson("volume_types")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||||
FluentIterable<? extends VolumeType> list();
|
FluentIterable<? extends VolumeType> list();
|
||||||
|
|
||||||
|
@ -62,11 +61,11 @@ public interface VolumeTypeApi {
|
||||||
* @param volumeTypeId Id of the VolumeType
|
* @param volumeTypeId Id of the VolumeType
|
||||||
* @return Details of a specific VolumeType
|
* @return Details of a specific VolumeType
|
||||||
*/
|
*/
|
||||||
@Named("volumetype:get")
|
@Named("volumeType:get")
|
||||||
@GET
|
@GET
|
||||||
@Path("/types/{id}")
|
@Path("/{id}")
|
||||||
@SelectJson("volume_type")
|
@SelectJson("volume_type")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Fallback(NullOnNotFoundOr404.class)
|
||||||
@Fallback(NullOnNotFoundOr404.class)
|
@Nullable
|
||||||
VolumeType get(@PathParam("id") String volumeTypeId);
|
VolumeType get(@PathParam("id") String volumeTypeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,21 +37,21 @@ import com.google.common.base.Predicate;
|
||||||
* Snapshot snapshot = snapshotApi.create(volumeId);
|
* Snapshot snapshot = snapshotApi.create(volumeId);
|
||||||
* RetryablePredicate<String> awaitAvailable = RetryablePredicate.create(
|
* RetryablePredicate<String> awaitAvailable = RetryablePredicate.create(
|
||||||
* SnapshotPredicates.available(snapshotApi), 600, 10, 10, TimeUnit.SECONDS);
|
* SnapshotPredicates.available(snapshotApi), 600, 10, 10, TimeUnit.SECONDS);
|
||||||
*
|
*
|
||||||
* if (!awaitAvailable.apply(snapshot.getId())) {
|
* if (!awaitAvailable.apply(snapshot.getId())) {
|
||||||
* throw new TimeoutException("Timeout on snapshot: " + snapshot);
|
* throw new TimeoutException("Timeout on snapshot: " + snapshot);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* You can also use the static convenience methods as so.
|
* You can also use the static convenience methods as so.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* Snapshot snapshot = snapshotApi.create(volumeId);
|
* Snapshot snapshot = snapshotApi.create(volumeId);
|
||||||
*
|
*
|
||||||
* if (!SnapshotPredicates.awaitAvailable(snapshotApi).apply(snapshot.getId())) {
|
* if (!SnapshotPredicates.awaitAvailable(snapshotApi).apply(snapshot.getId())) {
|
||||||
* throw new TimeoutException("Timeout on snapshot: " + snapshot);
|
* throw new TimeoutException("Timeout on snapshot: " + snapshot);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -59,20 +59,20 @@ import com.google.common.base.Predicate;
|
||||||
public class SnapshotPredicates {
|
public class SnapshotPredicates {
|
||||||
/**
|
/**
|
||||||
* Wait until a Snapshot is Available.
|
* Wait until a Snapshot is Available.
|
||||||
*
|
*
|
||||||
* @param snapshotApi The SnapshotApi in the zone where your Snapshot resides.
|
* @param snapshotApi The SnapshotApi in the region where your Snapshot resides.
|
||||||
* @return RetryablePredicate That will check the status every 5 seconds for a maxiumum of 20 minutes.
|
* @return RetryablePredicate That will check the status every 5 seconds for a maxiumum of 20 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<Snapshot> awaitAvailable(SnapshotApi snapshotApi) {
|
public static Predicate<Snapshot> awaitAvailable(SnapshotApi snapshotApi) {
|
||||||
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(snapshotApi, Volume.Status.AVAILABLE);
|
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(snapshotApi, Volume.Status.AVAILABLE);
|
||||||
return retry(statusPredicate, 1200, 5, 5, SECONDS);
|
return retry(statusPredicate, 1200, 5, 5, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait until a Snapshot no longer exists.
|
* Wait until a Snapshot no longer exists.
|
||||||
*
|
*
|
||||||
* @param snapshotApi The SnapshotApi in the zone where your Snapshot resides.
|
* @param snapshotApi The SnapshotApi in the region where your Snapshot resides.
|
||||||
* @return RetryablePredicate That will check the whether the Snapshot exists
|
* @return RetryablePredicate That will check the whether the Snapshot exists
|
||||||
* every 5 seconds for a maxiumum of 20 minutes.
|
* every 5 seconds for a maxiumum of 20 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<Snapshot> awaitDeleted(SnapshotApi snapshotApi) {
|
public static Predicate<Snapshot> awaitDeleted(SnapshotApi snapshotApi) {
|
||||||
|
@ -85,7 +85,7 @@ public class SnapshotPredicates {
|
||||||
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(snapshotApi, status);
|
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(snapshotApi, status);
|
||||||
return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS);
|
return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StatusUpdatedPredicate implements Predicate<Snapshot> {
|
private static class StatusUpdatedPredicate implements Predicate<Snapshot> {
|
||||||
private SnapshotApi snapshotApi;
|
private SnapshotApi snapshotApi;
|
||||||
private Status status;
|
private Status status;
|
||||||
|
@ -108,7 +108,7 @@ public class SnapshotPredicates {
|
||||||
else {
|
else {
|
||||||
Snapshot snapshotUpdated = snapshotApi.get(snapshot.getId());
|
Snapshot snapshotUpdated = snapshotApi.get(snapshot.getId());
|
||||||
checkNotNull(snapshotUpdated, "Snapshot %s not found.", snapshot.getId());
|
checkNotNull(snapshotUpdated, "Snapshot %s not found.", snapshot.getId());
|
||||||
|
|
||||||
return status.equals(snapshotUpdated.getStatus());
|
return status.equals(snapshotUpdated.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,24 +34,24 @@ import com.google.common.base.Predicate;
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* Volume volume = volumeApi.create(100);
|
* Volume volume = volumeApi.create(100);
|
||||||
*
|
*
|
||||||
* RetryablePredicate<String> awaitAvailable = RetryablePredicate.create(
|
* RetryablePredicate<String> awaitAvailable = RetryablePredicate.create(
|
||||||
* VolumePredicates.available(volumeApi), 600, 10, 10, TimeUnit.SECONDS);
|
* VolumePredicates.available(volumeApi), 600, 10, 10, TimeUnit.SECONDS);
|
||||||
*
|
*
|
||||||
* if (!awaitAvailable.apply(volume.getId())) {
|
* if (!awaitAvailable.apply(volume.getId())) {
|
||||||
* throw new TimeoutException("Timeout on volume: " + volume);
|
* throw new TimeoutException("Timeout on volume: " + volume);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* You can also use the static convenience methods as so.
|
* You can also use the static convenience methods as so.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* Volume volume = volumeApi.create(100);
|
* Volume volume = volumeApi.create(100);
|
||||||
*
|
*
|
||||||
* if (!VolumePredicates.awaitAvailable(volumeApi).apply(volume.getId())) {
|
* if (!VolumePredicates.awaitAvailable(volumeApi).apply(volume.getId())) {
|
||||||
* throw new TimeoutException("Timeout on volume: " + volume);
|
* throw new TimeoutException("Timeout on volume: " + volume);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -59,19 +59,19 @@ import com.google.common.base.Predicate;
|
||||||
public class VolumePredicates {
|
public class VolumePredicates {
|
||||||
/**
|
/**
|
||||||
* Wait until a Volume is Available.
|
* Wait until a Volume is Available.
|
||||||
*
|
*
|
||||||
* @param volumeApi The VolumeApi in the zone where your Volume resides.
|
* @param volumeApi The VolumeApi in the region where your Volume resides.
|
||||||
* @return RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
|
* @return RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<Volume> awaitAvailable(VolumeApi volumeApi) {
|
public static Predicate<Volume> awaitAvailable(VolumeApi volumeApi) {
|
||||||
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(volumeApi, Volume.Status.AVAILABLE);
|
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(volumeApi, Volume.Status.AVAILABLE);
|
||||||
return retry(statusPredicate, 600, 5, 5, SECONDS);
|
return retry(statusPredicate, 600, 5, 5, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait until a Volume is In Use.
|
* Wait until a Volume is In Use.
|
||||||
*
|
*
|
||||||
* @param volumeApi The VolumeApi in the zone where your Volume resides.
|
* @param volumeApi The VolumeApi in the region where your Volume resides.
|
||||||
* @return RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
|
* @return RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<Volume> awaitInUse(VolumeApi volumeApi) {
|
public static Predicate<Volume> awaitInUse(VolumeApi volumeApi) {
|
||||||
|
@ -81,22 +81,22 @@ public class VolumePredicates {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait until a Volume no longer exists.
|
* Wait until a Volume no longer exists.
|
||||||
*
|
*
|
||||||
* @param volumeApi The VolumeApi in the zone where your Volume resides.
|
* @param volumeApi The VolumeApi in the region where your Volume resides.
|
||||||
* @return RetryablePredicate That will check the whether the Volume exists
|
* @return RetryablePredicate That will check the whether the Volume exists
|
||||||
* every 5 seconds for a maxiumum of 10 minutes.
|
* every 5 seconds for a maxiumum of 10 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<Volume> awaitDeleted(VolumeApi volumeApi) {
|
public static Predicate<Volume> awaitDeleted(VolumeApi volumeApi) {
|
||||||
DeletedPredicate deletedPredicate = new DeletedPredicate(volumeApi);
|
DeletedPredicate deletedPredicate = new DeletedPredicate(volumeApi);
|
||||||
return retry(deletedPredicate, 600, 5, 5, SECONDS);
|
return retry(deletedPredicate, 600, 5, 5, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<Volume> awaitStatus(
|
public static Predicate<Volume> awaitStatus(
|
||||||
VolumeApi volumeApi, Volume.Status status, long maxWaitInSec, long periodInSec) {
|
VolumeApi volumeApi, Volume.Status status, long maxWaitInSec, long periodInSec) {
|
||||||
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(volumeApi, status);
|
StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(volumeApi, status);
|
||||||
return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS);
|
return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StatusUpdatedPredicate implements Predicate<Volume> {
|
private static class StatusUpdatedPredicate implements Predicate<Volume> {
|
||||||
private VolumeApi volumeApi;
|
private VolumeApi volumeApi;
|
||||||
private Status status;
|
private Status status;
|
||||||
|
@ -112,14 +112,14 @@ public class VolumePredicates {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Volume volume) {
|
public boolean apply(Volume volume) {
|
||||||
checkNotNull(volume, "volume must be defined");
|
checkNotNull(volume, "volume must be defined");
|
||||||
|
|
||||||
if (status.equals(volume.getStatus())) {
|
if (status.equals(volume.getStatus())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Volume volumeUpdated = volumeApi.get(volume.getId());
|
Volume volumeUpdated = volumeApi.get(volume.getId());
|
||||||
checkNotNull(volumeUpdated, "Volume %s not found.", volume.getId());
|
checkNotNull(volumeUpdated, "Volume %s not found.", volume.getId());
|
||||||
|
|
||||||
return status.equals(volumeUpdated.getStatus());
|
return status.equals(volumeUpdated.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.cinder.v1.features;
|
package org.jclouds.openstack.cinder.v1.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.openstack.cinder.v1.domain.VolumeQuota;
|
import org.jclouds.openstack.cinder.v1.domain.VolumeQuota;
|
||||||
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiExpectTest;
|
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "QuotaApiExpectTest")
|
@Test(groups = "unit", testName = "QuotaApiExpectTest")
|
||||||
public class QuotasApiExpectTest extends BaseCinderApiExpectTest {
|
public class QuotasApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.cinder.v1.features;
|
package org.jclouds.openstack.cinder.v1.features;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.jclouds.openstack.cinder.v1.domain.VolumeQuota;
|
import org.jclouds.openstack.cinder.v1.domain.VolumeQuota;
|
||||||
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiLiveTest;
|
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
@Test(groups = "live", testName = "QuotasApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "QuotasApiLiveTest", singleThreaded = true)
|
||||||
public class QuotasApiLiveTest extends BaseCinderApiLiveTest {
|
public class QuotasApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
|
@ -39,8 +40,8 @@ public class QuotasApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setup();
|
super.setup();
|
||||||
String zone = Iterables.getFirst(api.getConfiguredZones(), "nova");
|
String region = Iterables.getFirst(api.getConfiguredRegions(), "nova");
|
||||||
quotaApi = api.getQuotaApi(zone);
|
quotaApi = api.getQuotaApi(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetStorageQuotas() throws ExecutionException, InterruptedException {
|
public void testGetStorageQuotas() throws ExecutionException, InterruptedException {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_list_simple.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_list_simple.json")).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Snapshot> snapshots = api.list().toSet();
|
Set<? extends Snapshot> snapshots = api.list().toSet();
|
||||||
assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
|
assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
|
||||||
|
@ -69,7 +69,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Snapshot> snapshots = api.list().toSet();
|
Set<? extends Snapshot> snapshots = api.list().toSet();
|
||||||
assertTrue(snapshots.isEmpty());
|
assertTrue(snapshots.isEmpty());
|
||||||
|
@ -82,7 +82,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_list_details.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_list_details.json")).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Snapshot> snapshots = api.listInDetail().toSet();
|
Set<? extends Snapshot> snapshots = api.listInDetail().toSet();
|
||||||
assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
|
assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
|
||||||
|
@ -104,7 +104,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Snapshot> snapshots = api.listInDetail().toSet();
|
Set<? extends Snapshot> snapshots = api.listInDetail().toSet();
|
||||||
assertTrue(snapshots.isEmpty());
|
assertTrue(snapshots.isEmpty());
|
||||||
|
@ -117,7 +117,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_get.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_get.json")).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
Snapshot snapshot = api.get("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
Snapshot snapshot = api.get("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||||
assertEquals(snapshot, testSnapshot());
|
assertEquals(snapshot, testSnapshot());
|
||||||
|
@ -130,7 +130,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
assertNull(api.get("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
assertNull(api.get("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_create_response.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_create_response.json")).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
||||||
.name("jclouds-test-snapshot")
|
.name("jclouds-test-snapshot")
|
||||||
|
@ -167,7 +167,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
||||||
.name("jclouds-test-snapshot")
|
.name("jclouds-test-snapshot")
|
||||||
|
@ -193,7 +193,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.wrap("{\"badRequest\": {\"message\": \"Invalid volume: must be available\", \"code\": 400}}"
|
.wrap("{\"badRequest\": {\"message\": \"Invalid volume: must be available\", \"code\": 400}}"
|
||||||
.getBytes())))
|
.getBytes())))
|
||||||
.build()
|
.build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
||||||
.name("jclouds-test-snapshot")
|
.name("jclouds-test-snapshot")
|
||||||
|
@ -214,7 +214,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(401).build()
|
HttpResponse.builder().statusCode(401).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
||||||
.name("jclouds-test-snapshot")
|
.name("jclouds-test-snapshot")
|
||||||
|
@ -231,7 +231,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(200).build()
|
HttpResponse.builder().statusCode(200).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
assertTrue(api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
assertTrue(api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(401).build()
|
HttpResponse.builder().statusCode(401).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
assertFalse(api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
assertFalse(api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.wrap("{\"badRequest\": {\"message\": \"Invalid volume: Volume Snapshot status must be available or error\", \"code\": 400}}"
|
.wrap("{\"badRequest\": {\"message\": \"Invalid volume: Volume Snapshot status must be available or error\", \"code\": 400}}"
|
||||||
.getBytes())))
|
.getBytes())))
|
||||||
.build()
|
.build()
|
||||||
).getSnapshotApiForZone("RegionOne");
|
).getSnapshotApi("RegionOne");
|
||||||
|
|
||||||
api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,12 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live", testName = "VolumeApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "VolumeApiLiveTest", singleThreaded = true)
|
||||||
public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
|
public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
private static final String name = System.getProperty("user.name").replace('.', '-').toLowerCase();
|
private static final String name = System.getProperty("user.name").replace('.', '-').toLowerCase();
|
||||||
|
|
||||||
private String zone;
|
private String region;
|
||||||
|
|
||||||
private VolumeApi volumeApi;
|
private VolumeApi volumeApi;
|
||||||
private SnapshotApi snapshotApi;
|
private SnapshotApi snapshotApi;
|
||||||
|
|
||||||
private Volume testVolume;
|
private Volume testVolume;
|
||||||
private Snapshot testSnapshot;
|
private Snapshot testSnapshot;
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
volumeApi = api.getVolumeApiForZone(zone);
|
volumeApi = api.getVolumeApi(region);
|
||||||
snapshotApi = api.getSnapshotApiForZone(zone);
|
snapshotApi = api.getSnapshotApi(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
@ -81,7 +81,7 @@ public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
.name(name)
|
.name(name)
|
||||||
.description("description of test volume");
|
.description("description of test volume");
|
||||||
testVolume = volumeApi.create(100, options);
|
testVolume = volumeApi.create(100, options);
|
||||||
|
|
||||||
assertTrue(VolumePredicates.awaitAvailable(volumeApi).apply(testVolume));
|
assertTrue(VolumePredicates.awaitAvailable(volumeApi).apply(testVolume));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_list_simple.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_list_simple.json")).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Volume> volumes = api.list().toSet();
|
Set<? extends Volume> volumes = api.list().toSet();
|
||||||
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
||||||
|
@ -66,7 +66,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Volume> volumes = api.list().toSet();
|
Set<? extends Volume> volumes = api.list().toSet();
|
||||||
assertTrue(volumes.isEmpty());
|
assertTrue(volumes.isEmpty());
|
||||||
|
@ -79,7 +79,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_list_details.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_list_details.json")).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Volume> volumes = api.listInDetail().toSet();
|
Set<? extends Volume> volumes = api.listInDetail().toSet();
|
||||||
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
||||||
|
@ -92,7 +92,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends Volume> volumes = api.listInDetail().toSet();
|
Set<? extends Volume> volumes = api.listInDetail().toSet();
|
||||||
assertTrue(volumes.isEmpty());
|
assertTrue(volumes.isEmpty());
|
||||||
|
@ -108,7 +108,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.payload(payloadFromResourceWithContentType("/volume_create.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/volume_create.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_create_response.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_create_response.json")).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
CreateVolumeOptions options = CreateVolumeOptions.Builder
|
CreateVolumeOptions options = CreateVolumeOptions.Builder
|
||||||
.name("jclouds-test-volume")
|
.name("jclouds-test-volume")
|
||||||
|
@ -129,7 +129,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
.payload(payloadFromResourceWithContentType("/volume_create.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/volume_create.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/volume_create_response.json")).build()
|
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/volume_create_response.json")).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
CreateVolumeOptions options = CreateVolumeOptions.Builder
|
CreateVolumeOptions options = CreateVolumeOptions.Builder
|
||||||
.name("jclouds-test-volume")
|
.name("jclouds-test-volume")
|
||||||
|
@ -144,7 +144,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_get.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_get.json")).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
Volume volume = api.get("60761c60-0f56-4499-b522-ff13e120af10");
|
Volume volume = api.get("60761c60-0f56-4499-b522-ff13e120af10");
|
||||||
assertEquals(volume, testVolume());
|
assertEquals(volume, testVolume());
|
||||||
|
@ -163,7 +163,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
assertNull(api.get("60761c60-0f56-4499-b522-ff13e120af10"));
|
assertNull(api.get("60761c60-0f56-4499-b522-ff13e120af10"));
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
assertTrue(api.delete("60761c60-0f56-4499-b522-ff13e120af10"));
|
assertTrue(api.delete("60761c60-0f56-4499-b522-ff13e120af10"));
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getVolumeApiForZone("RegionOne");
|
).getVolumeApi("RegionOne");
|
||||||
|
|
||||||
assertFalse(api.delete("60761c60-0f56-4499-b522-ff13e120af10"));
|
assertFalse(api.delete("60761c60-0f56-4499-b522-ff13e120af10"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class VolumeTypeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_list_simple.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_list_simple.json")).build()
|
||||||
).getVolumeTypeApiForZone("RegionOne");
|
).getVolumeTypeApi("RegionOne");
|
||||||
|
|
||||||
Set<? extends VolumeType> types = api.list().toSet();
|
Set<? extends VolumeType> types = api.list().toSet();
|
||||||
assertEquals(types, ImmutableSet.of(testVolumeType()));
|
assertEquals(types, ImmutableSet.of(testVolumeType()));
|
||||||
|
@ -59,7 +59,7 @@ public class VolumeTypeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_get.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_get.json")).build()
|
||||||
).getVolumeTypeApiForZone("RegionOne");
|
).getVolumeTypeApi("RegionOne");
|
||||||
|
|
||||||
VolumeType type = api.get("1");
|
VolumeType type = api.get("1");
|
||||||
assertEquals(type, testVolumeType());
|
assertEquals(type, testVolumeType());
|
||||||
|
@ -72,7 +72,7 @@ public class VolumeTypeApiExpectTest extends BaseCinderApiExpectTest {
|
||||||
responseWithKeystoneAccess,
|
responseWithKeystoneAccess,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getVolumeTypeApiForZone("RegionOne");
|
).getVolumeTypeApi("RegionOne");
|
||||||
|
|
||||||
assertNull(api.get("X"));
|
assertNull(api.get("X"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,14 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live", testName = "VolumeTypeApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "VolumeTypeApiLiveTest", singleThreaded = true)
|
||||||
public class VolumeTypeApiLiveTest extends BaseCinderApiLiveTest {
|
public class VolumeTypeApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
private VolumeTypeApi volumeTypeApi;
|
private VolumeTypeApi volumeTypeApi;
|
||||||
private String zone;
|
private String region;
|
||||||
|
|
||||||
@BeforeGroups(groups = {"integration", "live"})
|
@BeforeGroups(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
volumeTypeApi = api.getVolumeTypeApiForZone(zone);
|
volumeTypeApi = api.getVolumeTypeApi(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
* <li>add the above annotation to any {@link AsyncApi} classes by placing it on the type. ex.
|
* <li>add the above annotation to any {@link AsyncApi} classes by placing it on the type. ex.
|
||||||
* {@code @Endpoint(CloudDNS.class)}</li>
|
* {@code @Endpoint(CloudDNS.class)}</li>
|
||||||
* <li>add the following to your {@link org.jclouds.rest.config.RestClientModule}</li>
|
* <li>add the following to your {@link org.jclouds.rest.config.RestClientModule}</li>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* bind(new TypeLiteral<Supplier<URI>>() {
|
* bind(new TypeLiteral<Supplier<URI>>() {
|
||||||
* }).annotatedWith(CloudDNS.class).to(new TypeLiteral<Supplier<URI>>() {
|
* }).annotatedWith(CloudDNS.class).to(new TypeLiteral<Supplier<URI>>() {
|
||||||
|
@ -148,6 +148,11 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated All OpenStack APIs rely on regions in jclouds 2.0 and this module will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static class ZoneModule extends AbstractModule {
|
public static class ZoneModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class KeystoneHttpApiModule extends HttpApiModule<KeystoneApi> {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final javax.inject.Provider<KeystoneApi> keystoneApi) {
|
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final javax.inject.Provider<KeystoneApi> keystoneApi) {
|
||||||
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
|
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
|
||||||
.build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() {
|
.build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class KeystoneRestClientModule<S extends KeystoneApi, A extends KeystoneA
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final javax.inject.Provider<KeystoneApi> keystoneApi) {
|
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final javax.inject.Provider<KeystoneApi> keystoneApi) {
|
||||||
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
|
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
|
||||||
.build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() {
|
.build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio
|
||||||
"Keypair Support").build();
|
"Keypair Support").build();
|
||||||
|
|
||||||
@org.jclouds.openstack.v2_0.services.Extension(of = ServiceType.COMPUTE, namespace = "http://docs.openstack.org/ext/keypairs/api/v1.1")
|
@org.jclouds.openstack.v2_0.services.Extension(of = ServiceType.COMPUTE, namespace = "http://docs.openstack.org/ext/keypairs/api/v1.1")
|
||||||
interface KeyPairAsyncApi {
|
interface KeyPairApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,50 +64,50 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio
|
||||||
"Floating IPs support").build();
|
"Floating IPs support").build();
|
||||||
|
|
||||||
@org.jclouds.openstack.v2_0.services.Extension(of = ServiceType.COMPUTE, namespace = "http://docs.openstack.org/ext/floating_ips/api/v1.1")
|
@org.jclouds.openstack.v2_0.services.Extension(of = ServiceType.COMPUTE, namespace = "http://docs.openstack.org/ext/floating_ips/api/v1.1")
|
||||||
interface FloatingIPAsyncApi {
|
interface FloatingIPApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NovaAsyncApi {
|
interface NovaApi {
|
||||||
|
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<FloatingIPAsyncApi> getFloatingIPExtensionForZone(String zone);
|
Optional<FloatingIPApi> getFloatingIPExtensionApi(String region);
|
||||||
|
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<KeyPairAsyncApi> getKeyPairExtensionForZone(String zone);
|
Optional<KeyPairApi> getKeyPairExtensionApi(String region);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InvocationSuccess getFloatingIPExtension(List<Object> args) throws SecurityException, NoSuchMethodException {
|
InvocationSuccess getFloatingIPExtension(List<Object> args) throws SecurityException, NoSuchMethodException {
|
||||||
return InvocationSuccess.create(
|
return InvocationSuccess.create(
|
||||||
Invocation.create(method(NovaAsyncApi.class, "getFloatingIPExtensionForZone", String.class), args), "foo");
|
Invocation.create(method(NovaApi.class, "getFloatingIPExtensionApi", String.class), args), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvocationSuccess getKeyPairExtension(List<Object> args) throws SecurityException, NoSuchMethodException {
|
InvocationSuccess getKeyPairExtension(List<Object> args) throws SecurityException, NoSuchMethodException {
|
||||||
return InvocationSuccess.create(
|
return InvocationSuccess.create(
|
||||||
Invocation.create(method(NovaAsyncApi.class, "getKeyPairExtensionForZone", String.class), args), "foo");
|
Invocation.create(method(NovaApi.class, "getKeyPairExtensionApi", String.class), args), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPresentWhenExtensionsIncludeNamespaceFromAnnotationAbsentWhenNot() throws SecurityException, NoSuchMethodException {
|
public void testPresentWhenExtensionsIncludeNamespaceFromAnnotationAbsentWhenNot() throws SecurityException, NoSuchMethodException {
|
||||||
|
|
||||||
assertEquals(whenExtensionsInZoneInclude("zone", keypairs, floatingIps).apply(getFloatingIPExtension(ImmutableList.<Object> of("zone"))), Optional.of("foo"));
|
assertEquals(whenExtensionsInRegionInclude("region", keypairs, floatingIps).apply(getFloatingIPExtension(ImmutableList.<Object> of("region"))), Optional.of("foo"));
|
||||||
assertEquals(whenExtensionsInZoneInclude("zone", keypairs, floatingIps).apply(getKeyPairExtension(ImmutableList.<Object> of("zone"))), Optional.of("foo"));
|
assertEquals(whenExtensionsInRegionInclude("region", keypairs, floatingIps).apply(getKeyPairExtension(ImmutableList.<Object> of("region"))), Optional.of("foo"));
|
||||||
assertEquals(whenExtensionsInZoneInclude("zone", keypairs).apply(getFloatingIPExtension(ImmutableList.<Object> of("zone"))), Optional.absent());
|
assertEquals(whenExtensionsInRegionInclude("region", keypairs).apply(getFloatingIPExtension(ImmutableList.<Object> of("region"))), Optional.absent());
|
||||||
assertEquals(whenExtensionsInZoneInclude("zone", floatingIps).apply(getKeyPairExtension(ImmutableList.<Object> of("zone"))), Optional.absent());
|
assertEquals(whenExtensionsInRegionInclude("region", floatingIps).apply(getKeyPairExtension(ImmutableList.<Object> of("region"))), Optional.absent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testZoneWithoutExtensionsReturnsAbsent() throws SecurityException, NoSuchMethodException {
|
public void testRegionWithoutExtensionsReturnsAbsent() throws SecurityException, NoSuchMethodException {
|
||||||
assertEquals(whenExtensionsInZoneInclude("zone", floatingIps).apply(
|
assertEquals(whenExtensionsInRegionInclude("region", floatingIps).apply(
|
||||||
getFloatingIPExtension(ImmutableList.<Object> of("differentzone"))), Optional.absent());
|
getFloatingIPExtension(ImmutableList.<Object> of("differentregion"))), Optional.absent());
|
||||||
assertEquals(whenExtensionsInZoneInclude("zone", keypairs).apply(
|
assertEquals(whenExtensionsInRegionInclude("region", keypairs).apply(
|
||||||
getKeyPairExtension(ImmutableList.<Object> of("differentzone"))), Optional.absent());
|
getKeyPairExtension(ImmutableList.<Object> of("differentregion"))), Optional.absent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It is possible that the /extensions call returned the correct extension, but that the
|
* It is possible that the /extensions call returned the correct extension, but that the
|
||||||
* namespaces were different, for whatever reason. One way to address this is to have a multimap
|
* namespaces were different, for whatever reason. One way to address this is to have a multimap
|
||||||
* of the authoritative namespace to alternate onces, which could be wired up with guice
|
* of the authoritative namespace to alternate onces, which could be wired up with guice
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testPresentWhenAliasForExtensionMapsToNamespace() throws SecurityException, NoSuchMethodException {
|
public void testPresentWhenAliasForExtensionMapsToNamespace() throws SecurityException, NoSuchMethodException {
|
||||||
Extension keypairsWithDifferentNamespace = keypairs.toBuilder().namespace(
|
Extension keypairsWithDifferentNamespace = keypairs.toBuilder().namespace(
|
||||||
|
@ -116,22 +116,22 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio
|
||||||
Multimap<URI, URI> aliases = ImmutableMultimap.of(keypairs.getNamespace(), keypairsWithDifferentNamespace
|
Multimap<URI, URI> aliases = ImmutableMultimap.of(keypairs.getNamespace(), keypairsWithDifferentNamespace
|
||||||
.getNamespace());
|
.getNamespace());
|
||||||
|
|
||||||
assertEquals(whenExtensionsAndAliasesInZoneInclude("zone", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply(
|
assertEquals(whenExtensionsAndAliasesInRegionInclude("region", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply(
|
||||||
getKeyPairExtension(ImmutableList.<Object> of("zone"))), Optional.of("foo"));
|
getKeyPairExtension(ImmutableList.<Object> of("region"))), Optional.of("foo"));
|
||||||
assertEquals(whenExtensionsAndAliasesInZoneInclude("zone", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply(
|
assertEquals(whenExtensionsAndAliasesInRegionInclude("region", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply(
|
||||||
getFloatingIPExtension(ImmutableList.<Object> of("zone"))), Optional.absent());
|
getFloatingIPExtension(ImmutableList.<Object> of("region"))), Optional.absent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet whenExtensionsInZoneInclude(
|
private PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet whenExtensionsInRegionInclude(
|
||||||
String zone, Extension... extensions) {
|
String region, Extension... extensions) {
|
||||||
return whenExtensionsAndAliasesInZoneInclude(zone, ImmutableSet.copyOf(extensions), ImmutableMultimap.<URI, URI> of());
|
return whenExtensionsAndAliasesInRegionInclude(region, ImmutableSet.copyOf(extensions), ImmutableMultimap.<URI, URI> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
private PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet whenExtensionsAndAliasesInZoneInclude(
|
private PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet whenExtensionsAndAliasesInRegionInclude(
|
||||||
String zone, final Set<Extension> extensions, final Multimap<URI, URI> aliases) {
|
String region, final Set<Extension> extensions, final Multimap<URI, URI> aliases) {
|
||||||
final LoadingCache<String, Set<? extends Extension>> extensionsForZone = CacheBuilder.newBuilder().build(
|
final LoadingCache<String, Set<? extends Extension>> extensionsForRegion = CacheBuilder.newBuilder().build(
|
||||||
CacheLoader.from(Functions.forMap(ImmutableMap.<String, Set<? extends Extension>>of(zone, extensions, "differentzone",
|
CacheLoader.from(Functions.forMap(ImmutableMap.<String, Set<? extends Extension>>of(region, extensions, "differentregion",
|
||||||
ImmutableSet.<Extension> of()))));
|
ImmutableSet.<Extension> of()))));
|
||||||
|
|
||||||
PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = Guice.createInjector(
|
PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = Guice.createInjector(
|
||||||
|
@ -142,7 +142,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
LoadingCache<String, Set<? extends Extension>> getExtensions() {
|
LoadingCache<String, Set<? extends Extension>> getExtensions() {
|
||||||
return extensionsForZone;
|
return extensionsForRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -150,7 +150,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio
|
||||||
return aliases;
|
return aliases;
|
||||||
}
|
}
|
||||||
}).getInstance(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
|
}).getInstance(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
|
||||||
|
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import java.io.Closeable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.Zone;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.location.functions.ZoneToEndpoint;
|
import org.jclouds.location.functions.RegionToEndpoint;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.ConsolesApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.ConsolesApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
|
||||||
|
@ -49,156 +49,413 @@ import com.google.common.base.Optional;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to the OpenStack Compute (Nova) API.
|
* Provides access to the OpenStack Compute (Nova) v2 API.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface NovaApi extends Closeable {
|
public interface NovaApi extends Closeable {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the Zone codes configured
|
* @return the Region codes configured
|
||||||
*/
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Zone
|
@Region
|
||||||
Set<String> getConfiguredZones();
|
Set<String> getConfiguredRegions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Server features.
|
* Provides access to Server features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
ServerApi getServerApiForZone(
|
ServerApi getServerApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Flavor features.
|
* Provides access to Flavor features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
FlavorApi getFlavorApiForZone(
|
FlavorApi getFlavorApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Extension features.
|
* Provides access to Extension features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
ExtensionApi getExtensionApiForZone(
|
ExtensionApi getExtensionApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Image features.
|
* Provides access to Image features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
ImageApi getImageApiForZone(
|
ImageApi getImageApi(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to availability zone features
|
* Provides access to Availability Zone 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
|
@Delegate
|
||||||
Optional<? extends AvailabilityZoneApi> getAvailabilityZoneApi(
|
Optional<? extends AvailabilityZoneApi> getAvailabilityZoneApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Floating IP features.
|
* Provides access to Floating IP 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
|
@Delegate
|
||||||
Optional<? extends FloatingIPApi> getFloatingIPExtensionForZone(
|
Optional<? extends FloatingIPApi> getFloatingIPApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Security Group features.
|
* Provides access to Security Group 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
|
@Delegate
|
||||||
Optional<? extends SecurityGroupApi> getSecurityGroupExtensionForZone(
|
Optional<? extends SecurityGroupApi> getSecurityGroupApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Key Pair features.
|
* Provides access to Key Pair 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
|
@Delegate
|
||||||
Optional<? extends KeyPairApi> getKeyPairExtensionForZone(
|
Optional<? extends KeyPairApi> getKeyPairApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Host Administration features.
|
* Provides access to Host Administration 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
|
@Delegate
|
||||||
Optional<? extends HostAdministrationApi> getHostAdministrationExtensionForZone(
|
Optional<? extends HostAdministrationApi> getHostAdministrationApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Simple Tenant Usage features.
|
* Provides access to Simple Tenant Usage 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
|
@Delegate
|
||||||
Optional<? extends SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
|
Optional<? extends SimpleTenantUsageApi> getSimpleTenantUsageApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Virtual Interface features.
|
* Provides access to Virtual Interface 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
|
@Delegate
|
||||||
Optional<? extends VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
|
Optional<? extends VirtualInterfaceApi> getVirtualInterfaceApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Server Extra Data features.
|
* Provides access to Server Extra Data 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
|
@Delegate
|
||||||
Optional<? extends ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
|
Optional<? extends ServerWithSecurityGroupsApi> getServerWithSecurityGroupsApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Server Admin Actions features.
|
* Provides access to Server Admin Actions 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
|
@Delegate
|
||||||
Optional<? extends ServerAdminApi> getServerAdminExtensionForZone(
|
Optional<? extends ServerAdminApi> getServerAdminApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Aggregate features.
|
* Provides access to Aggregate 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
|
@Delegate
|
||||||
Optional<? extends HostAggregateApi> getHostAggregateExtensionForZone(
|
Optional<? extends HostAggregateApi> getHostAggregateApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Flavor extra specs features.
|
* Provides access to Flavor extra specs 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
|
@Delegate
|
||||||
Optional<? extends FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
|
Optional<? extends FlavorExtraSpecsApi> getFlavorExtraSpecsApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Quota features.
|
* Provides access to Quota 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
|
@Delegate
|
||||||
Optional<? extends QuotaApi> getQuotaExtensionForZone(
|
Optional<? extends QuotaApi> getQuotaApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Volume features.
|
* Provides access to Volume 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
|
@Delegate
|
||||||
Optional<? extends VolumeApi> getVolumeExtensionForZone(
|
Optional<? extends VolumeApi> getVolumeApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Volume Attachment features.
|
* Provides access to Volume Attachment 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
|
@Delegate
|
||||||
Optional<? extends VolumeAttachmentApi> getVolumeAttachmentExtensionForZone(
|
Optional<? extends VolumeAttachmentApi> getVolumeAttachmentApi(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Volume Type features.
|
* Provides access to Volume Type 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
|
@Delegate
|
||||||
|
Optional<? extends VolumeTypeApi> getVolumeTypeApi(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Console 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 ConsolesApi> getConsolesApi(
|
||||||
|
@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
|
||||||
|
@Region
|
||||||
|
Set<String> getConfiguredZones();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Server features.
|
||||||
|
* @deprecated Please use {@link #getServerApi(String)} as this method will be removed in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
ServerApi getServerApiForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Flavor features.
|
||||||
|
* @deprecated Please use {@link #getFlavorApi(String)} as this method will be removed in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
FlavorApi getFlavorApiForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Extension features.
|
||||||
|
* @deprecated Please use {@link #getExtensionApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
ExtensionApi getExtensionApiForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Image features.
|
||||||
|
* @deprecated Please use {@link #getImageApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
ImageApi getImageApiForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Floating IP features.
|
||||||
|
* @deprecated Please use {@link #getFloatingIPApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends FloatingIPApi> getFloatingIPExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Security Group features.
|
||||||
|
* @deprecated Please use {@link #getSecurityGroupApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends SecurityGroupApi> getSecurityGroupExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Key Pair features.
|
||||||
|
* @deprecated Please use {@link #getKeyPairApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends KeyPairApi> getKeyPairExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Host Administration features.
|
||||||
|
* @deprecated Please use {@link #getHostAdministrationApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends HostAdministrationApi> getHostAdministrationExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Simple Tenant Usage features.
|
||||||
|
* @deprecated Please use {@link #getSimpleTenantUsageApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Virtual Interface features.
|
||||||
|
* @deprecated Please use {@link #getVirtualInterfaceApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Server Extra Data features.
|
||||||
|
* @deprecated Please use {@link #getServerWithSecurityGroupsApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Server Admin Actions features.
|
||||||
|
* @deprecated Please use {@link #getServerAdminApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends ServerAdminApi> getServerAdminExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Aggregate features.
|
||||||
|
* @deprecated Please use {@link #getHostAggregateApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends HostAggregateApi> getHostAggregateExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Flavor extra specs features.
|
||||||
|
* @deprecated Please use {@link #getFlavorExtraSpecsApi(String)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Quota features.
|
||||||
|
* @deprecated Please use {@link #getQuotaApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends QuotaApi> getQuotaExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Volume features.
|
||||||
|
* @deprecated Please use {@link #getVolumeApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends VolumeApi> getVolumeExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Volume Attachment features.
|
||||||
|
* @deprecated Please use {@link #getVolumeAttachmentApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
|
Optional<? extends VolumeAttachmentApi> getVolumeAttachmentExtensionForZone(
|
||||||
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Volume Type features.
|
||||||
|
* @deprecated Please use {@link #getVolumeTypeApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Delegate
|
||||||
Optional<? extends VolumeTypeApi> getVolumeTypeExtensionForZone(
|
Optional<? extends VolumeTypeApi> getVolumeTypeExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Console features.
|
* Provides synchronous access to Console features.
|
||||||
|
* @deprecated Please use {@link #getConsolesApi(String region)} as this method will be removed
|
||||||
|
* in jclouds 3.0.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<? extends ConsolesApi> getConsolesExtensionForZone(
|
Optional<? extends ConsolesApi> getConsolesExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String zone);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
|
import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.config.NovaHttpApiModule;
|
import org.jclouds.openstack.nova.v2_0.config.NovaHttpApiModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
|
import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
|
||||||
|
@ -92,7 +92,7 @@ public class NovaApiMetadata extends BaseHttpApiMetadata<NovaApi> {
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(AuthenticationApiModule.class)
|
.add(AuthenticationApiModule.class)
|
||||||
.add(KeystoneAuthenticationModule.class)
|
.add(KeystoneAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(RegionModule.class)
|
||||||
.add(NovaParserModule.class)
|
.add(NovaParserModule.class)
|
||||||
.add(NovaHttpApiModule.class)
|
.add(NovaHttpApiModule.class)
|
||||||
.add(NovaComputeServiceContextModule.class).build());
|
.add(NovaComputeServiceContextModule.class).build());
|
||||||
|
|
|
@ -61,8 +61,8 @@ import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates;
|
import org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates;
|
||||||
|
@ -81,9 +81,9 @@ import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NovaComputeService extends BaseComputeService {
|
public class NovaComputeService extends BaseComputeService {
|
||||||
protected final NovaApi novaApi;
|
protected final NovaApi novaApi;
|
||||||
protected final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap;
|
protected final LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupMap;
|
||||||
protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
|
protected final LoadingCache<RegionAndName, KeyPair> keyPairCache;
|
||||||
protected final Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId;
|
protected final Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByRegionId;
|
||||||
protected final GroupNamingConvention.Factory namingConvention;
|
protected final GroupNamingConvention.Factory namingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -102,9 +102,9 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
|
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
|
||||||
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, NovaApi novaApi,
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, NovaApi novaApi,
|
||||||
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap,
|
LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupMap,
|
||||||
LoadingCache<ZoneAndName, KeyPair> keyPairCache,
|
LoadingCache<RegionAndName, KeyPair> keyPairCache,
|
||||||
Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId,
|
Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByRegionId,
|
||||||
GroupNamingConvention.Factory namingConvention, Optional<ImageExtension> imageExtension,
|
GroupNamingConvention.Factory namingConvention, Optional<ImageExtension> imageExtension,
|
||||||
Optional<SecurityGroupExtension> securityGroupExtension) {
|
Optional<SecurityGroupExtension> securityGroupExtension) {
|
||||||
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
|
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
|
||||||
|
@ -115,53 +115,53 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
this.securityGroupMap = checkNotNull(securityGroupMap, "securityGroupMap");
|
this.securityGroupMap = checkNotNull(securityGroupMap, "securityGroupMap");
|
||||||
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
|
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
|
||||||
this.orphanedGroupsByZoneId = checkNotNull(orphanedGroupsByZoneId, "orphanedGroupsByZoneId");
|
this.orphanedGroupsByRegionId = checkNotNull(orphanedGroupsByRegionId, "orphanedGroupsByRegionId");
|
||||||
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
|
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
|
protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
|
||||||
Multimap<String, String> zoneToZoneAndGroupNames = orphanedGroupsByZoneId.apply(deadNodes);
|
Multimap<String, String> regionToRegionAndGroupNames = orphanedGroupsByRegionId.apply(deadNodes);
|
||||||
for (Map.Entry<String, Collection<String>> entry : zoneToZoneAndGroupNames.asMap().entrySet()) {
|
for (Map.Entry<String, Collection<String>> entry : regionToRegionAndGroupNames.asMap().entrySet()) {
|
||||||
cleanOrphanedGroupsInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
|
cleanOrphanedGroupsInRegion(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanOrphanedGroupsInZone(Set<String> groups, String zoneId) {
|
protected void cleanOrphanedGroupsInRegion(Set<String> groups, String regionId) {
|
||||||
cleanupOrphanedSecurityGroupsInZone(groups, zoneId);
|
cleanupOrphanedSecurityGroupsInRegion(groups, regionId);
|
||||||
cleanupOrphanedKeyPairsInZone(groups, zoneId);
|
cleanupOrphanedKeyPairsInRegion(groups, regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
|
private void cleanupOrphanedSecurityGroupsInRegion(Set<String> groups, String regionId) {
|
||||||
Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
|
Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupApi(regionId);
|
||||||
if (securityGroupApi.isPresent()) {
|
if (securityGroupApi.isPresent()) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
|
for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
|
||||||
SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
|
SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
|
||||||
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
|
RegionAndName regionAndName = RegionAndName.fromRegionAndName(regionId, securityGroup.getName());
|
||||||
logger.debug(">> deleting securityGroup(%s)", zoneAndName);
|
logger.debug(">> deleting securityGroup(%s)", regionAndName);
|
||||||
securityGroupApi.get().delete(securityGroup.getId());
|
securityGroupApi.get().delete(securityGroup.getId());
|
||||||
// TODO: test this clear happens
|
// TODO: test this clear happens
|
||||||
securityGroupMap.invalidate(zoneAndName);
|
securityGroupMap.invalidate(regionAndName);
|
||||||
logger.debug("<< deleted securityGroup(%s)", zoneAndName);
|
logger.debug("<< deleted securityGroup(%s)", regionAndName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
|
private void cleanupOrphanedKeyPairsInRegion(Set<String> groups, String regionId) {
|
||||||
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
|
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairApi(regionId);
|
||||||
if (keyPairApi.isPresent()) {
|
if (keyPairApi.isPresent()) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
|
for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
|
||||||
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
|
RegionAndName regionAndName = RegionAndName.fromRegionAndName(regionId, pair.getName());
|
||||||
logger.debug(">> deleting keypair(%s)", zoneAndName);
|
logger.debug(">> deleting keypair(%s)", regionAndName);
|
||||||
keyPairApi.get().delete(pair.getName());
|
keyPairApi.get().delete(pair.getName());
|
||||||
// TODO: test this clear happens
|
// TODO: test this clear happens
|
||||||
keyPairCache.invalidate(zoneAndName);
|
keyPairCache.invalidate(regionAndName);
|
||||||
logger.debug("<< deleted keypair(%s)", zoneAndName);
|
logger.debug("<< deleted keypair(%s)", regionAndName);
|
||||||
}
|
}
|
||||||
keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId,
|
keyPairCache.invalidate(RegionAndName.fromRegionAndName(regionId,
|
||||||
namingConvention.create().sharedNameForGroup(group)));
|
namingConvention.create().sharedNameForGroup(group)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,5 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
public NovaTemplateOptions templateOptions() {
|
public NovaTemplateOptions templateOptions() {
|
||||||
return NovaTemplateOptions.class.cast(super.templateOptions());
|
return NovaTemplateOptions.class.cast(super.templateOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,22 +34,23 @@ import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.location.Zone;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.RemoveFloatingIpFromNodeAndDeallocate;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.RemoveFloatingIpFromNodeAndDeallocate;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
||||||
|
import org.jclouds.openstack.nova.v2_0.compute.strategy.ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.RebootType;
|
import org.jclouds.openstack.nova.v2_0.domain.RebootType;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
|
import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.FlavorInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ImageInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
|
import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
|
||||||
import org.jclouds.openstack.nova.v2_0.predicates.ImagePredicates;
|
import org.jclouds.openstack.nova.v2_0.predicates.ImagePredicates;
|
||||||
|
|
||||||
|
@ -67,23 +68,23 @@ import com.google.common.collect.ImmutableSet.Builder;
|
||||||
* model to the computeService generic domain model.
|
* model to the computeService generic domain model.
|
||||||
*/
|
*/
|
||||||
public class NovaComputeServiceAdapter implements
|
public class NovaComputeServiceAdapter implements
|
||||||
ComputeServiceAdapter<ServerInZone, FlavorInZone, ImageInZone, Location> {
|
ComputeServiceAdapter<ServerInRegion, FlavorInRegion, ImageInRegion, Location> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected final NovaApi novaApi;
|
protected final NovaApi novaApi;
|
||||||
protected final Supplier<Set<String>> zoneIds;
|
protected final Supplier<Set<String>> regionIds;
|
||||||
protected final RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate;
|
protected final RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate;
|
||||||
protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
|
protected final LoadingCache<RegionAndName, KeyPair> keyPairCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NovaComputeServiceAdapter(NovaApi novaApi, @Zone Supplier<Set<String>> zoneIds,
|
public NovaComputeServiceAdapter(NovaApi novaApi, @Region Supplier<Set<String>> regionIds,
|
||||||
RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate,
|
RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate,
|
||||||
LoadingCache<ZoneAndName, KeyPair> keyPairCache) {
|
LoadingCache<RegionAndName, KeyPair> keyPairCache) {
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
this.zoneIds = checkNotNull(zoneIds, "zoneIds");
|
this.regionIds = checkNotNull(regionIds, "regionIds");
|
||||||
this.removeFloatingIpFromNodeAndDeallocate = checkNotNull(removeFloatingIpFromNodeAndDeallocate,
|
this.removeFloatingIpFromNodeAndDeallocate = checkNotNull(removeFloatingIpFromNodeAndDeallocate,
|
||||||
"removeFloatingIpFromNodeAndDeallocate");
|
"removeFloatingIpFromNodeAndDeallocate");
|
||||||
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
|
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
|
||||||
|
@ -95,7 +96,7 @@ public class NovaComputeServiceAdapter implements
|
||||||
* done so.
|
* done so.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NodeAndInitialCredentials<ServerInZone> createNodeWithGroupEncodedIntoName(String group, String name,
|
public NodeAndInitialCredentials<ServerInRegion> createNodeWithGroupEncodedIntoName(String group, String name,
|
||||||
Template template) {
|
Template template) {
|
||||||
|
|
||||||
LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder();
|
LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder();
|
||||||
|
@ -118,40 +119,40 @@ public class NovaComputeServiceAdapter implements
|
||||||
Optional<String> privateKey = Optional.absent();
|
Optional<String> privateKey = Optional.absent();
|
||||||
if (templateOptions.getKeyPairName() != null) {
|
if (templateOptions.getKeyPairName() != null) {
|
||||||
options.keyPairName(templateOptions.getKeyPairName());
|
options.keyPairName(templateOptions.getKeyPairName());
|
||||||
KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
|
KeyPair keyPair = keyPairCache.getIfPresent(RegionAndName.fromRegionAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
|
||||||
if (keyPair != null && keyPair.getPrivateKey() != null) {
|
if (keyPair != null && keyPair.getPrivateKey() != null) {
|
||||||
privateKey = Optional.of(keyPair.getPrivateKey());
|
privateKey = Optional.of(keyPair.getPrivateKey());
|
||||||
credentialsBuilder.privateKey(privateKey.get());
|
credentialsBuilder.privateKey(privateKey.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String zoneId = template.getLocation().getId();
|
String regionId = template.getLocation().getId();
|
||||||
String imageId = template.getImage().getProviderId();
|
String imageId = template.getImage().getProviderId();
|
||||||
String flavorId = template.getHardware().getProviderId();
|
String flavorId = template.getHardware().getProviderId();
|
||||||
|
|
||||||
logger.debug(">> creating new server zone(%s) name(%s) image(%s) flavor(%s) options(%s)", zoneId, name, imageId, flavorId, options);
|
logger.debug(">> creating new server region(%s) name(%s) image(%s) flavor(%s) options(%s)", regionId, name, imageId, flavorId, options);
|
||||||
ServerCreated lightweightServer = novaApi.getServerApiForZone(zoneId).create(name, imageId, flavorId, options);
|
ServerCreated lightweightServer = novaApi.getServerApi(regionId).create(name, imageId, flavorId, options);
|
||||||
Server server = novaApi.getServerApiForZone(zoneId).get(lightweightServer.getId());
|
Server server = novaApi.getServerApi(regionId).get(lightweightServer.getId());
|
||||||
|
|
||||||
logger.trace("<< server(%s)", server.getId());
|
logger.trace("<< server(%s)", server.getId());
|
||||||
|
|
||||||
ServerInZone serverInZone = new ServerInZone(server, zoneId);
|
ServerInRegion serverInRegion = new ServerInRegion(server, regionId);
|
||||||
if (!privateKey.isPresent() && lightweightServer.getAdminPass().isPresent())
|
if (!privateKey.isPresent() && lightweightServer.getAdminPass().isPresent())
|
||||||
credentialsBuilder.password(lightweightServer.getAdminPass().get());
|
credentialsBuilder.password(lightweightServer.getAdminPass().get());
|
||||||
return new NodeAndInitialCredentials<ServerInZone>(serverInZone, serverInZone.slashEncode(), credentialsBuilder
|
return new NodeAndInitialCredentials<ServerInRegion>(serverInRegion, serverInRegion.slashEncode(), credentialsBuilder
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<FlavorInZone> listHardwareProfiles() {
|
public Iterable<FlavorInRegion> listHardwareProfiles() {
|
||||||
Builder<FlavorInZone> builder = ImmutableSet.builder();
|
Builder<FlavorInRegion> builder = ImmutableSet.builder();
|
||||||
for (final String zoneId : zoneIds.get()) {
|
for (final String regionId : regionIds.get()) {
|
||||||
builder.addAll(transform(novaApi.getFlavorApiForZone(zoneId).listInDetail().concat(),
|
builder.addAll(transform(novaApi.getFlavorApi(regionId).listInDetail().concat(),
|
||||||
new Function<Flavor, FlavorInZone>() {
|
new Function<Flavor, FlavorInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FlavorInZone apply(Flavor arg0) {
|
public FlavorInRegion apply(Flavor arg0) {
|
||||||
return new FlavorInZone(arg0, zoneId);
|
return new FlavorInRegion(arg0, regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
@ -160,19 +161,19 @@ public class NovaComputeServiceAdapter implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ImageInZone> listImages() {
|
public Iterable<ImageInRegion> listImages() {
|
||||||
Builder<ImageInZone> builder = ImmutableSet.builder();
|
Builder<ImageInRegion> builder = ImmutableSet.builder();
|
||||||
Set<String> zones = zoneIds.get();
|
Set<String> regions = regionIds.get();
|
||||||
checkState(zones.size() > 0, "no zones found in supplier %s", zoneIds);
|
checkState(regions.size() > 0, "no regions found in supplier %s", regionIds);
|
||||||
for (final String zoneId : zones) {
|
for (final String regionId : regions) {
|
||||||
Set<? extends Image> images = novaApi.getImageApiForZone(zoneId).listInDetail().concat().toSet();
|
Set<? extends Image> images = novaApi.getImageApi(regionId).listInDetail().concat().toSet();
|
||||||
if (images.size() == 0) {
|
if (images.size() == 0) {
|
||||||
logger.debug("no images found in zone %s", zoneId);
|
logger.debug("no images found in region %s", regionId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Iterable<? extends Image> active = filter(images, ImagePredicates.statusEquals(Image.Status.ACTIVE));
|
Iterable<? extends Image> active = filter(images, ImagePredicates.statusEquals(Image.Status.ACTIVE));
|
||||||
if (images.size() == 0) {
|
if (images.size() == 0) {
|
||||||
logger.debug("no images with status active in zone %s; non-active: %s", zoneId,
|
logger.debug("no images with status active in region %s; non-active: %s", regionId,
|
||||||
transform(active, new Function<Image, String>() {
|
transform(active, new Function<Image, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -184,11 +185,11 @@ public class NovaComputeServiceAdapter implements
|
||||||
}));
|
}));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
builder.addAll(transform(active, new Function<Image, ImageInZone>() {
|
builder.addAll(transform(active, new Function<Image, ImageInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageInZone apply(Image arg0) {
|
public ImageInRegion apply(Image arg0) {
|
||||||
return new ImageInZone(arg0, zoneId);
|
return new ImageInRegion(arg0, regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
@ -197,15 +198,15 @@ public class NovaComputeServiceAdapter implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ServerInZone> listNodes() {
|
public Iterable<ServerInRegion> listNodes() {
|
||||||
Builder<ServerInZone> builder = ImmutableSet.builder();
|
Builder<ServerInRegion> builder = ImmutableSet.builder();
|
||||||
for (final String zoneId : zoneIds.get()) {
|
for (final String regionId : regionIds.get()) {
|
||||||
builder.addAll(novaApi.getServerApiForZone(zoneId).listInDetail().concat()
|
builder.addAll(novaApi.getServerApi(regionId).listInDetail().concat()
|
||||||
.transform(new Function<Server, ServerInZone>() {
|
.transform(new Function<Server, ServerInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerInZone apply(Server arg0) {
|
public ServerInRegion apply(Server arg0) {
|
||||||
return new ServerInZone(arg0, zoneId);
|
return new ServerInRegion(arg0, regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
@ -214,11 +215,11 @@ public class NovaComputeServiceAdapter implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ServerInZone> listNodesByIds(final Iterable<String> ids) {
|
public Iterable<ServerInRegion> listNodesByIds(final Iterable<String> ids) {
|
||||||
return filter(listNodes(), new Predicate<ServerInZone>() {
|
return filter(listNodes(), new Predicate<ServerInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ServerInZone server) {
|
public boolean apply(ServerInRegion server) {
|
||||||
return contains(ids, server.slashEncode());
|
return contains(ids, server.slashEncode());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -231,43 +232,43 @@ public class NovaComputeServiceAdapter implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerInZone getNode(String id) {
|
public ServerInRegion getNode(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
|
Server server = novaApi.getServerApi(regionAndId.getRegion()).get(regionAndId.getId());
|
||||||
return server == null ? null : new ServerInZone(server, zoneAndId.getZone());
|
return server == null ? null : new ServerInRegion(server, regionAndId.getRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageInZone getImage(String id) {
|
public ImageInRegion getImage(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
Image image = novaApi.getImageApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
|
Image image = novaApi.getImageApi(regionAndId.getRegion()).get(regionAndId.getId());
|
||||||
return image == null ? null : new ImageInZone(image, zoneAndId.getZone());
|
return image == null ? null : new ImageInRegion(image, regionAndId.getRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyNode(String id) {
|
public void destroyNode(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
if (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
|
if (novaApi.getFloatingIPApi(regionAndId.getRegion()).isPresent()) {
|
||||||
try {
|
try {
|
||||||
removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
|
removeFloatingIpFromNodeAndDeallocate.apply(regionAndId);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
logger.warn(e, "<< error removing and deallocating ip from node(%s): %s", id, e.getMessage());
|
logger.warn(e, "<< error removing and deallocating ip from node(%s): %s", id, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
|
novaApi.getServerApi(regionAndId.getRegion()).delete(regionAndId.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rebootNode(String id) {
|
public void rebootNode(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
novaApi.getServerApiForZone(zoneAndId.getZone()).reboot(zoneAndId.getId(), RebootType.HARD);
|
novaApi.getServerApi(regionAndId.getRegion()).reboot(regionAndId.getId(), RebootType.HARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resumeNode(String id) {
|
public void resumeNode(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) {
|
if (novaApi.getServerAdminApi(regionAndId.getRegion()).isPresent()) {
|
||||||
novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().resume(zoneAndId.getId());
|
novaApi.getServerAdminApi(regionAndId.getRegion()).get().resume(regionAndId.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension");
|
throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension");
|
||||||
}
|
}
|
||||||
|
@ -275,9 +276,9 @@ public class NovaComputeServiceAdapter implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void suspendNode(String id) {
|
public void suspendNode(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) {
|
if (novaApi.getServerAdminApi(regionAndId.getRegion()).isPresent()) {
|
||||||
novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().suspend(zoneAndId.getId());
|
novaApi.getServerAdminApi(regionAndId.getRegion()).get().suspend(regionAndId.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension");
|
throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension");
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,14 +52,14 @@ import org.jclouds.openstack.nova.v2_0.compute.NovaComputeServiceAdapter;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaImageExtension;
|
import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaImageExtension;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaSecurityGroupExtension;
|
import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaSecurityGroupExtension;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.CreateSecurityGroupIfNeeded;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.CreateSecurityGroupIfNeeded;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.FlavorInZoneToHardware;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.FlavorInRegionToHardware;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.ImageInZoneToImage;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.ImageInRegionToImage;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.ImageToOperatingSystem;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.ImageToOperatingSystem;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupInZoneToSecurityGroup;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupInRegionToSecurityGroup;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupToSecurityGroup;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupToSecurityGroup;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.OrphanedGroupsByZoneId;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.OrphanedGroupsByRegionId;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.SecurityGroupRuleToIpPermission;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.SecurityGroupRuleToIpPermission;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.functions.ServerInZoneToNodeMetadata;
|
import org.jclouds.openstack.nova.v2_0.compute.functions.ServerInRegionToNodeMetadata;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.loaders.CreateUniqueKeyPair;
|
import org.jclouds.openstack.nova.v2_0.compute.loaders.CreateUniqueKeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.loaders.FindSecurityGroupOrCreate;
|
import org.jclouds.openstack.nova.v2_0.compute.loaders.FindSecurityGroupOrCreate;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.loaders.LoadFloatingIpsForInstance;
|
import org.jclouds.openstack.nova.v2_0.compute.loaders.LoadFloatingIpsForInstance;
|
||||||
|
@ -69,13 +69,13 @@ import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.FlavorInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ImageInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
|
||||||
import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
|
import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -100,19 +100,19 @@ import com.google.inject.name.Names;
|
||||||
* Module for building a compute service context for Nova
|
* Module for building a compute service context for Nova
|
||||||
*/
|
*/
|
||||||
public class NovaComputeServiceContextModule extends
|
public class NovaComputeServiceContextModule extends
|
||||||
ComputeServiceAdapterContextModule<ServerInZone, FlavorInZone, ImageInZone, Location> {
|
ComputeServiceAdapterContextModule<ServerInRegion, FlavorInRegion, ImageInRegion, Location> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
bind(new TypeLiteral<ComputeServiceAdapter<ServerInZone, FlavorInZone, ImageInZone, Location>>() {
|
bind(new TypeLiteral<ComputeServiceAdapter<ServerInRegion, FlavorInRegion, ImageInRegion, Location>>() {
|
||||||
}).to(NovaComputeServiceAdapter.class);
|
}).to(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
bind(ComputeService.class).to(NovaComputeService.class);
|
bind(ComputeService.class).to(NovaComputeService.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<ServerInZone, NodeMetadata>>() {
|
bind(new TypeLiteral<Function<ServerInRegion, NodeMetadata>>() {
|
||||||
}).to(ServerInZoneToNodeMetadata.class);
|
}).to(ServerInRegionToNodeMetadata.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<SecurityGroupRule, IpPermission>>() {
|
bind(new TypeLiteral<Function<SecurityGroupRule, IpPermission>>() {
|
||||||
}).to(SecurityGroupRuleToIpPermission.class);
|
}).to(SecurityGroupRuleToIpPermission.class);
|
||||||
|
@ -120,19 +120,19 @@ public class NovaComputeServiceContextModule extends
|
||||||
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup>>() {
|
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup>>() {
|
||||||
}).to(NovaSecurityGroupToSecurityGroup.class);
|
}).to(NovaSecurityGroupToSecurityGroup.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<SecurityGroupInZone, SecurityGroup>>() {
|
bind(new TypeLiteral<Function<SecurityGroupInRegion, SecurityGroup>>() {
|
||||||
}).to(NovaSecurityGroupInZoneToSecurityGroup.class);
|
}).to(NovaSecurityGroupInRegionToSecurityGroup.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<Set<? extends NodeMetadata>, Multimap<String, String>>>() {
|
bind(new TypeLiteral<Function<Set<? extends NodeMetadata>, Multimap<String, String>>>() {
|
||||||
}).to(OrphanedGroupsByZoneId.class);
|
}).to(OrphanedGroupsByRegionId.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<ImageInZone, Image>>() {
|
bind(new TypeLiteral<Function<ImageInRegion, Image>>() {
|
||||||
}).to(ImageInZoneToImage.class);
|
}).to(ImageInRegionToImage.class);
|
||||||
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem>>() {
|
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem>>() {
|
||||||
}).to(ImageToOperatingSystem.class);
|
}).to(ImageToOperatingSystem.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<FlavorInZone, Hardware>>() {
|
bind(new TypeLiteral<Function<FlavorInRegion, Hardware>>() {
|
||||||
}).to(FlavorInZoneToHardware.class);
|
}).to(FlavorInRegionToHardware.class);
|
||||||
|
|
||||||
// we aren't converting location from a provider-specific type
|
// we aren't converting location from a provider-specific type
|
||||||
bind(new TypeLiteral<Function<Location, Location>>() {
|
bind(new TypeLiteral<Function<Location, Location>>() {
|
||||||
|
@ -140,19 +140,19 @@ public class NovaComputeServiceContextModule extends
|
||||||
|
|
||||||
bind(TemplateOptions.class).to(NovaTemplateOptions.class);
|
bind(TemplateOptions.class).to(NovaTemplateOptions.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>>>() {
|
bind(new TypeLiteral<CacheLoader<RegionAndId, Iterable<? extends FloatingIP>>>() {
|
||||||
}).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
|
}).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>>() {
|
bind(new TypeLiteral<Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion>>() {
|
||||||
}).to(CreateSecurityGroupIfNeeded.class);
|
}).to(CreateSecurityGroupIfNeeded.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<CacheLoader<ZoneAndName, SecurityGroupInZone>>() {
|
bind(new TypeLiteral<CacheLoader<RegionAndName, SecurityGroupInRegion>>() {
|
||||||
}).to(FindSecurityGroupOrCreate.class);
|
}).to(FindSecurityGroupOrCreate.class);
|
||||||
|
|
||||||
bind(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to(
|
bind(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to(
|
||||||
ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.class);
|
ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<CacheLoader<ZoneAndName, KeyPair>>() {
|
bind(new TypeLiteral<CacheLoader<RegionAndName, KeyPair>>() {
|
||||||
}).to(CreateUniqueKeyPair.class);
|
}).to(CreateUniqueKeyPair.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<ImageExtension>() {
|
bind(new TypeLiteral<ImageExtension>() {
|
||||||
|
@ -174,15 +174,15 @@ public class NovaComputeServiceContextModule extends
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("FLOATINGIP")
|
@Named("FLOATINGIP")
|
||||||
protected LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
|
protected LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
|
||||||
@Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> in) {
|
@Named("FLOATINGIP") CacheLoader<RegionAndId, Iterable<? extends FloatingIP>> in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap(
|
protected LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupMap(
|
||||||
CacheLoader<ZoneAndName, SecurityGroupInZone> in) {
|
CacheLoader<RegionAndName, SecurityGroupInRegion> in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public class NovaComputeServiceContextModule extends
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("SECURITYGROUP_PRESENT")
|
@Named("SECURITYGROUP_PRESENT")
|
||||||
protected Predicate<AtomicReference<ZoneAndName>> securityGroupEventualConsistencyDelay(
|
protected Predicate<AtomicReference<RegionAndName>> securityGroupEventualConsistencyDelay(
|
||||||
FindSecurityGroupWithNameAndReturnTrue in,
|
FindSecurityGroupWithNameAndReturnTrue in,
|
||||||
@Named(TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
|
@Named(TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
|
||||||
return retry(in, msDelay, 100l, MILLISECONDS);
|
return retry(in, msDelay, 100l, MILLISECONDS);
|
||||||
|
@ -203,8 +203,8 @@ public class NovaComputeServiceContextModule extends
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected LoadingCache<ZoneAndName, KeyPair> keyPairMap(
|
protected LoadingCache<RegionAndName, KeyPair> keyPairMap(
|
||||||
CacheLoader<ZoneAndName, KeyPair> in) {
|
CacheLoader<RegionAndName, KeyPair> in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -82,10 +82,10 @@ public class NovaImageExtension implements ImageExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
|
public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
|
Server server = novaApi.getServerApi(regionAndId.getRegion()).get(regionAndId.getId());
|
||||||
if (server == null)
|
if (server == null)
|
||||||
throw new NoSuchElementException("Cannot find server with id: " + zoneAndId);
|
throw new NoSuchElementException("Cannot find server with id: " + regionAndId);
|
||||||
CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
|
CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
@ -95,19 +95,19 @@ public class NovaImageExtension implements ImageExtension {
|
||||||
checkState(template instanceof CloneImageTemplate,
|
checkState(template instanceof CloneImageTemplate,
|
||||||
" openstack-nova only supports creating images through cloning.");
|
" openstack-nova only supports creating images through cloning.");
|
||||||
CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
|
CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
|
||||||
ZoneAndId sourceImageZoneAndId = ZoneAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
|
RegionAndId sourceImageRegionAndId = RegionAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
|
||||||
|
|
||||||
String newImageId = novaApi.getServerApiForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
|
String newImageId = novaApi.getServerApi(sourceImageRegionAndId.getRegion()).createImageFromServer(
|
||||||
cloneTemplate.getName(), sourceImageZoneAndId.getId());
|
cloneTemplate.getName(), sourceImageRegionAndId.getId());
|
||||||
|
|
||||||
final ZoneAndId targetImageZoneAndId = ZoneAndId.fromZoneAndId(sourceImageZoneAndId.getZone(), newImageId);
|
final RegionAndId targetImageRegionAndId = RegionAndId.fromRegionAndId(sourceImageRegionAndId.getRegion(), newImageId);
|
||||||
|
|
||||||
logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
|
logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
|
||||||
|
|
||||||
final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
|
final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
|
||||||
.location(find(locations.get(), idEquals(targetImageZoneAndId.getZone())))
|
.location(find(locations.get(), idEquals(targetImageRegionAndId.getRegion())))
|
||||||
.id(targetImageZoneAndId.slashEncode())
|
.id(targetImageRegionAndId.slashEncode())
|
||||||
.providerId(targetImageZoneAndId.getId())
|
.providerId(targetImageRegionAndId.getId())
|
||||||
.description(cloneTemplate.getName())
|
.description(cloneTemplate.getName())
|
||||||
.operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
|
.operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
|
||||||
.status(Image.Status.PENDING).build());
|
.status(Image.Status.PENDING).build());
|
||||||
|
@ -125,9 +125,9 @@ public class NovaImageExtension implements ImageExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteImage(String id) {
|
public boolean deleteImage(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
try {
|
try {
|
||||||
this.novaApi.getImageApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
|
this.novaApi.getImageApi(regionAndId.getRegion()).delete(regionAndId.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,17 +40,17 @@ import org.jclouds.compute.domain.SecurityGroup;
|
||||||
import org.jclouds.compute.extensions.SecurityGroupExtension;
|
import org.jclouds.compute.extensions.SecurityGroupExtension;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.location.Zone;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.net.domain.IpPermission;
|
import org.jclouds.net.domain.IpPermission;
|
||||||
import org.jclouds.net.domain.IpProtocol;
|
import org.jclouds.net.domain.IpProtocol;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Ingress;
|
import org.jclouds.openstack.nova.v2_0.domain.Ingress;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
|
import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
|
||||||
|
|
||||||
|
@ -70,22 +70,22 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
|
||||||
protected final NovaApi api;
|
protected final NovaApi api;
|
||||||
protected final ListeningExecutorService userExecutor;
|
protected final ListeningExecutorService userExecutor;
|
||||||
protected final Supplier<Set<String>> zoneIds;
|
protected final Supplier<Set<String>> regionIds;
|
||||||
protected final Function<SecurityGroupInZone, SecurityGroup> groupConverter;
|
protected final Function<SecurityGroupInRegion, SecurityGroup> groupConverter;
|
||||||
protected final LoadingCache<ZoneAndName, SecurityGroupInZone> groupCreator;
|
protected final LoadingCache<RegionAndName, SecurityGroupInRegion> groupCreator;
|
||||||
protected final GroupNamingConvention.Factory namingConvention;
|
protected final GroupNamingConvention.Factory namingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NovaSecurityGroupExtension(NovaApi api,
|
public NovaSecurityGroupExtension(NovaApi api,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
||||||
@Zone Supplier<Set<String>> zoneIds,
|
@Region Supplier<Set<String>> regionIds,
|
||||||
Function<SecurityGroupInZone, SecurityGroup> groupConverter,
|
Function<SecurityGroupInRegion, SecurityGroup> groupConverter,
|
||||||
LoadingCache<ZoneAndName, SecurityGroupInZone> groupCreator,
|
LoadingCache<RegionAndName, SecurityGroupInRegion> groupCreator,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
|
|
||||||
this.api = checkNotNull(api, "api");
|
this.api = checkNotNull(api, "api");
|
||||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||||
this.zoneIds = checkNotNull(zoneIds, "zoneIds");
|
this.regionIds = checkNotNull(regionIds, "regionIds");
|
||||||
this.groupConverter = checkNotNull(groupConverter, "groupConverter");
|
this.groupConverter = checkNotNull(groupConverter, "groupConverter");
|
||||||
this.groupCreator = checkNotNull(groupCreator, "groupCreator");
|
this.groupCreator = checkNotNull(groupCreator, "groupCreator");
|
||||||
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
|
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
|
||||||
|
@ -93,7 +93,7 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<SecurityGroup> listSecurityGroups() {
|
public Set<SecurityGroup> listSecurityGroups() {
|
||||||
Iterable<? extends SecurityGroupInZone> rawGroups = pollSecurityGroups();
|
Iterable<? extends SecurityGroupInRegion> rawGroups = pollSecurityGroups();
|
||||||
Iterable<SecurityGroup> groups = transform(filter(rawGroups, notNull()),
|
Iterable<SecurityGroup> groups = transform(filter(rawGroups, notNull()),
|
||||||
groupConverter);
|
groupConverter);
|
||||||
return ImmutableSet.copyOf(groups);
|
return ImmutableSet.copyOf(groups);
|
||||||
|
@ -102,15 +102,15 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<SecurityGroup> listSecurityGroupsInLocation(final Location location) {
|
public Set<SecurityGroup> listSecurityGroupsInLocation(final Location location) {
|
||||||
String zone = location.getId();
|
String region = location.getId();
|
||||||
if (zone == null) {
|
if (region == null) {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of();
|
||||||
}
|
}
|
||||||
return listSecurityGroupsInLocation(zone);
|
return listSecurityGroupsInLocation(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<SecurityGroup> listSecurityGroupsInLocation(String zone) {
|
public Set<SecurityGroup> listSecurityGroupsInLocation(String region) {
|
||||||
Iterable<? extends SecurityGroupInZone> rawGroups = pollSecurityGroupsByZone(zone);
|
Iterable<? extends SecurityGroupInRegion> rawGroups = pollSecurityGroupsByRegion(region);
|
||||||
Iterable<SecurityGroup> groups = transform(filter(rawGroups, notNull()),
|
Iterable<SecurityGroup> groups = transform(filter(rawGroups, notNull()),
|
||||||
groupConverter);
|
groupConverter);
|
||||||
return ImmutableSet.copyOf(groups);
|
return ImmutableSet.copyOf(groups);
|
||||||
|
@ -118,12 +118,12 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<SecurityGroup> listSecurityGroupsForNode(String id) {
|
public Set<SecurityGroup> listSecurityGroupsForNode(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(checkNotNull(id, "id"));
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(checkNotNull(id, "id"));
|
||||||
String zone = zoneAndId.getZone();
|
String region = regionAndId.getRegion();
|
||||||
String instanceId = zoneAndId.getId();
|
String instanceId = regionAndId.getId();
|
||||||
|
|
||||||
Optional<? extends ServerWithSecurityGroupsApi> serverApi = api.getServerWithSecurityGroupsExtensionForZone(zone);
|
Optional<? extends ServerWithSecurityGroupsApi> serverApi = api.getServerWithSecurityGroupsApi(region);
|
||||||
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
|
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);
|
||||||
|
|
||||||
if (!serverApi.isPresent() || !sgApi.isPresent()) {
|
if (!serverApi.isPresent() || !sgApi.isPresent()) {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of();
|
||||||
|
@ -135,54 +135,54 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> groupNames = instance.getSecurityGroupNames();
|
Set<String> groupNames = instance.getSecurityGroupNames();
|
||||||
Set<? extends SecurityGroupInZone> rawGroups =
|
Set<? extends SecurityGroupInRegion> rawGroups =
|
||||||
sgApi.get().list().filter(nameIn(groupNames)).transform(groupToGroupInZone(zone)).toSet();
|
sgApi.get().list().filter(nameIn(groupNames)).transform(groupToGroupInRegion(region)).toSet();
|
||||||
|
|
||||||
return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter));
|
return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroup getSecurityGroupById(String id) {
|
public SecurityGroup getSecurityGroupById(String id) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(checkNotNull(id, "id"));
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(checkNotNull(id, "id"));
|
||||||
String zone = zoneAndId.getZone();
|
String region = regionAndId.getRegion();
|
||||||
String groupId = zoneAndId.getId();
|
String groupId = regionAndId.getId();
|
||||||
|
|
||||||
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
|
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);
|
||||||
|
|
||||||
if (!sgApi.isPresent()) {
|
if (!sgApi.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityGroupInZone rawGroup = new SecurityGroupInZone(sgApi.get().get(groupId), zone);
|
SecurityGroupInRegion rawGroup = new SecurityGroupInRegion(sgApi.get().get(groupId), region);
|
||||||
|
|
||||||
return groupConverter.apply(rawGroup);
|
return groupConverter.apply(rawGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroup createSecurityGroup(String name, Location location) {
|
public SecurityGroup createSecurityGroup(String name, Location location) {
|
||||||
String zone = location.getId();
|
String region = location.getId();
|
||||||
if (zone == null) {
|
if (region == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return createSecurityGroup(name, zone);
|
return createSecurityGroup(name, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecurityGroup createSecurityGroup(String name, String zone) {
|
public SecurityGroup createSecurityGroup(String name, String region) {
|
||||||
String markerGroup = namingConvention.create().sharedNameForGroup(name);
|
String markerGroup = namingConvention.create().sharedNameForGroup(name);
|
||||||
ZoneSecurityGroupNameAndPorts zoneAndName = new ZoneSecurityGroupNameAndPorts(zone, markerGroup, ImmutableSet.<Integer> of());
|
RegionSecurityGroupNameAndPorts regionAndName = new RegionSecurityGroupNameAndPorts(region, markerGroup, ImmutableSet.<Integer> of());
|
||||||
|
|
||||||
SecurityGroupInZone rawGroup = groupCreator.getUnchecked(zoneAndName);
|
SecurityGroupInRegion rawGroup = groupCreator.getUnchecked(regionAndName);
|
||||||
return groupConverter.apply(rawGroup);
|
return groupConverter.apply(rawGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeSecurityGroup(String id) {
|
public boolean removeSecurityGroup(String id) {
|
||||||
checkNotNull(id, "id");
|
checkNotNull(id, "id");
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
|
||||||
String zone = zoneAndId.getZone();
|
String region = regionAndId.getRegion();
|
||||||
String groupId = zoneAndId.getId();
|
String groupId = regionAndId.getId();
|
||||||
|
|
||||||
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
|
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);
|
||||||
|
|
||||||
if (!sgApi.isPresent()) {
|
if (!sgApi.isPresent()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -194,16 +194,16 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
|
||||||
sgApi.get().delete(groupId);
|
sgApi.get().delete(groupId);
|
||||||
// TODO: test this clear happens
|
// TODO: test this clear happens
|
||||||
groupCreator.invalidate(new ZoneSecurityGroupNameAndPorts(zone, groupId, ImmutableSet.<Integer> of()));
|
groupCreator.invalidate(new RegionSecurityGroupNameAndPorts(region, groupId, ImmutableSet.<Integer> of()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
|
public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
|
||||||
String zone = group.getLocation().getId();
|
String region = group.getLocation().getId();
|
||||||
ZoneAndId groupZoneAndId = ZoneAndId.fromSlashEncoded(group.getId());
|
RegionAndId groupRegionAndId = RegionAndId.fromSlashEncoded(group.getId());
|
||||||
String id = groupZoneAndId.getId();
|
String id = groupRegionAndId.getId();
|
||||||
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
|
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);
|
||||||
|
|
||||||
if (!sgApi.isPresent()) {
|
if (!sgApi.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -222,9 +222,9 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipPermission.getGroupIds().size() > 0) {
|
if (ipPermission.getGroupIds().size() > 0) {
|
||||||
for (String zoneAndGroupRaw : ipPermission.getGroupIds()) {
|
for (String regionAndGroupRaw : ipPermission.getGroupIds()) {
|
||||||
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(zoneAndGroupRaw);
|
RegionAndId regionAndId = RegionAndId.fromSlashEncoded(regionAndGroupRaw);
|
||||||
String groupId = zoneAndId.getId();
|
String groupId = regionAndId.getId();
|
||||||
sgApi.get().createRuleAllowingSecurityGroupId(id,
|
sgApi.get().createRuleAllowingSecurityGroupId(id,
|
||||||
Ingress.builder()
|
Ingress.builder()
|
||||||
.ipProtocol(ipPermission.getIpProtocol())
|
.ipProtocol(ipPermission.getIpProtocol())
|
||||||
|
@ -235,7 +235,7 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getSecurityGroupById(ZoneAndId.fromZoneAndId(zone, id).slashEncode());
|
return getSecurityGroupById(RegionAndId.fromRegionAndId(region, id).slashEncode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -256,11 +256,11 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
|
public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
|
||||||
String zone = group.getLocation().getId();
|
String region = group.getLocation().getId();
|
||||||
ZoneAndId groupZoneAndId = ZoneAndId.fromSlashEncoded(group.getId());
|
RegionAndId groupRegionAndId = RegionAndId.fromSlashEncoded(group.getId());
|
||||||
String id = groupZoneAndId.getId();
|
String id = groupRegionAndId.getId();
|
||||||
|
|
||||||
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
|
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region);
|
||||||
|
|
||||||
if (!sgApi.isPresent()) {
|
if (!sgApi.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -291,7 +291,7 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getSecurityGroupById(ZoneAndId.fromZoneAndId(zone, id).slashEncode());
|
return getSecurityGroupById(RegionAndId.fromRegionAndId(region, id).slashEncode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -330,41 +330,41 @@ public class NovaSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Iterable<? extends SecurityGroupInZone> pollSecurityGroups() {
|
protected Iterable<? extends SecurityGroupInRegion> pollSecurityGroups() {
|
||||||
Iterable<? extends Set<? extends SecurityGroupInZone>> groups
|
Iterable<? extends Set<? extends SecurityGroupInRegion>> groups
|
||||||
= transform(zoneIds.get(), allSecurityGroupsInZone());
|
= transform(regionIds.get(), allSecurityGroupsInRegion());
|
||||||
|
|
||||||
return concat(groups);
|
return concat(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Iterable<? extends SecurityGroupInZone> pollSecurityGroupsByZone(String zone) {
|
protected Iterable<? extends SecurityGroupInRegion> pollSecurityGroupsByRegion(String region) {
|
||||||
return allSecurityGroupsInZone().apply(zone);
|
return allSecurityGroupsInRegion().apply(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Function<String, Set<? extends SecurityGroupInZone>> allSecurityGroupsInZone() {
|
protected Function<String, Set<? extends SecurityGroupInRegion>> allSecurityGroupsInRegion() {
|
||||||
return new Function<String, Set<? extends SecurityGroupInZone>>() {
|
return new Function<String, Set<? extends SecurityGroupInRegion>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends SecurityGroupInZone> apply(final String from) {
|
public Set<? extends SecurityGroupInRegion> apply(final String from) {
|
||||||
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(from);
|
Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(from);
|
||||||
|
|
||||||
if (!sgApi.isPresent()) {
|
if (!sgApi.isPresent()) {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return sgApi.get().list().transform(groupToGroupInZone(from)).toSet();
|
return sgApi.get().list().transform(groupToGroupInRegion(from)).toSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInZone> groupToGroupInZone(final String zone) {
|
protected Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInRegion> groupToGroupInRegion(final String region) {
|
||||||
return new Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInZone>() {
|
return new Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInRegion>() {
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupInZone apply(org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group) {
|
public SecurityGroupInRegion apply(org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group) {
|
||||||
return new SecurityGroupInZone(group, zone);
|
return new SecurityGroupInRegion(group, region);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions;
|
import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
||||||
import org.jclouds.rest.InsufficientResourcesException;
|
import org.jclouds.rest.InsufficientResourcesException;
|
||||||
|
|
||||||
|
@ -60,11 +60,11 @@ public class AllocateAndAddFloatingIpToNode implements
|
||||||
|
|
||||||
private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
|
private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
|
||||||
private final NovaApi novaApi;
|
private final NovaApi novaApi;
|
||||||
private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
|
private final LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> floatingIpCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
|
public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
|
||||||
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
|
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
|
||||||
this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
|
this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
||||||
|
@ -75,8 +75,8 @@ public class AllocateAndAddFloatingIpToNode implements
|
||||||
checkState(nodeRunning.apply(input.get().getNodeMetadata()), "node never achieved state running %s", input.get().getNodeMetadata());
|
checkState(nodeRunning.apply(input.get().getNodeMetadata()), "node never achieved state running %s", input.get().getNodeMetadata());
|
||||||
NodeMetadata node = input.get().getNodeMetadata().get();
|
NodeMetadata node = input.get().getNodeMetadata().get();
|
||||||
// node's location is a host
|
// node's location is a host
|
||||||
String zoneId = node.getLocation().getParent().getId();
|
String regionId = node.getLocation().getParent().getId();
|
||||||
FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(zoneId).get();
|
FloatingIPApi floatingIpApi = novaApi.getFloatingIPApi(regionId).get();
|
||||||
Optional<Set<String>> poolNames = input.get().getNovaTemplateOptions().get().getFloatingIpPoolNames();
|
Optional<Set<String>> poolNames = input.get().getNovaTemplateOptions().get().getFloatingIpPoolNames();
|
||||||
|
|
||||||
Optional<FloatingIP> ip = allocateFloatingIPForNode(floatingIpApi, poolNames, node.getId());
|
Optional<FloatingIP> ip = allocateFloatingIPForNode(floatingIpApi, poolNames, node.getId());
|
||||||
|
@ -87,7 +87,7 @@ public class AllocateAndAddFloatingIpToNode implements
|
||||||
|
|
||||||
floatingIpApi.addToServer(ip.get().getIp(), node.getProviderId());
|
floatingIpApi.addToServer(ip.get().getIp(), node.getProviderId());
|
||||||
input.get().getNodeMetadata().set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.get().getIp())).build());
|
input.get().getNodeMetadata().set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.get().getIp())).build());
|
||||||
floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId()));
|
floatingIpCache.invalidate(RegionAndId.fromSlashEncoded(node.getId()));
|
||||||
return input.get().getNodeMetadata();
|
return input.get().getNodeMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,15 @@ import org.jclouds.net.domain.IpProtocol;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Ingress;
|
import org.jclouds.openstack.nova.v2_0.domain.Ingress;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class CreateSecurityGroupIfNeeded implements Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> {
|
public class CreateSecurityGroupIfNeeded implements Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
@ -52,29 +52,29 @@ public class CreateSecurityGroupIfNeeded implements Function<ZoneSecurityGroupNa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts zoneSecurityGroupNameAndPorts) {
|
public SecurityGroupInRegion apply(RegionSecurityGroupNameAndPorts regionSecurityGroupNameAndPorts) {
|
||||||
checkNotNull(zoneSecurityGroupNameAndPorts, "zoneSecurityGroupNameAndPorts");
|
checkNotNull(regionSecurityGroupNameAndPorts, "regionSecurityGroupNameAndPorts");
|
||||||
|
|
||||||
String zoneId = zoneSecurityGroupNameAndPorts.getZone();
|
String regionId = regionSecurityGroupNameAndPorts.getRegion();
|
||||||
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
|
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupApi(regionId);
|
||||||
checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
|
checkArgument(api.isPresent(), "Security groups are required, but the extension is not available in region %s!", regionId);
|
||||||
logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
|
logger.debug(">> creating securityGroup %s", regionSecurityGroupNameAndPorts);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
SecurityGroup securityGroup = api.get().createWithDescription(
|
SecurityGroup securityGroup = api.get().createWithDescription(
|
||||||
zoneSecurityGroupNameAndPorts.getName(), zoneSecurityGroupNameAndPorts.getName());
|
regionSecurityGroupNameAndPorts.getName(), regionSecurityGroupNameAndPorts.getName());
|
||||||
|
|
||||||
logger.debug("<< created securityGroup(%s)", securityGroup);
|
logger.debug("<< created securityGroup(%s)", securityGroup);
|
||||||
for (int port : zoneSecurityGroupNameAndPorts.getPorts()) {
|
for (int port : regionSecurityGroupNameAndPorts.getPorts()) {
|
||||||
authorizeGroupToItselfAndAllIPsToTCPPort(api.get(), securityGroup, port);
|
authorizeGroupToItselfAndAllIPsToTCPPort(api.get(), securityGroup, port);
|
||||||
}
|
}
|
||||||
return new SecurityGroupInZone(api.get().get(securityGroup.getId()), zoneId);
|
return new SecurityGroupInRegion(api.get().get(securityGroup.getId()), regionId);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
logger.trace("<< trying to find securityGroup(%s): %s", zoneSecurityGroupNameAndPorts, e.getMessage());
|
logger.trace("<< trying to find securityGroup(%s): %s", regionSecurityGroupNameAndPorts, e.getMessage());
|
||||||
SecurityGroup group = find(api.get().list(), nameEquals(zoneSecurityGroupNameAndPorts
|
SecurityGroup group = find(api.get().list(), nameEquals(regionSecurityGroupNameAndPorts
|
||||||
.getName()));
|
.getName()));
|
||||||
logger.debug("<< reused securityGroup(%s)", group.getId());
|
logger.debug("<< reused securityGroup(%s)", group.getId());
|
||||||
return new SecurityGroupInZone(group, zoneId);
|
return new SecurityGroupInRegion(group, regionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,29 +29,29 @@ import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.FlavorInRegion;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function for transforming the nova specific FlavorInZone object to the generic Hardware object.
|
* A function for transforming the nova specific FlavorInRegion object to the generic Hardware object.
|
||||||
*/
|
*/
|
||||||
public class FlavorInZoneToHardware implements Function<FlavorInZone, Hardware> {
|
public class FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> {
|
||||||
|
|
||||||
private final Supplier<Map<String, Location>> locationIndex;
|
private final Supplier<Map<String, Location>> locationIndex;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FlavorInZoneToHardware(Supplier<Map<String, Location>> locationIndex) {
|
public FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex) {
|
||||||
this.locationIndex = checkNotNull(locationIndex, "locationIndex");
|
this.locationIndex = checkNotNull(locationIndex, "locationIndex");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hardware apply(FlavorInZone flavorInZone) {
|
public Hardware apply(FlavorInRegion flavorInRegion) {
|
||||||
Location location = locationIndex.get().get(flavorInZone.getZone());
|
Location location = locationIndex.get().get(flavorInRegion.getRegion());
|
||||||
checkState(location != null, "location %s not in locationIndex: %s", flavorInZone.getZone(), locationIndex.get());
|
checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get());
|
||||||
Flavor flavor = flavorInZone.getFlavor();
|
Flavor flavor = flavorInRegion.getFlavor();
|
||||||
return new HardwareBuilder().id(flavorInZone.slashEncode()).providerId(flavor.getId()).name(flavor.getName())
|
return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName())
|
||||||
.ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume(
|
.ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume(
|
||||||
new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build();
|
new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build();
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ import org.jclouds.compute.domain.ImageBuilder;
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
|
import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ImageInRegion;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
|
@ -37,13 +37,13 @@ import com.google.common.base.Supplier;
|
||||||
/**
|
/**
|
||||||
* A function for transforming a nova-specific Image into a generic Image object.
|
* A function for transforming a nova-specific Image into a generic Image object.
|
||||||
*/
|
*/
|
||||||
public class ImageInZoneToImage implements Function<ImageInZone, Image> {
|
public class ImageInRegionToImage implements Function<ImageInRegion, Image> {
|
||||||
private final Map<Status, org.jclouds.compute.domain.Image.Status> toPortableImageStatus;
|
private final Map<Status, org.jclouds.compute.domain.Image.Status> toPortableImageStatus;
|
||||||
private final Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem> imageToOs;
|
private final Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem> imageToOs;
|
||||||
private final Supplier<Map<String, Location>> locationIndex;
|
private final Supplier<Map<String, Location>> locationIndex;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ImageInZoneToImage(Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus,
|
public ImageInRegionToImage(Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus,
|
||||||
Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem> imageToOs,
|
Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem> imageToOs,
|
||||||
Supplier<Map<String, Location>> locationIndex) {
|
Supplier<Map<String, Location>> locationIndex) {
|
||||||
this.toPortableImageStatus = checkNotNull(toPortableImageStatus, "toPortableImageStatus");
|
this.toPortableImageStatus = checkNotNull(toPortableImageStatus, "toPortableImageStatus");
|
||||||
|
@ -52,15 +52,15 @@ public class ImageInZoneToImage implements Function<ImageInZone, Image> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image apply(ImageInZone imageInZone) {
|
public Image apply(ImageInRegion imageInRegion) {
|
||||||
Location location = locationIndex.get().get(imageInZone.getZone());
|
Location location = locationIndex.get().get(imageInRegion.getRegion());
|
||||||
checkState(location != null, "location %s not in locationIndex: %s", imageInZone.getZone(), locationIndex.get());
|
checkState(location != null, "location %s not in locationIndex: %s", imageInRegion.getRegion(), locationIndex.get());
|
||||||
org.jclouds.openstack.nova.v2_0.domain.Image image = imageInZone.getImage();
|
org.jclouds.openstack.nova.v2_0.domain.Image image = imageInRegion.getImage();
|
||||||
return new ImageBuilder().id(imageInZone.slashEncode()).providerId(image.getId()).name(image.getName())
|
return new ImageBuilder().id(imageInRegion.slashEncode()).providerId(image.getId()).name(image.getName())
|
||||||
.userMetadata(image.getMetadata()).operatingSystem(imageToOs.apply(image)).description(image.getName())
|
.userMetadata(image.getMetadata()).operatingSystem(imageToOs.apply(image)).description(image.getName())
|
||||||
.location(location).status(toPortableImageStatus.get(image.getStatus())).build();
|
.location(location).status(toPortableImageStatus.get(image.getStatus())).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return MoreObjects.toStringHelper(this).toString();
|
return MoreObjects.toStringHelper(this).toString();
|
|
@ -30,7 +30,7 @@ import org.jclouds.compute.domain.SecurityGroupBuilder;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -42,7 +42,7 @@ import com.google.inject.Inject;
|
||||||
* SecurityGroup object.
|
* SecurityGroup object.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NovaSecurityGroupInZoneToSecurityGroup implements Function<SecurityGroupInZone, SecurityGroup> {
|
public class NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
@ -51,22 +51,22 @@ public class NovaSecurityGroupInZoneToSecurityGroup implements Function<Security
|
||||||
protected final Supplier<Map<String, Location>> locationIndex;
|
protected final Supplier<Map<String, Location>> locationIndex;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NovaSecurityGroupInZoneToSecurityGroup(Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup> baseConverter,
|
public NovaSecurityGroupInRegionToSecurityGroup(Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup> baseConverter,
|
||||||
Supplier<Map<String, Location>> locationIndex) {
|
Supplier<Map<String, Location>> locationIndex) {
|
||||||
this.baseConverter = checkNotNull(baseConverter, "baseConverter");
|
this.baseConverter = checkNotNull(baseConverter, "baseConverter");
|
||||||
this.locationIndex = checkNotNull(locationIndex, "locationIndex");
|
this.locationIndex = checkNotNull(locationIndex, "locationIndex");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroup apply(SecurityGroupInZone group) {
|
public SecurityGroup apply(SecurityGroupInRegion group) {
|
||||||
SecurityGroupBuilder builder = SecurityGroupBuilder.fromSecurityGroup(baseConverter.apply(group.getSecurityGroup()));
|
SecurityGroupBuilder builder = SecurityGroupBuilder.fromSecurityGroup(baseConverter.apply(group.getSecurityGroup()));
|
||||||
|
|
||||||
Location zone = locationIndex.get().get(group.getZone());
|
Location region = locationIndex.get().get(group.getRegion());
|
||||||
checkState(zone != null, "location %s not in locationIndex: %s", group.getZone(), locationIndex.get());
|
checkState(region != null, "location %s not in locationIndex: %s", group.getRegion(), locationIndex.get());
|
||||||
|
|
||||||
builder.location(zone);
|
builder.location(region);
|
||||||
|
|
||||||
builder.id(group.getZone() + "/" + group.getSecurityGroup().getId());
|
builder.id(group.getRegion() + "/" + group.getSecurityGroup().getId());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
|
@ -30,7 +30,7 @@ import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.predicates.NodePredicates;
|
import org.jclouds.compute.predicates.NodePredicates;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.predicates.AllNodesInGroupTerminated;
|
import org.jclouds.openstack.nova.v2_0.compute.predicates.AllNodesInGroupTerminated;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -39,35 +39,35 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.Multimaps;
|
import com.google.common.collect.Multimaps;
|
||||||
|
|
||||||
public class OrphanedGroupsByZoneId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> {
|
public class OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> {
|
||||||
private final Predicate<ZoneAndName> allNodesInGroupTerminated;
|
private final Predicate<RegionAndName> allNodesInGroupTerminated;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OrphanedGroupsByZoneId(ComputeService computeService) {
|
protected OrphanedGroupsByRegionId(ComputeService computeService) {
|
||||||
this(new AllNodesInGroupTerminated(checkNotNull(computeService, "computeService")));
|
this(new AllNodesInGroupTerminated(checkNotNull(computeService, "computeService")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
OrphanedGroupsByZoneId(Predicate<ZoneAndName> allNodesInGroupTerminated) {
|
OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated) {
|
||||||
this.allNodesInGroupTerminated = checkNotNull(allNodesInGroupTerminated, "allNodesInGroupTerminated");
|
this.allNodesInGroupTerminated = checkNotNull(allNodesInGroupTerminated, "allNodesInGroupTerminated");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) {
|
public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) {
|
||||||
Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup());
|
Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup());
|
||||||
Set<ZoneAndName> zoneAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup,
|
Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup,
|
||||||
new Function<NodeMetadata, ZoneAndName>() {
|
new Function<NodeMetadata, RegionAndName>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZoneAndName apply(NodeMetadata input) {
|
public RegionAndName apply(NodeMetadata input) {
|
||||||
String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation()
|
String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation()
|
||||||
.getParent().getId() : input.getLocation().getId();
|
.getParent().getId() : input.getLocation().getId();
|
||||||
return ZoneAndName.fromZoneAndName(zoneId, input.getGroup());
|
return RegionAndName.fromRegionAndName(regionId, input.getGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
}), allNodesInGroupTerminated));
|
}), allNodesInGroupTerminated));
|
||||||
Multimap<String, String> zoneToZoneAndGroupNames = Multimaps.transformValues(Multimaps.index(zoneAndGroupNames,
|
Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames,
|
||||||
ZoneAndName.ZONE_FUNCTION), ZoneAndName.NAME_FUNCTION);
|
RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION);
|
||||||
return zoneToZoneAndGroupNames;
|
return regionToRegionAndGroupNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -36,25 +36,25 @@ import com.google.common.cache.LoadingCache;
|
||||||
/**
|
/**
|
||||||
* A function for removing and deallocating an ip address from a node
|
* A function for removing and deallocating an ip address from a node
|
||||||
*/
|
*/
|
||||||
public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId, ZoneAndId> {
|
public class RemoveFloatingIpFromNodeAndDeallocate implements Function<RegionAndId, RegionAndId> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final NovaApi novaApi;
|
private final NovaApi novaApi;
|
||||||
private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
|
private final LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> floatingIpCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
|
public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
|
||||||
@Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
|
@Named("FLOATINGIP") LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZoneAndId apply(ZoneAndId id) {
|
public RegionAndId apply(RegionAndId id) {
|
||||||
FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
|
FloatingIPApi floatingIpApi = novaApi.getFloatingIPApi(id.getRegion()).get();
|
||||||
for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
|
for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
|
||||||
logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
|
logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
|
||||||
floatingIpApi.removeFromServer(ip.getIp(), id.getId());
|
floatingIpApi.removeFromServer(ip.getIp(), id.getId());
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.net.domain.IpPermission;
|
import org.jclouds.net.domain.IpPermission;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -50,16 +50,16 @@ public class SecurityGroupRuleToIpPermission implements Function<SecurityGroupRu
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
protected final Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone;
|
protected final Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion;
|
||||||
protected final Supplier<Map<String, Location>> locationIndex;
|
protected final Supplier<Map<String, Location>> locationIndex;
|
||||||
LoadingCache<ZoneAndName, SecurityGroupInZone> groupMap;
|
LoadingCache<RegionAndName, SecurityGroupInRegion> groupMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SecurityGroupRuleToIpPermission(@Named("SECURITYGROUP_PRESENT") Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone,
|
public SecurityGroupRuleToIpPermission(@Named("SECURITYGROUP_PRESENT") Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion,
|
||||||
Supplier<Map<String, Location>> locationIndex,
|
Supplier<Map<String, Location>> locationIndex,
|
||||||
LoadingCache<ZoneAndName, SecurityGroupInZone> groupMap) {
|
LoadingCache<RegionAndName, SecurityGroupInRegion> groupMap) {
|
||||||
this.returnSecurityGroupExistsInZone = checkNotNull(returnSecurityGroupExistsInZone,
|
this.returnSecurityGroupExistsInRegion = checkNotNull(returnSecurityGroupExistsInRegion,
|
||||||
"returnSecurityGroupExistsInZone");
|
"returnSecurityGroupExistsInRegion");
|
||||||
this.locationIndex = checkNotNull(locationIndex, "locationIndex");
|
this.locationIndex = checkNotNull(locationIndex, "locationIndex");
|
||||||
this.groupMap = checkNotNull(groupMap, "groupMap");
|
this.groupMap = checkNotNull(groupMap, "groupMap");
|
||||||
}
|
}
|
||||||
|
@ -71,26 +71,26 @@ public class SecurityGroupRuleToIpPermission implements Function<SecurityGroupRu
|
||||||
builder.fromPort(rule.getFromPort());
|
builder.fromPort(rule.getFromPort());
|
||||||
builder.toPort(rule.getToPort());
|
builder.toPort(rule.getToPort());
|
||||||
if (rule.getGroup() != null) {
|
if (rule.getGroup() != null) {
|
||||||
String zone = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInZone(rule.getGroup().getName())),
|
String region = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInRegion(rule.getGroup().getName())),
|
||||||
null);
|
null);
|
||||||
if (zone != null) {
|
if (region != null) {
|
||||||
SecurityGroupInZone group = groupMap.getUnchecked(ZoneAndName.fromZoneAndName(zone, rule.getGroup().getName()));
|
SecurityGroupInRegion group = groupMap.getUnchecked(RegionAndName.fromRegionAndName(region, rule.getGroup().getName()));
|
||||||
builder.groupId(zone + "/" + group.getSecurityGroup().getId());
|
builder.groupId(region + "/" + group.getSecurityGroup().getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rule.getIpRange() != null)
|
if (rule.getIpRange() != null)
|
||||||
builder.cidrBlock(rule.getIpRange());
|
builder.cidrBlock(rule.getIpRange());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Predicate<String> isSecurityGroupInZone(final String groupName) {
|
protected Predicate<String> isSecurityGroupInRegion(final String groupName) {
|
||||||
return new Predicate<String>() {
|
return new Predicate<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String zone) {
|
public boolean apply(String region) {
|
||||||
AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(ZoneAndName.fromZoneAndName(zone, groupName));
|
AtomicReference<RegionAndName> securityGroupInRegionRef = Atomics.newReference(RegionAndName.fromRegionAndName(region, groupName));
|
||||||
return returnSecurityGroupExistsInZone.apply(securityGroupInZoneRef);
|
return returnSecurityGroupExistsInRegion.apply(securityGroupInRegionRef);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Address;
|
import org.jclouds.openstack.nova.v2_0.domain.Address;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
|
import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
import org.jclouds.util.InetAddresses2;
|
import org.jclouds.util.InetAddresses2;
|
||||||
|
|
||||||
|
@ -67,11 +67,11 @@ import com.google.common.net.InetAddresses;
|
||||||
* A function for transforming a nova-specific Server into a generic
|
* A function for transforming a nova-specific Server into a generic
|
||||||
* NodeMetadata object.
|
* NodeMetadata object.
|
||||||
*/
|
*/
|
||||||
public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMetadata> {
|
public class ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected Map<Status, org.jclouds.compute.domain.NodeMetadata.Status> toPortableNodeStatus;
|
protected Map<Status, org.jclouds.compute.domain.NodeMetadata.Status> toPortableNodeStatus;
|
||||||
protected final Supplier<Map<String, Location>> locationIndex;
|
protected final Supplier<Map<String, Location>> locationIndex;
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
|
@ -79,7 +79,7 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ServerInZoneToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus,
|
public ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus,
|
||||||
Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images,
|
Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images,
|
||||||
@Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention) {
|
@Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention) {
|
||||||
this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "toPortableNodeStatus");
|
this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "toPortableNodeStatus");
|
||||||
|
@ -90,27 +90,27 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata apply(ServerInZone serverInZone) {
|
public NodeMetadata apply(ServerInRegion serverInRegion) {
|
||||||
Location zone = locationIndex.get().get(serverInZone.getZone());
|
Location region = locationIndex.get().get(serverInRegion.getRegion());
|
||||||
checkState(zone != null, "location %s not in locationIndex: %s", serverInZone.getZone(), locationIndex.get());
|
checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get());
|
||||||
Server from = serverInZone.getServer();
|
Server from = serverInRegion.getServer();
|
||||||
|
|
||||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||||
builder.id(serverInZone.slashEncode());
|
builder.id(serverInRegion.slashEncode());
|
||||||
builder.providerId(from.getId());
|
builder.providerId(from.getId());
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
builder.hostname(from.getName());
|
builder.hostname(from.getName());
|
||||||
builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId())
|
builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId())
|
||||||
.description(from.getHostId()).parent(zone).build() : zone);
|
.description(from.getHostId()).parent(region).build() : region);
|
||||||
builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention));
|
builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention));
|
||||||
addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
|
addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
|
||||||
|
|
||||||
if (from.getImage() != null) {
|
if (from.getImage() != null) {
|
||||||
builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
|
builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode());
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
|
builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion));
|
||||||
builder.hardware(findHardwareForServerOrNull(serverInZone));
|
builder.hardware(findHardwareForServerOrNull(serverInRegion));
|
||||||
builder.status(toPortableNodeStatus.get(from.getStatus()));
|
builder.status(toPortableNodeStatus.get(from.getStatus()));
|
||||||
|
|
||||||
Set<Address> addresses = newHashSet(from.getAddresses().values());
|
Set<Address> addresses = newHashSet(from.getAddresses().values());
|
||||||
|
@ -140,16 +140,16 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
builder.uri(link.getHref());
|
builder.uri(link.getHref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Predicate<Address> isPrivateAddress = new Predicate<Address>() {
|
private static final Predicate<Address> isPrivateAddress = new Predicate<Address>() {
|
||||||
public boolean apply(Address in) {
|
public boolean apply(Address in) {
|
||||||
return InetAddresses2.IsPrivateIPAddress.INSTANCE.apply(in.getAddr());
|
return InetAddresses2.IsPrivateIPAddress.INSTANCE.apply(in.getAddr());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Predicate<String> isInet4Address = new Predicate<String>() {
|
public static final Predicate<String> isInet4Address = new Predicate<String>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String input) {
|
public boolean apply(String input) {
|
||||||
|
@ -172,15 +172,15 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Hardware findHardwareForServerOrNull(ServerInZone serverInZone) {
|
protected Hardware findHardwareForServerOrNull(ServerInRegion serverInRegion) {
|
||||||
return findObjectOfTypeForServerOrNull(hardwares.get(), "hardware", serverInZone.getServer().getFlavor().getId(),
|
return findObjectOfTypeForServerOrNull(hardwares.get(), "hardware", serverInRegion.getServer().getFlavor().getId(),
|
||||||
serverInZone);
|
serverInRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected OperatingSystem findOperatingSystemForServerOrNull(ServerInZone serverInZone) {
|
protected OperatingSystem findOperatingSystemForServerOrNull(ServerInRegion serverInRegion) {
|
||||||
if (serverInZone.getServer().getImage() != null) {
|
if (serverInRegion.getServer().getImage() != null) {
|
||||||
Image image = findObjectOfTypeForServerOrNull(
|
Image image = findObjectOfTypeForServerOrNull(
|
||||||
images.get(), "image", serverInZone.getServer().getImage().getId(), serverInZone);
|
images.get(), "image", serverInRegion.getServer().getImage().getId(), serverInRegion);
|
||||||
|
|
||||||
return (image != null) ? image.getOperatingSystem() : null;
|
return (image != null) ? image.getOperatingSystem() : null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -190,16 +190,16 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends ComputeMetadata> T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type,
|
public <T extends ComputeMetadata> T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type,
|
||||||
final String objectId, final ZoneAndId serverInZone) {
|
final String objectId, final RegionAndId serverInRegion) {
|
||||||
try {
|
try {
|
||||||
return find(supply, new Predicate<T>() {
|
return find(supply, new Predicate<T>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input) {
|
public boolean apply(T input) {
|
||||||
return input.getId().equals(ZoneAndId.fromZoneAndId(serverInZone.getZone(), objectId).slashEncode());
|
return input.getId().equals(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), objectId).slashEncode());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
logger.trace("could not find %s with id(%s) for server(%s)", type, objectId, serverInZone);
|
logger.trace("could not find %s with id(%s) for server(%s)", type, objectId, serverInRegion);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
@ -36,7 +36,7 @@ import com.google.common.cache.CacheLoader;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
|
public class CreateUniqueKeyPair extends CacheLoader<RegionAndName, KeyPair> {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
@ -50,15 +50,15 @@ public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KeyPair load(ZoneAndName zoneAndName) {
|
public KeyPair load(RegionAndName regionAndName) {
|
||||||
String zoneId = checkNotNull(zoneAndName, "zoneAndName").getZone();
|
String regionId = checkNotNull(regionAndName, "regionAndName").getRegion();
|
||||||
String prefix = zoneAndName.getName();
|
String prefix = regionAndName.getName();
|
||||||
|
|
||||||
Optional<? extends KeyPairApi> api = novaApi.getKeyPairExtensionForZone(zoneId);
|
Optional<? extends KeyPairApi> api = novaApi.getKeyPairApi(regionId);
|
||||||
checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
|
checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in region %s!",
|
||||||
zoneId);
|
regionId);
|
||||||
|
|
||||||
logger.debug(">> creating keyPair zone(%s) prefix(%s)", zoneId, prefix);
|
logger.debug(">> creating keyPair region(%s) prefix(%s)", regionId, prefix);
|
||||||
|
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
while (keyPair == null) {
|
while (keyPair == null) {
|
||||||
|
|
|
@ -23,60 +23,60 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.util.concurrent.Atomics;
|
import com.google.common.util.concurrent.Atomics;
|
||||||
|
|
||||||
public class FindSecurityGroupOrCreate extends CacheLoader<ZoneAndName, SecurityGroupInZone> {
|
public class FindSecurityGroupOrCreate extends CacheLoader<RegionAndName, SecurityGroupInRegion> {
|
||||||
|
|
||||||
protected final Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone;
|
protected final Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion;
|
||||||
protected final Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator;
|
protected final Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FindSecurityGroupOrCreate(
|
public FindSecurityGroupOrCreate(
|
||||||
@Named("SECURITYGROUP_PRESENT") Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone,
|
@Named("SECURITYGROUP_PRESENT") Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion,
|
||||||
Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator) {
|
Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator) {
|
||||||
this.returnSecurityGroupExistsInZone = checkNotNull(returnSecurityGroupExistsInZone,
|
this.returnSecurityGroupExistsInRegion = checkNotNull(returnSecurityGroupExistsInRegion,
|
||||||
"returnSecurityGroupExistsInZone");
|
"returnSecurityGroupExistsInRegion");
|
||||||
this.groupCreator = checkNotNull(groupCreator, "groupCreator");
|
this.groupCreator = checkNotNull(groupCreator, "groupCreator");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupInZone load(ZoneAndName in) {
|
public SecurityGroupInRegion load(RegionAndName in) {
|
||||||
AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(checkNotNull(in,
|
AtomicReference<RegionAndName> securityGroupInRegionRef = Atomics.newReference(checkNotNull(in,
|
||||||
"zoneSecurityGroupNameAndPorts"));
|
"regionSecurityGroupNameAndPorts"));
|
||||||
if (returnSecurityGroupExistsInZone.apply(securityGroupInZoneRef)) {
|
if (returnSecurityGroupExistsInRegion.apply(securityGroupInRegionRef)) {
|
||||||
return returnExistingSecurityGroup(securityGroupInZoneRef);
|
return returnExistingSecurityGroup(securityGroupInRegionRef);
|
||||||
} else {
|
} else {
|
||||||
return createNewSecurityGroup(in);
|
return createNewSecurityGroup(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SecurityGroupInZone returnExistingSecurityGroup(AtomicReference<ZoneAndName> securityGroupInZoneRef) {
|
private SecurityGroupInRegion returnExistingSecurityGroup(AtomicReference<RegionAndName> securityGroupInRegionRef) {
|
||||||
ZoneAndName securityGroupInZone = securityGroupInZoneRef.get();
|
RegionAndName securityGroupInRegion = securityGroupInRegionRef.get();
|
||||||
checkState(securityGroupInZone instanceof SecurityGroupInZone,
|
checkState(securityGroupInRegion instanceof SecurityGroupInRegion,
|
||||||
"programming error: predicate %s should update the atomic reference to the actual security group found",
|
"programming error: predicate %s should update the atomic reference to the actual security group found",
|
||||||
returnSecurityGroupExistsInZone);
|
returnSecurityGroupExistsInRegion);
|
||||||
return SecurityGroupInZone.class.cast(securityGroupInZone);
|
return SecurityGroupInRegion.class.cast(securityGroupInRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SecurityGroupInZone createNewSecurityGroup(ZoneAndName in) {
|
private SecurityGroupInRegion createNewSecurityGroup(RegionAndName in) {
|
||||||
checkState(
|
checkState(
|
||||||
checkNotNull(in, "zoneSecurityGroupNameAndPorts") instanceof ZoneSecurityGroupNameAndPorts,
|
checkNotNull(in, "regionSecurityGroupNameAndPorts") instanceof RegionSecurityGroupNameAndPorts,
|
||||||
"programming error: when issuing get to this cacheloader, you need to pass an instance of ZoneSecurityGroupNameAndPorts, not %s",
|
"programming error: when issuing get to this cacheloader, you need to pass an instance of RegionSecurityGroupNameAndPorts, not %s",
|
||||||
in);
|
in);
|
||||||
ZoneSecurityGroupNameAndPorts zoneSecurityGroupNameAndPorts = ZoneSecurityGroupNameAndPorts.class.cast(in);
|
RegionSecurityGroupNameAndPorts regionSecurityGroupNameAndPorts = RegionSecurityGroupNameAndPorts.class.cast(in);
|
||||||
return groupCreator.apply(zoneSecurityGroupNameAndPorts);
|
return groupCreator.apply(regionSecurityGroupNameAndPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "returnExistingSecurityGroupInZoneOrCreateAsNeeded()";
|
return "returnExistingSecurityGroupInRegionOrCreateAsNeeded()";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
@ -30,12 +30,12 @@ import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each zone may or may not have the floating ip function present. In order to safely proceed, we
|
* Each region may or may not have the floating ip function present. In order to safely proceed, we
|
||||||
* must allow the user to determine if a zone has floating ip services before attempting to use
|
* must allow the user to determine if a region has floating ip services before attempting to use
|
||||||
* them.
|
* them.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> {
|
public class LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIP>> {
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -44,9 +44,9 @@ public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends FloatingIP> load(final ZoneAndId key) throws Exception {
|
public Iterable<? extends FloatingIP> load(final RegionAndId key) throws Exception {
|
||||||
String zone = key.getZone();
|
String region = key.getRegion();
|
||||||
Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
|
Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region);
|
||||||
if (ipApiOptional.isPresent()) {
|
if (ipApiOptional.isPresent()) {
|
||||||
return ipApiOptional.get().list().filter(
|
return ipApiOptional.get().list().filter(
|
||||||
new Predicate<FloatingIP>() {
|
new Predicate<FloatingIP>() {
|
||||||
|
|
|
@ -196,10 +196,10 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h3>Note</h3>
|
* <h3>Note</h3>
|
||||||
*
|
*
|
||||||
* This requires that {@link NovaApi#getExtensionForZone(String)} to return
|
* This requires that {@link NovaApi#getExtensionForRegion(String)} to return
|
||||||
* {@link Optional#isPresent present}
|
* {@link Optional#isPresent present}
|
||||||
*
|
*
|
||||||
* @return true if auto assignment of a floating ip to each vm is enabled
|
* @return true if auto assignment of a floating ip to each vm is enabled
|
||||||
*/
|
*/
|
||||||
public boolean shouldAutoAssignFloatingIp() {
|
public boolean shouldAutoAssignFloatingIp() {
|
||||||
|
@ -229,7 +229,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* <h3>Note</h3>
|
* <h3>Note</h3>
|
||||||
*
|
*
|
||||||
* This requires that {@link NovaApi#getKeyPairExtensionForZone(String)} to return
|
* This requires that {@link NovaApi#getKeyPairExtensionApi(String)} to return
|
||||||
* {@link Optional#isPresent present}
|
* {@link Optional#isPresent present}
|
||||||
*
|
*
|
||||||
* @return true if auto generation of keypairs is enabled
|
* @return true if auto generation of keypairs is enabled
|
||||||
|
@ -241,7 +241,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* if unset, generate a default group prefixed with {@link jclouds#} according
|
* if unset, generate a default group prefixed with {@link jclouds#} according
|
||||||
* to {@link #getInboundPorts()}
|
* to {@link #getInboundPorts()}
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
|
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
|
||||||
* @deprecated Use {@link TemplateOptions#getGroups()} instead.
|
* @deprecated Use {@link TemplateOptions#getGroups()} instead.
|
||||||
*/
|
*/
|
||||||
|
@ -301,14 +301,14 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NovaTemplateOptions#shouldGenerateKeyPair()
|
* @see NovaTemplateOptions#shouldGenerateKeyPair()
|
||||||
*/
|
*/
|
||||||
public static NovaTemplateOptions generateKeyPair(boolean enable) {
|
public static NovaTemplateOptions generateKeyPair(boolean enable) {
|
||||||
return new NovaTemplateOptions().generateKeyPair(enable);
|
return new NovaTemplateOptions().generateKeyPair(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NovaTemplateOptions#getKeyPairName()
|
* @see NovaTemplateOptions#getKeyPairName()
|
||||||
*/
|
*/
|
||||||
public static NovaTemplateOptions keyPairName(String keyPairName) {
|
public static NovaTemplateOptions keyPairName(String keyPairName) {
|
||||||
return new NovaTemplateOptions().keyPairName(keyPairName);
|
return new NovaTemplateOptions().keyPairName(keyPairName);
|
||||||
|
@ -645,8 +645,8 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OpenStack can be configured to write metadata to a special configuration drive that will be
|
* OpenStack can be configured to write metadata to a special configuration drive that will be
|
||||||
* attached to the instance when it boots. The instance can retrieve any information that would
|
* attached to the instance when it boots. The instance can retrieve any information that would
|
||||||
* normally be available through the metadata service by mounting this disk and reading files from it.
|
* normally be available through the metadata service by mounting this disk and reading files from it.
|
||||||
* To enable the config drive, set this parameter to "true".
|
* To enable the config drive, set this parameter to "true".
|
||||||
* This has to be enabled for user data cases.
|
* This has to be enabled for user data cases.
|
||||||
|
|
|
@ -28,15 +28,15 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
public class AllNodesInGroupTerminated implements Predicate<ZoneAndName> {
|
public class AllNodesInGroupTerminated implements Predicate<RegionAndName> {
|
||||||
private final ComputeService computeService;
|
private final ComputeService computeService;
|
||||||
|
|
||||||
|
|
||||||
//TODO: TESTME
|
//TODO: TESTME
|
||||||
@Inject
|
@Inject
|
||||||
public AllNodesInGroupTerminated(ComputeService computeService) {
|
public AllNodesInGroupTerminated(ComputeService computeService) {
|
||||||
|
@ -44,10 +44,10 @@ public class AllNodesInGroupTerminated implements Predicate<ZoneAndName> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ZoneAndName input) {
|
public boolean apply(RegionAndName input) {
|
||||||
// new nodes can have the zone as their location, existing nodes, the parent is the
|
// new nodes can have the region as their location, existing nodes, the parent is the
|
||||||
// location
|
// location
|
||||||
return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()),
|
return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getRegion()),
|
||||||
parentLocationId(input.getZone()))), and(inGroup(input.getName()), TERMINATED));
|
parentLocationId(input.getRegion()))), and(inGroup(input.getName()), TERMINATED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ import org.jclouds.openstack.nova.v2_0.compute.functions.AllocateAndAddFloatingI
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions;
|
import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
|
@ -64,8 +64,8 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
|
||||||
CreateNodesWithGroupEncodedIntoNameThenAddToSet {
|
CreateNodesWithGroupEncodedIntoNameThenAddToSet {
|
||||||
|
|
||||||
private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
|
private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
|
||||||
private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
|
private final LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupCache;
|
||||||
private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
|
private final LoadingCache<RegionAndName, KeyPair> keyPairCache;
|
||||||
private final NovaApi novaApi;
|
private final NovaApi novaApi;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -76,8 +76,8 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
|
||||||
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
|
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
||||||
AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode,
|
AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode,
|
||||||
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
|
LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupCache,
|
||||||
LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) {
|
LoadingCache<RegionAndName, KeyPair> keyPairCache, NovaApi novaApi) {
|
||||||
super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, userExecutor,
|
super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, userExecutor,
|
||||||
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
|
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
|
||||||
this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
|
this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
|
||||||
|
@ -97,21 +97,21 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
|
||||||
|
|
||||||
assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
|
assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
|
||||||
|
|
||||||
String zone = mutableTemplate.getLocation().getId();
|
String region = mutableTemplate.getLocation().getId();
|
||||||
|
|
||||||
if (templateOptions.shouldAutoAssignFloatingIp()) {
|
if (templateOptions.shouldAutoAssignFloatingIp()) {
|
||||||
checkArgument(novaApi.getFloatingIPExtensionForZone(zone).isPresent(),
|
checkArgument(novaApi.getFloatingIPApi(region).isPresent(),
|
||||||
"Floating IPs are required by options, but the extension is not available! options: %s",
|
"Floating IPs are required by options, but the extension is not available! options: %s",
|
||||||
templateOptions);
|
templateOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean keyPairExtensionPresent = novaApi.getKeyPairExtensionForZone(zone).isPresent();
|
boolean keyPairExtensionPresent = novaApi.getKeyPairApi(region).isPresent();
|
||||||
if (templateOptions.shouldGenerateKeyPair()) {
|
if (templateOptions.shouldGenerateKeyPair()) {
|
||||||
checkArgument(keyPairExtensionPresent,
|
checkArgument(keyPairExtensionPresent,
|
||||||
"Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
|
"Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
|
||||||
KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create()
|
KeyPair keyPair = keyPairCache.getUnchecked(RegionAndName.fromRegionAndName(region, namingConvention.create()
|
||||||
.sharedNameForGroup(group)));
|
.sharedNameForGroup(group)));
|
||||||
keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
|
keyPairCache.asMap().put(RegionAndName.fromRegionAndName(region, keyPair.getName()), keyPair);
|
||||||
templateOptions.keyPairName(keyPair.getName());
|
templateOptions.keyPairName(keyPair.getName());
|
||||||
} else if (templateOptions.getKeyPairName() != null) {
|
} else if (templateOptions.getKeyPairName() != null) {
|
||||||
checkArgument(keyPairExtensionPresent,
|
checkArgument(keyPairExtensionPresent,
|
||||||
|
@ -120,11 +120,11 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
|
||||||
String pem = templateOptions.getLoginPrivateKey();
|
String pem = templateOptions.getLoginPrivateKey();
|
||||||
KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName())
|
KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName())
|
||||||
.fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
|
.fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
|
||||||
keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
|
keyPairCache.asMap().put(RegionAndName.fromRegionAndName(region, keyPair.getName()), keyPair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean securityGroupExtensionPresent = novaApi.getSecurityGroupExtensionForZone(zone).isPresent();
|
boolean securityGroupExtensionPresent = novaApi.getSecurityGroupApi(region).isPresent();
|
||||||
List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
|
List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
|
||||||
if (!templateOptions.getGroups().isEmpty()) {
|
if (!templateOptions.getGroups().isEmpty()) {
|
||||||
checkArgument(securityGroupExtensionPresent,
|
checkArgument(securityGroupExtensionPresent,
|
||||||
|
@ -134,7 +134,7 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
|
||||||
if (templateOptions.getGroups().isEmpty() && !inboundPorts.isEmpty()) {
|
if (templateOptions.getGroups().isEmpty() && !inboundPorts.isEmpty()) {
|
||||||
String securityGroupName = namingConvention.create().sharedNameForGroup(group);
|
String securityGroupName = namingConvention.create().sharedNameForGroup(group);
|
||||||
try {
|
try {
|
||||||
securityGroupCache.get(new ZoneSecurityGroupNameAndPorts(zone, securityGroupName, inboundPorts));
|
securityGroupCache.get(new RegionSecurityGroupNameAndPorts(region, securityGroupName, inboundPorts));
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw Throwables.propagate(e.getCause());
|
throw Throwables.propagate(e.getCause());
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,12 +97,12 @@ public class NovaHttpApiModule extends HttpApiModule<NovaApi> {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final Provider<NovaApi> novaApi) {
|
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final Provider<NovaApi> novaApi) {
|
||||||
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
|
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
|
||||||
.build(new CacheLoader<String, Set<? extends Extension>>() {
|
.build(new CacheLoader<String, Set<? extends Extension>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Extension> load(String key) throws Exception {
|
public Set<? extends Extension> load(String key) throws Exception {
|
||||||
return novaApi.get().getExtensionApiForZone(key).list();
|
return novaApi.get().getExtensionApi(key).list();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,16 +36,16 @@ import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aggregates can be manipulated using the Aggregate Extension to Nova (alias "OS-AGGREGATES")
|
* Aggregates can be manipulated using the Aggregate Extension to Nova (alias "OS-AGGREGATES")
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi
|
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi
|
||||||
*/
|
*/
|
||||||
public class HostAggregate {
|
public class HostAggregate {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromHostAggregate(this);
|
return new ConcreteBuilder().fromHostAggregate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ public class HostAggregate {
|
||||||
protected Date created;
|
protected Date created;
|
||||||
protected Date updated;
|
protected Date updated;
|
||||||
protected Map<String, String> metadata = ImmutableMap.of();
|
protected Map<String, String> metadata = ImmutableMap.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getId()
|
* @see HostAggregate#getId()
|
||||||
*/
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
|
@ -69,7 +69,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getName()
|
* @see HostAggregate#getName()
|
||||||
*/
|
*/
|
||||||
public T name(String name) {
|
public T name(String name) {
|
||||||
|
@ -77,7 +77,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getAvailabilityZone()
|
* @see HostAggregate#getAvailabilityZone()
|
||||||
*/
|
*/
|
||||||
public T availabilityZone(String availabilityZone) {
|
public T availabilityZone(String availabilityZone) {
|
||||||
|
@ -85,11 +85,11 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getHosts()
|
* @see HostAggregate#getHosts()
|
||||||
*/
|
*/
|
||||||
public T hosts(Set<String> hosts) {
|
public T hosts(Set<String> hosts) {
|
||||||
this.hosts = ImmutableSet.copyOf(checkNotNull(hosts, "hosts"));
|
this.hosts = ImmutableSet.copyOf(checkNotNull(hosts, "hosts"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class HostAggregate {
|
||||||
return hosts(ImmutableSet.copyOf(in));
|
return hosts(ImmutableSet.copyOf(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getState()
|
* @see HostAggregate#getState()
|
||||||
*/
|
*/
|
||||||
public T state(String state) {
|
public T state(String state) {
|
||||||
|
@ -105,7 +105,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getCreated()
|
* @see HostAggregate#getCreated()
|
||||||
*/
|
*/
|
||||||
public T created(Date created) {
|
public T created(Date created) {
|
||||||
|
@ -113,7 +113,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getUpdated()
|
* @see HostAggregate#getUpdated()
|
||||||
*/
|
*/
|
||||||
public T updated(Date updated) {
|
public T updated(Date updated) {
|
||||||
|
@ -121,18 +121,18 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getMetadata()
|
* @see HostAggregate#getMetadata()
|
||||||
*/
|
*/
|
||||||
public T metadata(Map<String, String> metadata) {
|
public T metadata(Map<String, String> metadata) {
|
||||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostAggregate build() {
|
public HostAggregate build() {
|
||||||
return new HostAggregate(id, name, availabilityZone, hosts, state, created, updated, metadata);
|
return new HostAggregate(id, name, availabilityZone, hosts, state, created, updated, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromHostAggregate(HostAggregate in) {
|
public T fromHostAggregate(HostAggregate in) {
|
||||||
return this
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
|
@ -174,11 +174,11 @@ public class HostAggregate {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
|
this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
|
||||||
this.hosts = hosts == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(hosts);
|
this.hosts = hosts == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(hosts);
|
||||||
this.state = checkNotNull(state, "state");
|
this.state = checkNotNull(state, "state");
|
||||||
this.created = checkNotNull(created, "created");
|
this.created = checkNotNull(created, "created");
|
||||||
this.updated = Optional.fromNullable(updated);
|
this.updated = Optional.fromNullable(updated);
|
||||||
this.metadata = metadata == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(metadata);
|
this.metadata = metadata == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -190,8 +190,6 @@ public class HostAggregate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* note: an "Availability Zone" is different from a Nova "Zone"
|
|
||||||
*
|
|
||||||
* @return the availability zone this aggregate is in
|
* @return the availability zone this aggregate is in
|
||||||
*/
|
*/
|
||||||
public String getAvailabilityZone() {
|
public String getAvailabilityZone() {
|
||||||
|
@ -237,12 +235,12 @@ public class HostAggregate {
|
||||||
&& Objects.equal(this.updated, that.updated)
|
&& Objects.equal(this.updated, that.updated)
|
||||||
&& Objects.equal(this.metadata, that.metadata);
|
&& Objects.equal(this.metadata, that.metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return MoreObjects.toStringHelper(this)
|
return MoreObjects.toStringHelper(this)
|
||||||
.add("id", id).add("name", name).add("availabilityZone", availabilityZone).add("hosts", hosts).add("state", state).add("created", created).add("updated", updated).add("metadata", metadata);
|
.add("id", id).add("name", name).add("availabilityZone", availabilityZone).add("hosts", hosts).add("state", state).add("created", created).add("updated", updated).add("metadata", metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
|
@ -14,17 +14,17 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
|
|
||||||
public class FlavorInZone extends ZoneAndId {
|
public class FlavorInRegion extends RegionAndId {
|
||||||
protected final Flavor image;
|
protected final Flavor image;
|
||||||
|
|
||||||
public FlavorInZone(Flavor image, String zoneId) {
|
public FlavorInRegion(Flavor image, String regionId) {
|
||||||
super(zoneId, checkNotNull(image, "image").getId());
|
super(regionId, checkNotNull(image, "image").getId());
|
||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ public class FlavorInZone extends ZoneAndId {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// superclass hashCode/equals are good enough, and help us use ZoneAndId and FlavorInZone
|
// superclass hashCode/equals are good enough, and help us use RegionAndId and FlavorInRegion
|
||||||
// interchangeably as Map keys
|
// interchangeably as Map keys
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[image=" + image + ", zoneId=" + zoneId + "]";
|
return "[image=" + image + ", regionId=" + regionId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,17 +14,17 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||||
|
|
||||||
public class ImageInZone extends ZoneAndId {
|
public class ImageInRegion extends RegionAndId {
|
||||||
protected final Image image;
|
protected final Image image;
|
||||||
|
|
||||||
public ImageInZone(Image image, String zoneId) {
|
public ImageInRegion(Image image, String regionId) {
|
||||||
super(zoneId, checkNotNull(image, "image").getId());
|
super(regionId, checkNotNull(image, "image").getId());
|
||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ public class ImageInZone extends ZoneAndId {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// superclass hashCode/equals are good enough, and help us use ZoneAndId and ImageInZone
|
// superclass hashCode/equals are good enough, and help us use RegionAndId and ImageInRegion
|
||||||
// interchangeably as Map keys
|
// interchangeably as Map keys
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[image=" + image + ", zoneId=" + zoneId + "]";
|
return "[image=" + image + ", regionId=" + regionId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -23,36 +23,36 @@ import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
public class ZoneAndId {
|
public class RegionAndId {
|
||||||
public static ZoneAndId fromSlashEncoded(String id) {
|
public static RegionAndId fromSlashEncoded(String id) {
|
||||||
Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
|
Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
|
||||||
checkArgument(Iterables.size(parts) == 2, "id must be in format zoneId/id");
|
checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id");
|
||||||
return new ZoneAndId(Iterables.get(parts, 0), Iterables.get(parts, 1));
|
return new RegionAndId(Iterables.get(parts, 0), Iterables.get(parts, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ZoneAndId fromZoneAndId(String zoneId, String id) {
|
public static RegionAndId fromRegionAndId(String regionId, String id) {
|
||||||
return new ZoneAndId(zoneId, id);
|
return new RegionAndId(regionId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String slashEncodeZoneAndId(String zoneId, String id) {
|
private static String slashEncodeRegionAndId(String regionId, String id) {
|
||||||
return checkNotNull(zoneId, "zoneId") + "/" + checkNotNull(id, "id");
|
return checkNotNull(regionId, "regionId") + "/" + checkNotNull(id, "id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String slashEncode() {
|
public String slashEncode() {
|
||||||
return slashEncodeZoneAndId(zoneId, id);
|
return slashEncodeRegionAndId(regionId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String zoneId;
|
protected final String regionId;
|
||||||
protected final String id;
|
protected final String id;
|
||||||
|
|
||||||
protected ZoneAndId(String zoneId, String id) {
|
protected RegionAndId(String regionId, String id) {
|
||||||
this.zoneId = checkNotNull(zoneId, "zoneId");
|
this.regionId = checkNotNull(regionId, "regionId");
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(zoneId, id);
|
return Objects.hashCode(regionId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,12 +63,12 @@ public class ZoneAndId {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
ZoneAndId other = (ZoneAndId) obj;
|
RegionAndId other = (RegionAndId) obj;
|
||||||
return Objects.equal(zoneId, other.zoneId) && Objects.equal(id, other.id);
|
return Objects.equal(regionId, other.regionId) && Objects.equal(id, other.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getZone() {
|
public String getRegion() {
|
||||||
return zoneId;
|
return regionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -77,7 +77,7 @@ public class ZoneAndId {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[zoneId=" + zoneId + ", id=" + id + "]";
|
return "[regionId=" + regionId + ", id=" + id + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,70 +14,70 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpful when looking for resources by zone and name
|
* Helpful when looking for resources by region and name
|
||||||
*/
|
*/
|
||||||
public class ZoneAndName {
|
public class RegionAndName {
|
||||||
|
|
||||||
public static final Function<ZoneAndName, String> NAME_FUNCTION = new Function<ZoneAndName, String>() {
|
public static final Function<RegionAndName, String> NAME_FUNCTION = new Function<RegionAndName, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(ZoneAndName input) {
|
public String apply(RegionAndName input) {
|
||||||
return input.getName();
|
return input.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Function<ZoneAndName, String> ZONE_FUNCTION = new Function<ZoneAndName, String>() {
|
public static final Function<RegionAndName, String> REGION_FUNCTION = new Function<RegionAndName, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(ZoneAndName input) {
|
public String apply(RegionAndName input) {
|
||||||
return input.getZone();
|
return input.getRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ZoneAndName fromSlashEncoded(String name) {
|
public static RegionAndName fromSlashEncoded(String name) {
|
||||||
Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name"));
|
Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name"));
|
||||||
checkArgument(Iterables.size(parts) == 2, "name must be in format zoneId/name");
|
checkArgument(Iterables.size(parts) == 2, "name must be in format regionId/name");
|
||||||
return new ZoneAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
|
return new RegionAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ZoneAndName fromZoneAndName(String zoneId, String name) {
|
public static RegionAndName fromRegionAndName(String regionId, String name) {
|
||||||
return new ZoneAndName(zoneId, name);
|
return new RegionAndName(regionId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String slashEncodeZoneAndName(String zoneId, String name) {
|
private static String slashEncodeRegionAndName(String regionId, String name) {
|
||||||
return checkNotNull(zoneId, "zoneId") + "/" + checkNotNull(name, "name");
|
return checkNotNull(regionId, "regionId") + "/" + checkNotNull(name, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String slashEncode() {
|
public String slashEncode() {
|
||||||
return slashEncodeZoneAndName(zoneId, name);
|
return slashEncodeRegionAndName(regionId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String zoneId;
|
protected final String regionId;
|
||||||
protected final String name;
|
protected final String name;
|
||||||
|
|
||||||
protected ZoneAndName(String zoneId, String name) {
|
protected RegionAndName(String regionId, String name) {
|
||||||
this.zoneId = checkNotNull(zoneId, "zoneId");
|
this.regionId = checkNotNull(regionId, "regionId");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getZone() {
|
public String getRegion() {
|
||||||
return zoneId;
|
return regionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -90,13 +90,13 @@ public class ZoneAndName {
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
ZoneAndName that = ZoneAndName.class.cast(o);
|
RegionAndName that = RegionAndName.class.cast(o);
|
||||||
return equal(this.zoneId, that.zoneId) && equal(this.name, that.name);
|
return equal(this.regionId, that.regionId) && equal(this.name, that.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(zoneId, name);
|
return Objects.hashCode(regionId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,6 +105,6 @@ public class ZoneAndName {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return MoreObjects.toStringHelper("").add("zoneId", zoneId).add("name", name);
|
return MoreObjects.toStringHelper("").add("regionId", regionId).add("name", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -25,11 +25,11 @@ import com.google.common.base.Objects;
|
||||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
public class ZoneSecurityGroupNameAndPorts extends ZoneAndName {
|
public class RegionSecurityGroupNameAndPorts extends RegionAndName {
|
||||||
protected final Set<Integer> ports;
|
protected final Set<Integer> ports;
|
||||||
|
|
||||||
public ZoneSecurityGroupNameAndPorts(String zoneId, String name, Iterable<Integer> ports) {
|
public RegionSecurityGroupNameAndPorts(String regionId, String name, Iterable<Integer> ports) {
|
||||||
super(zoneId, name);
|
super(regionId, name);
|
||||||
this.ports = ImmutableSet.<Integer> copyOf(checkNotNull(ports, "ports"));
|
this.ports = ImmutableSet.<Integer> copyOf(checkNotNull(ports, "ports"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class ZoneSecurityGroupNameAndPorts extends ZoneAndName {
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
ZoneSecurityGroupNameAndPorts that = ZoneSecurityGroupNameAndPorts.class.cast(o);
|
RegionSecurityGroupNameAndPorts that = RegionSecurityGroupNameAndPorts.class.cast(o);
|
||||||
return super.equals(that) && equal(this.ports, that.ports);
|
return super.equals(that) && equal(this.ports, that.ports);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,17 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
||||||
|
|
||||||
public class SecurityGroupInZone extends ZoneAndName {
|
public class SecurityGroupInRegion extends RegionAndName {
|
||||||
protected final SecurityGroup securityGroup;
|
protected final SecurityGroup securityGroup;
|
||||||
|
|
||||||
public SecurityGroupInZone(SecurityGroup securityGroup, String zoneId) {
|
public SecurityGroupInRegion(SecurityGroup securityGroup, String regionId) {
|
||||||
super(zoneId, checkNotNull(securityGroup, "securityGroup").getName());
|
super(regionId, checkNotNull(securityGroup, "securityGroup").getName());
|
||||||
this.securityGroup = securityGroup;
|
this.securityGroup = securityGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ public class SecurityGroupInZone extends ZoneAndName {
|
||||||
return securityGroup;
|
return securityGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// superclass hashCode/equals are good enough, and help us use ZoneAndName and ServerInZone
|
// superclass hashCode/equals are good enough, and help us use RegionAndName and ServerInRegion
|
||||||
// interchangeably as Map keys
|
// interchangeably as Map keys
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[securityGroup=" + securityGroup + ", zoneId=" + zoneId + "]";
|
return "[securityGroup=" + securityGroup + ", regionId=" + regionId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,17 +14,17 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
|
|
||||||
public class ServerInZone extends ZoneAndId {
|
public class ServerInRegion extends RegionAndId {
|
||||||
protected final Server server;
|
protected final Server server;
|
||||||
|
|
||||||
public ServerInZone(Server server, String zoneId) {
|
public ServerInRegion(Server server, String regionId) {
|
||||||
super(zoneId, checkNotNull(server, "server").getId());
|
super(regionId, checkNotNull(server, "server").getId());
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ public class ServerInZone extends ZoneAndId {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
// superclass hashCode/equals are good enough, and help us use ZoneAndId and ServerInZone
|
// superclass hashCode/equals are good enough, and help us use RegionAndId and ServerInRegion
|
||||||
// interchangeably as Map keys
|
// interchangeably as Map keys
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[server=" + server + ", zoneId=" + zoneId + "]";
|
return "[server=" + server + ", regionId=" + regionId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
|
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
|
@ -24,7 +24,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone;
|
||||||
import org.jclouds.openstack.v2_0.ServiceType;
|
import org.jclouds.openstack.v2_0.ServiceType;
|
||||||
import org.jclouds.openstack.v2_0.services.Extension;
|
import org.jclouds.openstack.v2_0.services.Extension;
|
||||||
import org.jclouds.rest.annotations.Fallback;
|
import org.jclouds.rest.annotations.Fallback;
|
||||||
|
|
|
@ -23,22 +23,22 @@ import java.beans.ConstructorProperties;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails.Flavors;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails.Flavors;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
|
@ -71,8 +71,8 @@ public class ParseFlavorDetails extends ParseJson<Flavors> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Flavor>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Flavor>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.get().toString();
|
String region = arg0.get().toString();
|
||||||
final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
|
final FlavorApi flavorApi = api.getFlavorApi(region);
|
||||||
return new Function<Object, IterableWithMarker<Flavor>>() {
|
return new Function<Object, IterableWithMarker<Flavor>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class ParseFlavors extends ParseJson<Flavors> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.get().toString();
|
String region = arg0.get().toString();
|
||||||
final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
|
final FlavorApi flavorApi = api.getFlavorApi(region);
|
||||||
return new Function<Object, IterableWithMarker<Resource>>() {
|
return new Function<Object, IterableWithMarker<Resource>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class ParseImageDetails extends ParseJson<Images> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Image>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Image>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.get().toString();
|
String region = arg0.get().toString();
|
||||||
final ImageApi imageApi = api.getImageApiForZone(zone);
|
final ImageApi imageApi = api.getImageApi(region);
|
||||||
return new Function<Object, IterableWithMarker<Image>>() {
|
return new Function<Object, IterableWithMarker<Image>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -23,22 +23,22 @@ import java.beans.ConstructorProperties;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
|
@ -71,8 +71,8 @@ public class ParseImages extends ParseJson<Images> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.get().toString();
|
String region = arg0.get().toString();
|
||||||
final ImageApi imageApi = api.getImageApiForZone(zone);
|
final ImageApi imageApi = api.getImageApi(region);
|
||||||
return new Function<Object, IterableWithMarker<Resource>>() {
|
return new Function<Object, IterableWithMarker<Resource>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class ParseServerDetails extends ParseJson<Servers> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.get().toString();
|
String region = arg0.get().toString();
|
||||||
final ServerApi serverApi = api.getServerApiForZone(zone);
|
final ServerApi serverApi = api.getServerApi(region);
|
||||||
return new Function<Object, IterableWithMarker<Server>>() {
|
return new Function<Object, IterableWithMarker<Server>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -23,22 +23,22 @@ import java.beans.ConstructorProperties;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
|
@ -71,8 +71,8 @@ public class ParseServers extends ParseJson<Servers> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.get().toString();
|
String region = arg0.get().toString();
|
||||||
final ServerApi serverApi = api.getServerApiForZone(zone);
|
final ServerApi serverApi = api.getServerApi(region);
|
||||||
return new Function<Object, IterableWithMarker<Resource>>() {
|
return new Function<Object, IterableWithMarker<Resource>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -360,7 +360,7 @@ public class CreateServerOptions implements MapBinder {
|
||||||
* <p/>
|
* <p/>
|
||||||
* <h3>Note</h3>
|
* <h3>Note</h3>
|
||||||
* <p/>
|
* <p/>
|
||||||
* This requires that {@link NovaApi#getSecurityGroupExtensionForZone(String)} to return
|
* This requires that {@link NovaApi#getSecurityGroupExtensionApi(String)} to return
|
||||||
* {@link Optional#isPresent present}
|
* {@link Optional#isPresent present}
|
||||||
*/
|
*/
|
||||||
public Set<String> getSecurityGroupNames() {
|
public Set<String> getSecurityGroupNames() {
|
||||||
|
@ -376,7 +376,7 @@ public class CreateServerOptions implements MapBinder {
|
||||||
public Set<String> getNetworks() {
|
public Set<String> getNetworks() {
|
||||||
return networks;
|
return networks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get custom networks specified for the server.
|
* Get custom networks specified for the server.
|
||||||
*
|
*
|
||||||
|
@ -429,7 +429,7 @@ public class CreateServerOptions implements MapBinder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a configuration drive will be attached to the server or not.
|
* Determines if a configuration drive will be attached to the server or not.
|
||||||
* This can be used for cloud-init or other configuration purposes.
|
* This can be used for cloud-init or other configuration purposes.
|
||||||
*/
|
*/
|
||||||
public boolean getConfigDrive() {
|
public boolean getConfigDrive() {
|
||||||
return configDrive;
|
return configDrive;
|
||||||
|
|
|
@ -28,8 +28,8 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import com.google.inject.Inject;
|
||||||
* AtomicReference is so that we can return the securityGroup that matched.
|
* AtomicReference is so that we can return the securityGroup that matched.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicReference<ZoneAndName>> {
|
public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicReference<RegionAndName>> {
|
||||||
|
|
||||||
private final NovaApi novaApi;
|
private final NovaApi novaApi;
|
||||||
|
|
||||||
|
@ -54,24 +54,24 @@ public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicR
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean apply(AtomicReference<ZoneAndName> securityGroupInZoneRef) {
|
public boolean apply(AtomicReference<RegionAndName> securityGroupInRegionRef) {
|
||||||
checkNotNull(securityGroupInZoneRef, "securityGroupRef");
|
checkNotNull(securityGroupInRegionRef, "securityGroupRef");
|
||||||
final ZoneAndName securityGroupInZone = checkNotNull(securityGroupInZoneRef.get(), "securityGroupInZone");
|
final RegionAndName securityGroupInRegion = checkNotNull(securityGroupInRegionRef.get(), "securityGroupInRegion");
|
||||||
|
|
||||||
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
|
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupApi(securityGroupInRegion.getRegion());
|
||||||
checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");
|
checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");
|
||||||
|
|
||||||
logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
|
logger.trace("looking for security group %s", securityGroupInRegion.slashEncode());
|
||||||
try {
|
try {
|
||||||
SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {
|
SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(SecurityGroup input) {
|
public boolean apply(SecurityGroup input) {
|
||||||
return input.getName().equals(securityGroupInZone.getName());
|
return input.getName().equals(securityGroupInRegion.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
securityGroupInZoneRef.set(new SecurityGroupInZone(returnVal, securityGroupInZone.getZone()));
|
securityGroupInRegionRef.set(new SecurityGroupInRegion(returnVal, securityGroupInRegion.getRegion()));
|
||||||
return true;
|
return true;
|
||||||
} catch (ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -57,18 +57,18 @@ public class ServerPredicates {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits until a Server is ACTIVE.
|
* Waits until a Server is ACTIVE.
|
||||||
*
|
*
|
||||||
* @param serverApi The ServerApi in the zone where your Server resides.
|
* @param serverApi The ServerApi in the region where your Server resides.
|
||||||
* @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
|
* @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<String> awaitActive(ServerApi serverApi) {
|
public static Predicate<String> awaitActive(ServerApi serverApi) {
|
||||||
return awaitStatus(serverApi, ACTIVE, TEN_MINUTES, FIVE_SECONDS);
|
return awaitStatus(serverApi, ACTIVE, TEN_MINUTES, FIVE_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits until a Server is SHUTOFF.
|
* Waits until a Server is SHUTOFF.
|
||||||
*
|
*
|
||||||
* @param serverApi The ServerApi in the zone where your Server resides.
|
* @param serverApi The ServerApi in the region where your Server resides.
|
||||||
* @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
|
* @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<String> awaitShutoff(ServerApi serverApi) {
|
public static Predicate<String> awaitShutoff(ServerApi serverApi) {
|
||||||
|
@ -78,7 +78,7 @@ public class ServerPredicates {
|
||||||
/**
|
/**
|
||||||
* Waits until a Server reaches Status.
|
* Waits until a Server reaches Status.
|
||||||
*
|
*
|
||||||
* @param serverApi The ServerApi in the zone where your Server resides.
|
* @param serverApi The ServerApi in the region where your Server resides.
|
||||||
* @return Predicate that will check the status every periodInSec seconds for a maximum of maxWaitInSec minutes.
|
* @return Predicate that will check the status every periodInSec seconds for a maximum of maxWaitInSec minutes.
|
||||||
*/
|
*/
|
||||||
public static Predicate<String> awaitStatus(
|
public static Predicate<String> awaitStatus(
|
||||||
|
@ -87,7 +87,7 @@ public class ServerPredicates {
|
||||||
|
|
||||||
return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS);
|
return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ServerStatusPredicate implements Predicate<String> {
|
public static class ServerStatusPredicate implements Predicate<String> {
|
||||||
private final ServerApi serverApi;
|
private final ServerApi serverApi;
|
||||||
private final Status status;
|
private final Status status;
|
||||||
|
|
|
@ -30,8 +30,8 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see KeystoneProperties#CREDENTIAL_TYPE
|
* @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest")
|
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest")
|
||||||
public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
@ -64,9 +64,9 @@ public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends Ba
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId,
|
||||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
|
assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(),
|
||||||
new ParseServerListTest().expected().toString());
|
new ParseServerListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see KeystoneProperties#CREDENTIAL_TYPE
|
* @see KeystoneProperties#CREDENTIAL_TYPE
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest")
|
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest")
|
||||||
|
@ -64,9 +64,9 @@ public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
|
||||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
|
assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(),
|
||||||
new ParseServerListTest().expected().toString());
|
new ParseServerListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see KeystoneProperties#CREDENTIAL_TYPE
|
* @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest")
|
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest")
|
||||||
public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
@ -59,9 +59,9 @@ public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiEx
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
|
||||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
|
assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(),
|
||||||
new ParseServerListTest().expected().toString());
|
new ParseServerListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class EndpointIdIsRandomExpectTest extends BaseNovaApiExpectTest {
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVersionMatchOnConfiguredZonesWhenResponseIs2xx() {
|
public void testVersionMatchOnConfiguredRegionsWhenResponseIs2xx() {
|
||||||
|
|
||||||
HttpRequest authenticate = HttpRequest
|
HttpRequest authenticate = HttpRequest
|
||||||
.builder()
|
.builder()
|
||||||
|
@ -63,7 +63,7 @@ public class EndpointIdIsRandomExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
|
||||||
NovaApi whenNovaRegionExists = requestSendsResponse(authenticate, authenticationResponse);
|
NovaApi whenNovaRegionExists = requestSendsResponse(authenticate, authenticationResponse);
|
||||||
|
|
||||||
assertEquals(whenNovaRegionExists.getConfiguredZones(), ImmutableSet.of("RegionOne"));
|
assertEquals(whenNovaRegionExists.getConfiguredRegions(), ImmutableSet.of("RegionOne"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,15 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see KeystoneProperties#CREDENTIAL_TYPE
|
* @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "PasswordAuthenticationExpectTest")
|
@Test(groups = "unit", testName = "PasswordAuthenticationExpectTest")
|
||||||
public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
||||||
public PasswordAuthenticationExpectTest() {
|
public PasswordAuthenticationExpectTest() {
|
||||||
identity = "identity";
|
identity = "identity";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListServersWhenResponseIs2xx() throws Exception {
|
public void testListServersWhenResponseIs2xx() throws Exception {
|
||||||
HttpRequest listServers = HttpRequest
|
HttpRequest listServers = HttpRequest
|
||||||
.builder()
|
.builder()
|
||||||
|
@ -50,9 +50,9 @@ public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
|
||||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
|
assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(),
|
||||||
new ParseServerListTest().expected().toString());
|
new ParseServerListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see KeystoneProperties#CREDENTIAL_TYPE
|
* @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest")
|
@Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest")
|
||||||
public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiExpectTest {
|
public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
@ -59,9 +59,9 @@ public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiE
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
|
assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(),
|
||||||
new ParseServerListTest().expected().toString());
|
new ParseServerListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Network;
|
import org.jclouds.openstack.nova.v2_0.domain.Network;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceContextExpectTest;
|
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceContextExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
|
|
||||||
NovaComputeServiceAdapter adapter = forNetworks.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forNetworks.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
// Response irrelevant in this expect test - just verifying the request.
|
// Response irrelevant in this expect test - just verifying the request.
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
|
|
||||||
NovaComputeServiceAdapter adapter = forDiskConfig.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forDiskConfig.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
assertEquals(server.getNode().getServer().getDiskConfig().orNull(), Server.DISK_CONFIG_AUTO);
|
assertEquals(server.getNode().getServer().getDiskConfig().orNull(), Server.DISK_CONFIG_AUTO);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
|
|
||||||
NovaComputeServiceAdapter adapter = forConfigDrive.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forConfigDrive.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
|
|
||||||
NovaComputeServiceAdapter adapter = forNovaNetworks.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forNovaNetworks.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
|
|
||||||
NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
|
||||||
template);
|
template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
assertEquals(server.getCredentials(), LoginCredentials.builder().password("ZWuHcmTMQ7eXoHeM").build());
|
assertEquals(server.getCredentials(), LoginCredentials.builder().password("ZWuHcmTMQ7eXoHeM").build());
|
||||||
|
@ -286,13 +286,13 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
// we expect to have already an entry in the cache for the key
|
// we expect to have already an entry in the cache for the key
|
||||||
LoadingCache<ZoneAndName, KeyPair> keyPairCache = forSecurityGroups.getInstance(Key
|
LoadingCache<RegionAndName, KeyPair> keyPairCache = forSecurityGroups.getInstance(Key
|
||||||
.get(new TypeLiteral<LoadingCache<ZoneAndName, KeyPair>>() {
|
.get(new TypeLiteral<LoadingCache<RegionAndName, KeyPair>>() {
|
||||||
}));
|
}));
|
||||||
keyPairCache.put(ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo")
|
keyPairCache.put(RegionAndName.fromRegionAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo")
|
||||||
.privateKey("privateKey").build());
|
.privateKey("privateKey").build());
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
|
||||||
template);
|
template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
assertEquals(server.getCredentials(), LoginCredentials.builder().privateKey("privateKey").build());
|
assertEquals(server.getCredentials(), LoginCredentials.builder().privateKey("privateKey").build());
|
||||||
|
@ -333,7 +333,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
|
|
||||||
NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
|
NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
|
||||||
|
|
||||||
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
|
NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
|
||||||
template);
|
template);
|
||||||
assertNotNull(server);
|
assertNotNull(server);
|
||||||
assertNull(server.getCredentials());
|
assertNull(server.getCredentials());
|
||||||
|
@ -417,8 +417,8 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties overrides = super.setupProperties();
|
Properties overrides = super.setupProperties();
|
||||||
// only specify one zone so that we don't have to configure requests for multiple zones
|
// only specify one region so that we don't have to configure requests for multiple regions
|
||||||
overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1");
|
overrides.setProperty("jclouds.regions", "az-1.region-a.geo-1");
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,17 +50,17 @@ import com.google.inject.TypeLiteral;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "NovaComputeServiceExpectTest")
|
@Test(groups = "unit", testName = "NovaComputeServiceExpectTest")
|
||||||
public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest {
|
public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties overrides = super.setupProperties();
|
Properties overrides = super.setupProperties();
|
||||||
// only specify limited zones so that we don't have to configure requests for multiple zones.
|
// only specify limited regions so that we don't have to configure requests for multiple regions.
|
||||||
// since we are doing tests with keystone responses from hpcloud and also openstack, we have
|
// since we are doing tests with keystone responses from hpcloud and also openstack, we have
|
||||||
// to whitelist one zone from each
|
// to whitelist one region from each
|
||||||
overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1,RegionOne");
|
overrides.setProperty("jclouds.regions", "az-1.region-a.geo-1,RegionOne");
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListLocationsWhenResponseIs2xx() throws Exception {
|
public void testListLocationsWhenResponseIs2xx() throws Exception {
|
||||||
|
|
||||||
Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
|
Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
|
||||||
|
@ -189,7 +189,7 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
|
||||||
|
|
||||||
HttpResponse securityGroupWithPort22 = HttpResponse.builder().statusCode(200)
|
HttpResponse securityGroupWithPort22 = HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromResource("/securitygroup_details_port22.json")).build();
|
.payload(payloadFromResource("/securitygroup_details_port22.json")).build();
|
||||||
|
|
||||||
HttpRequest create = HttpRequest
|
HttpRequest create = HttpRequest
|
||||||
.builder()
|
.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
|
|
|
@ -34,11 +34,11 @@ import com.google.common.util.concurrent.Futures;
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "NovaImageExtensionExpectTest")
|
@Test(groups = "unit", testName = "NovaImageExtensionExpectTest")
|
||||||
public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTest {
|
public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties overrides = super.setupProperties();
|
Properties overrides = super.setupProperties();
|
||||||
overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1");
|
overrides.setProperty("jclouds.regions", "az-1.region-a.geo-1");
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTe
|
||||||
payloadFromStringWithContentType(
|
payloadFromStringWithContentType(
|
||||||
"{\"createImage\":{\"name\":\"test\", \"metadata\": {}}}",
|
"{\"createImage\":{\"name\":\"test\", \"metadata\": {}}}",
|
||||||
"application/json")).build();
|
"application/json")).build();
|
||||||
|
|
||||||
HttpResponse createImageResponse = HttpResponse.builder().statusCode(202)
|
HttpResponse createImageResponse = HttpResponse.builder().statusCode(202)
|
||||||
.addHeader("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
|
.addHeader("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
|
||||||
.build();
|
.build();
|
||||||
|
@ -67,7 +67,7 @@ public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTe
|
||||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
|
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.addHeader("X-Auth-Token", authToken).build();
|
.addHeader("X-Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse getImageResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse getImageResponse = HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromResource("/image_active.json")).build();
|
.payload(payloadFromResource("/image_active.json")).build();
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTe
|
||||||
requestResponseMap.put(getImage, getImageResponse).build();
|
requestResponseMap.put(getImage, getImageResponse).build();
|
||||||
|
|
||||||
ImageExtension apiThatCreatesImage = requestsSendResponses(requestResponseMap.build()).getImageExtension().get();
|
ImageExtension apiThatCreatesImage = requestsSendResponses(requestResponseMap.build()).getImageExtension().get();
|
||||||
|
|
||||||
ImageTemplate newImageTemplate = apiThatCreatesImage.buildImageTemplateFromNode("test", "az-1.region-a.geo-1/71752");
|
ImageTemplate newImageTemplate = apiThatCreatesImage.buildImageTemplateFromNode("test", "az-1.region-a.geo-1/71752");
|
||||||
|
|
||||||
Image image = Futures.getUnchecked(apiThatCreatesImage.createImage(newImageTemplate));
|
Image image = Futures.getUnchecked(apiThatCreatesImage.createImage(newImageTemplate));
|
||||||
|
|
|
@ -47,7 +47,7 @@ import com.google.common.collect.Sets;
|
||||||
@Test(groups = "unit", testName = "NovaSecurityGroupExtensionExpectTest")
|
@Test(groups = "unit", testName = "NovaSecurityGroupExtensionExpectTest")
|
||||||
public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeServiceExpectTest {
|
public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeServiceExpectTest {
|
||||||
|
|
||||||
protected String zone = "az-1.region-a.geo-1";
|
protected String region = "az-1.region-a.geo-1";
|
||||||
protected HttpRequest list = HttpRequest.builder().method("GET").endpoint(
|
protected HttpRequest list = HttpRequest.builder().method("GET").endpoint(
|
||||||
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers(
|
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers(
|
||||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||||
|
@ -59,7 +59,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties overrides = super.setupProperties();
|
Properties overrides = super.setupProperties();
|
||||||
overrides.setProperty("jclouds.zones", zone);
|
overrides.setProperty("jclouds.regions", region);
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
Set<SecurityGroup> groups = extension.listSecurityGroupsInLocation(new LocationBuilder()
|
Set<SecurityGroup> groups = extension.listSecurityGroupsInLocation(new LocationBuilder()
|
||||||
.scope(LocationScope.ZONE)
|
.scope(LocationScope.REGION)
|
||||||
.id(zone)
|
.id(region)
|
||||||
.description("zone")
|
.description("region")
|
||||||
.build());
|
.build());
|
||||||
assertEquals(groups.size(), 1);
|
assertEquals(groups.size(), 1);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
|
|
||||||
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
Set<SecurityGroup> groups = extension.listSecurityGroupsForNode(zone + "/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
|
Set<SecurityGroup> groups = extension.listSecurityGroupsForNode(region + "/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
|
||||||
assertEquals(groups.size(), 1);
|
assertEquals(groups.size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
|
|
||||||
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
SecurityGroup group = extension.getSecurityGroupById(zone + "/160");
|
SecurityGroup group = extension.getSecurityGroupById(region + "/160");
|
||||||
assertEquals(group.getId(), zone + "/160");
|
assertEquals(group.getId(), region + "/160");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateSecurityGroup() {
|
public void testCreateSecurityGroup() {
|
||||||
|
@ -193,11 +193,11 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
SecurityGroup group = extension.createSecurityGroup("test", new LocationBuilder()
|
SecurityGroup group = extension.createSecurityGroup("test", new LocationBuilder()
|
||||||
.scope(LocationScope.ZONE)
|
.scope(LocationScope.REGION)
|
||||||
.id(zone)
|
.id(region)
|
||||||
.description("zone")
|
.description("region")
|
||||||
.build());
|
.build());
|
||||||
assertEquals(group.getId(), zone + "/160");
|
assertEquals(group.getId(), region + "/160");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemoveSecurityGroup() {
|
public void testRemoveSecurityGroup() {
|
||||||
|
@ -225,7 +225,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
|
|
||||||
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
assertTrue(extension.removeSecurityGroup(zone + "/160"), "Expected removal of securitygroup to be successful");
|
assertTrue(extension.removeSecurityGroup(region + "/160"), "Expected removal of securitygroup to be successful");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddIpPermissionCidrFromIpPermission() {
|
public void testAddIpPermissionCidrFromIpPermission() {
|
||||||
|
@ -269,7 +269,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
|
|
||||||
IpPermission perm = builder.build();
|
IpPermission perm = builder.build();
|
||||||
|
|
||||||
SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
|
SecurityGroup origGroup = extension.getSecurityGroupById(region + "/160");
|
||||||
|
|
||||||
assertNotNull(origGroup);
|
assertNotNull(origGroup);
|
||||||
SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
|
SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
|
||||||
|
@ -309,7 +309,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
|
ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
|
||||||
createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
|
createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
|
SecurityGroup origGroup = extension.getSecurityGroupById(region + "/160");
|
||||||
|
|
||||||
assertNotNull(origGroup);
|
assertNotNull(origGroup);
|
||||||
SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
|
SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
|
||||||
|
@ -364,7 +364,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
|
|
||||||
IpPermission perm = builder.build();
|
IpPermission perm = builder.build();
|
||||||
|
|
||||||
SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
|
SecurityGroup origGroup = extension.getSecurityGroupById(region + "/160");
|
||||||
|
|
||||||
assertNotNull(origGroup);
|
assertNotNull(origGroup);
|
||||||
SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
|
SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
|
||||||
|
@ -404,7 +404,7 @@ public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeService
|
||||||
ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
|
ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
|
||||||
createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
|
createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
|
||||||
|
|
||||||
SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
|
SecurityGroup origGroup = extension.getSecurityGroupById(region + "/160");
|
||||||
|
|
||||||
assertNotNull(origGroup);
|
assertNotNull(origGroup);
|
||||||
SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
|
SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
|
||||||
|
|
|
@ -48,10 +48,10 @@ import com.google.common.util.concurrent.Atomics;
|
||||||
public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeServiceExpectTest {
|
public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeServiceExpectTest {
|
||||||
final Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
final Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
||||||
"openstack-nova").build();
|
"openstack-nova").build();
|
||||||
final Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
final Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
||||||
LocationScope.ZONE).parent(provider).build();
|
LocationScope.REGION).parent(provider).build();
|
||||||
final Location host = new LocationBuilder().scope(LocationScope.HOST).id("hostId").description("hostId")
|
final Location host = new LocationBuilder().scope(LocationScope.HOST).id("hostId").description("hostId")
|
||||||
.parent(zone).build();
|
.parent(region).build();
|
||||||
final NodeMetadata node = new NodeMetadataBuilder().id("az-1.region-a.geo-1/71592").providerId("71592").location(
|
final NodeMetadata node = new NodeMetadataBuilder().id("az-1.region-a.geo-1/71592").providerId("71592").location(
|
||||||
host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
|
host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
|
||||||
.credentials(LoginCredentials.builder().password("foo").build()).build();
|
.credentials(LoginCredentials.builder().password("foo").build()).build();
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.FlavorInRegion;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -38,28 +38,28 @@ import com.google.common.collect.ImmutableMap;
|
||||||
/**
|
/**
|
||||||
* Tests the function used to transform Flavor objects into Hardware objects
|
* Tests the function used to transform Flavor objects into Hardware objects
|
||||||
*/
|
*/
|
||||||
@Test(testName = "FlavorInZoneToHardwareTest")
|
@Test(testName = "FlavorInRegionToHardwareTest")
|
||||||
public class FlavorInZoneToHardwareTest {
|
public class FlavorInRegionToHardwareTest {
|
||||||
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
||||||
"openstack-nova").build();
|
"openstack-nova").build();
|
||||||
Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
||||||
LocationScope.ZONE).parent(provider).build();
|
LocationScope.REGION).parent(provider).build();
|
||||||
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
||||||
.<String, Location> of("az-1.region-a.geo-1", zone));
|
.<String, Location> of("az-1.region-a.geo-1", region));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConversionWhereLocationFound() {
|
public void testConversionWhereLocationFound() {
|
||||||
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
FlavorInZone flavorInZoneToConvert = new FlavorInZone(Flavor.builder().id(id.toString())
|
FlavorInRegion flavorInRegionToConvert = new FlavorInRegion(Flavor.builder().id(id.toString())
|
||||||
.name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1");
|
.name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1");
|
||||||
|
|
||||||
Hardware converted = new FlavorInZoneToHardware(locationIndex).apply(flavorInZoneToConvert);
|
Hardware converted = new FlavorInRegionToHardware(locationIndex).apply(flavorInRegionToConvert);
|
||||||
|
|
||||||
Flavor flavorToConvert = flavorInZoneToConvert.getFlavor();
|
Flavor flavorToConvert = flavorInRegionToConvert.getFlavor();
|
||||||
assertEquals(converted.getName(), flavorToConvert.getName());
|
assertEquals(converted.getName(), flavorToConvert.getName());
|
||||||
assertEquals(converted.getId(), flavorInZoneToConvert.slashEncode());
|
assertEquals(converted.getId(), flavorInRegionToConvert.slashEncode());
|
||||||
assertEquals(converted.getProviderId(), flavorToConvert.getId());
|
assertEquals(converted.getProviderId(), flavorToConvert.getId());
|
||||||
assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));
|
assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ public class FlavorInZoneToHardwareTest {
|
||||||
|
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|
||||||
FlavorInZone flavorInZoneToConvert = new FlavorInZone(Flavor.builder().id(id.toString())
|
FlavorInRegion flavorInRegionToConvert = new FlavorInRegion(Flavor.builder().id(id.toString())
|
||||||
.name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "South");
|
.name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "South");
|
||||||
new FlavorInZoneToHardware(locationIndex).apply(flavorInZoneToConvert);
|
new FlavorInRegionToHardware(locationIndex).apply(flavorInRegionToConvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ImageInRegion;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -40,30 +40,30 @@ import com.google.common.collect.ImmutableMap;
|
||||||
/**
|
/**
|
||||||
* Tests the function that transforms nova-specific images to generic images.
|
* Tests the function that transforms nova-specific images to generic images.
|
||||||
*/
|
*/
|
||||||
@Test(testName = "ImageInZoneToHardwareTest")
|
@Test(testName = "ImageInRegionToHardwareTest")
|
||||||
public class ImageInZoneToImageTest {
|
public class ImageInRegionToImageTest {
|
||||||
|
|
||||||
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
||||||
"openstack-nova").build();
|
"openstack-nova").build();
|
||||||
Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
||||||
LocationScope.ZONE).parent(provider).build();
|
LocationScope.REGION).parent(provider).build();
|
||||||
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
||||||
.<String, Location> of("az-1.region-a.geo-1", zone));
|
.<String, Location> of("az-1.region-a.geo-1", region));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConversionWhereLocationFound() {
|
public void testConversionWhereLocationFound() {
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).status(Image.Status.DELETED).build();
|
Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).status(Image.Status.DELETED).build();
|
||||||
OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
|
OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
|
||||||
"My Test OS", true);
|
"My Test OS", true);
|
||||||
ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
|
ImageInRegionToImage converter = new ImageInRegionToImage(NovaComputeServiceContextModule.toPortableImageStatus,
|
||||||
constant(operatingSystem), locationIndex);
|
constant(operatingSystem), locationIndex);
|
||||||
|
|
||||||
ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "az-1.region-a.geo-1");
|
ImageInRegion novaImageInRegionToConvert = new ImageInRegion(novaImageToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
org.jclouds.compute.domain.Image convertedImage = converter.apply(novaImageInZoneToConvert);
|
org.jclouds.compute.domain.Image convertedImage = converter.apply(novaImageInRegionToConvert);
|
||||||
|
|
||||||
assertEquals(convertedImage.getId(), novaImageInZoneToConvert.slashEncode());
|
assertEquals(convertedImage.getId(), novaImageInRegionToConvert.slashEncode());
|
||||||
assertEquals(convertedImage.getProviderId(), novaImageToConvert.getId());
|
assertEquals(convertedImage.getProviderId(), novaImageToConvert.getId());
|
||||||
assertEquals(convertedImage.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));
|
assertEquals(convertedImage.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ public class ImageInZoneToImageTest {
|
||||||
Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build();
|
Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build();
|
||||||
OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
|
OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
|
||||||
"My Test OS", true);
|
"My Test OS", true);
|
||||||
ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
|
ImageInRegionToImage converter = new ImageInRegionToImage(NovaComputeServiceContextModule.toPortableImageStatus,
|
||||||
constant(operatingSystem), locationIndex);
|
constant(operatingSystem), locationIndex);
|
||||||
|
|
||||||
ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "South");
|
ImageInRegion novaImageInRegionToConvert = new ImageInRegion(novaImageToConvert, "South");
|
||||||
|
|
||||||
converter.apply(novaImageInZoneToConvert);
|
converter.apply(novaImageInRegionToConvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
|
@ -27,7 +27,7 @@ import org.jclouds.compute.domain.SecurityGroup;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -35,56 +35,56 @@ import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "NovaSecurityGroupInZoneToSecurityGroupTest")
|
@Test(groups = "unit", testName = "NovaSecurityGroupInRegionToSecurityGroupTest")
|
||||||
public class NovaSecurityGroupInZoneToSecurityGroupTest {
|
public class NovaSecurityGroupInRegionToSecurityGroupTest {
|
||||||
|
|
||||||
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
|
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
|
||||||
.description("openstack-nova").build();
|
.description("openstack-nova").build();
|
||||||
Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
|
Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
|
||||||
.scope(LocationScope.ZONE).parent(provider).build();
|
.scope(LocationScope.REGION).parent(provider).build();
|
||||||
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
||||||
.<String, Location>of("az-1.region-a.geo-1", zone));
|
.<String, Location>of("az-1.region-a.geo-1", region));
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWithGroup() {
|
public void testApplyWithGroup() {
|
||||||
NovaSecurityGroupInZoneToSecurityGroup parser = createGroupParser();
|
NovaSecurityGroupInRegionToSecurityGroup parser = createGroupParser();
|
||||||
|
|
||||||
SecurityGroupInZone origGroup = new SecurityGroupInZone(securityGroupWithGroup(), zone.getId());
|
SecurityGroupInRegion origGroup = new SecurityGroupInRegion(securityGroupWithGroup(), region.getId());
|
||||||
|
|
||||||
SecurityGroup newGroup = parser.apply(origGroup);
|
SecurityGroup newGroup = parser.apply(origGroup);
|
||||||
|
|
||||||
assertEquals(newGroup.getId(), origGroup.getZone() + "/" + origGroup.getSecurityGroup().getId());
|
assertEquals(newGroup.getId(), origGroup.getRegion() + "/" + origGroup.getSecurityGroup().getId());
|
||||||
assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
|
assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
|
||||||
assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
|
assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
|
||||||
assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
|
assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
|
||||||
assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
|
assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
|
||||||
NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
|
NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
|
||||||
assertEquals(newGroup.getLocation().getId(), origGroup.getZone());
|
assertEquals(newGroup.getLocation().getId(), origGroup.getRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWithCidr() {
|
public void testApplyWithCidr() {
|
||||||
|
|
||||||
NovaSecurityGroupInZoneToSecurityGroup parser = createGroupParser();
|
NovaSecurityGroupInRegionToSecurityGroup parser = createGroupParser();
|
||||||
|
|
||||||
SecurityGroupInZone origGroup = new SecurityGroupInZone(securityGroupWithCidr(), zone.getId());
|
SecurityGroupInRegion origGroup = new SecurityGroupInRegion(securityGroupWithCidr(), region.getId());
|
||||||
|
|
||||||
SecurityGroup newGroup = parser.apply(origGroup);
|
SecurityGroup newGroup = parser.apply(origGroup);
|
||||||
|
|
||||||
assertEquals(newGroup.getId(), origGroup.getZone() + "/" + origGroup.getSecurityGroup().getId());
|
assertEquals(newGroup.getId(), origGroup.getRegion() + "/" + origGroup.getSecurityGroup().getId());
|
||||||
assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
|
assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
|
||||||
assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
|
assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
|
||||||
assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
|
assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
|
||||||
assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
|
assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
|
||||||
NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
|
NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
|
||||||
assertEquals(newGroup.getLocation().getId(), origGroup.getZone());
|
assertEquals(newGroup.getLocation().getId(), origGroup.getRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
private NovaSecurityGroupInZoneToSecurityGroup createGroupParser() {
|
private NovaSecurityGroupInRegionToSecurityGroup createGroupParser() {
|
||||||
NovaSecurityGroupToSecurityGroup baseParser = new NovaSecurityGroupToSecurityGroup(NovaSecurityGroupToSecurityGroupTest.ruleConverter);
|
NovaSecurityGroupToSecurityGroup baseParser = new NovaSecurityGroupToSecurityGroup(NovaSecurityGroupToSecurityGroupTest.ruleConverter);
|
||||||
|
|
||||||
NovaSecurityGroupInZoneToSecurityGroup parser = new NovaSecurityGroupInZoneToSecurityGroup(baseParser, locationIndex);
|
NovaSecurityGroupInRegionToSecurityGroup parser = new NovaSecurityGroupInRegionToSecurityGroup(baseParser, locationIndex);
|
||||||
|
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
|
@ -29,8 +29,8 @@ import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.net.domain.IpProtocol;
|
import org.jclouds.net.domain.IpProtocol;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
|
@ -49,23 +49,23 @@ public class NovaSecurityGroupToSecurityGroupTest {
|
||||||
|
|
||||||
private static final Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
|
private static final Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
|
||||||
.description("openstack-nova").build();
|
.description("openstack-nova").build();
|
||||||
private static final Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
|
private static final Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
|
||||||
.scope(LocationScope.ZONE).parent(provider).build();
|
.scope(LocationScope.REGION).parent(provider).build();
|
||||||
private static final Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
private static final Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
||||||
.<String, Location>of("az-1.region-a.geo-1", zone));
|
.<String, Location>of("az-1.region-a.geo-1", region));
|
||||||
|
|
||||||
|
|
||||||
private static final Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysTrue();
|
private static final Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = Predicates.alwaysTrue();
|
||||||
|
|
||||||
private static final Map<ZoneAndName, SecurityGroupInZone> groupMap = ImmutableMap.of(
|
private static final Map<RegionAndName, SecurityGroupInRegion> groupMap = ImmutableMap.of(
|
||||||
ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "some-group"), new SecurityGroupInZone(securityGroupWithGroup(), "az-1.region-a.geo-1"),
|
RegionAndName.fromRegionAndName("az-1.region-a.geo-1", "some-group"), new SecurityGroupInRegion(securityGroupWithGroup(), "az-1.region-a.geo-1"),
|
||||||
ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "some-other-group"), new SecurityGroupInZone(securityGroupWithCidr(), "az-1.region-a.geo-1"));
|
RegionAndName.fromRegionAndName("az-1.region-a.geo-1", "some-other-group"), new SecurityGroupInRegion(securityGroupWithCidr(), "az-1.region-a.geo-1"));
|
||||||
|
|
||||||
// weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
// weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
||||||
private static final Supplier <LoadingCache<ZoneAndName, SecurityGroupInZone>> groupCache = Suppliers.<LoadingCache<ZoneAndName, SecurityGroupInZone>> ofInstance(
|
private static final Supplier <LoadingCache<RegionAndName, SecurityGroupInRegion>> groupCache = Suppliers.<LoadingCache<RegionAndName, SecurityGroupInRegion>> ofInstance(
|
||||||
CacheBuilder.newBuilder().<ZoneAndName, SecurityGroupInZone>build(CacheLoader.from(Functions.forMap(groupMap))));
|
CacheBuilder.newBuilder().<RegionAndName, SecurityGroupInRegion>build(CacheLoader.from(Functions.forMap(groupMap))));
|
||||||
|
|
||||||
public static final SecurityGroupRuleToIpPermission ruleConverter = new SecurityGroupRuleToIpPermission(returnSecurityGroupExistsInZone, locationIndex,
|
public static final SecurityGroupRuleToIpPermission ruleConverter = new SecurityGroupRuleToIpPermission(returnSecurityGroupExistsInRegion, locationIndex,
|
||||||
groupCache.get());
|
groupCache.get());
|
||||||
|
|
||||||
public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithGroup() {
|
public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithGroup() {
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.parse.ParseServerTest;
|
import org.jclouds.openstack.nova.v2_0.parse.ParseServerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -42,49 +42,49 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
|
||||||
@Test(testName = "OrphanedGroupsByZoneIdTest")
|
@Test(testName = "OrphanedGroupsByRegionIdTest")
|
||||||
public class OrphanedGroupsByZoneIdTest {
|
public class OrphanedGroupsByRegionIdTest {
|
||||||
|
|
||||||
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
|
||||||
"openstack-nova").build();
|
"openstack-nova").build();
|
||||||
Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
|
||||||
LocationScope.ZONE).parent(provider).build();
|
LocationScope.REGION).parent(provider).build();
|
||||||
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
||||||
.<String, Location> of("az-1.region-a.geo-1", zone));
|
.<String, Location> of("az-1.region-a.geo-1", region));
|
||||||
|
|
||||||
GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
|
GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenComputeServiceSaysAllNodesAreDeadBothGroupsAreReturned() {
|
public void testWhenComputeServiceSaysAllNodesAreDeadBothGroupsAreReturned() {
|
||||||
|
|
||||||
ServerInZone withoutHost = new ServerInZone(new ServerInZoneToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1");
|
ServerInRegion withoutHost = new ServerInRegion(new ServerInRegionToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1");
|
||||||
ServerInZone withHost = new ServerInZone(new ParseServerTest().expected(), "az-1.region-a.geo-1");
|
ServerInRegion withHost = new ServerInRegion(new ParseServerTest().expected(), "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers
|
.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention);
|
||||||
|
|
||||||
Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost));
|
Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost));
|
||||||
|
|
||||||
assertEquals(new OrphanedGroupsByZoneId(Predicates.<ZoneAndName> alwaysTrue()).apply(set), ImmutableMultimap
|
assertEquals(new OrphanedGroupsByRegionId(Predicates.<RegionAndName> alwaysTrue()).apply(set), ImmutableMultimap
|
||||||
.<String, String> builder().putAll("az-1.region-a.geo-1", "sample", "test").build());
|
.<String, String> builder().putAll("az-1.region-a.geo-1", "sample", "test").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenComputeServiceSaysAllNodesAreDeadNoGroupsAreReturned() {
|
public void testWhenComputeServiceSaysAllNodesAreDeadNoGroupsAreReturned() {
|
||||||
|
|
||||||
ServerInZone withoutHost = new ServerInZone(new ServerInZoneToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1");
|
ServerInRegion withoutHost = new ServerInRegion(new ServerInRegionToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1");
|
||||||
ServerInZone withHost = new ServerInZone(new ParseServerTest().expected(), "az-1.region-a.geo-1");
|
ServerInRegion withHost = new ServerInRegion(new ParseServerTest().expected(), "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers
|
.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention);
|
||||||
|
|
||||||
Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost));
|
Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost));
|
||||||
|
|
||||||
assertEquals(new OrphanedGroupsByZoneId(Predicates.<ZoneAndName> alwaysFalse()).apply(set), ImmutableMultimap
|
assertEquals(new OrphanedGroupsByRegionId(Predicates.<RegionAndName> alwaysFalse()).apply(set), ImmutableMultimap
|
||||||
.<String, String> of());
|
.<String, String> of());
|
||||||
|
|
||||||
}
|
}
|
|
@ -38,7 +38,7 @@ import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.parse.ParseServerTest;
|
import org.jclouds.openstack.nova.v2_0.parse.ParseServerTest;
|
||||||
import org.jclouds.openstack.nova.v2_0.parse.ParseServerWithoutImageTest;
|
import org.jclouds.openstack.nova.v2_0.parse.ParseServerWithoutImageTest;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
@ -55,15 +55,15 @@ import com.google.inject.Guice;
|
||||||
* Tests for the function for transforming a nova specific Server into a generic
|
* Tests for the function for transforming a nova specific Server into a generic
|
||||||
* NodeMetadata object.
|
* NodeMetadata object.
|
||||||
*/
|
*/
|
||||||
@Test(testName = "ServerInZoneToNodeMetadataTest")
|
@Test(testName = "ServerInRegionToNodeMetadataTest")
|
||||||
public class ServerInZoneToNodeMetadataTest {
|
public class ServerInRegionToNodeMetadataTest {
|
||||||
|
|
||||||
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
|
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
|
||||||
.description("openstack-nova").build();
|
.description("openstack-nova").build();
|
||||||
Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
|
Location region = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
|
||||||
.scope(LocationScope.ZONE).parent(provider).build();
|
.scope(LocationScope.REGION).parent(provider).build();
|
||||||
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
|
||||||
.<String, Location> of("az-1.region-a.geo-1", zone));
|
.<String, Location> of("az-1.region-a.geo-1", region));
|
||||||
|
|
||||||
GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
|
GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
public void testWhenNoHardwareOrImageMatchServerScopedIdsImageIdIsStillSet() {
|
public void testWhenNoHardwareOrImageMatchServerScopedIdsImageIdIsStillSet() {
|
||||||
|
|
||||||
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/FOOOOOOOO").providerId("FOOOOOOOO")
|
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/FOOOOOOOO").providerId("FOOOOOOOO")
|
||||||
.location(zone).build();
|
.location(region).build();
|
||||||
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/FOOOOOOOO")
|
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/FOOOOOOOO")
|
||||||
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
||||||
.providerId("FOOOOOOOO").description("foobuntu").location(zone).status(Image.Status.AVAILABLE).build();
|
.providerId("FOOOOOOOO").description("foobuntu").location(region).status(Image.Status.AVAILABLE).build();
|
||||||
|
|
||||||
checkHardwareAndImageStatus(null, existingHardware, "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54",
|
checkHardwareAndImageStatus(null, existingHardware, "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54",
|
||||||
null, existingImage);
|
null, existingImage);
|
||||||
|
@ -84,11 +84,11 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
public void testWhenNoHardwareAndImageMatchServerScopedIdsHardwareOperatingSystemAndImageIdAreSet() {
|
public void testWhenNoHardwareAndImageMatchServerScopedIdsHardwareOperatingSystemAndImageIdAreSet() {
|
||||||
|
|
||||||
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
|
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build();
|
||||||
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
||||||
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
||||||
.location(zone).build();
|
.location(region).build();
|
||||||
|
|
||||||
checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(),
|
checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(),
|
||||||
existingImage.getOperatingSystem(), existingImage);
|
existingImage.getOperatingSystem(), existingImage);
|
||||||
|
@ -97,11 +97,11 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNullAccessIPs() {
|
public void testNullAccessIPs() {
|
||||||
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
|
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build();
|
||||||
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
||||||
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
||||||
.location(zone).build();
|
.location(region).build();
|
||||||
|
|
||||||
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
|
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
|
||||||
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
|
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
|
||||||
|
@ -111,14 +111,14 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
.accessIPv6(null)
|
.accessIPv6(null)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
|
ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
|
NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert);
|
||||||
|
|
||||||
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
||||||
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
||||||
|
@ -131,11 +131,11 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateAccessIPs() {
|
public void testDuplicateAccessIPs() {
|
||||||
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
|
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build();
|
||||||
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
||||||
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
||||||
.location(zone).build();
|
.location(region).build();
|
||||||
|
|
||||||
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
|
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
|
||||||
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
|
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
|
||||||
|
@ -145,14 +145,14 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
.accessIPv6("::babe:67.23.10.132")
|
.accessIPv6("::babe:67.23.10.132")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
|
ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
|
NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert);
|
||||||
|
|
||||||
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
||||||
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
||||||
|
@ -165,11 +165,11 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAlternateAccessIPs() {
|
public void testAlternateAccessIPs() {
|
||||||
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
|
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build();
|
||||||
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
||||||
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
||||||
.location(zone).build();
|
.location(region).build();
|
||||||
|
|
||||||
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
|
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
|
||||||
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
|
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
|
||||||
|
@ -179,14 +179,14 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
.accessIPv6("::babe:76.32.1.231")
|
.accessIPv6("::babe:76.32.1.231")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
|
ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
|
NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert);
|
||||||
|
|
||||||
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
||||||
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
||||||
|
@ -206,22 +206,22 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testServerWithoutImage() {
|
public void testServerWithoutImage() {
|
||||||
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
|
.providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build();
|
||||||
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
|
||||||
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
.operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
|
||||||
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
.providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
|
||||||
.location(zone).build();
|
.location(region).build();
|
||||||
|
|
||||||
Server serverToConvert = new ParseServerWithoutImageTest().expected();
|
Server serverToConvert = new ParseServerWithoutImageTest().expected();
|
||||||
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
|
ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex,
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex,
|
||||||
Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.of(existingImage)),
|
Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.of(existingImage)),
|
||||||
Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet.of(existingHardware)),
|
Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet.of(existingHardware)),
|
||||||
namingConvention);
|
namingConvention);
|
||||||
|
|
||||||
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
|
NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert);
|
||||||
|
|
||||||
assertNull(convertedNodeMetadata.getImageId());
|
assertNull(convertedNodeMetadata.getImageId());
|
||||||
}
|
}
|
||||||
|
@ -235,16 +235,16 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
.of(existingHardware);
|
.of(existingHardware);
|
||||||
Server serverToConvert = new ParseServerTest().expected();
|
Server serverToConvert = new ParseServerTest().expected();
|
||||||
|
|
||||||
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
|
ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
|
NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert);
|
||||||
|
|
||||||
assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
|
assertEquals(serverInRegionToConvert.slashEncode(), convertedNodeMetadata.getId());
|
||||||
assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
|
assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
|
||||||
|
|
||||||
assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.HOST);
|
assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.HOST);
|
||||||
|
@ -279,26 +279,26 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewServerWithoutHostIdSetsZoneAsLocation() {
|
public void testNewServerWithoutHostIdSetsRegionAsLocation() {
|
||||||
|
|
||||||
Set<Image> images = ImmutableSet.<Image> of();
|
Set<Image> images = ImmutableSet.<Image> of();
|
||||||
Set<Hardware> hardwares = ImmutableSet.<Hardware> of();
|
Set<Hardware> hardwares = ImmutableSet.<Hardware> of();
|
||||||
|
|
||||||
Server serverToConvert = expectedServer();
|
Server serverToConvert = expectedServer();
|
||||||
|
|
||||||
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
|
ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1");
|
||||||
|
|
||||||
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
|
ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata(
|
||||||
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
|
NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert);
|
||||||
|
|
||||||
assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
|
assertEquals(serverInRegionToConvert.slashEncode(), convertedNodeMetadata.getId());
|
||||||
assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
|
assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
|
||||||
|
|
||||||
assertEquals(convertedNodeMetadata.getLocation(), zone);
|
assertEquals(convertedNodeMetadata.getLocation(), region);
|
||||||
|
|
||||||
URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752");
|
URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752");
|
||||||
assertEquals(convertedNodeMetadata.getUri(), expectedURI);
|
assertEquals(convertedNodeMetadata.getUri(), expectedURI);
|
|
@ -26,7 +26,7 @@ import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ public class CreateUniqueKeyPairTest {
|
||||||
KeyPair pair = createMock(KeyPair.class);
|
KeyPair pair = createMock(KeyPair.class);
|
||||||
|
|
||||||
Optional optKeyApi = Optional.of(keyApi);
|
Optional optKeyApi = Optional.of(keyApi);
|
||||||
|
|
||||||
expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();
|
expect(api.getKeyPairApi("region")).andReturn(optKeyApi).atLeastOnce();
|
||||||
|
|
||||||
expect(keyApi.create("group-1")).andReturn(pair);
|
expect(keyApi.create("group-1")).andReturn(pair);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class CreateUniqueKeyPairTest {
|
||||||
|
|
||||||
}).getInstance(CreateUniqueKeyPair.class);
|
}).getInstance(CreateUniqueKeyPair.class);
|
||||||
|
|
||||||
assertEquals(parser.load(ZoneAndName.fromZoneAndName("zone", "group")), pair);
|
assertEquals(parser.load(RegionAndName.fromRegionAndName("region", "group")), pair);
|
||||||
|
|
||||||
verify(api, keyApi);
|
verify(api, keyApi);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class CreateUniqueKeyPairTest {
|
||||||
|
|
||||||
KeyPair pair = createMock(KeyPair.class);
|
KeyPair pair = createMock(KeyPair.class);
|
||||||
|
|
||||||
expect(api.getKeyPairExtensionForZone("zone")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
|
expect(api.getKeyPairApi("region")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
|
||||||
|
|
||||||
expect(uniqueIdSupplier.get()).andReturn("1");
|
expect(uniqueIdSupplier.get()).andReturn("1");
|
||||||
expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
|
expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
|
||||||
|
@ -100,7 +100,7 @@ public class CreateUniqueKeyPairTest {
|
||||||
|
|
||||||
}).getInstance(CreateUniqueKeyPair.class);
|
}).getInstance(CreateUniqueKeyPair.class);
|
||||||
|
|
||||||
assertEquals(parser.load(ZoneAndName.fromZoneAndName("zone", "group")), pair);
|
assertEquals(parser.load(RegionAndName.fromRegionAndName("region", "group")), pair);
|
||||||
|
|
||||||
verify(api, keyApi, uniqueIdSupplier);
|
verify(api, keyApi, uniqueIdSupplier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ import static org.testng.Assert.fail;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -39,43 +39,43 @@ public class FindSecurityGroupOrCreateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenNotFoundCreatesANewSecurityGroup() throws Exception {
|
public void testWhenNotFoundCreatesANewSecurityGroup() throws Exception {
|
||||||
Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();
|
Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = Predicates.alwaysFalse();
|
||||||
|
|
||||||
SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);
|
SecurityGroupInRegion securityGroupInRegion = createMock(SecurityGroupInRegion.class);
|
||||||
|
|
||||||
ZoneSecurityGroupNameAndPorts input = new ZoneSecurityGroupNameAndPorts("zone", "groupName", ImmutableSet
|
RegionSecurityGroupNameAndPorts input = new RegionSecurityGroupNameAndPorts("region", "groupName", ImmutableSet
|
||||||
.<Integer> of(22, 8080));
|
.<Integer> of(22, 8080));
|
||||||
|
|
||||||
Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = Functions.forMap(ImmutableMap
|
Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator = Functions.forMap(ImmutableMap
|
||||||
.<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> of(input, securityGroupInZone));
|
.<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> of(input, securityGroupInRegion));
|
||||||
|
|
||||||
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
||||||
returnSecurityGroupExistsInZone, groupCreator);
|
returnSecurityGroupExistsInRegion, groupCreator);
|
||||||
|
|
||||||
assertEquals(parser.load(input), securityGroupInZone);
|
assertEquals(parser.load(input), securityGroupInRegion);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenFoundReturnsSecurityGroupFromAtomicReferenceValueUpdatedDuringPredicateCheck() throws Exception {
|
public void testWhenFoundReturnsSecurityGroupFromAtomicReferenceValueUpdatedDuringPredicateCheck() throws Exception {
|
||||||
final SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);
|
final SecurityGroupInRegion securityGroupInRegion = createMock(SecurityGroupInRegion.class);
|
||||||
|
|
||||||
Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = new Predicate<AtomicReference<ZoneAndName>>() {
|
Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = new Predicate<AtomicReference<RegionAndName>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(AtomicReference<ZoneAndName> input) {
|
public boolean apply(AtomicReference<RegionAndName> input) {
|
||||||
input.set(securityGroupInZone);
|
input.set(securityGroupInRegion);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
|
RegionAndName input = RegionAndName.fromRegionAndName("region", "groupName");
|
||||||
|
|
||||||
Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
|
Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator = new Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
|
public SecurityGroupInRegion apply(RegionSecurityGroupNameAndPorts input) {
|
||||||
fail();
|
fail();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -83,24 +83,24 @@ public class FindSecurityGroupOrCreateTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
||||||
returnSecurityGroupExistsInZone, groupCreator);
|
returnSecurityGroupExistsInRegion, groupCreator);
|
||||||
|
|
||||||
assertEquals(parser.load(input), securityGroupInZone);
|
assertEquals(parser.load(input), securityGroupInRegion);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testWhenFoundPredicateMustUpdateAtomicReference() throws Exception {
|
public void testWhenFoundPredicateMustUpdateAtomicReference() throws Exception {
|
||||||
|
|
||||||
Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysTrue();
|
Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = Predicates.alwaysTrue();
|
||||||
|
|
||||||
ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
|
RegionAndName input = RegionAndName.fromRegionAndName("region", "groupName");
|
||||||
|
|
||||||
Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
|
Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator = new Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
|
public SecurityGroupInRegion apply(RegionSecurityGroupNameAndPorts input) {
|
||||||
fail();
|
fail();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class FindSecurityGroupOrCreateTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
||||||
returnSecurityGroupExistsInZone, groupCreator);
|
returnSecurityGroupExistsInRegion, groupCreator);
|
||||||
|
|
||||||
parser.load(input);
|
parser.load(input);
|
||||||
|
|
||||||
|
@ -117,15 +117,15 @@ public class FindSecurityGroupOrCreateTest {
|
||||||
|
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testWhenNotFoundInputMustBeZoneSecurityGroupNameAndPorts() throws Exception {
|
public void testWhenNotFoundInputMustBeRegionSecurityGroupNameAndPorts() throws Exception {
|
||||||
Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();
|
Predicate<AtomicReference<RegionAndName>> returnSecurityGroupExistsInRegion = Predicates.alwaysFalse();
|
||||||
|
|
||||||
ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
|
RegionAndName input = RegionAndName.fromRegionAndName("region", "groupName");
|
||||||
|
|
||||||
Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
|
Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion> groupCreator = new Function<RegionSecurityGroupNameAndPorts, SecurityGroupInRegion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
|
public SecurityGroupInRegion apply(RegionSecurityGroupNameAndPorts input) {
|
||||||
fail();
|
fail();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public class FindSecurityGroupOrCreateTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
|
||||||
returnSecurityGroupExistsInZone, groupCreator);
|
returnSecurityGroupExistsInRegion, groupCreator);
|
||||||
|
|
||||||
parser.load(input);
|
parser.load(input);
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,9 @@ import static org.easymock.EasyMock.verify;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.AssertJUnit.assertFalse;
|
import static org.testng.AssertJUnit.assertFalse;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
||||||
FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();
|
FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();
|
||||||
|
|
||||||
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
expect(api.getFloatingIPApi("RegionOne")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
||||||
expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp)))
|
expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp)))
|
||||||
.atLeastOnce();
|
.atLeastOnce();
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
|
|
||||||
LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
|
LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
|
||||||
|
|
||||||
assertEquals(ImmutableSet.copyOf(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah"))), ImmutableSet.of(testIp));
|
assertEquals(ImmutableSet.copyOf(parser.load(RegionAndId.fromRegionAndId("RegionOne", "i-blah"))), ImmutableSet.of(testIp));
|
||||||
|
|
||||||
verify(api);
|
verify(api);
|
||||||
verify(ipApi);
|
verify(ipApi);
|
||||||
|
@ -63,7 +62,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
NovaApi api = createMock(NovaApi.class);
|
NovaApi api = createMock(NovaApi.class);
|
||||||
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
||||||
|
|
||||||
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
expect(api.getFloatingIPApi("region")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
||||||
|
|
||||||
expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of()))
|
expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of()))
|
||||||
.atLeastOnce();
|
.atLeastOnce();
|
||||||
|
@ -73,7 +72,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
|
|
||||||
LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
|
LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
|
||||||
|
|
||||||
assertFalse(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah")).iterator().hasNext());
|
assertFalse(parser.load(RegionAndId.fromRegionAndId("region", "i-blah")).iterator().hasNext());
|
||||||
|
|
||||||
verify(api);
|
verify(api);
|
||||||
verify(ipApi);
|
verify(ipApi);
|
||||||
|
@ -85,7 +84,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
NovaApi api = createMock(NovaApi.class);
|
NovaApi api = createMock(NovaApi.class);
|
||||||
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
||||||
|
|
||||||
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
expect(api.getFloatingIPApi("region")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
||||||
|
|
||||||
expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(FloatingIP.builder().id("1").ip("1.1.1.1").build())))
|
expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(FloatingIP.builder().id("1").ip("1.1.1.1").build())))
|
||||||
.atLeastOnce();
|
.atLeastOnce();
|
||||||
|
@ -95,7 +94,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
|
|
||||||
LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
|
LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
|
||||||
|
|
||||||
assertFalse(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah")).iterator().hasNext());
|
assertFalse(parser.load(RegionAndId.fromRegionAndId("region", "i-blah")).iterator().hasNext());
|
||||||
|
|
||||||
verify(api);
|
verify(api);
|
||||||
verify(ipApi);
|
verify(ipApi);
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.suspend("1"));
|
assertTrue(api.suspend("1"));
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.suspend("1"));
|
assertFalse(api.suspend("1"));
|
||||||
}
|
}
|
||||||
|
@ -73,11 +73,11 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
||||||
HttpResponse.builder().statusCode(403).build()
|
HttpResponse.builder().statusCode(403).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
api.suspend("1");
|
api.suspend("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResume() {
|
public void testResume() {
|
||||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||||
ServerAdminApi api = requestsSendResponses(
|
ServerAdminApi api = requestsSendResponses(
|
||||||
|
@ -85,7 +85,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.resume("1"));
|
assertTrue(api.resume("1"));
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.resume("1"));
|
assertFalse(api.resume("1"));
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
||||||
HttpResponse.builder().statusCode(403).build()
|
HttpResponse.builder().statusCode(403).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
api.resume("1");
|
api.resume("1");
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.lock("1"));
|
assertTrue(api.lock("1"));
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.lock("1"));
|
assertFalse(api.lock("1"));
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.unlock("1"));
|
assertTrue(api.unlock("1"));
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.unlock("1"));
|
assertFalse(api.unlock("1"));
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.pause("1"));
|
assertTrue(api.pause("1"));
|
||||||
}
|
}
|
||||||
|
@ -182,11 +182,11 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.pause("1"));
|
assertFalse(api.pause("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnpause() {
|
public void testUnpause() {
|
||||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||||
ServerAdminApi api = requestsSendResponses(
|
ServerAdminApi api = requestsSendResponses(
|
||||||
|
@ -194,7 +194,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.unpause("1"));
|
assertTrue(api.unpause("1"));
|
||||||
}
|
}
|
||||||
|
@ -206,11 +206,11 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.unpause("1"));
|
assertFalse(api.unpause("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMigrateServer() {
|
public void testMigrateServer() {
|
||||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||||
ServerAdminApi api = requestsSendResponses(
|
ServerAdminApi api = requestsSendResponses(
|
||||||
|
@ -218,7 +218,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.migrate("1"));
|
assertTrue(api.migrate("1"));
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.migrate("1"));
|
assertFalse(api.migrate("1"));
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.resetNetwork("1"));
|
assertTrue(api.resetNetwork("1"));
|
||||||
}
|
}
|
||||||
|
@ -255,11 +255,11 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.resetNetwork("1"));
|
assertFalse(api.resetNetwork("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInjectNetworkInfoIntoServer() {
|
public void testInjectNetworkInfoIntoServer() {
|
||||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||||
ServerAdminApi api = requestsSendResponses(
|
ServerAdminApi api = requestsSendResponses(
|
||||||
|
@ -267,7 +267,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.injectNetworkInfo("1"));
|
assertTrue(api.injectNetworkInfo("1"));
|
||||||
}
|
}
|
||||||
|
@ -279,11 +279,11 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
|
standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.injectNetworkInfo("1"));
|
assertFalse(api.injectNetworkInfo("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBackupServer() {
|
public void testBackupServer() {
|
||||||
ServerAdminApi api = requestsSendResponses(
|
ServerAdminApi api = requestsSendResponses(
|
||||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
|
@ -291,7 +291,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
authenticatedGET().endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action").method("POST")
|
authenticatedGET().endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action").method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(202).addHeader("Location", "http://172.16.89.149:8774/v2/images/1976b3b3-409a-468d-b16c-a9172c341b46").build()
|
HttpResponse.builder().statusCode(202).addHeader("Location", "http://172.16.89.149:8774/v2/images/1976b3b3-409a-468d-b16c-a9172c341b46").build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
String imageId = api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
|
String imageId = api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
|
||||||
assertEquals(imageId, "1976b3b3-409a-468d-b16c-a9172c341b46");
|
assertEquals(imageId, "1976b3b3-409a-468d-b16c-a9172c341b46");
|
||||||
|
@ -306,7 +306,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
authenticatedGET().endpoint(endpoint).method("POST")
|
authenticatedGET().endpoint(endpoint).method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
|
api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
|
standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
|
||||||
.payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(202).build()
|
HttpResponse.builder().statusCode(202).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.liveMigrate("1", "bighost", true, false));
|
assertTrue(api.liveMigrate("1", "bighost", true, false));
|
||||||
}
|
}
|
||||||
|
@ -332,11 +332,11 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
|
standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
|
||||||
.payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
|
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.liveMigrate("1", "bighost", true, false));
|
assertFalse(api.liveMigrate("1", "bighost", true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HttpRequest.Builder<?> standardActionRequestBuilderVoidResponse(URI endpoint, String actionName) {
|
protected HttpRequest.Builder<?> standardActionRequestBuilderVoidResponse(URI endpoint, String actionName) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
|
|
|
@ -42,7 +42,7 @@ import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of HostAdministrationApi
|
* Tests behavior of HostAdministrationApi
|
||||||
*
|
*
|
||||||
* TODO test migration methods
|
* TODO test migration methods
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "AdminActionsApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "AdminActionsApiLiveTest", singleThreaded = true)
|
||||||
|
@ -51,7 +51,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private ServerApi serverApi;
|
private ServerApi serverApi;
|
||||||
private ExtensionApi extensionApi;
|
private ExtensionApi extensionApi;
|
||||||
private Optional<? extends ServerAdminApi> apiOption;
|
private Optional<? extends ServerAdminApi> apiOption;
|
||||||
private String zone;
|
private String region;
|
||||||
|
|
||||||
private String testServerId;
|
private String testServerId;
|
||||||
private String backupImageId;
|
private String backupImageId;
|
||||||
|
@ -60,13 +60,13 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
serverApi = api.getServerApiForZone(zone);
|
serverApi = api.getServerApi(region);
|
||||||
extensionApi = api.getExtensionApiForZone(zone);
|
extensionApi = api.getExtensionApi(region);
|
||||||
imageApi = api.getImageApiForZone(zone);
|
imageApi = api.getImageApi(region);
|
||||||
apiOption = api.getServerAdminExtensionForZone(zone);
|
apiOption = api.getServerAdminApi(region);
|
||||||
if (apiOption.isPresent()) {
|
if (apiOption.isPresent()) {
|
||||||
testServerId = createServerInZone(zone).getId();
|
testServerId = createServerInRegion(region).getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if (apiOption.isPresent()) {
|
if (apiOption.isPresent()) {
|
||||||
if (testServerId != null) {
|
if (testServerId != null) {
|
||||||
assertTrue(api.getServerApiForZone(zone).delete(testServerId));
|
assertTrue(api.getServerApi(region).delete(testServerId));
|
||||||
}
|
}
|
||||||
if (backupImageId != null) {
|
if (backupImageId != null) {
|
||||||
imageApi.delete(backupImageId);
|
imageApi.delete(backupImageId);
|
||||||
|
|
|
@ -19,10 +19,11 @@ package org.jclouds.openstack.nova.v2_0.extensions;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone;
|
||||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class AvailabilityZoneApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi availabilityZonesApi = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi availabilityZonesApi = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||||
|
|
||||||
assertEquals(availabilityZonesApi.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(availabilityZonesApi.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
FluentIterable<? extends AvailabilityZone> zones = availabilityZonesApi.getAvailabilityZoneApi("az-1.region-a.geo-1").get().list();
|
FluentIterable<? extends AvailabilityZone> zones = availabilityZonesApi.getAvailabilityZoneApi("az-1.region-a.geo-1").get().list();
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,11 @@ package org.jclouds.openstack.nova.v2_0.extensions;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
|
|
||||||
|
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone;
|
||||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
|
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,16 @@ public class ConsolesApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testGetConsole(Console.Type consoleType) {
|
private void testGetConsole(Console.Type consoleType) {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
Optional<? extends ConsolesApi> apiOption = api.getConsolesExtensionForZone(zoneId);
|
Optional<? extends ConsolesApi> apiOption = api.getConsolesApi(regionId);
|
||||||
if (!apiOption.isPresent()) {
|
if (!apiOption.isPresent()) {
|
||||||
System.err.println("Consoles extension not present in server.");
|
System.err.println("Consoles extension not present in server.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsolesApi api = apiOption.get();
|
ConsolesApi api = apiOption.get();
|
||||||
ServerApi serverApi = this.api.getServerApiForZone(zoneId);
|
ServerApi serverApi = this.api.getServerApi(regionId);
|
||||||
Server server = createServerInZone(zoneId);
|
Server server = createServerInRegion(regionId);
|
||||||
Console console = api.getConsole(server.getId(), consoleType);
|
Console console = api.getConsole(server.getId(), consoleType);
|
||||||
assertNotNull(console.getType());
|
assertNotNull(console.getType());
|
||||||
assertTrue(consoleType.equals(console.getType()));
|
assertTrue(consoleType.equals(console.getType()));
|
||||||
|
|
|
@ -90,9 +90,9 @@ public class ConsolesApiMockTest extends BaseOpenStackMockTest<NovaApi> {
|
||||||
try {
|
try {
|
||||||
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
||||||
|
|
||||||
String zoneId = getFirst(novaApi.getConfiguredZones(), "RegionTwo");
|
String regionId = getFirst(novaApi.getConfiguredRegions(), "RegionTwo");
|
||||||
|
|
||||||
ConsolesApi consolesApi = novaApi.getConsolesExtensionForZone(zoneId).get();
|
ConsolesApi consolesApi = novaApi.getConsolesApi(regionId).get();
|
||||||
|
|
||||||
assertEquals(server.getRequestCount(), 2);
|
assertEquals(server.getRequestCount(), 2);
|
||||||
assertAuthentication(server);
|
assertAuthentication(server);
|
||||||
|
@ -120,9 +120,9 @@ public class ConsolesApiMockTest extends BaseOpenStackMockTest<NovaApi> {
|
||||||
try {
|
try {
|
||||||
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
||||||
|
|
||||||
String zoneId = getFirst(novaApi.getConfiguredZones(), "RegionTwo");
|
String regionId = getFirst(novaApi.getConfiguredRegions(), "RegionTwo");
|
||||||
|
|
||||||
ConsolesApi consolesApi = novaApi.getConsolesExtensionForZone(zoneId).get();
|
ConsolesApi consolesApi = novaApi.getConsolesApi(regionId).get();
|
||||||
|
|
||||||
assertEquals(server.getRequestCount(), 2);
|
assertEquals(server.getRequestCount(), 2);
|
||||||
assertAuthentication(server);
|
assertAuthentication(server);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_extra_specs.json")).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_extra_specs.json")).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.getMetadata("9"), ImmutableMap.of("test", "value1"));
|
assertEquals(api.getMetadata("9"), ImmutableMap.of("test", "value1"));
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.getMetadata("9").isEmpty());
|
assertTrue(api.getMetadata("9").isEmpty());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"extra_specs\":{\"test1\":\"somevalue\"}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"extra_specs\":{\"test1\":\"somevalue\"}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).build()
|
HttpResponse.builder().statusCode(200).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.updateMetadata("9", ImmutableMap.of("test1", "somevalue")));
|
assertTrue(api.updateMetadata("9", ImmutableMap.of("test1", "somevalue")));
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.method("PUT")
|
.method("PUT")
|
||||||
.payload(payloadFromStringWithContentType("{\"test1\":\"somevalue\"}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"test1\":\"somevalue\"}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).build()
|
HttpResponse.builder().statusCode(200).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.updateMetadataEntry("5", "test1", "somevalue"));
|
assertTrue(api.updateMetadataEntry("5", "test1", "somevalue"));
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"test1\":\"another value\"}", MediaType.APPLICATION_JSON)).build()
|
HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"test1\":\"another value\"}", MediaType.APPLICATION_JSON)).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.getMetadataKey("5", "test1"), "another value");
|
assertEquals(api.getMetadataKey("5", "test1"), "another value");
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertNull(api.getMetadataKey("5", "test1"));
|
assertNull(api.getMetadataKey("5", "test1"));
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(200).build()
|
HttpResponse.builder().statusCode(200).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.deleteMetadataKey("5", "test1"));
|
assertTrue(api.deleteMetadataKey("5", "test1"));
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()
|
HttpResponse.builder().statusCode(404).build()
|
||||||
).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
|
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.deleteMetadataKey("5", "test1"));
|
assertFalse(api.deleteMetadataKey("5", "test1"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ import com.google.common.collect.Maps;
|
||||||
public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private FlavorApi flavorApi;
|
private FlavorApi flavorApi;
|
||||||
private Optional<? extends FlavorExtraSpecsApi> apiOption;
|
private Optional<? extends FlavorExtraSpecsApi> apiOption;
|
||||||
private String zone;
|
private String region;
|
||||||
|
|
||||||
private Resource testFlavor;
|
private Resource testFlavor;
|
||||||
private Map<String, String> testSpecs = ImmutableMap.of("jclouds-test", "some data", "jclouds-test2", "more data!");
|
private Map<String, String> testSpecs = ImmutableMap.of("jclouds-test", "some data", "jclouds-test2", "more data!");
|
||||||
|
@ -50,9 +50,9 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
flavorApi = api.getFlavorApiForZone(zone);
|
flavorApi = api.getFlavorApi(region);
|
||||||
apiOption = api.getFlavorExtraSpecsExtensionForZone(zone);
|
apiOption = api.getFlavorExtraSpecsApi(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
|
|
@ -41,9 +41,9 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenExtensionNotInList.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
|
assertTrue(apiWhenExtensionNotInList.getFloatingIPApi("az-1.region-a.geo-1").isPresent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenExtensionNotInList.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
|
assertFalse(apiWhenExtensionNotInList.getFloatingIPApi("az-1.region-a.geo-1").isPresent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenFloatingIPsExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list()
|
assertEquals(apiWhenFloatingIPsExist.getFloatingIPApi("az-1.region-a.geo-1").get().list()
|
||||||
.toString(), new ParseFloatingIPListTest().expected().toString());
|
.toString(), new ParseFloatingIPListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||||
|
|
||||||
assertTrue(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list().isEmpty());
|
assertTrue(apiWhenNoServersExist.getFloatingIPApi("az-1.region-a.geo-1").get().list().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
|
public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
|
||||||
|
@ -108,7 +108,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().get("1")
|
assertEquals(apiWhenFloatingIPsExist.getFloatingIPApi("az-1.region-a.geo-1").get().get("1")
|
||||||
.toString(), new ParseFloatingIPTest().expected().toString());
|
.toString(), new ParseFloatingIPTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
||||||
|
|
||||||
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().get("1"));
|
assertNull(apiWhenNoServersExist.getFloatingIPApi("az-1.region-a.geo-1").get().get("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocateWhenResponseIs2xx() throws Exception {
|
public void testAllocateWhenResponseIs2xx() throws Exception {
|
||||||
|
@ -144,7 +144,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
||||||
createFloatingIPResponse);
|
createFloatingIPResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().toString(),
|
assertEquals(apiWhenFloatingIPsExist.getFloatingIPApi("az-1.region-a.geo-1").get().create().toString(),
|
||||||
new ParseFloatingIPTest().expected().toString());
|
new ParseFloatingIPTest().expected().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
||||||
createFloatingIPResponse);
|
createFloatingIPResponse);
|
||||||
|
|
||||||
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create());
|
assertNull(apiWhenNoServersExist.getFloatingIPApi("az-1.region-a.geo-1").get().create());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocateWithPoolNameWhenResponseIs2xx() throws Exception {
|
public void testAllocateWithPoolNameWhenResponseIs2xx() throws Exception {
|
||||||
|
@ -183,7 +183,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
||||||
createFloatingIPResponse);
|
createFloatingIPResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocateFromPool("myPool").toString(),
|
assertEquals(apiWhenFloatingIPsExist.getFloatingIPApi("az-1.region-a.geo-1").get().allocateFromPool("myPool").toString(),
|
||||||
new ParseFloatingIPTest().expected().toString());
|
new ParseFloatingIPTest().expected().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListFloatingIPs() throws Exception {
|
public void testListFloatingIPs() throws Exception {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPApi(regionId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
@ -65,8 +65,8 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllocateAndDecreateFloatingIPs() throws Exception {
|
public void testAllocateAndDecreateFloatingIPs() throws Exception {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPApi(regionId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
@ -96,13 +96,13 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndRemoveFloatingIp() throws Exception {
|
public void testAddAndRemoveFloatingIp() throws Exception {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPApi(regionId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
ServerApi serverApi = this.api.getServerApiForZone(zoneId);
|
ServerApi serverApi = this.api.getServerApi(regionId);
|
||||||
Server server = createServerInZone(zoneId);
|
Server server = createServerInRegion(regionId);
|
||||||
FloatingIP floatingIP = api.create();
|
FloatingIP floatingIP = api.create();
|
||||||
assertNotNull(floatingIP);
|
assertNotNull(floatingIP);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -41,8 +41,8 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "HostAdministrationApiExpectTest")
|
@Test(groups = "unit", testName = "HostAdministrationApiExpectTest")
|
||||||
public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
|
||||||
|
|
||||||
public void testList() {
|
public void testList() {
|
||||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts");
|
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts");
|
||||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
|
@ -51,8 +51,8 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.addHeader("X-Auth-Token", authToken)
|
.addHeader("X-Auth-Token", authToken)
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/hosts_list.json")).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/hosts_list.json")).build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
Host expected = Host.builder().name("ubuntu").service("compute").build();
|
Host expected = Host.builder().name("ubuntu").service("compute").build();
|
||||||
|
|
||||||
Set<? extends Host> result = api.list().toSet();
|
Set<? extends Host> result = api.list().toSet();
|
||||||
|
@ -71,7 +71,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.addHeader("X-Auth-Token", authToken)
|
.addHeader("X-Auth-Token", authToken)
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host.json")).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host.json")).build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
Set<HostResourceUsage> expected = ImmutableSet.of(
|
Set<HostResourceUsage> expected = ImmutableSet.of(
|
||||||
HostResourceUsage.builder().memoryMb(16083).project("(total)").cpu(4).diskGb(181).host("ubuntu").build(),
|
HostResourceUsage.builder().memoryMb(16083).project("(total)").cpu(4).diskGb(181).host("ubuntu").build(),
|
||||||
|
@ -82,7 +82,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
|
||||||
assertEquals(api.listResourceUsage("xyz").toSet(), expected);
|
assertEquals(api.listResourceUsage("xyz").toSet(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnableHost() {
|
public void testEnableHost() {
|
||||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu");
|
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu");
|
||||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
|
@ -94,7 +94,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"enabled\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"enabled\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.enable("ubuntu"));
|
assertTrue(api.enable("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.payload(payloadFromStringWithContentType("{\"status\":\"enable\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"status\":\"enable\"}", MediaType.APPLICATION_JSON))
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404)
|
HttpResponse.builder().statusCode(404)
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
api.enable("ubuntu");
|
api.enable("ubuntu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"disabled\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"disabled\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertFalse(api.enable("ubuntu"));
|
assertFalse(api.enable("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"disabled\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"disabled\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.disable("ubuntu"));
|
assertTrue(api.disable("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"maintenance_mode\":\"on_maintenance\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"maintenance_mode\":\"on_maintenance\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.startMaintenance("ubuntu"));
|
assertTrue(api.startMaintenance("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,10 +169,10 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"maintenance_mode\":\"off_maintenance\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"maintenance_mode\":\"off_maintenance\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.stopMaintenance("ubuntu"));
|
assertTrue(api.stopMaintenance("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStartupHost() {
|
public void testStartupHost() {
|
||||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
|
@ -182,7 +182,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("X-Auth-Token", authToken).build(),
|
.addHeader("X-Auth-Token", authToken).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"startup\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"startup\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.startup("ubuntu"));
|
assertTrue(api.startup("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/startup")
|
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/startup")
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.addHeader("X-Auth-Token", authToken).build(),
|
.addHeader("X-Auth-Token", authToken).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(404).build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.startup("ubuntu"));
|
assertTrue(api.startup("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,10 +207,10 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("X-Auth-Token", authToken).build(),
|
.addHeader("X-Auth-Token", authToken).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"shutdown\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"shutdown\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertFalse(api.startup("ubuntu"));
|
assertFalse(api.startup("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testShutdownHost() {
|
public void testShutdownHost() {
|
||||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
|
@ -220,10 +220,10 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("X-Auth-Token", authToken).build(),
|
.addHeader("X-Auth-Token", authToken).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"shutdown\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"shutdown\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.shutdown("ubuntu"));
|
assertTrue(api.shutdown("ubuntu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRebootHost() {
|
public void testRebootHost() {
|
||||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
|
@ -233,7 +233,7 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("X-Auth-Token", authToken).build(),
|
.addHeader("X-Auth-Token", authToken).build(),
|
||||||
HttpResponse.builder().statusCode(200)
|
HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"reboot\"}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"reboot\"}", MediaType.APPLICATION_JSON))
|
||||||
.build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
|
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||||
assertTrue(api.reboot("ubuntu"));
|
assertTrue(api.reboot("ubuntu"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
super.setup();
|
super.setup();
|
||||||
|
|
||||||
if (identity.endsWith(":admin")) {
|
if (identity.endsWith(":admin")) {
|
||||||
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
String region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
optApi = api.getHostAdministrationExtensionForZone(zone);
|
optApi = api.getHostAdministrationApi(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_list.json")).build())
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_list.json")).build())
|
||||||
.getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
.getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
HostAggregate result = Iterables.getOnlyElement(api.list());
|
HostAggregate result = Iterables.getOnlyElement(api.list());
|
||||||
assertEquals(result, exampleHostAggregate());
|
assertEquals(result, exampleHostAggregate());
|
||||||
|
@ -60,7 +60,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_with_host_details.json")).build())
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_with_host_details.json")).build())
|
||||||
.getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
.getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.get("1"), exampleHostAggregateWithHost());
|
assertEquals(api.get("1"), exampleHostAggregateWithHost());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(404).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertNull(api.get("1"));
|
assertNull(api.get("1"));
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"ubuntu1\",\"availability_zone\":\"nova\"}}", MediaType.APPLICATION_JSON))
|
.payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"ubuntu1\",\"availability_zone\":\"nova\"}}", MediaType.APPLICATION_JSON))
|
||||||
.endpoint(endpoint).build(),
|
.endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build())
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build())
|
||||||
.getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
.getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.createInAvailabilityZone("ubuntu1", "nova"), exampleHostAggregate());
|
assertEquals(api.createInAvailabilityZone("ubuntu1", "nova"), exampleHostAggregate());
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(200).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.delete("1"));
|
assertTrue(api.delete("1"));
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(404).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertFalse(api.delete("1"));
|
assertFalse(api.delete("1"));
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("POST")
|
authenticatedGET().endpoint(endpoint).method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"newaggregatename\"}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"newaggregatename\"}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.updateName("1", "newaggregatename"), exampleHostAggregate());
|
assertEquals(api.updateName("1", "newaggregatename"), exampleHostAggregate());
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("POST")
|
authenticatedGET().endpoint(endpoint).method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"aggregate\":{\"availability_zone\":\"zone1\"}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"aggregate\":{\"availability_zone\":\"zone1\"}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.updateAvailabilityZone("1", "zone1"), exampleHostAggregate());
|
assertEquals(api.updateAvailabilityZone("1", "zone1"), exampleHostAggregate());
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("POST")
|
authenticatedGET().endpoint(endpoint).method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"add_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"add_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.addHost("1", "ubuntu"), exampleHostAggregate());
|
assertEquals(api.addHost("1", "ubuntu"), exampleHostAggregate());
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("POST")
|
authenticatedGET().endpoint(endpoint).method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"remove_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"remove_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.removeHost("1", "ubuntu"), exampleHostAggregate());
|
assertEquals(api.removeHost("1", "ubuntu"), exampleHostAggregate());
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).method("POST")
|
authenticatedGET().endpoint(endpoint).method("POST")
|
||||||
.payload(payloadFromStringWithContentType("{\"set_metadata\":{\"metadata\":{\"mykey\":\"some value or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
.payload(payloadFromStringWithContentType("{\"set_metadata\":{\"metadata\":{\"mykey\":\"some value or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.setMetadata("1", ImmutableMap.of("mykey", "some value or other")), exampleHostAggregate());
|
assertEquals(api.setMetadata("1", ImmutableMap.of("mykey", "some value or other")), exampleHostAggregate());
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
String region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
apiOption = api.getHostAggregateExtensionForZone(zone);
|
apiOption = api.getHostAggregateApi(region);
|
||||||
hostAdminOption = api.getHostAdministrationExtensionForZone(zone);
|
hostAdminOption = api.getHostAdministrationApi(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
@ -99,7 +99,7 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
)) {
|
)) {
|
||||||
// Apply changes
|
// Apply changes
|
||||||
HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData);
|
HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData);
|
||||||
|
|
||||||
// bug in openstack - metadata values are never removed, so we just checking what we've set
|
// bug in openstack - metadata values are never removed, so we just checking what we've set
|
||||||
for (Map.Entry<String, String> entry : theMetaData.entrySet()) {
|
for (Map.Entry<String, String> entry : theMetaData.entrySet()) {
|
||||||
assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue());
|
assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue());
|
||||||
|
|
|
@ -50,10 +50,10 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
|
||||||
|
|
||||||
// NOTE this required a change to the KeyPair domain object toString method
|
// NOTE this required a change to the KeyPair domain object toString method
|
||||||
assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().list().toString(),
|
assertEquals(apiWhenServersExist.getKeyPairApi("az-1.region-a.geo-1").get().list().toString(),
|
||||||
new ParseKeyPairListTest().expected().toString());
|
new ParseKeyPairListTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||||
|
|
||||||
assertTrue(apiWhenNoServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().list().isEmpty());
|
assertTrue(apiWhenNoServersExist.getKeyPairApi("az-1.region-a.geo-1").get().list().isEmpty());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().create("testkeypair")
|
assertEquals(apiWhenServersExist.getKeyPairApi("az-1.region-a.geo-1").get().create("testkeypair")
|
||||||
.toString(), new ParseKeyPairTest().expected().toString());
|
.toString(), new ParseKeyPairTest().expected().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
apiWhenServersExist
|
apiWhenServersExist
|
||||||
.getKeyPairExtensionForZone("az-1.region-a.geo-1")
|
.getKeyPairApi("az-1.region-a.geo-1")
|
||||||
.get()
|
.get()
|
||||||
.createWithPublicKey(
|
.createWithPublicKey(
|
||||||
"testkeypair",
|
"testkeypair",
|
||||||
|
@ -136,7 +136,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, delete, deleteResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, delete, deleteResponse);
|
||||||
|
|
||||||
assertTrue(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().delete("testkeypair"));
|
assertTrue(apiWhenServersExist.getKeyPairApi("az-1.region-a.geo-1").get().delete("testkeypair"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetKeyPairWhenResponseIs2xx() throws Exception {
|
public void testGetKeyPairWhenResponseIs2xx() throws Exception {
|
||||||
|
@ -153,7 +153,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
||||||
|
|
||||||
assertEquals(apiWhenKeyPairExists.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().get("testkeypair"),
|
assertEquals(apiWhenKeyPairExists.getKeyPairApi("az-1.region-a.geo-1").get().get("testkeypair"),
|
||||||
new ParseKeyPairTest().expected());
|
new ParseKeyPairTest().expected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +170,6 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
NovaApi apiWhenNoKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
NovaApi apiWhenNoKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
||||||
|
|
||||||
assertNull(apiWhenNoKeyPairExists.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().get("testkeypair"));
|
assertNull(apiWhenNoKeyPairExists.getKeyPairApi("az-1.region-a.geo-1").get().get("testkeypair"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,16 +35,16 @@ public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
|
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
|
||||||
|
|
||||||
public void testListKeyPairs() throws Exception {
|
public void testListKeyPairs() throws Exception {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
|
KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get();
|
||||||
FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
|
FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
|
||||||
assertNotNull(keyPairsList);
|
assertNotNull(keyPairsList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateAndGetAndDeleteKeyPair() throws Exception {
|
public void testCreateAndGetAndDeleteKeyPair() throws Exception {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
|
KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get();
|
||||||
KeyPair createdKeyPair = null;
|
KeyPair createdKeyPair = null;
|
||||||
try {
|
try {
|
||||||
createdKeyPair = keyPairApi.create(KEYPAIR_NAME);
|
createdKeyPair = keyPairApi.create(KEYPAIR_NAME);
|
||||||
|
@ -63,8 +63,8 @@ public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
|
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
|
||||||
for (String zoneId : api.getConfiguredZones()) {
|
for (String regionId : api.getConfiguredRegions()) {
|
||||||
KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
|
KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get();
|
||||||
KeyPair createdKeyPair = null;
|
KeyPair createdKeyPair = null;
|
||||||
try {
|
try {
|
||||||
createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
|
createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.getByTenant("demo"), getTestQuotas());
|
assertEquals(api.getByTenant("demo"), getTestQuotas());
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(404).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||||
assertNull(api.getByTenant("demo"));
|
assertNull(api.getByTenant("demo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertEquals(api.getDefaultsForTenant("demo"), getTestQuotas());
|
assertEquals(api.getDefaultsForTenant("demo"), getTestQuotas());
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||||
authenticatedGET().endpoint(endpoint).build(),
|
authenticatedGET().endpoint(endpoint).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(404).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||||
assertNull(api.getDefaultsForTenant("demo"));
|
assertNull(api.getDefaultsForTenant("demo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(200).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(200).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
assertTrue(api.updateQuotaOfTenant(getTestQuotas(), "demo"));
|
assertTrue(api.updateQuotaOfTenant(getTestQuotas(), "demo"));
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON))
|
.payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON))
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
|
HttpResponse.builder().statusCode(404).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||||
|
|
||||||
api.updateQuotaOfTenant(getTestQuotas(), "demo");
|
api.updateQuotaOfTenant(getTestQuotas(), "demo");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class QuotaApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
tenant = identity.split(":")[0];
|
tenant = identity.split(":")[0];
|
||||||
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
String region = Iterables.getLast(api.getConfiguredRegions(), "nova");
|
||||||
apiOption = api.getQuotaExtensionForZone(zone);
|
apiOption = api.getQuotaApi(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetQuotasForCurrentTenant() {
|
public void testGetQuotasForCurrentTenant() {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue