Issue 1022:Move naming convention to Api from Client or Services:: glesys jenkins openstack-* opsource-servers savvis-symphonyvpdc cloudwatch cloudidentity rackspace-cloudidentity aws-cloudwatch rackspace-cloudservers-us hpcloud-compute rackspace-cloudservers-us trystack-nova

This commit is contained in:
Adrian Cole 2012-07-15 15:00:42 -07:00
parent b49f2e99c7
commit 180265fe49
453 changed files with 3666 additions and 3656 deletions

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.jclouds.cloudwatch.domain.Metric;
import org.jclouds.cloudwatch.domain.MetricDatum;
import org.jclouds.cloudwatch.features.MetricClient;
import org.jclouds.cloudwatch.features.MetricApi;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
import org.jclouds.collect.PaginatedIterable;
import org.jclouds.collect.PaginatedIterables;
@ -40,17 +40,17 @@ public class CloudWatch {
/**
* List metrics based on the criteria in the {@link ListMetricsOptions} passed in.
*
* @param metricClient the {@link MetricClient} to use for the request
* @param metricApi the {@link MetricApi} to use for the request
* @param options the {@link ListMetricsOptions} describing the ListMetrics request
*
* @return iterable of metrics fitting the criteria
*/
public static Iterable<Metric> listMetrics(final MetricClient metricClient, final ListMetricsOptions options) {
return PaginatedIterables.lazyContinue(metricClient.list(options), new Function<Object, PaginatedIterable<Metric>>() {
public static Iterable<Metric> listMetrics(final MetricApi metricApi, final ListMetricsOptions options) {
return PaginatedIterables.lazyContinue(metricApi.list(options), new Function<Object, PaginatedIterable<Metric>>() {
@Override
public PaginatedIterable<Metric> apply(Object input) {
return metricClient.list(options.clone().afterMarker(input));
return metricApi.list(options.clone().afterMarker(input));
}
@Override
@ -63,31 +63,31 @@ public class CloudWatch {
/**
* List metrics based on the criteria in the {@link ListMetricsOptions} passed in.
*
* @param cloudWatchClient the {@link CloudWatchClient} to use for the request
* @param cloudWatchApi the {@link CloudWatchApi} to use for the request
* @param region the region to list metrics in
* @param options the options describing the ListMetrics request
*
* @return iterable of metrics fitting the criteria
*/
public static Iterable<Metric> listMetrics(CloudWatchClient cloudWatchClient, String region,
public static Iterable<Metric> listMetrics(CloudWatchApi cloudWatchApi, String region,
final ListMetricsOptions options) {
return listMetrics(cloudWatchClient.getMetricClientForRegion(region), options);
return listMetrics(cloudWatchApi.getMetricApiForRegion(region), options);
}
/**
* Pushes metrics to CloudWatch.
*
* @param cloudWatchClient the {@link CloudWatchClient} to use for the request
* @param cloudWatchApi the {@link CloudWatchApi} to use for the request
* @param region the region to put the metrics in
* @param metrics the metrics to publish
* @param namespace the namespace to publish the metrics in
*/
public static void putMetricData(CloudWatchClient cloudWatchClient, String region, Iterable<MetricDatum> metrics,
public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics,
String namespace) {
MetricClient metricClient = cloudWatchClient.getMetricClientForRegion(region);
MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region);
for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) {
metricClient.putMetricsInNamespace(slice, namespace);
metricApi.putMetricsInNamespace(slice, namespace);
}
}

View File

@ -21,7 +21,7 @@ package org.jclouds.cloudwatch;
import com.google.inject.Provides;
import org.jclouds.cloudwatch.domain.Datapoint;
import org.jclouds.cloudwatch.domain.Statistics;
import org.jclouds.cloudwatch.features.MetricClient;
import org.jclouds.cloudwatch.features.MetricApi;
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.concurrent.Timeout;
import org.jclouds.javax.annotation.Nullable;
@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
* @author Adrian Cole
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface CloudWatchClient {
public interface CloudWatchApi {
/**
*
* @return the Region codes configured
@ -89,7 +89,7 @@ public interface CloudWatchClient {
* The statistics to be returned for the given metric. ex. Average
* @param options
* more filtering options (e.g. instance ID)
* @see MetricClient#getMetricStatistics(org.jclouds.cloudwatch.domain.GetMetricStatistics)
* @see MetricApi#getMetricStatistics(org.jclouds.cloudwatch.domain.GetMetricStatistics)
*/
@Deprecated
Set<Datapoint> getMetricStatisticsInRegion(@Nullable String region, String metricName, String namespace,
@ -99,11 +99,11 @@ public interface CloudWatchClient {
* Provides synchronous access to Metric features.
*/
@Delegate
MetricClient getMetricClient();
MetricApi getMetricApi();
/**
* Provides synchronous access to Metric features.
*/
@Delegate
MetricClient getMetricClientForRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
MetricApi getMetricApiForRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
}

View File

@ -41,7 +41,7 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 3450830053589179249L;
public static final TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>>() {
public static final TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@ -51,7 +51,7 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
}
public CloudWatchApiMetadata() {
this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class));
this(new Builder(CloudWatchApi.class, CloudWatchAsyncApi.class));
}
protected CloudWatchApiMetadata(Builder builder) {
@ -67,8 +67,8 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder(Class<?> client, Class<?> asyncClient) {
super(client, asyncClient);
protected Builder(Class<?> api, Class<?> asyncApi) {
super(api, asyncApi);
id("cloudwatch")
.name("Amazon CloudWatch Api")
.identityName("Access Key ID")
@ -92,4 +92,4 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
}
}
}
}

View File

@ -28,7 +28,7 @@ import javax.ws.rs.Path;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.cloudwatch.domain.Datapoint;
import org.jclouds.cloudwatch.domain.Statistics;
import org.jclouds.cloudwatch.features.MetricAsyncClient;
import org.jclouds.cloudwatch.features.MetricAsyncApi;
import org.jclouds.cloudwatch.functions.ISO8601Format;
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler;
@ -57,7 +57,7 @@ import com.google.inject.Provides;
*/
@RequestFilters(FormSigner.class)
@VirtualHost
public interface CloudWatchAsyncClient {
public interface CloudWatchAsyncApi {
/**
*
* @return the Region codes configured
@ -67,7 +67,7 @@ public interface CloudWatchAsyncClient {
Set<String> getConfiguredRegions();
/**
* @see MetricAsyncClient#getMetricStatistics
* @see MetricAsyncApi#getMetricStatistics
*/
@Deprecated
@POST
@ -88,9 +88,9 @@ public interface CloudWatchAsyncClient {
* Provides asynchronous access to Metric features.
*/
@Delegate
MetricAsyncClient getMetricClient();
MetricAsyncApi getMetricApi();
@Delegate
MetricAsyncClient getMetricClientForRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
MetricAsyncApi getMetricApiForRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
}

View File

@ -87,4 +87,4 @@ public class GetMetricStatisticsBinder implements org.jclouds.rest.Binder {
return (R) request.toBuilder().replaceFormParams(formParameters.build()).build();
}
}
}

View File

@ -21,10 +21,10 @@ package org.jclouds.cloudwatch.config;
import java.util.Map;
import org.jclouds.aws.config.FormSigningRestClientModule;
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
import org.jclouds.cloudwatch.CloudWatchClient;
import org.jclouds.cloudwatch.features.MetricAsyncClient;
import org.jclouds.cloudwatch.features.MetricClient;
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
import org.jclouds.cloudwatch.CloudWatchApi;
import org.jclouds.cloudwatch.features.MetricAsyncApi;
import org.jclouds.cloudwatch.features.MetricApi;
import org.jclouds.rest.ConfiguresRestClient;
import com.google.common.collect.ImmutableMap;
@ -36,13 +36,13 @@ import com.google.common.reflect.TypeToken;
* @author Adrian Cole
*/
@ConfiguresRestClient
public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchClient, CloudWatchAsyncClient> {
public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchApi, CloudWatchAsyncApi> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(MetricClient.class, MetricAsyncClient.class)
.put(MetricApi.class, MetricAsyncApi.class)
.build();
public CloudWatchRestClientModule() {
super(TypeToken.of(CloudWatchClient.class), TypeToken.of(CloudWatchAsyncClient.class), DELEGATE_MAP);
super(TypeToken.of(CloudWatchApi.class), TypeToken.of(CloudWatchAsyncApi.class), DELEGATE_MAP);
}
}

View File

@ -37,7 +37,7 @@ import org.jclouds.concurrent.Timeout;
* @author Jeremy Whitlock
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface MetricClient {
public interface MetricApi {
/**
* Returns a list of valid metrics stored for the AWS account owner.
@ -47,7 +47,7 @@ public interface MetricClient {
* use returned NextToken (
* {@link org.jclouds.cloudwatch.domain.ListMetricsResponse#getNextToken()}) value with
* subsequent calls .To retrieve all available metrics with one call, use
* {@link org.jclouds.cloudwatch.CloudWatch#listMetrics(MetricClient,
* {@link org.jclouds.cloudwatch.CloudWatch#listMetrics(MetricApi,
* org.jclouds.cloudwatch.options.ListMetricsOptions)}
*
* @param options the options describing the metrics query

View File

@ -51,10 +51,10 @@ import com.google.common.util.concurrent.ListenableFuture;
*/
@RequestFilters(FormSigner.class)
@VirtualHost
public interface MetricAsyncClient {
public interface MetricAsyncApi {
/**
* @see MetricClient#list()
* @see MetricApi#list()
*/
@POST
@Path("/")
@ -63,7 +63,7 @@ public interface MetricAsyncClient {
ListenableFuture<? extends PaginatedIterable<Metric>> list();
/**
* @see MetricClient#list(ListMetricsOptions)
* @see MetricApi#list(ListMetricsOptions)
*/
@POST
@Path("/")
@ -72,7 +72,7 @@ public interface MetricAsyncClient {
ListenableFuture<? extends PaginatedIterable<Metric>> list(ListMetricsOptions options);
/**
* @see MetricClient#getMetricStatistics(GetMetricStatistics)
* @see MetricApi#getMetricStatistics(GetMetricStatistics)
*/
@POST
@Path("/")
@ -82,7 +82,7 @@ public interface MetricAsyncClient {
@BinderParam(GetMetricStatisticsBinder.class) GetMetricStatistics statistics);
/**
* @see MetricClient#getMetricStatistics(GetMetricStatistics, GetMetricStatisticsOptions)
* @see MetricApi#getMetricStatistics(GetMetricStatistics, GetMetricStatisticsOptions)
*/
@POST
@Path("/")
@ -93,7 +93,7 @@ public interface MetricAsyncClient {
GetMetricStatisticsOptions options);
/**
* @see MetricClient#putMetricsInNamespace(Iterable, String)
* @see MetricApi#putMetricsInNamespace(Iterable, String)
*/
@POST
@Path("/")

View File

@ -36,24 +36,24 @@ import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/**
* Tests behavior of {@code CloudWatchClient}
* Tests behavior of {@code CloudWatchApi}
*
* @author Adrian Cole
*/
@Test(groups = "live", testName ="CloudWatchClientLiveTest", singleThreaded = true)
@Test(groups = "live", testName ="CloudWatchApiLiveTest", singleThreaded = true)
@Deprecated
public class CloudWatchClientLiveTest extends BaseContextLiveTest<RestContext<CloudWatchClient, CloudWatchAsyncClient>> {
public CloudWatchClientLiveTest() {
public class CloudWatchApiLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
public CloudWatchApiLiveTest() {
provider = "cloudwatch";
}
private CloudWatchClient client;
private CloudWatchApi api;
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
client = context.getApi();
api = context.getApi();
}
@ -61,14 +61,14 @@ public class CloudWatchClientLiveTest extends BaseContextLiveTest<RestContext<Cl
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(region, "CPUUtilization", "AWS/EC2",
Set<Datapoint> datapoints = api.getMetricStatisticsInRegion(region, "CPUUtilization", "AWS/EC2",
cal.getTime(), new Date(), 180, Statistics.AVERAGE, GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT));
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
}
@Override
protected TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> contextType() {
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
return CloudWatchApiMetadata.CONTEXT_TOKEN;
}

View File

@ -40,7 +40,7 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.location.config.LocationModule;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.BaseAsyncApiTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Suppliers2;
import org.testng.annotations.Test;
@ -51,19 +51,19 @@ import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* Tests behavior of {@code CloudWatchAsyncClient}
* Tests behavior of {@code CloudWatchAsyncApi}
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "CloudWatchAsyncClientTest")
@Test(groups = "unit", testName = "CloudWatchAsyncApiTest")
@Deprecated
public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsyncClient> {
public class CloudWatchAsyncApiTest extends BaseAsyncApiTest<CloudWatchAsyncApi> {
public void testRegisterInstancesWithMeasure() throws SecurityException, NoSuchMethodException, IOException {
Date date = new Date(10000000l);
Method method = CloudWatchAsyncClient.class.getMethod("getMetricStatisticsInRegion", String.class, String.class,
Method method = CloudWatchAsyncApi.class.getMethod("getMetricStatisticsInRegion", String.class, String.class,
String.class, Date.class, Date.class, int.class, Statistics.class, GetMetricStatisticsOptions[].class);
HttpRequest request = processor.createRequest(method, (String) null, "CPUUtilization", "AWS/EC2", date, date, 60,
Statistics.AVERAGE, GetMetricStatisticsOptions.Builder.instanceId("i-12312313"));
@ -83,8 +83,8 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy
}
@Override
protected TypeLiteral<RestAnnotationProcessor<CloudWatchAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<CloudWatchAsyncClient>>() {
protected TypeLiteral<RestAnnotationProcessor<CloudWatchAsyncApi>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<CloudWatchAsyncApi>>() {
};
}

View File

@ -44,30 +44,30 @@ import static com.google.common.base.Preconditions.checkArgument;
*
* @author Jeremy Whitlock
*/
public class CloudWatchLiveTest extends BaseContextLiveTest<RestContext<CloudWatchClient, CloudWatchAsyncClient>> {
public class CloudWatchLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
public CloudWatchLiveTest() {
provider = "cloudwatch";
}
private CloudWatchClient client;
private CloudWatchApi api;
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
client = context.getApi();
api = context.getApi();
}
@Override
protected TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> contextType() {
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
return CloudWatchApiMetadata.CONTEXT_TOKEN;
}
@Test
protected void testCloudWatchListMetrics() {
// Just make sure there is at least one metric returned (Much better if the account you use has more than 500)
checkArgument(CloudWatch.listMetrics(client, null, new ListMetricsOptions()).iterator().hasNext());
checkArgument(CloudWatch.listMetrics(api, null, new ListMetricsOptions()).iterator().hasNext());
}
@Test
@ -87,14 +87,14 @@ public class CloudWatchLiveTest extends BaseContextLiveTest<RestContext<CloudWat
.build());
}
CloudWatch.putMetricData(client, null, metrics, namespace);
CloudWatch.putMetricData(api, null, metrics, namespace);
ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
.dimension(new Dimension("BaseMetricName", metricName));
boolean success = new RetryablePredicate<ListMetricsOptions>(new Predicate<ListMetricsOptions>() {
@Override
public boolean apply(ListMetricsOptions options) {
return Iterables.size(CloudWatch.listMetrics(client, null, options)) == 11;
return Iterables.size(CloudWatch.listMetrics(api, null, options)) == 11;
}
}, 20, 1, TimeUnit.MINUTES).apply(lmo);

View File

@ -28,7 +28,7 @@ import java.util.Set;
import org.easymock.EasyMock;
import org.jclouds.cloudwatch.domain.Metric;
import org.jclouds.cloudwatch.domain.MetricDatum;
import org.jclouds.cloudwatch.features.MetricClient;
import org.jclouds.cloudwatch.features.MetricApi;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
import org.jclouds.collect.PaginatedIterable;
import org.jclouds.collect.PaginatedIterables;
@ -48,72 +48,72 @@ import com.google.common.collect.Sets;
public class CloudWatchTest {
/**
* Tests {@link CloudWatch#listMetrics(CloudWatchClient, String, org.jclouds.cloudwatch.options.ListMetricsOptions)}
* Tests {@link CloudWatch#listMetrics(CloudWatchApi, String, org.jclouds.cloudwatch.options.ListMetricsOptions)}
* where a single response returns all results.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testSinglePageResult() throws Exception {
CloudWatchClient client = createMock(CloudWatchClient.class);
MetricClient metricClient = createMock(MetricClient.class);
CloudWatchApi api = createMock(CloudWatchApi.class);
MetricApi metricApi = createMock(MetricApi.class);
ListMetricsOptions options = new ListMetricsOptions();
PaginatedIterable<Metric> response = PaginatedIterables.forwardWithMarker(ImmutableSet.of(createMock(Metric.class)), null);
expect(client.getMetricClientForRegion(null))
.andReturn(metricClient)
expect(api.getMetricApiForRegion(null))
.andReturn(metricApi)
.atLeastOnce();
expect(metricClient.list(options))
expect(metricApi.list(options))
.andReturn(response)
.once();
EasyMock.replay(client, metricClient);
EasyMock.replay(api, metricApi);
Assert.assertEquals(1, Iterables.size(CloudWatch.listMetrics(client, null, options)));
Assert.assertEquals(1, Iterables.size(CloudWatch.listMetrics(api, null, options)));
}
/**
* Tests {@link CloudWatch#listMetrics(CloudWatchClient, String, org.jclouds.cloudwatch.options.ListMetricsOptions)}
* Tests {@link CloudWatch#listMetrics(CloudWatchApi, String, org.jclouds.cloudwatch.options.ListMetricsOptions)}
* where retrieving all results requires multiple requests.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testMultiPageResult() throws Exception {
CloudWatchClient client = createMock(CloudWatchClient.class);
MetricClient metricClient = createMock(MetricClient.class);
CloudWatchApi api = createMock(CloudWatchApi.class);
MetricApi metricApi = createMock(MetricApi.class);
ListMetricsOptions options = new ListMetricsOptions();
PaginatedIterable<Metric> response1 = PaginatedIterables.forwardWithMarker(ImmutableSet.of(createMock(Metric.class)), "NEXTTOKEN");
PaginatedIterable<Metric> response2 = PaginatedIterables.forwardWithMarker(ImmutableSet.of(createMock(Metric.class)), null);
// Using EasyMock.eq("") because EasyMock makes it impossible to pass null as a String value here
expect(client.getMetricClientForRegion(EasyMock.eq("")))
.andReturn(metricClient)
expect(api.getMetricApiForRegion(EasyMock.eq("")))
.andReturn(metricApi)
.atLeastOnce();
expect(metricClient.list(anyObject(ListMetricsOptions.class)))
expect(metricApi.list(anyObject(ListMetricsOptions.class)))
.andReturn(response1)
.once();
expect(metricClient.list(anyObject(ListMetricsOptions.class)))
expect(metricApi.list(anyObject(ListMetricsOptions.class)))
.andReturn(response2)
.once();
EasyMock.replay(client, metricClient);
EasyMock.replay(api, metricApi);
Assert.assertEquals(2, Iterables.size(CloudWatch.listMetrics(client, "", options)));
Assert.assertEquals(2, Iterables.size(CloudWatch.listMetrics(api, "", options)));
}
/**
* Tests {@link CloudWatch#putMetricData(CloudWatchClient, String, Iterable, String)} where the set of metrics is
* Tests {@link CloudWatch#putMetricData(CloudWatchApi, String, Iterable, String)} where the set of metrics is
* greater than 10.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testPutMetricData() throws Exception {
CloudWatchClient client = createMock(CloudWatchClient.class);
MetricClient metricClient = createMock(MetricClient.class);
CloudWatchApi api = createMock(CloudWatchApi.class);
MetricApi metricApi = createMock(MetricApi.class);
Set<MetricDatum> metrics = Sets.newLinkedHashSet();
String namespace = "JCLOUDS/Test";
@ -122,19 +122,19 @@ public class CloudWatchTest {
}
// Using EasyMock.eq("") because EasyMock makes it impossible to pass null as a String value here
expect(client.getMetricClientForRegion(EasyMock.eq("")))
.andReturn(metricClient)
expect(api.getMetricApiForRegion(EasyMock.eq("")))
.andReturn(metricApi)
.atLeastOnce();
for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) {
metricClient.putMetricsInNamespace(slice, namespace);
metricApi.putMetricsInNamespace(slice, namespace);
}
EasyMock.replay(client, metricClient);
EasyMock.replay(api, metricApi);
CloudWatch.putMetricData(client, "", metrics, namespace);
CloudWatch.putMetricData(api, "", metrics, namespace);
EasyMock.verify(metricClient);
EasyMock.verify(metricApi);
}
}

View File

@ -23,14 +23,14 @@ import static org.testng.Assert.assertEquals;
import java.util.Date;
import java.util.TimeZone;
import org.jclouds.cloudwatch.CloudWatchClient;
import org.jclouds.cloudwatch.CloudWatchApi;
import org.jclouds.cloudwatch.domain.Dimension;
import org.jclouds.cloudwatch.domain.EC2Constants;
import org.jclouds.cloudwatch.domain.GetMetricStatistics;
import org.jclouds.cloudwatch.domain.Namespaces;
import org.jclouds.cloudwatch.domain.Statistics;
import org.jclouds.cloudwatch.domain.Unit;
import org.jclouds.cloudwatch.internal.BaseCloudWatchClientExpectTest;
import org.jclouds.cloudwatch.internal.BaseCloudWatchApiExpectTest;
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
import org.jclouds.http.HttpRequest;
@ -41,10 +41,10 @@ import org.testng.annotations.Test;
/**
* @author Jeremy Whitlock, Adrian Cole
*/
@Test(groups = "unit", testName = "MetricClientExpectTest")
public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
@Test(groups = "unit", testName = "MetricApiExpectTest")
public class MetricApiExpectTest extends BaseCloudWatchApiExpectTest {
public MetricClientExpectTest() {
public MetricApiExpectTest() {
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
}
@ -69,10 +69,10 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
HttpResponse listMetricsResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/list_metrics.xml", "text/xml")).build();
CloudWatchClient clientWhenMetricsExist = requestSendsResponse(
CloudWatchApi apiWhenMetricsExist = requestSendsResponse(
listMetrics, listMetricsResponse);
assertEquals(clientWhenMetricsExist.getMetricClientForRegion(null).list().toString(),
assertEquals(apiWhenMetricsExist.getMetricApiForRegion(null).list().toString(),
"{elements=[Metric{namespace=AWS/EC2, metricName=CPUUtilization, dimension=[Dimension{name=InstanceId, value=i-689fcf0f}]}], marker=null}");
}
@ -82,10 +82,10 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
HttpResponse listMetricsResponse = HttpResponse.builder().statusCode(404).build();
CloudWatchClient clientWhenMetricsDontExist = requestSendsResponse(
CloudWatchApi apiWhenMetricsDontExist = requestSendsResponse(
listMetrics, listMetricsResponse);
clientWhenMetricsDontExist.getMetricClientForRegion(null).list();
apiWhenMetricsDontExist.getMetricApiForRegion(null).list();
}
public void testListMetricsWithOptionsWhenResponseIs2xx() throws Exception {
@ -113,11 +113,11 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
HttpResponse listMetricsWithOptionsResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/list_metrics.xml", "text/xml")).build();
CloudWatchClient clientWhenMetricsWithOptionsExist = requestSendsResponse(listMetricsWithOptions,
CloudWatchApi apiWhenMetricsWithOptionsExist = requestSendsResponse(listMetricsWithOptions,
listMetricsWithOptionsResponse);
assertEquals(
clientWhenMetricsWithOptionsExist.getMetricClientForRegion(null).list(
apiWhenMetricsWithOptionsExist.getMetricApiForRegion(null).list(
ListMetricsOptions.Builder
.dimension(new Dimension(EC2Constants.Dimension.INSTANCE_ID,
"SOMEINSTANCEID"))
@ -166,10 +166,10 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
HttpResponse getMetricStatisticsResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/get_metric_statistics.xml", "text/xml")).build();
CloudWatchClient clientWhenMetricsExist = requestSendsResponse(getMetricStatistics, getMetricStatisticsResponse);
CloudWatchApi apiWhenMetricsExist = requestSendsResponse(getMetricStatistics, getMetricStatisticsResponse);
assertEquals(
clientWhenMetricsExist.getMetricClientForRegion(null).getMetricStatistics(stats).toString(),
apiWhenMetricsExist.getMetricApiForRegion(null).getMetricStatistics(stats).toString(),
// TODO: make an object for this
"GetMetricStatisticsResponse{label=CPUUtilization, " +
"datapoints=[Datapoint{timestamp=Thu Jan 15 16:00:00 PST 2009, customUnit=null, maximum=null, " +
@ -184,9 +184,9 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
HttpResponse getMetricStatisticsResponse = HttpResponse.builder().statusCode(404).build();
CloudWatchClient clientWhenMetricsDontExist = requestSendsResponse(getMetricStatistics, getMetricStatisticsResponse);
CloudWatchApi apiWhenMetricsDontExist = requestSendsResponse(getMetricStatistics, getMetricStatisticsResponse);
clientWhenMetricsDontExist.getMetricClientForRegion(null).getMetricStatistics(stats);
apiWhenMetricsDontExist.getMetricApiForRegion(null).getMetricStatistics(stats);
}
public void testGetMetricStatisticsWithOptionsWhenResponseIs2xx() throws Exception {
@ -221,13 +221,13 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
HttpResponse getMetricStatisticsResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/get_metric_statistics.xml", "text/xml")).build();
CloudWatchClient clientWhenMetricsExist = requestSendsResponse(getMetricStatistics, getMetricStatisticsResponse);
CloudWatchApi apiWhenMetricsExist = requestSendsResponse(getMetricStatistics, getMetricStatisticsResponse);
Dimension dimension1 = new Dimension(EC2Constants.Dimension.INSTANCE_ID, "SOMEINSTANCEID");
Dimension dimension2 = new Dimension(EC2Constants.Dimension.INSTANCE_TYPE, "t1.micro");
assertEquals(
clientWhenMetricsExist.getMetricClientForRegion(null).getMetricStatistics(stats,
apiWhenMetricsExist.getMetricApiForRegion(null).getMetricStatistics(stats,
GetMetricStatisticsOptions.Builder.dimension(dimension1).dimension(dimension2)).toString(),
// TODO: make an object for this
"GetMetricStatisticsResponse{label=CPUUtilization, " +

View File

@ -37,7 +37,7 @@ import org.jclouds.cloudwatch.domain.Namespaces;
import org.jclouds.cloudwatch.domain.StatisticValues;
import org.jclouds.cloudwatch.domain.Statistics;
import org.jclouds.cloudwatch.domain.Unit;
import org.jclouds.cloudwatch.internal.BaseCloudWatchClientLiveTest;
import org.jclouds.cloudwatch.internal.BaseCloudWatchApiLiveTest;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
import org.jclouds.collect.PaginatedIterable;
import org.jclouds.predicates.RetryablePredicate;
@ -51,8 +51,8 @@ import com.google.common.collect.Iterables;
/**
* @author Jeremy Whitlock, Adrian Cole
*/
@Test(groups = "live", testName = "MetricClientLiveTest")
public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
@Test(groups = "live", testName = "MetricApiLiveTest")
public class MetricApiLiveTest extends BaseCloudWatchApiLiveTest {
@Test
protected void testPutMetricData() throws Exception {
@ -84,14 +84,14 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
.value(10.0)
.build();
client().putMetricsInNamespace(ImmutableSet.of(metricDatum, metricDatum2), namespace);
api().putMetricsInNamespace(ImmutableSet.of(metricDatum, metricDatum2), namespace);
ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
.dimension(new Dimension("BaseMetricName", metricName));
boolean success = new RetryablePredicate<ListMetricsOptions>(new Predicate<ListMetricsOptions>() {
@Override
public boolean apply(ListMetricsOptions options) {
return Iterables.size(client().list(options)) == 2;
return Iterables.size(api().list(options)) == 2;
}
}, 20, 1, TimeUnit.MINUTES).apply(lmo);
@ -99,7 +99,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
Assert.fail("Unable to gather the created CloudWatch data within the time (20m) allotted.");
}
PaginatedIterable<Metric> lmr = client().list(lmo);
PaginatedIterable<Metric> lmr = api().list(lmo);
Date endTime = new Date(metricTimestampInCloudWatch.getTime() + (60 * 1000)); // Pad a minute just in case
Date startTime = new Date(metricTimestampInCloudWatch.getTime() - (60 * 1000)); // Pad a minute just in case
@ -117,7 +117,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
.startTime(startTime)
.unit(Unit.COUNT)
.build();
GetMetricStatisticsResponse gmr = client().getMetricStatistics(gms);
GetMetricStatisticsResponse gmr = api().getMetricStatistics(gms);
Assert.assertEquals(1, Iterables.size(gmr));
@ -145,7 +145,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
// TODO: change this test to retrieve pre-seeded custom metrics
@Test
protected void testGetMetricStatistics() {
PaginatedIterable<Metric> metricsResponse = client().list();
PaginatedIterable<Metric> metricsResponse = api().list();
// Walk through all datapoints in all metrics until we find a metric datapoint that returns statistics
if (Iterables.size(metricsResponse) > 0) {
@ -170,7 +170,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
.statistics(ImmutableSet.of(Statistics.MAXIMUM,
Statistics.MINIMUM))
.unit(Unit.PERCENT).build();
GetMetricStatisticsResponse response = client().getMetricStatistics(options);
GetMetricStatisticsResponse response = api().getMetricStatistics(options);
if (response.size() > 0) {
checkNotNull(response.getLabel());
@ -202,7 +202,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
String testDimensionValue = "t1.micro";
// Test an empty request (pulls all stored metric options across all products)
response = client().list();
response = api().list();
performDefaultMetricsTests(response);
@ -236,12 +236,12 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
}
// Test with a NextToken, even if it's null
response = client().list(ListMetricsOptions.Builder.afterMarker(response.getNextMarker().toString()));
response = api().list(ListMetricsOptions.Builder.afterMarker(response.getNextMarker().toString()));
performDefaultMetricsTests(response);
// Test with a Namespace
response = client().list(ListMetricsOptions.Builder.namespace(testNamespace));
response = api().list(ListMetricsOptions.Builder.namespace(testNamespace));
performDefaultMetricsTests(response);
@ -251,7 +251,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
}
// Test with a MetricName
response = client().list(ListMetricsOptions.Builder.metricName(testMetricName));
response = api().list(ListMetricsOptions.Builder.metricName(testMetricName));
performDefaultMetricsTests(response);
@ -264,7 +264,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
if (testDimensionName != null) {
Dimension testDimension = new Dimension(testDimensionName, testDimensionValue);
response = client().list(ListMetricsOptions.Builder.dimension(testDimension));
response = api().list(ListMetricsOptions.Builder.dimension(testDimension));
performDefaultMetricsTests(response);
@ -303,7 +303,7 @@ public class MetricClientLiveTest extends BaseCloudWatchClientLiveTest {
}
}
protected MetricClient client() {
return context.getApi().getMetricClientForRegion(null);
protected MetricApi api() {
return context.getApi().getMetricApiForRegion(null);
}
}

View File

@ -18,12 +18,12 @@
*/
package org.jclouds.cloudwatch.internal;
import org.jclouds.cloudwatch.CloudWatchClient;
import org.jclouds.cloudwatch.CloudWatchApi;
/**
*
* @author Adrian Cole
*/
public class BaseCloudWatchClientExpectTest extends BaseCloudWatchExpectTest<CloudWatchClient> {
public class BaseCloudWatchApiExpectTest extends BaseCloudWatchExpectTest<CloudWatchApi> {
}

View File

@ -20,8 +20,8 @@ package org.jclouds.cloudwatch.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.cloudwatch.CloudWatchApiMetadata;
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
import org.jclouds.cloudwatch.CloudWatchClient;
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
import org.jclouds.cloudwatch.CloudWatchApi;
import org.jclouds.rest.RestContext;
import org.testng.annotations.Test;
@ -32,14 +32,14 @@ import com.google.common.reflect.TypeToken;
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseCloudWatchClientLiveTest extends BaseContextLiveTest<RestContext<CloudWatchClient, CloudWatchAsyncClient>> {
public class BaseCloudWatchApiLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
public BaseCloudWatchClientLiveTest() {
public BaseCloudWatchApiLiveTest() {
provider = "cloudwatch";
}
@Override
protected TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> contextType() {
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
return CloudWatchApiMetadata.CONTEXT_TOKEN;
}

View File

@ -20,7 +20,7 @@ package org.jclouds.cloudwatch.internal;
import java.util.Properties;
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
@ -31,8 +31,8 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
public class BaseCloudWatchAsyncClientExpectTest extends BaseCloudWatchExpectTest<CloudWatchAsyncClient> {
public CloudWatchAsyncClient createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props).getInstance(CloudWatchAsyncClient.class);
public class BaseCloudWatchAsyncApiExpectTest extends BaseCloudWatchExpectTest<CloudWatchAsyncApi> {
public CloudWatchAsyncApi createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props).getInstance(CloudWatchAsyncApi.class);
}
}

View File

@ -29,7 +29,7 @@ import org.jclouds.date.DateService;
import org.jclouds.location.config.LocationModule;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
import org.jclouds.rest.internal.BaseRestApiExpectTest;
import org.jclouds.util.Suppliers2;
import com.google.common.base.Supplier;
@ -40,7 +40,7 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
public class BaseCloudWatchExpectTest<T> extends BaseRestClientExpectTest<T> {
public class BaseCloudWatchExpectTest<T> extends BaseRestApiExpectTest<T> {
public BaseCloudWatchExpectTest() {
provider = "cloudwatch";

View File

@ -30,13 +30,13 @@ import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials;
* Provides synchronous access to the KeyStone Service API.
* <p/>
*
* @see AuthenticationAsyncClient
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* @see AuthenticationAsyncApi
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
* @author Adrian Cole
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface AuthenticationClient {
public interface AuthenticationApi {
/**
* Authenticate to generate a token.
@ -65,4 +65,4 @@ public interface AuthenticationClient {
* @return access with token
*/
Access authenticateWithTenantIdAndCredentials(@Nullable String tenantId, ApiAccessKeyCredentials passwordCredentials);
}
}

View File

@ -38,16 +38,16 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides asynchronous access to Service via their REST API.
* <p/>
*
* @see AuthenticationClient
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* @see AuthenticationApi
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
* @author Adrian Cole
*/
@Path("/v2.0")
public interface AuthenticationAsyncClient {
public interface AuthenticationAsyncApi {
/**
* @see AuthenticationClient#authenticateWithTenantNameAndCredentials(String,PasswordCredentials)
* @see AuthenticationApi#authenticateWithTenantNameAndCredentials(String,PasswordCredentials)
*/
@POST
@SelectJson("access")
@ -58,7 +58,7 @@ public interface AuthenticationAsyncClient {
PasswordCredentials passwordCredentials);
/**
* @see AuthenticationClient#authenticateWithTenantIdAndCredentials(String,PasswordCredentials)
* @see AuthenticationApi#authenticateWithTenantIdAndCredentials(String,PasswordCredentials)
*/
@POST
@SelectJson("access")
@ -69,7 +69,7 @@ public interface AuthenticationAsyncClient {
PasswordCredentials passwordCredentials);
/**
* @see AuthenticationClient#authenticateWithTenantNameAndCredentials(String,ApiAccessKeyCredentials)
* @see AuthenticationApi#authenticateWithTenantNameAndCredentials(String,ApiAccessKeyCredentials)
*/
@POST
@SelectJson("access")
@ -82,7 +82,7 @@ public interface AuthenticationAsyncClient {
ApiAccessKeyCredentials apiAccessKeyCredentials);
/**
* @see AuthenticationClient#authenticateWithTenantIdAndCredentials(String,ApiAccessKeyCredentials)
* @see AuthenticationApi#authenticateWithTenantIdAndCredentials(String,ApiAccessKeyCredentials)
*/
@POST
@SelectJson("access")

View File

@ -22,10 +22,10 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.features.ServiceClient;
import org.jclouds.openstack.keystone.v2_0.features.TenantClient;
import org.jclouds.openstack.keystone.v2_0.features.TokenClient;
import org.jclouds.openstack.keystone.v2_0.features.UserClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenApi;
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
import org.jclouds.rest.annotations.Delegate;
import com.google.common.base.Optional;
@ -36,10 +36,10 @@ import com.google.common.base.Optional;
*
* @author Adam Lowe
* @see <a href="http://keystone.openstack.org/" />
* @see KeystoneAsyncClient
* @see KeystoneAsyncApi
*/
@Timeout(duration = 10, timeUnit = TimeUnit.SECONDS)
public interface KeystoneClient {
public interface KeystoneApi {
/**
* Discover API version information, links to documentation (PDF, HTML, WADL), and supported media types
@ -52,24 +52,24 @@ public interface KeystoneClient {
* Provides synchronous access to Token features
*/
@Delegate
ServiceClient getServiceClient();
ServiceApi getServiceApi();
/**
* Provides synchronous access to Token features
*/
@Delegate
Optional<TokenClient> getTokenClient();
Optional<TokenApi> getTokenApi();
/**
* Provides synchronous access to User features
*/
@Delegate
Optional<UserClient> getUserClient();
Optional<UserApi> getUserApi();
/**
* Provides synchronous access to Tenant features
*/
@Delegate
Optional<TenantClient> getTenantClient();
}
Optional<TenantApi> getTenantApi();
}

View File

@ -50,7 +50,7 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<? extends KeystoneClient,? extends KeystoneAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends KeystoneClient,? extends KeystoneAsyncClient>>() {
public static final TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@ -60,7 +60,7 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
}
public KeystoneApiMetadata() {
this(new Builder(KeystoneClient.class, KeystoneAsyncClient.class));
this(new Builder(KeystoneApi.class, KeystoneAsyncApi.class));
}
protected KeystoneApiMetadata(Builder builder) {
@ -108,4 +108,4 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
}
}
}

View File

@ -25,10 +25,10 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.Constants;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.SelectJson;
@ -43,12 +43,12 @@ import com.google.common.util.concurrent.ListenableFuture;
*
* @author Adam Lowe
* @see <a href="http://keystone.openstack.org/" />
* @see KeystoneClient
* @see KeystoneApi
*/
public interface KeystoneAsyncClient {
public interface KeystoneAsyncApi {
/**
* @see KeystoneClient#getApiMetadata()
* @see KeystoneApi#getApiMetadata()
*/
@GET
@SelectJson("version")
@ -58,27 +58,27 @@ public interface KeystoneAsyncClient {
ListenableFuture<ApiMetadata> getApiMetadata();
/**
* @see KeystoneClient#getServiceClient()
* @see KeystoneApi#getServiceApi()
*/
@Delegate
ServiceAsyncClient getServiceClient();
ServiceAsyncApi getServiceApi();
/**
* @see KeystoneClient#getTokenClient()
* @see KeystoneApi#getTokenApi()
*/
@Delegate
Optional<TokenAsyncClient> getTokenClient();
Optional<TokenAsyncApi> getTokenApi();
/**
* @see KeystoneClient#getUserClient()
* @see KeystoneApi#getUserApi()
*/
@Delegate
Optional<UserAsyncClient> getUserClient();
Optional<UserAsyncApi> getUserApi();
/**
* @see KeystoneClient#getTenantClient()
* @see KeystoneApi#getTenantApi()
*/
@Delegate
Optional<TenantAsyncClient> getTenantClient();
Optional<TenantAsyncApi> getTenantApi();
}

View File

@ -35,4 +35,4 @@ import javax.inject.Qualifier;
@Qualifier
public @interface Authentication {
}
}

View File

@ -39,4 +39,4 @@ public @interface CredentialType {
*
*/
String value();
}
}

View File

@ -47,8 +47,8 @@ import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet;
import org.jclouds.location.suppliers.derived.ZoneIdsFromZoneIdToURIKeySet;
import org.jclouds.location.suppliers.implicit.FirstRegion;
import org.jclouds.location.suppliers.implicit.FirstZone;
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncClient;
import org.jclouds.openstack.keystone.v2_0.AuthenticationClient;
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncApi;
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
import org.jclouds.openstack.keystone.v2_0.domain.Access;
import org.jclouds.openstack.keystone.v2_0.functions.AuthenticateApiAccessKeyCredentials;
import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials;
@ -140,13 +140,13 @@ public class KeystoneAuthenticationModule extends AbstractModule {
@Override
protected void configure() {
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class);
bindAuthenticationClient();
bindAuthenticationApi();
}
protected void bindAuthenticationClient() {
// AuthenticationClient is used directly for filters and retry handlers, so let's bind it
protected void bindAuthenticationApi() {
// AuthenticationApi is used directly for filters and retry handlers, so let's bind it
// explicitly
bindClientAndAsyncClient(binder(), AuthenticationClient.class, AuthenticationAsyncClient.class);
bindClientAndAsyncClient(binder(), AuthenticationApi.class, AuthenticationAsyncApi.class);
}
/**
@ -211,4 +211,4 @@ public class KeystoneAuthenticationModule extends AbstractModule {
};
}
}
}

View File

@ -37,7 +37,7 @@ public interface KeystoneProperties {
* </ul>
*
* @see CredentialTypes
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Client_Operations.html"
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Api_Operations.html"
* />
*/
public static final String CREDENTIAL_TYPE = "jclouds.keystone.credential-type";

View File

@ -30,16 +30,16 @@ import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceClient;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.TenantClient;
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.TokenClient;
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.UserClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.ServiceApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenApi;
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
import org.jclouds.openstack.keystone.v2_0.functions.PresentWhenAdminURLExistsForIdentityService;
import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler;
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion;
@ -63,22 +63,22 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
* @author Adam Lowe
*/
@ConfiguresRestClient
public class KeystoneRestClientModule<S extends KeystoneClient, A extends KeystoneAsyncClient> extends
public class KeystoneRestClientModule<S extends KeystoneApi, A extends KeystoneAsyncApi> extends
RestClientModule<S, A> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
.put(ServiceClient.class, ServiceAsyncClient.class).put(TokenClient.class, TokenAsyncClient.class)
.put(UserClient.class, UserAsyncClient.class).put(TenantClient.class, TenantAsyncClient.class).build();
.put(ServiceApi.class, ServiceAsyncApi.class).put(TokenApi.class, TokenAsyncApi.class)
.put(UserApi.class, UserAsyncApi.class).put(TenantApi.class, TenantAsyncApi.class).build();
@SuppressWarnings("unchecked")
public KeystoneRestClientModule() {
super(TypeToken.class.cast(TypeToken.of(KeystoneClient.class)), TypeToken.class.cast(TypeToken
.of(KeystoneAsyncClient.class)), DELEGATE_MAP);
super(TypeToken.class.cast(TypeToken.of(KeystoneApi.class)), TypeToken.class.cast(TypeToken
.of(KeystoneAsyncApi.class)), DELEGATE_MAP);
}
protected KeystoneRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
protected KeystoneRestClientModule(TypeToken<S> syncApiType, TypeToken<A> asyncApiType,
Map<Class<?>, Class<?>> sync2Async) {
super(syncClientType, asyncClientType, sync2Async);
super(syncApiType, asyncApiType, sync2Async);
}
public static class KeystoneAdminURLModule extends AbstractModule {

View File

@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableSet;
* TODO
*
* @author Adrian Cole
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
/>
*/
public class Access implements Comparable<Access> {

View File

@ -31,7 +31,7 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* Api AccessKey Credentials
*
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Client_Operations.html#d662e583"
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Api_Operations.html#d662e583"
/>
* @author Adrian Cole
*/

View File

@ -30,7 +30,7 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* Password Credentials
*
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Client_Operations.html#d662e583"
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Api_Operations.html#d662e583"
/>
* @author Adrian Cole
*/

View File

@ -29,16 +29,16 @@ import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
* <p/>
*
* @author Adam Lowe
* @see ServiceAsyncClient
* @see ServiceAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface ServiceClient {
public interface ServiceApi {
/**
* The operation returns a list of tenants which the current token provides access to.
*/
Set<Tenant> listTenants();
}
}

View File

@ -40,18 +40,18 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides asynchronous access to Service via their REST API.
* <p/>
*
* @see ServiceClient
* @see ServiceApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
* @author Adam Lowe
*/
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
@SkipEncoding( { '/', '=' })
public interface ServiceAsyncClient {
public interface ServiceAsyncApi {
/**
* @see ServiceClient#listTenants()
* @see ServiceApi#listTenants()
*/
@GET
@SelectJson("tenants")

View File

@ -29,13 +29,13 @@ import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
* <p/>
*
* @author Adam Lowe
* @see TenantAsyncClient
* @see TenantAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Tenant_Operations.html"
* />
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface TenantClient {
public interface TenantApi {
/**
* The operation returns a list of tenants which the current token provides access to.
@ -57,4 +57,4 @@ public interface TenantClient {
* @return the information about the tenant
*/
Tenant getByName(String tenantName);
}
}

View File

@ -43,7 +43,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides asynchronous access to Tenant via their REST API.
* <p/>
*
* @see TenantClient
* @see TenantApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Tenant_Operations.html"
* />
@ -51,10 +51,10 @@ import com.google.common.util.concurrent.ListenableFuture;
*/
@org.jclouds.rest.annotations.Endpoint(Identity.class)
@SkipEncoding( { '/', '=' })
public interface TenantAsyncClient {
public interface TenantAsyncApi {
/**
* @see TenantClient#list()
* @see TenantApi#list()
*/
@GET
@SelectJson("tenants")
@ -64,7 +64,7 @@ public interface TenantAsyncClient {
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Tenant>> list();
/** @see TenantClient#get(String) */
/** @see TenantApi#get(String) */
@GET
@SelectJson("tenant")
@Consumes(MediaType.APPLICATION_JSON)
@ -73,7 +73,7 @@ public interface TenantAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Tenant> get(@PathParam("tenantId") String tenantId);
/** @see TenantClient#getByName(String) */
/** @see TenantApi#getByName(String) */
@GET
@SelectJson("tenant")
@Consumes(MediaType.APPLICATION_JSON)

View File

@ -33,14 +33,14 @@ import com.google.common.annotations.Beta;
* <p/>
*
* @author Adam Lowe
* @see TokenAsyncClient
* @see TokenAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Token_Operations.html"
* />
*/
@Beta
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface TokenClient {
public interface TokenApi {
/**
@ -74,4 +74,4 @@ public interface TokenClient {
*/
Set<Endpoint> listEndpointsForToken(String token);
}
}

View File

@ -46,7 +46,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides asynchronous access to Token via their REST API.
* <p/>
*
* @see TokenClient
* @see TokenApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Token_Operations.html"
* />
@ -54,10 +54,10 @@ import com.google.common.util.concurrent.ListenableFuture;
*/
@SkipEncoding({ '/', '=' })
@org.jclouds.rest.annotations.Endpoint(Identity.class)
public interface TokenAsyncClient {
public interface TokenAsyncApi {
/** @see TokenClient#get(String) */
/** @see TokenApi#get(String) */
@GET
@SelectJson("token")
@Consumes(MediaType.APPLICATION_JSON)
@ -66,7 +66,7 @@ public interface TokenAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Token> get(@PathParam("token") String token);
/** @see TokenClient#getUserOfToken(String) */
/** @see TokenApi#getUserOfToken(String) */
@GET
@SelectJson("user")
@Consumes(MediaType.APPLICATION_JSON)
@ -75,14 +75,14 @@ public interface TokenAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<User> getUserOfToken(@PathParam("token") String token);
/** @see TokenClient#isValid(String) */
/** @see TokenApi#isValid(String) */
@HEAD
@Path("/tokens/{token}")
@RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
ListenableFuture<Boolean> isValid(@PathParam("token") String token);
/** @see TokenClient#listEndpointsForToken(String) */
/** @see TokenApi#listEndpointsForToken(String) */
@GET
@SelectJson("endpoints")
@Consumes(MediaType.APPLICATION_JSON)

View File

@ -32,14 +32,14 @@ import com.google.common.annotations.Beta;
* <p/>
*
* @author Adam Lowe
* @see UserAsyncClient
* @see UserAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/User_Operations.html"
* />
*/
@Beta
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface UserClient {
public interface UserApi {
/**
* Retrieve the list of users
@ -82,4 +82,4 @@ public interface UserClient {
*/
Set<Role> listRolesOfUserOnTenant(String userId, String tenantId);
}
}

View File

@ -44,7 +44,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides asynchronous access to User via their REST API.
* <p/>
*
* @see UserClient
* @see UserApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/User_Operations.html"
* />
@ -52,9 +52,9 @@ import com.google.common.util.concurrent.ListenableFuture;
*/
@org.jclouds.rest.annotations.Endpoint(Identity.class)
@SkipEncoding({ '/', '=' })
public interface UserAsyncClient {
public interface UserAsyncApi {
/** @see UserClient#list() */
/** @see UserApi#list() */
@GET
@SelectJson("users")
@Consumes(MediaType.APPLICATION_JSON)
@ -63,7 +63,7 @@ public interface UserAsyncClient {
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<User>> list();
/** @see UserClient#get(String) */
/** @see UserApi#get(String) */
@GET
@SelectJson("user")
@Consumes(MediaType.APPLICATION_JSON)
@ -72,7 +72,7 @@ public interface UserAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<User> get(@PathParam("userId") String userId);
/** @see UserClient#getByName(String) */
/** @see UserApi#getByName(String) */
@GET
@SelectJson("user")
@Consumes(MediaType.APPLICATION_JSON)
@ -81,7 +81,7 @@ public interface UserAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<User> getByName(@QueryParam("name") String userName);
/** @see UserClient#listRolesOfUser(String) */
/** @see UserApi#listRolesOfUser(String) */
@GET
@SelectJson("roles")
@Consumes(MediaType.APPLICATION_JSON)
@ -90,7 +90,7 @@ public interface UserAsyncClient {
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Role>> listRolesOfUser(@PathParam("userId") String userId);
/** @see UserClient#listRolesOfUserOnTenant(String, String) */
/** @see UserApi#listRolesOfUserOnTenant(String, String) */
@GET
@SelectJson("roles")
@Consumes(MediaType.APPLICATION_JSON)

View File

@ -50,4 +50,4 @@ public class AuthenticateRequest implements HttpRequestFilter {
return request.toBuilder().replaceHeader(AuthHeaders.AUTH_TOKEN, authTokenProvider.get()).build();
}
}
}

View File

@ -40,4 +40,4 @@ public class AdminURL implements EndpointToSupplierAdminURI {
public String toString() {
return "supplyAdminURL()";
}
}
}

View File

@ -21,7 +21,7 @@ package org.jclouds.openstack.keystone.v2_0.functions;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.openstack.keystone.v2_0.AuthenticationClient;
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
import org.jclouds.openstack.keystone.v2_0.config.CredentialType;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.domain.Access;
@ -33,21 +33,21 @@ import com.google.common.base.Optional;
@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS)
@Singleton
public class AuthenticateApiAccessKeyCredentials extends BaseAuthenticator<ApiAccessKeyCredentials> {
protected final AuthenticationClient client;
protected final AuthenticationApi api;
@Inject
public AuthenticateApiAccessKeyCredentials(AuthenticationClient client) {
this.client = client;
public AuthenticateApiAccessKeyCredentials(AuthenticationApi api) {
this.api = api;
}
@Override
protected Access authenticateWithTenantName(Optional<String> tenantName, ApiAccessKeyCredentials apiAccessKeyCredentials) {
return client.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials);
return api.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials);
}
@Override
protected Access authenticateWithTenantId(Optional<String> tenantId, ApiAccessKeyCredentials apiAccessKeyCredentials) {
return client.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials);
return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials);
}
@Override
@ -59,4 +59,4 @@ public class AuthenticateApiAccessKeyCredentials extends BaseAuthenticator<ApiAc
public String toString() {
return "authenticateApiAccessKeyCredentials()";
}
}
}

View File

@ -21,7 +21,7 @@ package org.jclouds.openstack.keystone.v2_0.functions;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.openstack.keystone.v2_0.AuthenticationClient;
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
import org.jclouds.openstack.keystone.v2_0.config.CredentialType;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.domain.Access;
@ -33,21 +33,21 @@ import com.google.common.base.Optional;
@CredentialType(CredentialTypes.PASSWORD_CREDENTIALS)
@Singleton
public class AuthenticatePasswordCredentials extends BaseAuthenticator<PasswordCredentials> {
protected final AuthenticationClient client;
protected final AuthenticationApi api;
@Inject
public AuthenticatePasswordCredentials(AuthenticationClient client) {
this.client = client;
public AuthenticatePasswordCredentials(AuthenticationApi api) {
this.api = api;
}
@Override
protected Access authenticateWithTenantName(Optional<String> tenantName, PasswordCredentials apiAccessKeyCredentials) {
return client.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials);
return api.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials);
}
@Override
protected Access authenticateWithTenantId(Optional<String> tenantId, PasswordCredentials apiAccessKeyCredentials) {
return client.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials);
return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials);
}
@Override
@ -59,4 +59,4 @@ public class AuthenticatePasswordCredentials extends BaseAuthenticator<PasswordC
public String toString() {
return "authenticatePasswordCredentials()";
}
}
}

View File

@ -26,4 +26,4 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(ReturnRegionOrProvider.class)
public interface EndpointToRegion extends Function<Endpoint, String> {
}
}

View File

@ -25,4 +25,4 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(AdminURL.class)
public interface EndpointToSupplierAdminURI extends EndpointToSupplierURI {
}
}

View File

@ -28,4 +28,4 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(PublicURLOrInternalIfNull.class)
public interface EndpointToSupplierURI extends Function<Endpoint, Supplier<URI>> {
}
}

View File

@ -43,4 +43,4 @@ public class PresentWhenAdminURLExistsForIdentityService implements ImplicitOpti
return "presentWhenAdminURLExistsForIdentityService()";
}
}
}

View File

@ -38,4 +38,4 @@ public class PublicURLOrInternalIfNull implements EndpointToSupplierURI {
public String toString() {
return "supplyPublicURL()";
}
}
}

View File

@ -39,4 +39,4 @@ public class ReturnRegionOrProvider implements EndpointToRegion {
public String apply(Endpoint input) {
return input.getRegion() != null ? input.getRegion() : provider;
}
}
}

View File

@ -94,4 +94,4 @@ public abstract class BaseAuthenticator<C> implements Function<Credentials, Acce
protected abstract Access authenticateWithTenantName(Optional<String> tenantId, C apiAccessKeyCredentials);
}
}

View File

@ -98,4 +98,4 @@ public class LocationIdToURIFromAccessForTypeAndVersion implements Supplier<Map<
public String toString() {
return "locationIdToURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")";
}
}
}

View File

@ -43,4 +43,4 @@ public class RegionIdToAdminURIFromAccessForTypeAndVersion extends LocationIdToU
public String toString() {
return "regionIdToAdminURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")";
}
}
}

View File

@ -45,4 +45,4 @@ public class RegionIdToURIFromAccessForTypeAndVersion extends LocationIdToURIFro
public String toString() {
return "regionIdToURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")";
}
}
}

View File

@ -48,4 +48,4 @@ public class ZoneIdToURIFromAccessForTypeAndVersion extends LocationIdToURIFromA
public String toString() {
return "zoneIdToURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")";
}
}
}

View File

@ -49,4 +49,4 @@ public interface ServiceType {
* Network Service (Quantum)
*/
public static final String NETWORK = "network";
}
}

View File

@ -31,7 +31,7 @@ import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
* For convenience, resources contain links to themselves. This allows a client to easily obtain a
* For convenience, resources contain links to themselves. This allows a api to easily obtain a
* resource URIs rather than to construct them.
*
* @author AdrianCole

View File

@ -28,4 +28,4 @@ public interface AuthHeaders {
public static final String AUTH_KEY = "X-Auth-Key";
public static final String AUTH_TOKEN = "X-Auth-Token";
}
}

View File

@ -40,4 +40,4 @@ import org.jclouds.openstack.v2_0.ServiceType;
@Qualifier
public @interface Compute {
}
}

View File

@ -76,4 +76,4 @@ public @interface Extension {
*/
String namespace();
}
}

View File

@ -40,4 +40,4 @@ import org.jclouds.openstack.v2_0.ServiceType;
@Qualifier
public @interface Identity {
}
}

View File

@ -40,4 +40,4 @@ import org.jclouds.openstack.v2_0.ServiceType;
@Qualifier
public @interface Image {
}
}

View File

@ -40,4 +40,4 @@ import org.jclouds.openstack.v2_0.ServiceType;
@Qualifier
public @interface ObjectStore {
}
}

View File

@ -25,7 +25,7 @@ import static org.testng.Assert.assertNull;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceApiMetadataTest;
import org.testng.annotations.Test;
@ -33,27 +33,27 @@ import org.testng.annotations.Test;
*
* @author Adrian Cole
*/
@Test(testName = "KeystoneClientExpectTest")
public class KeystoneClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
@Test(testName = "KeystoneApiExpectTest")
public class KeystoneApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi> {
public void testGetApiMetaData() {
KeystoneClient client = requestsSendResponses(
KeystoneApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
HttpRequest.builder().method("GET").endpoint(endpoint + "/v2.0/").
addHeader("Accept", APPLICATION_JSON).build(),
HttpResponse.builder().statusCode(200).
payload(payloadFromResourceWithContentType("/raxVersion.json", APPLICATION_JSON)).build());
ApiMetadata metadata = client.getApiMetadata();
ApiMetadata metadata = api.getApiMetadata();
assertEquals(metadata, new ParseRackspaceApiMetadataTest().expected());
}
public void testGetApiMetaDataFailNotFound() {
KeystoneClient client = requestsSendResponses(
KeystoneApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
HttpRequest.builder().method("GET").endpoint(endpoint + "/v2.0/").addHeader("Accept", APPLICATION_JSON).build(),
HttpResponse.builder().statusCode(404).build());
assertNull(client.getApiMetadata());
assertNull(api.getApiMetadata());
}
}

View File

@ -21,16 +21,16 @@ package org.jclouds.openstack.keystone.v2_0;
import static org.testng.Assert.assertNotNull;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
import org.testng.annotations.Test;
/**
* Tests KeystoneClient
* Tests KeystoneApi
*
* @author Adam Lowe
*/
@Test(groups = "live", testName = "KeystoneClientLiveTest")
public class KeystoneClientLiveTest extends BaseKeystoneClientLiveTest {
@Test(groups = "live", testName = "KeystoneApiLiveTest")
public class KeystoneApiLiveTest extends BaseKeystoneApiLiveTest {
public void testGetApiMetaData() {
ApiMetadata result = keystoneContext.getApi().getApiMetadata();

View File

@ -27,30 +27,30 @@ import static org.testng.Assert.assertTrue;
import java.util.Set;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
* Tests parsing and Guice wiring of ServiceClient
* Tests parsing and Guice wiring of ServiceApi
*
* @author Adam Lowe
*/
@Test(testName = "ServiceClientExpectTest")
public class ServiceClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
@Test(testName = "ServiceApiExpectTest")
public class ServiceApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi> {
public void testListTenants() {
ServiceClient client = requestsSendResponses(
ServiceApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword,
responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(),
HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
.getServiceClient();
Set<Tenant> tenants = client.listTenants();
.getServiceApi();
Set<Tenant> tenants = api.listTenants();
assertNotNull(tenants);
assertFalse(tenants.isEmpty());
@ -61,9 +61,9 @@ public class ServiceClientExpectTest extends BaseKeystoneRestClientExpectTest<Ke
}
public void testListTenantsFailNotFound() {
ServiceClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
ServiceApi api = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(),
HttpResponse.builder().statusCode(404).build()).getServiceClient();
assertTrue(client.listTenants().isEmpty());
HttpResponse.builder().statusCode(404).build()).getServiceApi();
assertTrue(api.listTenants().isEmpty());
}
}

View File

@ -24,20 +24,20 @@ import static org.testng.Assert.assertNotNull;
import java.util.Set;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
import org.testng.annotations.Test;
/**
* Tests ServiceClient
* Tests ServiceApi
*
* @author Adam Lowe
*/
@Test(groups = "live", testName = "ServiceClientLiveTest")
public class ServiceClientLiveTest extends BaseKeystoneClientLiveTest {
@Test(groups = "live", testName = "ServiceApiLiveTest")
public class ServiceApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenants() {
ServiceClient client = keystoneContext.getApi().getServiceClient();
Set<Tenant> result = client.listTenants();
ServiceApi api = keystoneContext.getApi().getServiceApi();
Set<Tenant> result = api.listTenants();
assertNotNull(result);
assertFalse(result.isEmpty());

View File

@ -28,35 +28,35 @@ import static org.testng.Assert.assertTrue;
import java.util.Set;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
import org.jclouds.rest.AuthorizationException;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
* Tests parsing and Guice wiring of TenantClient
* Tests parsing and Guice wiring of TenantApi
*
* @author Adam Lowe
*/
@Test(testName = "TenantClientExpectTest")
public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
@Test(testName = "TenantApiExpectTest")
public class TenantApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi> {
public TenantClientExpectTest(){
public TenantApiExpectTest(){
endpoint = "https://csnode.jclouds.org:35357";
}
public void testListTenants() {
TenantClient client = requestsSendResponses(
TenantApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword,
responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(),
HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
.getTenantClient().get();
Set<Tenant> tenants = client.list();
.getTenantApi().get();
Set<Tenant> tenants = api.list();
assertNotNull(tenants);
assertFalse(tenants.isEmpty());
@ -67,14 +67,14 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
}
public void testListTenantsATT() {
TenantClient client = requestsSendResponses(
TenantApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword,
responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(),
HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/tenant_list_att.json", APPLICATION_JSON)).build())
.getTenantClient().get();
Set<Tenant> tenants = client.list();
.getTenantApi().get();
Set<Tenant> tenants = api.list();
assertNotNull(tenants);
assertFalse(tenants.isEmpty());
@ -84,51 +84,51 @@ public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest<Key
}
public void testListTenantsFailNotFound() {
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
TenantApi api = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(404).build())
.getTenantClient().get();
assertTrue(client.list().isEmpty());
.getTenantApi().get();
assertTrue(api.list().isEmpty());
}
public void testGetTenant() {
TenantClient client = requestsSendResponses(
TenantApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword,
responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
.getTenantClient().get();
Tenant tenant = client.get("013ba41150a14830bec85ffe93353bcc");
.getTenantApi().get();
Tenant tenant = api.get("013ba41150a14830bec85ffe93353bcc");
assertNotNull(tenant);
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
}
@Test(expectedExceptions = AuthorizationException.class)
public void testListTenantsFailNotAuthorized() {
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
TenantApi api = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(),
HttpResponse.builder().statusCode(401).build()).getTenantClient().get();
client.get("013ba41150a14830bec85ffe93353bcc");
HttpResponse.builder().statusCode(401).build()).getTenantApi().get();
api.get("013ba41150a14830bec85ffe93353bcc");
}
public void testGetTenantByName() {
TenantClient client = requestsSendResponses(
TenantApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword,
responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants?name=admin").build(),
HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build())
.getTenantClient().get();
Tenant tenant = client.getByName("admin");
.getTenantApi().get();
Tenant tenant = api.getByName("admin");
assertNotNull(tenant);
assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build());
}
public void testGetTenantByNameFailNotFound() {
TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
TenantApi api = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tenants?name=admin").build(),
HttpResponse.builder().statusCode(404).build()).getTenantClient().get();
assertNull(client.getByName("admin"));
HttpResponse.builder().statusCode(404).build()).getTenantApi().get();
assertNull(api.getByName("admin"));
}
}

View File

@ -25,27 +25,27 @@ import static org.testng.Assert.assertNotNull;
import java.util.Set;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
import org.testng.annotations.Test;
/**
* Tests TenantClient
* Tests TenantApi
*
* @author Adam Lowe
*/
@Test(groups = "live", testName = "TenantClientLiveTest")
public class TenantClientLiveTest extends BaseKeystoneClientLiveTest {
@Test(groups = "live", testName = "TenantApiLiveTest")
public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenants() {
TenantClient client = keystoneContext.getApi().getTenantClient().get();
Set<Tenant> result = client.list();
TenantApi api = keystoneContext.getApi().getTenantApi().get();
Set<Tenant> result = api.list();
assertNotNull(result);
assertFalse(result.isEmpty());
for (Tenant tenant : result) {
assertNotNull(tenant.getId());
Tenant aTenant = client.get(tenant.getId());
Tenant aTenant = api.get(tenant.getId());
assertNotNull(aTenant, "get returned null for tenant: " + tenant);
assertEquals(aTenant, tenant);
@ -54,10 +54,10 @@ public class TenantClientLiveTest extends BaseKeystoneClientLiveTest {
public void testTenantsByName() {
TenantClient client = keystoneContext.getApi().getTenantClient().get();
TenantApi api = keystoneContext.getApi().getTenantApi().get();
for (Tenant tenant : client.list()) {
Tenant aTenant = client.getByName(tenant.getName());
for (Tenant tenant : api.list()) {
Tenant aTenant = api.getByName(tenant.getName());
assertNotNull(aTenant, "get returned null for tenant: " + tenant);
assertEquals(aTenant, tenant);

View File

@ -33,38 +33,38 @@ import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
import org.jclouds.openstack.keystone.v2_0.domain.Role;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.domain.Token;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
* Tests parsing and Guice wiring of TokenClient
* Tests parsing and Guice wiring of TokenApi
*
* @author Adam Lowe
*/
@Test(testName = "TokenClientExpectTest")
public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
@Test(testName = "TokenApiExpectTest")
public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi> {
public TokenClientExpectTest(){
public TokenApiExpectTest(){
endpoint = "https://csnode.jclouds.org:35357";
}
private DateService dateService = new SimpleDateFormatDateService();
public void testGetToken() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
.getTokenClient().get();
Token token = client.get("sometokenorother");
.getTokenApi().get();
Token token = api.get("sometokenorother");
assertNotNull(token);
assertEquals(token,
Token.builder().id("167eccdc790946969ced473732e8109b").expires(dateService.iso8601SecondsDateParse("2012-04-28T12:42:50Z"))
@ -72,30 +72,30 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
}
public void testGetTokenFailNotFound() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(404).build())
.getTokenClient().get();
assertNull(client.get("sometokenorother"));
.getTokenApi().get();
assertNull(api.get("sometokenorother"));
}
@Test(expectedExceptions = HttpResponseException.class)
public void testGetTokenFail500() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(500).build()).getTokenClient().get();
client.get("sometokenorother");
HttpResponse.builder().statusCode(500).build()).getTokenApi().get();
api.get("sometokenorother");
}
public void testGetUserOfToken() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
.getTokenClient().get();
User user = client.getUserOfToken("sometokenorother");
.getTokenApi().get();
User user = api.getUserOfToken("sometokenorother");
assertNotNull(user);
assertEquals(user, User.builder().id("2b9b606181634ae9ac86fd95a8bc2cde").name("admin")
.roles(ImmutableSet.of(Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build()))
@ -103,42 +103,42 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
}
public void testGetUserOfTokenFailNotFound() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(404).build()).getTokenClient().get();
assertNull(client.getUserOfToken("sometokenorother"));
HttpResponse.builder().statusCode(404).build()).getTokenApi().get();
assertNull(api.getUserOfToken("sometokenorother"));
}
public void testCheckTokenIsValid() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
HttpRequest.builder().method("HEAD")
.endpoint(endpoint + "/v2.0/tokens/sometokenorother")
.addHeader("X-Auth-Token", authToken).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
.getTokenClient().get();
assertTrue(client.isValid("sometokenorother"));
.getTokenApi().get();
assertTrue(api.isValid("sometokenorother"));
}
public void testCheckTokenIsValidFailNotValid() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
HttpRequest.builder().method("HEAD")
.endpoint(endpoint + "/v2.0/tokens/sometokenorother")
.addHeader("X-Auth-Token", authToken).build(),
HttpResponse.builder().statusCode(404).build()).getTokenClient().get();
assertFalse(client.isValid("sometokenorother"));
HttpResponse.builder().statusCode(404).build()).getTokenApi().get();
assertFalse(api.isValid("sometokenorother"));
}
@Test
public void testGetEndpointsForToken() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build())
.getTokenClient().get();
Set<Endpoint> endpoints = client.listEndpointsForToken("XXXXXX");
.getTokenApi().get();
Set<Endpoint> endpoints = api.listEndpointsForToken("XXXXXX");
assertEquals(endpoints, ImmutableSet.of(
Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/"))
@ -149,12 +149,12 @@ public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest<Keys
@Test
public void testGetEndpointsForTokenFailNotFound() {
TokenClient client = requestsSendResponses(
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
HttpResponse.builder().statusCode(404).build())
.getTokenClient().get();
assertTrue(client.listEndpointsForToken("XXXXXX").isEmpty());
.getTokenApi().get();
assertTrue(api.listEndpointsForToken("XXXXXX").isEmpty());
}

View File

@ -31,19 +31,19 @@ import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
import org.jclouds.openstack.keystone.v2_0.domain.Token;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
* Tests TokenClient
* Tests TokenApi
*
* @author Adam Lowe
*/
@Test(groups = "live", testName = "TokenClientLiveTest", singleThreaded = true)
public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
@Test(groups = "live", testName = "TokenApiLiveTest", singleThreaded = true)
public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
protected String token;
@ -57,14 +57,14 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
public void testToken() {
TokenClient client = keystoneContext.getApi().getTokenClient().get();
assertTrue(client.isValid(token));
Token result = client.get(token);
TokenApi api = keystoneContext.getApi().getTokenApi().get();
assertTrue(api.isValid(token));
Token result = api.get(token);
assertNotNull(result);
assertEquals(result.getId(), token);
assertNotNull(result.getTenant());
User user = client.getUserOfToken(token);
User user = api.getUserOfToken(token);
assertNotNull(user);
assertNotNull(user.getId());
assertNotNull(user.getName());
@ -73,16 +73,16 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
public void testInvalidToken() {
TokenClient client = keystoneContext.getApi().getTokenClient().get();
assertFalse(client.isValid("thisisnotarealtoken!"));
assertNull(client.get("thisisnotarealtoken!"));
TokenApi api = keystoneContext.getApi().getTokenApi().get();
assertFalse(api.isValid("thisisnotarealtoken!"));
assertNull(api.get("thisisnotarealtoken!"));
}
public void testTokenEndpoints() {
TokenClient client = keystoneContext.getApi().getTokenClient().get();
Set<Endpoint> endpoints = client.listEndpointsForToken(token);
TokenApi api = keystoneContext.getApi().getTokenApi().get();
Set<Endpoint> endpoints = api.listEndpointsForToken(token);
assertNotNull(endpoints);
assertFalse(endpoints.isEmpty());
@ -90,8 +90,8 @@ public class TokenClientLiveTest extends BaseKeystoneClientLiveTest {
public void testInvalidTokenEndpoints() {
TokenClient client = keystoneContext.getApi().getTokenClient().get();
assertTrue(client.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
TokenApi api = keystoneContext.getApi().getTokenApi().get();
assertTrue(api.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
}
}
}

View File

@ -29,34 +29,34 @@ import java.util.Set;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.domain.Role;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
import org.jclouds.rest.AuthorizationException;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
* Tests parsing and Guice wiring of UserClient
* Tests parsing and Guice wiring of UserApi
*
* @author Adam Lowe
*/
@Test(testName = "UserClientExpectTest")
public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
@Test(testName = "UserApiExpectTest")
public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi> {
public UserClientExpectTest(){
public UserApiExpectTest(){
endpoint = "https://csnode.jclouds.org:35357";
}
public void testListUsers() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build())
.getUserClient().get();
Set<User> users = client.list();
.getUserApi().get();
Set<User> users = api.list();
assertNotNull(users);
assertFalse(users.isEmpty());
@ -72,58 +72,58 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
@Test(expectedExceptions = AuthorizationException.class)
public void testListUsersFailNotAuth() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users").build(),
HttpResponse.builder().statusCode(401).build()).getUserClient().get();
client.list();
HttpResponse.builder().statusCode(401).build()).getUserApi().get();
api.list();
}
public void testGetUser() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/e021dfd758eb44a89f1c57c8ef3be8e2").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build())
.getUserClient().get();
User user = client.get("e021dfd758eb44a89f1c57c8ef3be8e2");
.getUserApi().get();
User user = api.get("e021dfd758eb44a89f1c57c8ef3be8e2");
assertNotNull(user);
assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build());
}
public void testGetUserFailNotFound() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/f021dfd758eb44a89f1c57c8ef3be8e2").build(),
HttpResponse.builder().statusCode(404).build()).getUserClient().get();
assertNull(client.get("f021dfd758eb44a89f1c57c8ef3be8e2"));
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
assertNull(api.get("f021dfd758eb44a89f1c57c8ef3be8e2"));
}
public void testGetUserByName() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users?name=nova").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build())
.getUserClient().get();
User user = client.getByName("nova");
.getUserApi().get();
User user = api.getByName("nova");
assertNotNull(user);
assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build());
}
public void testGetUserByNameFailNotFound() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users?name=fred").build(),
HttpResponse.builder().statusCode(404).build()).getUserClient().get();
assertNull(client.getByName("fred"));
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
assertNull(api.getByName("fred"));
}
public void testListRolesOfUser() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build())
.getUserClient().get();
Set<Role> roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
.getUserApi().get();
Set<Role> roles = api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
assertNotNull(roles);
assertFalse(roles.isEmpty());
assertEquals(roles, ImmutableSet.of(
@ -132,29 +132,29 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
}
public void testListRolesOfUserFailNotFound() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/4f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(404).build()).getUserClient().get();
assertTrue(client.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
assertTrue(api.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
}
@Test(expectedExceptions = HttpResponseException.class)
public void testListRolesOfUserFailNotImplemented() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(501).build()).getUserClient().get();
assertTrue(client.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
HttpResponse.builder().statusCode(501).build()).getUserApi().get();
assertTrue(api.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
}
public void testListRolesOfUserInTenant() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build())
.getUserClient().get();
Set<Role> roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
.getUserApi().get();
Set<Role> roles = api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
assertNotNull(roles);
assertFalse(roles.isEmpty());
assertEquals(roles, ImmutableSet.of(
@ -164,11 +164,11 @@ public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest<Keyst
}
public void testListRolesOfUserInTenantFailNotFound() {
UserClient client = requestsSendResponses(
UserApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(404).build()).getUserClient().get();
assertTrue(client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
assertTrue(api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
}
}

View File

@ -27,25 +27,25 @@ import java.util.Set;
import org.jclouds.openstack.keystone.v2_0.domain.Role;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
import org.testng.annotations.Test;
/**
* Tests UserClient
* Tests UserApi
*
* @author Adam Lowe
*/
@Test(groups = "live", testName = "UserClientLiveTest", singleThreaded = true)
public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
@Test(groups = "live", testName = "UserApiLiveTest", singleThreaded = true)
public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testUsers() {
UserClient client = keystoneContext.getApi().getUserClient().get();
Set<User> users = client.list();
UserApi api = keystoneContext.getApi().getUserApi().get();
Set<User> users = api.list();
assertNotNull(users);
assertFalse(users.isEmpty());
for (User user : users) {
User aUser = client.get(user.getId());
User aUser = api.get(user.getId());
assertEquals(aUser, user);
}
@ -53,13 +53,13 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
public void testUserRolesOnTenant() {
UserClient client = keystoneContext.getApi().getUserClient().get();
Set<User> users = client.list();
Set<Tenant> tenants = keystoneContext.getApi().getTenantClient().get().list();
UserApi api = keystoneContext.getApi().getUserApi().get();
Set<User> users = api.list();
Set<Tenant> tenants = keystoneContext.getApi().getTenantApi().get().list();
for (User user : users) {
for (Tenant tenant : tenants) {
Set<Role> roles = client.listRolesOfUserOnTenant(user.getId(), tenant.getId());
Set<Role> roles = api.listRolesOfUserOnTenant(user.getId(), tenant.getId());
for (Role role : roles) {
assertNotNull(role.getId());
}
@ -70,9 +70,9 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
public void testListRolesOfUser() {
UserClient client = keystoneContext.getApi().getUserClient().get();
for (User user : client.list()) {
Set<Role> roles = client.listRolesOfUser(user.getId());
UserApi api = keystoneContext.getApi().getUserApi().get();
for (User user : api.list()) {
Set<Role> roles = api.listRolesOfUser(user.getId());
for (Role role : roles) {
assertNotNull(role.getId());
}
@ -82,11 +82,11 @@ public class UserClientLiveTest extends BaseKeystoneClientLiveTest {
public void testUsersByName() {
UserClient client = keystoneContext.getApi().getUserClient().get();
for (User user : client.list()) {
User aUser = client.getByName(user.getName());
UserApi api = keystoneContext.getApi().getUserApi().get();
for (User user : api.list()) {
User aUser = api.getByName(user.getName());
assertEquals(aUser, user);
}
}
}
}

View File

@ -22,8 +22,8 @@ import java.util.Properties;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterGroups;
@ -33,18 +33,18 @@ import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/**
* Tests behavior of {@code KeystoneClient}
* Tests behavior of {@code KeystoneApi}
*
* @author Adam Lowe
*/
@Test(groups = "live")
public class BaseKeystoneClientLiveTest extends BaseContextLiveTest<RestContext<? extends KeystoneClient,? extends KeystoneAsyncClient>> {
public class BaseKeystoneApiLiveTest extends BaseContextLiveTest<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> {
public BaseKeystoneClientLiveTest() {
public BaseKeystoneApiLiveTest() {
provider = "openstack-keystone";
}
protected RestContext<? extends KeystoneClient,? extends KeystoneAsyncClient> keystoneContext;
protected RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi> keystoneContext;
@BeforeGroups(groups = { "integration", "live" })
@Override
@ -67,7 +67,7 @@ public class BaseKeystoneClientLiveTest extends BaseContextLiveTest<RestContext<
}
@Override
protected TypeToken<RestContext<? extends KeystoneClient,? extends KeystoneAsyncClient>> contextType() {
protected TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> contextType() {
return KeystoneApiMetadata.CONTEXT_TOKEN;
}

View File

@ -29,23 +29,23 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
import org.jclouds.rest.internal.BaseRestApiExpectTest;
import com.google.common.base.Objects;
/**
* Base class for writing KeyStone 2.0 Rest Client Expect tests
* Base class for writing KeyStone 2.0 Rest Api Expect tests
*
* @author Adam Lowe
*/
public class BaseKeystoneRestClientExpectTest<S> extends BaseRestClientExpectTest<S> {
public class BaseKeystoneRestApiExpectTest<S> extends BaseRestApiExpectTest<S> {
protected HttpRequest keystoneAuthWithUsernameAndPassword;
protected HttpRequest keystoneAuthWithAccessKeyAndSecretKey;
protected String authToken;
protected HttpResponse responseWithKeystoneAccess;
protected String endpoint = "http://localhost:5000";
public BaseKeystoneRestClientExpectTest() {
public BaseKeystoneRestApiExpectTest() {
provider = "openstack-keystone";
keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity,
credential);

View File

@ -31,7 +31,7 @@ import com.google.common.base.Throwables;
import com.google.common.net.HttpHeaders;
/**
* Base class for writing KeyStone Rest Client Expect tests
* Base class for writing KeyStone Rest Api Expect tests
*
* @author Adrian Cole
*/

View File

@ -25,24 +25,24 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsClient;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateClient;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClient;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsClient;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageClient;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeClient;
import org.jclouds.openstack.nova.v2_0.features.ExtensionClient;
import org.jclouds.openstack.nova.v2_0.features.FlavorClient;
import org.jclouds.openstack.nova.v2_0.features.ImageClient;
import org.jclouds.openstack.nova.v2_0.features.ServerClient;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsApi;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
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.SimpleTenantUsageApi;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi;
import org.jclouds.openstack.nova.v2_0.features.ExtensionApi;
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
@ -53,13 +53,13 @@ import com.google.inject.Provides;
* Provides synchronous access to Nova.
* <p/>
*
* @see NovaAsyncClient
* @see NovaAsyncApi
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
* />
* @author Adrian Cole
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface NovaClient {
public interface NovaApi {
/**
*
* @return the Zone codes configured
@ -72,126 +72,126 @@ public interface NovaClient {
* Provides synchronous access to Server features.
*/
@Delegate
ServerClient getServerClientForZone(
ServerApi getServerApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Flavor features.
*/
@Delegate
FlavorClient getFlavorClientForZone(
FlavorApi getFlavorApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Extension features.
*/
@Delegate
ExtensionClient getExtensionClientForZone(
ExtensionApi getExtensionApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Image features.
*/
@Delegate
ImageClient getImageClientForZone(
ImageApi getImageApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Floating IP features.
*/
@Delegate
Optional<FloatingIPClient> getFloatingIPExtensionForZone(
Optional<FloatingIPApi> getFloatingIPExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Security Group features.
*/
@Delegate
Optional<SecurityGroupClient> getSecurityGroupExtensionForZone(
Optional<SecurityGroupApi> getSecurityGroupExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Key Pair features.
*/
@Delegate
Optional<KeyPairClient> getKeyPairExtensionForZone(
Optional<KeyPairApi> getKeyPairExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Host Administration features.
*/
@Delegate
Optional<HostAdministrationClient> getHostAdministrationExtensionForZone(
Optional<HostAdministrationApi> getHostAdministrationExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Simple Tenant Usage features.
*/
@Delegate
Optional<SimpleTenantUsageClient> getSimpleTenantUsageExtensionForZone(
Optional<SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Volume features.
*/
@Delegate
Optional<VolumeClient> getVolumeExtensionForZone(
Optional<VolumeApi> getVolumeExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Virtual Interface features.
*/
@Delegate
Optional<VirtualInterfaceClient> getVirtualInterfaceExtensionForZone(
Optional<VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Server Extra Data features.
*/
@Delegate
Optional<ServerWithSecurityGroupsClient> getServerWithSecurityGroupsExtensionForZone(
Optional<ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Server Admin Actions features.
*/
@Delegate
Optional<AdminActionsClient> getAdminActionsExtensionForZone(
Optional<AdminActionsApi> getAdminActionsExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Aggregate features.
*/
@Delegate
Optional<HostAggregateClient> getHostAggregateExtensionForZone(
Optional<HostAggregateApi> getHostAggregateExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Flavor extra specs features.
*/
@Delegate
Optional<FlavorExtraSpecsClient> getFlavorExtraSpecsExtensionForZone(
Optional<FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Quota features.
*/
@Delegate
Optional<QuotaClient> getQuotaExtensionForZone(
Optional<QuotaApi> getQuotaExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Quota Classes features.
*/
@Delegate
Optional<QuotaClassClient> getQuotaClassExtensionForZone(
Optional<QuotaClassApi> getQuotaClassExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Volume Type features.
*/
@Delegate
Optional<VolumeTypeClient> getVolumeTypeExtensionForZone(
Optional<VolumeTypeApi> getVolumeTypeExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
}

View File

@ -53,7 +53,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<NovaClient, NovaAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<NovaClient, NovaAsyncClient>>() {
public static final TypeToken<RestContext<NovaApi, NovaAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<NovaApi, NovaAsyncApi>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@ -91,7 +91,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(NovaClient.class, NovaAsyncClient.class);
super(NovaApi.class, NovaAsyncApi.class);
id("openstack-nova")
.name("OpenStack Nova Diablo+ API")
.identityName("tenantName:user or user")
@ -121,4 +121,4 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
}
}
}

View File

@ -23,24 +23,24 @@ import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.ExtensionAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.ImageAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.ServerAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ExtensionAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
@ -51,12 +51,12 @@ import com.google.inject.Provides;
* Provides asynchronous access to Nova via their REST API.
* <p/>
*
* @see NovaClient
* @see NovaApi
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
* />
* @author Adrian Cole
*/
public interface NovaAsyncClient {
public interface NovaAsyncApi {
/**
*
@ -70,77 +70,77 @@ public interface NovaAsyncClient {
* Provides asynchronous access to Server features.
*/
@Delegate
ServerAsyncClient getServerClientForZone(
ServerAsyncApi getServerApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Flavor features.
*/
@Delegate
FlavorAsyncClient getFlavorClientForZone(
FlavorAsyncApi getFlavorApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Extension features.
*/
@Delegate
ExtensionAsyncClient getExtensionClientForZone(
ExtensionAsyncApi getExtensionApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Image features.
*/
@Delegate
ImageAsyncClient getImageClientForZone(
ImageAsyncApi getImageApiForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Floating IP features.
*/
@Delegate
Optional<FloatingIPAsyncClient> getFloatingIPExtensionForZone(
Optional<FloatingIPAsyncApi> getFloatingIPExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Security Group features.
*/
@Delegate
Optional<SecurityGroupAsyncClient> getSecurityGroupExtensionForZone(
Optional<SecurityGroupAsyncApi> getSecurityGroupExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Key Pair features.
*/
@Delegate
Optional<KeyPairAsyncClient> getKeyPairExtensionForZone(
Optional<KeyPairAsyncApi> getKeyPairExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Host Administration features.
*/
@Delegate
Optional<HostAdministrationAsyncClient> getHostAdministrationExtensionForZone(
Optional<HostAdministrationAsyncApi> getHostAdministrationExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Simple Tenant Usage features.
*/
@Delegate
Optional<SimpleTenantUsageAsyncClient> getSimpleTenantUsageExtensionForZone(
Optional<SimpleTenantUsageAsyncApi> getSimpleTenantUsageExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Volume features.
*/
@Delegate
Optional<VolumeAsyncClient> getVolumeExtensionForZone(
Optional<VolumeAsyncApi> getVolumeExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Virtual Interface features.
*/
@Delegate
Optional<VirtualInterfaceAsyncClient> getVirtualInterfaceExtensionForZone(
Optional<VirtualInterfaceAsyncApi> getVirtualInterfaceExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
@ -148,49 +148,49 @@ public interface NovaAsyncClient {
* Provides asynchronous access to Server Extra Data features.
*/
@Delegate
Optional<ServerWithSecurityGroupsAsyncClient> getServerWithSecurityGroupsExtensionForZone(
Optional<ServerWithSecurityGroupsAsyncApi> getServerWithSecurityGroupsExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Server Admin Actions features.
*/
@Delegate
Optional<AdminActionsAsyncClient> getAdminActionsExtensionForZone(
Optional<AdminActionsAsyncApi> getAdminActionsExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to HostAggregate features.
*/
@Delegate
Optional<HostAggregateAsyncClient> getHostAggregateExtensionForZone(
Optional<HostAggregateAsyncApi> getHostAggregateExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Flavor extra specs features.
*/
@Delegate
Optional<FlavorExtraSpecsAsyncClient> getFlavorExtraSpecsExtensionForZone(
Optional<FlavorExtraSpecsAsyncApi> getFlavorExtraSpecsExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Quota features.
*/
@Delegate
Optional<QuotaAsyncClient> getQuotaExtensionForZone(
Optional<QuotaAsyncApi> getQuotaExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Quota Classes features.
*/
@Delegate
Optional<QuotaClassAsyncClient> getQuotaClassExtensionForZone(
Optional<QuotaClassAsyncApi> getQuotaClassExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Volume Type features.
*/
@Delegate
Optional<VolumeTypeAsyncClient> getVolumeTypeExtensionForZone(
Optional<VolumeTypeAsyncApi> getVolumeTypeExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
}

View File

@ -57,14 +57,14 @@ import org.jclouds.compute.strategy.ResumeNodeStrategy;
import org.jclouds.compute.strategy.SuspendNodeStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.domain.KeyPair;
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.zonescoped.ZoneAndName;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient;
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.predicates.KeyPairPredicates;
import org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates;
import org.jclouds.scriptbuilder.functions.InitAdminAccess;
@ -83,7 +83,7 @@ import com.google.common.collect.Multimap;
*/
@Singleton
public class NovaComputeService extends BaseComputeService {
protected final NovaClient novaClient;
protected final NovaApi novaApi;
protected final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap;
protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
protected final Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId;
@ -104,7 +104,7 @@ public class NovaComputeService extends BaseComputeService {
InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, NovaClient novaClient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, NovaApi novaApi,
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap,
LoadingCache<ZoneAndName, KeyPair> keyPairCache,
Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId,
@ -114,7 +114,7 @@ public class NovaComputeService extends BaseComputeService {
startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
persistNodeCredentials, timeouts, executor, imageExtension);
this.novaClient = checkNotNull(novaClient, "novaClient");
this.novaApi = checkNotNull(novaApi, "novaApi");
this.securityGroupMap = checkNotNull(securityGroupMap, "securityGroupMap");
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
this.orphanedGroupsByZoneId = checkNotNull(orphanedGroupsByZoneId, "orphanedGroupsByZoneId");
@ -135,14 +135,14 @@ public class NovaComputeService extends BaseComputeService {
}
private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
Optional<SecurityGroupClient> securityGroupClient = novaClient.getSecurityGroupExtensionForZone(zoneId);
if (securityGroupClient.isPresent()) {
Optional<SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
if (securityGroupApi.isPresent()) {
for (String group : groups) {
for (SecurityGroup securityGroup : Iterables.filter(securityGroupClient.get().listSecurityGroups(),
for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().listSecurityGroups(),
SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
logger.debug(">> deleting securityGroup(%s)", zoneAndName);
securityGroupClient.get().deleteSecurityGroup(securityGroup.getId());
securityGroupApi.get().deleteSecurityGroup(securityGroup.getId());
// TODO: test this clear happens
securityGroupMap.invalidate(zoneAndName);
logger.debug("<< deleted securityGroup(%s)", zoneAndName);
@ -152,15 +152,15 @@ public class NovaComputeService extends BaseComputeService {
}
private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
Optional<KeyPairClient> keyPairClient = novaClient.getKeyPairExtensionForZone(zoneId);
if (keyPairClient.isPresent()) {
Optional<KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
if (keyPairApi.isPresent()) {
for (String group : groups) {
for (Map<String, KeyPair> view : keyPairClient.get().listKeyPairs()) {
for (Map<String, KeyPair> view : keyPairApi.get().listKeyPairs()) {
for (KeyPair pair : Iterables.filter(view.values(),
KeyPairPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
logger.debug(">> deleting keypair(%s)", zoneAndName);
keyPairClient.get().deleteKeyPair(pair.getName());
keyPairApi.get().deleteKeyPair(pair.getName());
// TODO: test this clear happens
keyPairCache.invalidate(zoneAndName);
logger.debug("<< deleted keypair(%s)", zoneAndName);

View File

@ -37,7 +37,7 @@ import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.location.Zone;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.options.NovaTemplateOptions;
import org.jclouds.openstack.nova.v2_0.compute.strategy.ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet;
@ -76,16 +76,16 @@ public class NovaComputeServiceAdapter implements
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final NovaClient novaClient;
protected final NovaApi novaApi;
protected final Supplier<Set<String>> zoneIds;
protected final RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate;
protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
@Inject
public NovaComputeServiceAdapter(NovaClient novaClient, @Zone Supplier<Set<String>> zoneIds,
public NovaComputeServiceAdapter(NovaApi novaApi, @Zone Supplier<Set<String>> zoneIds,
RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate,
LoadingCache<ZoneAndName, KeyPair> keyPairCache) {
this.novaClient = checkNotNull(novaClient, "novaClient");
this.novaApi = checkNotNull(novaApi, "novaApi");
this.zoneIds = checkNotNull(zoneIds, "zoneIds");
this.removeFloatingIpFromNodeAndDeallocate = checkNotNull(removeFloatingIpFromNodeAndDeallocate,
"removeFloatingIpFromNodeAndDeallocate");
@ -124,8 +124,8 @@ public class NovaComputeServiceAdapter implements
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);
ServerCreated lightweightServer = novaClient.getServerClientForZone(zoneId).createServer(name, imageId, flavorId, options);
Server server = novaClient.getServerClientForZone(zoneId).getServer(lightweightServer.getId());
ServerCreated lightweightServer = novaApi.getServerApiForZone(zoneId).createServer(name, imageId, flavorId, options);
Server server = novaApi.getServerApiForZone(zoneId).getServer(lightweightServer.getId());
logger.trace("<< server(%s)", server.getId());
@ -140,7 +140,7 @@ public class NovaComputeServiceAdapter implements
public Iterable<FlavorInZone> listHardwareProfiles() {
Builder<FlavorInZone> builder = ImmutableSet.builder();
for (final String zoneId : zoneIds.get()) {
builder.addAll(transform(novaClient.getFlavorClientForZone(zoneId).listFlavorsInDetail(),
builder.addAll(transform(novaApi.getFlavorApiForZone(zoneId).listFlavorsInDetail(),
new Function<Flavor, FlavorInZone>() {
@Override
@ -159,7 +159,7 @@ public class NovaComputeServiceAdapter implements
Set<String> zones = zoneIds.get();
checkState(zones.size() > 0, "no zones found in supplier %s", zoneIds);
for (final String zoneId : zones) {
Set<Image> images = novaClient.getImageClientForZone(zoneId).listImagesInDetail();
Set<Image> images = novaApi.getImageApiForZone(zoneId).listImagesInDetail();
if (images.size() == 0) {
logger.debug("no images found in zone %s", zoneId);
continue;
@ -194,7 +194,7 @@ public class NovaComputeServiceAdapter implements
public Iterable<ServerInZone> listNodes() {
Builder<ServerInZone> builder = ImmutableSet.builder();
for (final String zoneId : zoneIds.get()) {
builder.addAll(transform(novaClient.getServerClientForZone(zoneId).listServersInDetail(),
builder.addAll(transform(novaApi.getServerApiForZone(zoneId).listServersInDetail(),
new Function<Server, ServerInZone>() {
@Override
@ -216,41 +216,41 @@ public class NovaComputeServiceAdapter implements
@Override
public ServerInZone getNode(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
Server server = novaClient.getServerClientForZone(zoneAndId.getZone()).getServer(zoneAndId.getId());
Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).getServer(zoneAndId.getId());
return server == null ? null : new ServerInZone(server, zoneAndId.getZone());
}
@Override
public ImageInZone getImage(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
Image image = novaClient.getImageClientForZone(zoneAndId.getZone()).getImage(zoneAndId.getId());
Image image = novaApi.getImageApiForZone(zoneAndId.getZone()).getImage(zoneAndId.getId());
return image == null ? null : new ImageInZone(image, zoneAndId.getZone());
}
@Override
public void destroyNode(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
if (novaClient.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
if (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
try {
removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
} catch (RuntimeException e) {
logger.warn(e, "<< error removing and deallocating ip from node(%s): %s", id, e.getMessage());
}
}
novaClient.getServerClientForZone(zoneAndId.getZone()).deleteServer(zoneAndId.getId());
novaApi.getServerApiForZone(zoneAndId.getZone()).deleteServer(zoneAndId.getId());
}
@Override
public void rebootNode(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
novaClient.getServerClientForZone(zoneAndId.getZone()).rebootServer(zoneAndId.getId(), RebootType.HARD);
novaApi.getServerApiForZone(zoneAndId.getZone()).rebootServer(zoneAndId.getId(), RebootType.HARD);
}
@Override
public void resumeNode(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
if (novaClient.getAdminActionsExtensionForZone(zoneAndId.getZone()).isPresent()) {
novaClient.getAdminActionsExtensionForZone(zoneAndId.getZone()).get().resumeServer(zoneAndId.getId());
if (novaApi.getAdminActionsExtensionForZone(zoneAndId.getZone()).isPresent()) {
novaApi.getAdminActionsExtensionForZone(zoneAndId.getZone()).get().resumeServer(zoneAndId.getId());
}
throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension");
}
@ -258,8 +258,8 @@ public class NovaComputeServiceAdapter implements
@Override
public void suspendNode(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
if (novaClient.getAdminActionsExtensionForZone(zoneAndId.getZone()).isPresent()) {
novaClient.getAdminActionsExtensionForZone(zoneAndId.getZone()).get().suspendServer(zoneAndId.getId());
if (novaApi.getAdminActionsExtensionForZone(zoneAndId.getZone()).isPresent()) {
novaApi.getAdminActionsExtensionForZone(zoneAndId.getZone()).get().suspendServer(zoneAndId.getId());
}
throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension");
}

View File

@ -265,4 +265,4 @@ public class NovaComputeServiceContextModule extends
protected Optional<ImageExtension> provideImageExtension(Injector i) {
return Optional.of(i.getInstance(ImageExtension.class));
}
}
}

View File

@ -41,7 +41,7 @@ import org.jclouds.compute.extensions.ImageExtension;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.concurrent.Futures;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.zonescoped.ZoneAndId;
import org.jclouds.predicates.PredicateWithResult;
@ -62,7 +62,7 @@ public class NovaImageExtension implements ImageExtension {
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
private final NovaClient novaClient;
private final NovaApi novaApi;
private final ExecutorService executor;
@com.google.inject.Inject(optional = true)
@Named("IMAGE_MAX_WAIT")
@ -73,10 +73,10 @@ public class NovaImageExtension implements ImageExtension {
private PredicateWithResult<ZoneAndId, Image> imageReadyPredicate;
@Inject
public NovaImageExtension(NovaClient novaClient,
public NovaImageExtension(NovaApi novaApi,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
PredicateWithResult<ZoneAndId, Image> imageReadyPredicate) {
this.novaClient = checkNotNull(novaClient);
this.novaApi = checkNotNull(novaApi);
this.executor = userThreads;
this.imageReadyPredicate = imageReadyPredicate;
}
@ -84,7 +84,7 @@ public class NovaImageExtension implements ImageExtension {
@Override
public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
Server server = novaClient.getServerClientForZone(zoneAndId.getZone()).getServer(zoneAndId.getId());
Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).getServer(zoneAndId.getId());
if (server == null)
throw new NoSuchElementException("Cannot find server with id: " + zoneAndId);
CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
@ -98,7 +98,7 @@ public class NovaImageExtension implements ImageExtension {
CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
ZoneAndId sourceImageZoneAndId = ZoneAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
String newImageId = novaClient.getServerClientForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
String newImageId = novaApi.getServerApiForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
cloneTemplate.getName(), sourceImageZoneAndId.getId());
final ZoneAndId targetImageZoneAndId = ZoneAndId.fromZoneAndId(sourceImageZoneAndId.getZone(), newImageId);
@ -119,7 +119,7 @@ public class NovaImageExtension implements ImageExtension {
public boolean deleteImage(String id) {
ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
try {
this.novaClient.getImageClientForZone(zoneAndId.getZone()).deleteImage(zoneAndId.getId());
this.novaApi.getImageApiForZone(zoneAndId.getZone()).deleteImage(zoneAndId.getId());
} catch (Exception e) {
return false;
}

View File

@ -33,10 +33,10 @@ import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.zonescoped.ZoneAndId;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
import org.jclouds.rest.InsufficientResourcesException;
import com.google.common.base.Function;
@ -60,14 +60,14 @@ public class AllocateAndAddFloatingIpToNode implements
protected Logger logger = Logger.NULL;
private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
private final NovaClient novaClient;
private final NovaApi novaApi;
private final LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache;
@Inject
public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
NovaClient novaClient, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
this.novaClient = checkNotNull(novaClient, "novaClient");
this.novaApi = checkNotNull(novaApi, "novaApi");
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
}
@ -77,16 +77,16 @@ public class AllocateAndAddFloatingIpToNode implements
NodeMetadata node = input.get();
// node's location is a host
String zoneId = node.getLocation().getParent().getId();
FloatingIPClient floatingIpClient = novaClient.getFloatingIPExtensionForZone(zoneId).get();
FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(zoneId).get();
FloatingIP ip = null;
try {
logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId());
ip = floatingIpClient.allocate();
ip = floatingIpApi.allocate();
} catch (InsufficientResourcesException e) {
logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
logger.trace(">> searching for existing, unassigned floating ip for node(%s)", node.getId());
ArrayList<FloatingIP> unassignedIps = Lists.newArrayList(Iterables.filter(floatingIpClient.listFloatingIPs(),
ArrayList<FloatingIP> unassignedIps = Lists.newArrayList(Iterables.filter(floatingIpApi.listFloatingIPs(),
new Predicate<FloatingIP>() {
@Override
@ -101,7 +101,7 @@ public class AllocateAndAddFloatingIpToNode implements
}
logger.debug(">> adding floatingIp(%s) to node(%s)", ip.getIp(), node.getId());
floatingIpClient.addFloatingIPToServer(ip.getIp(), node.getProviderId());
floatingIpApi.addFloatingIPToServer(ip.getIp(), node.getProviderId());
input.set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.getIp())).build());
floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId()));
return input;
@ -111,4 +111,4 @@ public class AllocateAndAddFloatingIpToNode implements
public String toString() {
return Objects.toStringHelper("AllocateAndAddFloatingIpToNode").toString();
}
}
}

View File

@ -30,13 +30,13 @@ import javax.inject.Singleton;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.IpProtocol;
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.zonescoped.ZoneSecurityGroupNameAndPorts;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import com.google.common.base.Function;
import com.google.common.base.Optional;
@ -50,11 +50,11 @@ public class CreateSecurityGroupIfNeeded implements Function<ZoneSecurityGroupNa
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final NovaClient novaClient;
protected final NovaApi novaApi;
@Inject
public CreateSecurityGroupIfNeeded(NovaClient novaClient) {
this.novaClient = checkNotNull(novaClient, "novaClient");
public CreateSecurityGroupIfNeeded(NovaApi novaApi) {
this.novaApi = checkNotNull(novaApi, "novaApi");
}
@Override
@ -62,33 +62,33 @@ public class CreateSecurityGroupIfNeeded implements Function<ZoneSecurityGroupNa
checkNotNull(zoneSecurityGroupNameAndPorts, "zoneSecurityGroupNameAndPorts");
String zoneId = zoneSecurityGroupNameAndPorts.getZone();
Optional<SecurityGroupClient> client = novaClient.getSecurityGroupExtensionForZone(zoneId);
checkArgument(client.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
Optional<SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
try {
SecurityGroup securityGroup = client.get().createSecurityGroupWithNameAndDescription(
SecurityGroup securityGroup = api.get().createSecurityGroupWithNameAndDescription(
zoneSecurityGroupNameAndPorts.getName(), zoneSecurityGroupNameAndPorts.getName());
logger.debug("<< created securityGroup(%s)", securityGroup);
for (int port : zoneSecurityGroupNameAndPorts.getPorts()) {
authorizeGroupToItselfAndAllIPsToTCPPort(client.get(), securityGroup, port);
authorizeGroupToItselfAndAllIPsToTCPPort(api.get(), securityGroup, port);
}
return new SecurityGroupInZone(client.get().getSecurityGroup(securityGroup.getId()), zoneId);
return new SecurityGroupInZone(api.get().getSecurityGroup(securityGroup.getId()), zoneId);
} catch (IllegalStateException e) {
logger.trace("<< trying to find securityGroup(%s): %s", zoneSecurityGroupNameAndPorts, e.getMessage());
SecurityGroup group = find(client.get().listSecurityGroups(), nameEquals(zoneSecurityGroupNameAndPorts
SecurityGroup group = find(api.get().listSecurityGroups(), nameEquals(zoneSecurityGroupNameAndPorts
.getName()));
logger.debug("<< reused securityGroup(%s)", group.getId());
return new SecurityGroupInZone(group, zoneId);
}
}
private void authorizeGroupToItselfAndAllIPsToTCPPort(SecurityGroupClient securityGroupClient,
private void authorizeGroupToItselfAndAllIPsToTCPPort(SecurityGroupApi securityGroupApi,
SecurityGroup securityGroup, int port) {
// NOTE that permission to itself isn't supported on trystack!
logger.debug(">> authorizing securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, port);
securityGroupClient.createSecurityGroupRuleAllowingCidrBlock(securityGroup.getId(), Ingress.builder().ipProtocol(
securityGroupApi.createSecurityGroupRuleAllowingCidrBlock(securityGroup.getId(), Ingress.builder().ipProtocol(
IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
logger.debug("<< authorized securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, port);

View File

@ -76,4 +76,4 @@ public class OrphanedGroupsByZoneId implements Function<Set<? extends NodeMetada
return zoneToZoneAndGroupNames;
}
}
}

View File

@ -26,10 +26,10 @@ import javax.inject.Named;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.zonescoped.ZoneAndId;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
import com.google.common.base.Function;
import com.google.common.base.Objects;
@ -46,24 +46,24 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
private final NovaClient novaClient;
private final NovaApi novaApi;
private final LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache;
@Inject
public RemoveFloatingIpFromNodeAndDeallocate(NovaClient novaClient,
public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
@Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
this.novaClient = checkNotNull(novaClient, "novaClient");
this.novaApi = checkNotNull(novaApi, "novaApi");
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
}
@Override
public ZoneAndId apply(ZoneAndId id) {
FloatingIPClient floatingIpClient = novaClient.getFloatingIPExtensionForZone(id.getZone()).get();
FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
floatingIpClient.removeFloatingIPFromServer(ip.getIp(), id.getId());
floatingIpApi.removeFloatingIPFromServer(ip.getIp(), id.getId());
logger.debug(">> deallocating floatingIp(%s)", ip);
floatingIpClient.deallocate(ip.getId());
floatingIpApi.deallocate(ip.getId());
}
floatingIpCache.invalidate(id);
return id;
@ -73,4 +73,4 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
public String toString() {
return Objects.toStringHelper("RemoveFloatingIpFromNodeAndDeallocate").toString();
}
}
}

View File

@ -28,10 +28,10 @@ import javax.inject.Singleton;
import org.jclouds.compute.functions.GroupNamingConvention;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.zonescoped.ZoneAndName;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import com.google.common.base.Optional;
import com.google.common.cache.CacheLoader;
@ -45,12 +45,12 @@ public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final NovaClient novaClient;
protected final NovaApi novaApi;
protected final GroupNamingConvention.Factory namingConvention;
@Inject
public CreateUniqueKeyPair(NovaClient novaClient, GroupNamingConvention.Factory namingConvention) {
this.novaClient = checkNotNull(novaClient, "novaClient");
public CreateUniqueKeyPair(NovaApi novaApi, GroupNamingConvention.Factory namingConvention) {
this.novaApi = checkNotNull(novaApi, "novaApi");
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
}
@ -59,8 +59,8 @@ public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
String zoneId = checkNotNull(zoneAndName, "zoneAndName").getZone();
String prefix = zoneAndName.getName();
Optional<KeyPairClient> client = novaClient.getKeyPairExtensionForZone(zoneId);
checkArgument(client.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
Optional<KeyPairApi> api = novaApi.getKeyPairExtensionForZone(zoneId);
checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
zoneId);
logger.debug(">> creating keyPair zone(%s) prefix(%s)", zoneId, prefix);
@ -68,7 +68,7 @@ public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
KeyPair keyPair = null;
while (keyPair == null) {
try {
keyPair = client.get().createKeyPair(namingConvention.createWithoutPrefix().uniqueNameForGroup(prefix));
keyPair = api.get().createKeyPair(namingConvention.createWithoutPrefix().uniqueNameForGroup(prefix));
} catch (IllegalStateException e) {
}

View File

@ -21,10 +21,10 @@ package org.jclouds.openstack.nova.v2_0.compute.loaders;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.openstack.nova.v2_0.NovaClient;
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.zonescoped.ZoneAndId;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
@ -41,19 +41,19 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<FloatingIP>> {
private final NovaClient client;
private final NovaApi api;
@Inject
public LoadFloatingIpsForInstance(NovaClient client) {
this.client = client;
public LoadFloatingIpsForInstance(NovaApi api) {
this.api = api;
}
@Override
public Iterable<FloatingIP> load(final ZoneAndId key) throws Exception {
String zone = key.getZone();
Optional<FloatingIPClient> ipClientOptional = client.getFloatingIPExtensionForZone(zone);
if (ipClientOptional.isPresent()) {
return Iterables.filter(ipClientOptional.get().listFloatingIPs(),
Optional<FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
if (ipApiOptional.isPresent()) {
return Iterables.filter(ipApiOptional.get().listFloatingIPs(),
new Predicate<FloatingIP>() {
@Override
public boolean apply(FloatingIP input) {
@ -63,4 +63,4 @@ public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<
}
return ImmutableSet.of();
}
}
}

View File

@ -28,7 +28,7 @@ import java.util.Set;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.openstack.nova.v2_0.NovaClient;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.util.Preconditions2;
@ -46,9 +46,9 @@ import com.google.common.collect.ImmutableSet;
* <code>
* import static org.jclouds.aws.ec2.compute.options.NovaTemplateOptions.Builder.*;
* <p/>
* ComputeService client = // get connection
* ComputeService api = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* Set<? extends NodeMetadata> set = api.createNodesInGroup(tag, 2, templateBuilder.build());
* <code>
*
* @author Adam Lowe
@ -162,7 +162,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
/**
* <h3>Note</h3>
*
* This requires that {@link NovaClient#getFloatingIPExtensionForZone(String)} to return
* This requires that {@link NovaApi#getFloatingIPExtensionForZone(String)} to return
* {@link Optional#isPresent present}
*
* @return true if auto assignment of a floating ip to each vm is enabled
@ -182,7 +182,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
/**
* <h3>Note</h3>
*
* This requires that {@link NovaClient#getKeyPairExtensionForZone(String)} to return
* This requires that {@link NovaApi#getKeyPairExtensionForZone(String)} to return
* {@link Optional#isPresent present}
*
* @return true if auto generation of keypairs is enabled

View File

@ -55,4 +55,4 @@ public class AllNodesInGroupTerminated implements Predicate<ZoneAndName> {
return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()),
parentLocationId(input.getZone()))), and(inGroup(input.getName()), TERMINATED));
}
}
}

View File

@ -28,7 +28,7 @@ import javax.inject.Named;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaClient;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
import org.jclouds.predicates.PredicateWithResult;
@ -51,13 +51,13 @@ public final class GetImageWhenImageInZoneHasActiveStatusPredicateWithResult imp
private ZoneAndId resultZoneAndId;
private RuntimeException lastFailure;
private Function<ImageInZone, Image> imageInZoneToImage;
private NovaClient client;
private NovaApi api;
@Inject
public GetImageWhenImageInZoneHasActiveStatusPredicateWithResult(Function<ImageInZone, Image> imageInZoneToImage,
NovaClient client) {
NovaApi api) {
this.imageInZoneToImage = imageInZoneToImage;
this.client = client;
this.api = api;
}
@Override
@ -89,7 +89,7 @@ public final class GetImageWhenImageInZoneHasActiveStatusPredicateWithResult imp
}
public org.jclouds.openstack.nova.v2_0.domain.Image findImage(final ZoneAndId zoneAndId) {
return Iterables.tryFind(client.getImageClientForZone(zoneAndId.getZone()).listImagesInDetail(),
return Iterables.tryFind(api.getImageApiForZone(zoneAndId.getZone()).listImagesInDetail(),
new Predicate<org.jclouds.openstack.nova.v2_0.domain.Image>() {
@Override
public boolean apply(org.jclouds.openstack.nova.v2_0.domain.Image input) {
@ -98,4 +98,4 @@ public final class GetImageWhenImageInZoneHasActiveStatusPredicateWithResult imp
}).orNull();
}
}
}

View File

@ -44,7 +44,7 @@ import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIn
import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
import org.jclouds.concurrent.Futures;
import org.jclouds.openstack.nova.v2_0.NovaClient;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.compute.functions.AllocateAndAddFloatingIpToNode;
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
@ -68,7 +68,7 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
private final AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode;
private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
private final NovaClient novaClient;
private final NovaApi novaApi;
@Inject
protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(
@ -79,14 +79,14 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode,
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaClient novaClient) {
LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) {
super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, executor,
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
this.allocateAndAddFloatingIpToNode = checkNotNull(allocateAndAddFloatingIpToNode,
"allocateAndAddFloatingIpToNode");
this.novaClient = checkNotNull(novaClient, "novaClient");
this.novaApi = checkNotNull(novaApi, "novaApi");
}
@Override
@ -102,12 +102,12 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
String zone = mutableTemplate.getLocation().getId();
if (templateOptions.shouldAutoAssignFloatingIp()) {
checkArgument(novaClient.getFloatingIPExtensionForZone(zone).isPresent(),
checkArgument(novaApi.getFloatingIPExtensionForZone(zone).isPresent(),
"Floating IPs are required by options, but the extension is not available! options: %s",
templateOptions);
}
boolean keyPairExensionPresent = novaClient.getKeyPairExtensionForZone(zone).isPresent();
boolean keyPairExensionPresent = novaApi.getKeyPairExtensionForZone(zone).isPresent();
if (templateOptions.shouldGenerateKeyPair()) {
checkArgument(keyPairExensionPresent,
"Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
@ -126,10 +126,10 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
}
}
boolean securityGroupExensionPresent = novaClient.getSecurityGroupExtensionForZone(zone).isPresent();
boolean securityGroupExensionPresent = novaApi.getSecurityGroupExtensionForZone(zone).isPresent();
List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
if (templateOptions.getSecurityGroupNames().size() > 0) {
checkArgument(novaClient.getSecurityGroupExtensionForZone(zone).isPresent(),
checkArgument(novaApi.getSecurityGroupExtensionForZone(zone).isPresent(),
"Security groups are required by options, but the extension is not available! options: %s",
templateOptions);
} else if (securityGroupExensionPresent && inboundPorts.size() > 0) {
@ -159,4 +159,4 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
}
}
}
}

View File

@ -29,45 +29,45 @@ import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.openstack.nova.v2_0.NovaAsyncClient;
import org.jclouds.openstack.nova.v2_0.NovaClient;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.Extension;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsClient;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateClient;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassClient;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClient;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsClient;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageClient;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncClient;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeClient;
import org.jclouds.openstack.nova.v2_0.features.ExtensionAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.ExtensionClient;
import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.FlavorClient;
import org.jclouds.openstack.nova.v2_0.features.ImageAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.ImageClient;
import org.jclouds.openstack.nova.v2_0.features.ServerAsyncClient;
import org.jclouds.openstack.nova.v2_0.features.ServerClient;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.AdminActionsApi;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageApi;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi;
import org.jclouds.openstack.nova.v2_0.features.ExtensionAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ExtensionApi;
import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.openstack.nova.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet;
import org.jclouds.openstack.nova.v2_0.handlers.NovaErrorHandler;
import org.jclouds.rest.ConfiguresRestClient;
@ -86,25 +86,25 @@ import com.google.inject.Provides;
* @author Adrian Cole
*/
@ConfiguresRestClient
public class NovaRestClientModule extends RestClientModule<NovaClient, NovaAsyncClient> {
public class NovaRestClientModule extends RestClientModule<NovaApi, NovaAsyncApi> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
.put(ServerClient.class, ServerAsyncClient.class).put(FlavorClient.class, FlavorAsyncClient.class)
.put(ImageClient.class, ImageAsyncClient.class).put(ExtensionClient.class, ExtensionAsyncClient.class)
.put(FloatingIPClient.class, FloatingIPAsyncClient.class)
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)
.put(KeyPairClient.class, KeyPairAsyncClient.class)
.put(HostAdministrationClient.class, HostAdministrationAsyncClient.class)
.put(SimpleTenantUsageClient.class, SimpleTenantUsageAsyncClient.class)
.put(VolumeClient.class, VolumeAsyncClient.class)
.put(VirtualInterfaceClient.class, VirtualInterfaceAsyncClient.class)
.put(ServerWithSecurityGroupsClient.class, ServerWithSecurityGroupsAsyncClient.class)
.put(AdminActionsClient.class, AdminActionsAsyncClient.class)
.put(HostAggregateClient.class, HostAggregateAsyncClient.class)
.put(FlavorExtraSpecsClient.class, FlavorExtraSpecsAsyncClient.class)
.put(QuotaClient.class, QuotaAsyncClient.class)
.put(QuotaClassClient.class, QuotaClassAsyncClient.class)
.put(VolumeTypeClient.class, VolumeTypeAsyncClient.class)
.put(ServerApi.class, ServerAsyncApi.class).put(FlavorApi.class, FlavorAsyncApi.class)
.put(ImageApi.class, ImageAsyncApi.class).put(ExtensionApi.class, ExtensionAsyncApi.class)
.put(FloatingIPApi.class, FloatingIPAsyncApi.class)
.put(SecurityGroupApi.class, SecurityGroupAsyncApi.class)
.put(KeyPairApi.class, KeyPairAsyncApi.class)
.put(HostAdministrationApi.class, HostAdministrationAsyncApi.class)
.put(SimpleTenantUsageApi.class, SimpleTenantUsageAsyncApi.class)
.put(VolumeApi.class, VolumeAsyncApi.class)
.put(VirtualInterfaceApi.class, VirtualInterfaceAsyncApi.class)
.put(ServerWithSecurityGroupsApi.class, ServerWithSecurityGroupsAsyncApi.class)
.put(AdminActionsApi.class, AdminActionsAsyncApi.class)
.put(HostAggregateApi.class, HostAggregateAsyncApi.class)
.put(FlavorExtraSpecsApi.class, FlavorExtraSpecsAsyncApi.class)
.put(QuotaApi.class, QuotaAsyncApi.class)
.put(QuotaClassApi.class, QuotaClassAsyncApi.class)
.put(VolumeTypeApi.class, VolumeTypeAsyncApi.class)
.build();
public NovaRestClientModule() {
@ -121,13 +121,13 @@ public class NovaRestClientModule extends RestClientModule<NovaClient, NovaAsync
@Provides
@Singleton
public LoadingCache<String, Set<Extension>> provideExtensionsByZone(final Provider<NovaClient> novaClient) {
public LoadingCache<String, Set<Extension>> provideExtensionsByZone(final Provider<NovaApi> novaApi) {
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
.build(new CacheLoader<String, Set<Extension>>() {
@Override
public Set<Extension> load(String key) throws Exception {
return novaClient.get().getExtensionClientForZone(key).listExtensions();
return novaApi.get().getExtensionApiForZone(key).listExtensions();
}
});

View File

@ -175,7 +175,7 @@ public class Flavor extends Resource {
* <p/>
* NOTE: This field is only present if the Flavor Extra Data extension is installed (alias "OS-FLV-EXT-DATA").
*
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#FLAVOR_EXTRA_DATA
*/
public Optional<Integer> getEphemeral() {

View File

@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableSet;
/**
* Aggregates can be manipulated using the Aggregate Extension to Nova (alias "OS-AGGREGATES")
*
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateClient
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi
*/
public class HostAggregate {

View File

@ -38,4 +38,4 @@ public enum IpProtocol {
return UNRECOGNIZED;
}
}
}
}

View File

@ -23,7 +23,7 @@ import java.beans.ConstructorProperties;
/**
* Represents the set of limits (quota class) returned by the Quota Class Extension
*
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassClient
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi
*/
public class QuotaClass extends Quotas {

View File

@ -30,7 +30,7 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* Represents the set of limits (quotas) returned by the Quota Extension
*
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClient
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaApi
*/
public class Quotas {
@ -298,7 +298,7 @@ public class Quotas {
/**
* @return the limit of the number of security groups that can be created for the tenant
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi
*/
public int getSecurityGroups() {
return this.securityGroups;
@ -306,7 +306,7 @@ public class Quotas {
/**
* @return the limit of the number of security group rules that can be created for the tenant
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi
*/
public int getSecurityGroupRules() {
return this.securityGroupRules;
@ -314,7 +314,7 @@ public class Quotas {
/**
* @return the limit of the number of key pairs that can be created for the tenant
* @see org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient
* @see org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi
*/
public int getKeyPairs() {
return this.keyPairs;

View File

@ -27,7 +27,7 @@ import java.util.Map;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.openstack.v2_0.domain.Resource;
@ -412,7 +412,7 @@ public class Server extends Resource {
/**
* @return keyName if extension is present and there is a valur for this server
* @see KeyPairClient
* @see KeyPairApi
*/
@Nullable
public String getKeyName() {
@ -424,7 +424,7 @@ public class Server extends Resource {
* <p/>
* NOTE: This field is only present if the Extended Status extension is installed.
*
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#EXTENDED_STATUS
*/
public Optional<ServerExtendedStatus> getExtendedStatus() {
@ -436,7 +436,7 @@ public class Server extends Resource {
* <p/>
* NOTE: This field is only present if the The Extended Server Attributes API extension is installed.
*
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#EXTENDED_STATUS
*/
public Optional<ServerExtendedAttributes> getExtendedAttributes() {
@ -448,7 +448,7 @@ public class Server extends Resource {
* <p/>
* NOTE: This field is only present if the Disk Config extension is installed
*
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#DISK_CONFIG
*/
public Optional<String> getDiskConfig() {

View File

@ -31,7 +31,7 @@ import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
* Server Resource with administrative password returned by ServerClient#CreateServer calls
* Server Resource with administrative password returned by ServerApi#CreateServer calls
*
* @author Adam Lowe
* @see <a href=

Some files were not shown because too many files have changed in this diff Show More