mirror of https://github.com/apache/jclouds.git
removed ContextBuilder subclasses; added unwrap; undid generic params
This commit is contained in:
parent
874884c61b
commit
0b59dea073
|
@ -25,19 +25,31 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
|
||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AtmosApiMetadata
|
||||
extends
|
||||
BaseBlobStoreApiMetadata<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
|
||||
public class AtmosApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 8067252472547486854L;
|
||||
|
||||
public static final TypeToken<RestContext<AtmosClient, AtmosAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<AtmosClient, AtmosAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
|
||||
private static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -55,17 +67,16 @@ public class AtmosApiMetadata
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
|
||||
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
extends
|
||||
BaseBlobStoreApiMetadata.Builder<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
protected Builder() {
|
||||
super(AtmosClient.class, AtmosAsyncClient.class);
|
||||
id("atmos")
|
||||
.name("EMC's Atmos API")
|
||||
.identityName("Subtenant ID (UID)")
|
||||
|
@ -73,9 +84,9 @@ public class AtmosApiMetadata
|
|||
.documentation(URI.create("https://community.emc.com/docs/DOC-10508"))
|
||||
.version("1.4.0")
|
||||
.defaultEndpoint("https://accesspoint.atmosonline.com")
|
||||
.contextBuilder(TypeToken.of(AtmosContextBuilder.class))
|
||||
.defaultProperties(AtmosApiMetadata.defaultProperties())
|
||||
.javaApi(AtmosClient.class, AtmosAsyncClient.class);
|
||||
.wrapper(TypeToken.of(BlobStoreContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +95,7 @@ public class AtmosApiMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(AtmosApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.atmos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
|
||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link AtmosStoreContext} or {@link Injector} instances based on
|
||||
* the most commonly requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or
|
||||
* Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default
|
||||
* {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
|
||||
* installed.
|
||||
*
|
||||
* @author Adrian Cole, Andrew Newdigate
|
||||
* @see AtmosStoreContext
|
||||
*/
|
||||
public class AtmosContextBuilder
|
||||
extends
|
||||
BlobStoreContextBuilder<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
|
||||
|
||||
public AtmosContextBuilder(
|
||||
ProviderMetadata<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public AtmosContextBuilder(AtmosApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new AtmosBlobStoreContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new AtmosRestClientModule());
|
||||
}
|
||||
}
|
|
@ -33,8 +33,8 @@ import org.jclouds.rest.Binder;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
|
|
@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
private final LoadingCache<String, Boolean> isPublic;
|
||||
|
||||
@Inject
|
||||
AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils,
|
||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async, AtmosClient sync,
|
||||
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||
|
|
|
@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore {
|
|||
private final LoadingCache<String, Boolean> isPublic;
|
||||
|
||||
@Inject
|
||||
AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||
AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, AtmosClient sync, ObjectToBlob object2Blob,
|
||||
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.atmos.AtmosAsyncClient;
|
||||
import org.jclouds.atmos.AtmosClient;
|
||||
import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore;
|
||||
import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner;
|
||||
|
@ -31,10 +30,8 @@ import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
|
|||
import org.jclouds.blobstore.AsyncBlobStore;
|
||||
import org.jclouds.blobstore.BlobRequestSigner;
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||
import org.jclouds.blobstore.config.BlobStoreMapModule;
|
||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
@ -43,7 +40,6 @@ import com.google.common.cache.LoadingCache;
|
|||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound.
|
||||
|
@ -58,8 +54,6 @@ public class AtmosBlobStoreContextModule extends AbstractModule {
|
|||
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
|
||||
bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON);
|
||||
bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON);
|
||||
bind(BlobStoreContext.class).to(new TypeLiteral<BlobStoreContextImpl<AtmosClient, AtmosAsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class);
|
||||
bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
package org.jclouds.atmos.blobstore.functions;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.date.DateService;
|
|||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
|
@ -50,7 +49,6 @@ import com.google.inject.Provides;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> {
|
||||
public AtmosRestClientModule() {
|
||||
super(AtmosClient.class, AtmosAsyncClient.class);
|
||||
|
|
|
@ -51,8 +51,8 @@ import org.jclouds.util.Strings2;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
/**
|
||||
* Signs the EMC Atmos Online Storage request.
|
||||
|
|
|
@ -33,9 +33,9 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
|
|||
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
|
@ -320,7 +319,6 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
return new TestAtmosRestClientModule();
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
|
||||
@Override
|
||||
|
@ -337,7 +335,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
protected String provider = "atmos";
|
||||
|
||||
@Override
|
||||
public ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
public ApiMetadata createApiMetadata() {
|
||||
return new AtmosApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ import com.google.common.collect.Sets;
|
|||
public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||
|
||||
public AtmosClient getApi() {
|
||||
return (AtmosClient) context.getProviderSpecificContext().getApi();
|
||||
return context.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
}
|
||||
|
||||
private static final class HeadMatches implements Runnable {
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.blobstore.domain.Blob;
|
|||
import org.jclouds.blobstore.domain.Blob.Factory;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
|
@ -128,7 +127,6 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
|
|||
return new TestAtmosRestClientModule();
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
|
||||
@Override
|
||||
|
@ -143,7 +141,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
|
|||
}
|
||||
|
||||
@Override
|
||||
public ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
public ApiMetadata createApiMetadata() {
|
||||
return new AtmosApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ package org.jclouds.atmos.blobstore.config;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.atmos.AtmosApiMetadata;
|
||||
import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
|
@ -41,7 +41,7 @@ import com.google.inject.Module;
|
|||
public class AtmosBlobStoreModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return BlobStoreContextBuilder
|
||||
return ContextBuilder
|
||||
.newBuilder(new AtmosApiMetadata())
|
||||
.credentials("uid", "key")
|
||||
.modules(
|
||||
|
@ -53,7 +53,7 @@ public class AtmosBlobStoreModuleTest {
|
|||
void testContextImpl() {
|
||||
|
||||
Injector injector = createInjector();
|
||||
BlobStoreContext<?, ?> handler = injector.getInstance(BlobStoreContext.class);
|
||||
BlobStoreContext handler = injector.getInstance(BlobStoreContext.class);
|
||||
assertEquals(handler.getClass(), BlobStoreContextImpl.class);
|
||||
ContainsValueInListStrategy valueList = injector
|
||||
.getInstance(ContainsValueInListStrategy.class);
|
||||
|
|
|
@ -28,12 +28,11 @@ import java.security.NoSuchAlgorithmException;
|
|||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||
import org.jclouds.atmos.reference.AtmosHeaders;
|
||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
|
||||
|
@ -43,9 +42,9 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
|
@ -97,7 +96,7 @@ public class SignRequestTest {
|
|||
|
||||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
Injector injector = BlobStoreContextBuilder
|
||||
Injector injector = ContextBuilder
|
||||
.newBuilder("atmos")
|
||||
.credentials(UID, KEY)
|
||||
.modules(
|
||||
|
@ -108,7 +107,6 @@ public class SignRequestTest {
|
|||
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.File;
|
||||
|
||||
import org.jclouds.atmos.domain.AtmosObject;
|
||||
import org.jclouds.atmos.domain.AtmosObject.Factory;
|
||||
import org.jclouds.atmos.domain.SystemMetadata;
|
||||
import org.jclouds.atmos.domain.UserMetadata;
|
||||
import org.jclouds.atmos.domain.AtmosObject.Factory;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
package org.jclouds.byon;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.JcloudsVersion;
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.apis.internal.BaseApiMetadata;
|
||||
import org.jclouds.byon.config.BYONComputeServiceContextModule;
|
||||
import org.jclouds.byon.config.YamlNodeStoreModule;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for jclouds BYON API
|
||||
|
@ -39,8 +40,10 @@ import com.google.common.reflect.TypeToken;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
|
||||
public class BYONApiMetadata extends BaseApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -4059125995177393819L;
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -55,11 +58,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Sup
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
return BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||
}
|
||||
|
||||
public static class Builder extends BaseComputeServiceApiMetadata.Builder<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
|
||||
public static class Builder extends BaseApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
id("byon")
|
||||
|
@ -71,9 +70,8 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Sup
|
|||
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
|
||||
.version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion))
|
||||
.buildVersion(JcloudsVersion.get().toString())
|
||||
.defaultProperties(BYONApiMetadata.defaultProperties())
|
||||
.javaApi(Supplier.class, Supplier.class)
|
||||
.contextBuilder(TypeToken.of(BYONComputeServiceContextBuilder.class));
|
||||
.wrapper(ComputeServiceContext.class)
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,7 +80,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Sup
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(BYONApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.byon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.byon.config.BYONComputeServiceContextModule;
|
||||
import org.jclouds.byon.config.ConfiguresNodeStore;
|
||||
import org.jclouds.byon.config.YamlNodeStoreModule;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder<Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
|
||||
|
||||
public BYONComputeServiceContextBuilder(
|
||||
ProviderMetadata<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new BYONComputeServiceContextModule());
|
||||
addNodeStoreModuleIfNotPresent(modules);
|
||||
}
|
||||
|
||||
protected void addNodeStoreModuleIfNotPresent(List<Module> modules) {
|
||||
if (!Iterables.any(modules, new Predicate<Module>() {
|
||||
public boolean apply(Module input) {
|
||||
return input.getClass().isAnnotationPresent(ConfiguresNodeStore.class);
|
||||
}
|
||||
|
||||
})) {
|
||||
addNodeStoreModule(modules);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addNodeStoreModule(List<Module> modules) {
|
||||
modules.add(new YamlNodeStoreModule());
|
||||
}
|
||||
}
|
|
@ -21,9 +21,6 @@ package org.jclouds.byon.config;
|
|||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.byon.Node;
|
||||
import org.jclouds.byon.internal.BYONComputeServiceAdapter;
|
||||
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
|
||||
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
|
||||
|
@ -36,27 +33,17 @@ import org.jclouds.location.Provider;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SingleThreaded
|
||||
public class BYONComputeServiceContextModule extends
|
||||
JCloudsNativeComputeServiceAdapterContextModule<Supplier, Supplier> {
|
||||
public class BYONComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule {
|
||||
|
||||
public BYONComputeServiceContextModule() {
|
||||
super(Supplier.class, Supplier.class, BYONComputeServiceAdapter.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Supplier provideApi(Supplier<LoadingCache<String, Node>> in) {
|
||||
return in;
|
||||
super(BYONComputeServiceAdapter.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +55,7 @@ public class BYONComputeServiceContextModule extends
|
|||
}).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class);
|
||||
bind(new TypeLiteral<Function<URI, InputStream>>() {
|
||||
}).to(SupplyFromProviderURIOrNodesProperty.class);
|
||||
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>(){});
|
||||
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ import org.yaml.snakeyaml.constructor.Constructor;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.io.Closeables;
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,8 +42,8 @@ import com.google.common.base.Predicates;
|
|||
import com.google.common.base.Supplier;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,14 +24,14 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.internal.ContextBuilder;
|
||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.AfterClass;
|
||||
|
@ -49,7 +49,7 @@ import com.google.inject.Module;
|
|||
@Test(groups = "live")
|
||||
public class BYONComputeServiceLiveTest {
|
||||
|
||||
private ComputeServiceContext<?, ?> context;
|
||||
private ComputeServiceContext context;
|
||||
|
||||
@BeforeClass(groups = "live")
|
||||
public void setup() throws FileNotFoundException, IOException {
|
||||
|
@ -72,8 +72,9 @@ public class BYONComputeServiceLiveTest {
|
|||
.append("\n");
|
||||
|
||||
contextProperties.setProperty("byon.nodes", nodes.toString());
|
||||
context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties)
|
||||
.modules(ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build();
|
||||
context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties).modules(
|
||||
ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build(
|
||||
ComputeServiceContext.class);
|
||||
}
|
||||
|
||||
public void testCanRunCommandAsCurrentUser() throws Exception {
|
||||
|
|
|
@ -23,16 +23,14 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.expectedProvider
|
|||
import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.byon.config.BYONComputeServiceContextModule;
|
||||
import org.jclouds.byon.config.CacheNodeStoreModule;
|
||||
import org.jclouds.byon.functions.NodesFromYamlTest;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||
import org.jclouds.rest.internal.ContextBuilder;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -40,7 +38,9 @@ import com.google.common.cache.LoadingCache;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,36 +51,31 @@ public class BYONComputeServiceTest {
|
|||
|
||||
@Test
|
||||
public void testNodesParseNodeMap() throws Exception {
|
||||
assertNodesParse(
|
||||
"foo",
|
||||
assertNodesParse("foo", ContextBuilder.newBuilder(
|
||||
new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build())
|
||||
.endpoint("foo").modules(
|
||||
ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of(
|
||||
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1))));
|
||||
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build(
|
||||
ComputeServiceContext.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodesParseWithFileUrl() throws Exception {
|
||||
assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ImmutableSet.<Module> of());
|
||||
assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
|
||||
"file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodesParseWithClasspathUrl() throws Exception {
|
||||
assertNodesParse("classpath:///test1.yaml", ImmutableSet.<Module> of());
|
||||
assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
|
||||
"classpath:///test1.yaml").build(ComputeServiceContext.class));
|
||||
}
|
||||
|
||||
private void assertNodesParse(String endpoint, Iterable<Module> modules) {
|
||||
ComputeServiceContext<?, ?> context = null;
|
||||
private void assertNodesParse(String endpoint, ComputeServiceContext context) {
|
||||
try {
|
||||
Location providerLocation = expectedProviderLocationFromResource(endpoint);
|
||||
|
||||
context = ContextBuilder.newBuilder(
|
||||
AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint))
|
||||
.modules(modules).build();
|
||||
|
||||
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
|
||||
.getApi();
|
||||
Supplier<LoadingCache<String, Node>> supplier = supplier(context);
|
||||
|
||||
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
|
||||
assertEquals(supplier.get().asMap(),
|
||||
|
@ -96,17 +91,12 @@ public class BYONComputeServiceTest {
|
|||
}
|
||||
|
||||
public void testNodesWithLocations() {
|
||||
ComputeServiceContext<?, ?> context = null;
|
||||
ComputeServiceContext context = null;
|
||||
try {
|
||||
String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath();
|
||||
context = ContextBuilder.newBuilder(
|
||||
AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build();
|
||||
context = ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(endpoint).build(ComputeServiceContext.class);
|
||||
|
||||
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
|
||||
.getApi();
|
||||
Supplier<LoadingCache<String, Node>> supplier = supplier(context);
|
||||
|
||||
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
|
||||
assertEquals(supplier.get().asMap(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST2.getId(),
|
||||
|
@ -143,4 +133,11 @@ public class BYONComputeServiceTest {
|
|||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
private Supplier<LoadingCache<String, Node>> supplier(ComputeServiceContext context) {
|
||||
Supplier<LoadingCache<String, Node>> supplier = context.utils().injector().getInstance(
|
||||
Key.get(new TypeLiteral<Supplier<LoadingCache<String, Node>>>() {
|
||||
}));
|
||||
return supplier;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,19 +26,29 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata;
|
||||
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
|
||||
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
|
||||
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudFilesApiMetadata
|
||||
extends
|
||||
BaseBlobStoreApiMetadata<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
|
||||
public class CloudFilesApiMetadata extends BaseRestApiMetadata {
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 820062881469203616L;
|
||||
|
||||
public static final TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
private static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -56,26 +66,25 @@ public class CloudFilesApiMetadata
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
|
||||
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
extends
|
||||
BaseBlobStoreApiMetadata.Builder<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
protected Builder() {
|
||||
super(CloudFilesClient.class, CloudFilesAsyncClient.class);
|
||||
id("cloudfiles")
|
||||
.name("Rackspace Cloud Files API")
|
||||
.identityName("Username")
|
||||
.credentialName("API Key")
|
||||
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
|
||||
.version(OpenStackAuthAsyncClient.VERSION)
|
||||
.contextBuilder(TypeToken.of(CloudFilesContextBuilder.class))
|
||||
.defaultProperties(CloudFilesApiMetadata.defaultProperties())
|
||||
.javaApi(CloudFilesClient.class, CloudFilesAsyncClient.class);
|
||||
.wrapper(TypeToken.of(BlobStoreContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +93,7 @@ public class CloudFilesApiMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(CloudFilesApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudfiles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
|
||||
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on
|
||||
* the most commonly requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or
|
||||
* Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default
|
||||
* {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
|
||||
* installed.
|
||||
*
|
||||
* @author Adrian Cole, Andrew Newdigate
|
||||
* @see CloudFilesStoreContext
|
||||
*/
|
||||
public class CloudFilesContextBuilder
|
||||
extends
|
||||
BlobStoreContextBuilder<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
|
||||
|
||||
public CloudFilesContextBuilder(
|
||||
ProviderMetadata<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new CloudFilesBlobStoreContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new CloudFilesRestClientModule());
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore {
|
|||
private final EnableCDNAndCache enableCDNAndCache;
|
||||
|
||||
@Inject
|
||||
protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils,
|
||||
protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, CloudFilesClient sync, CloudFilesAsyncClient async,
|
||||
ContainerToResourceMetadata container2ResourceMd,
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore {
|
|||
private EnableCDNAndCache enableCDNAndCache;
|
||||
|
||||
@Inject
|
||||
protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||
protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||
@Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
|
||||
ContainerToResourceMetadata container2ResourceMd,
|
||||
BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.cloudfiles.CDNManagement;
|
|||
import org.jclouds.cloudfiles.CloudFilesAsyncClient;
|
||||
import org.jclouds.cloudfiles.CloudFilesClient;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
|
@ -53,7 +52,6 @@ import com.google.inject.Provides;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> {
|
||||
|
||||
public CloudFilesRestClientModule() {
|
||||
|
|
|
@ -47,7 +47,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest<CloudFil
|
|||
|
||||
@Override
|
||||
public CloudFilesClient getApi() {
|
||||
return (CloudFilesClient) context.getProviderSpecificContext().getApi();
|
||||
return context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,21 +22,31 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.apis.ApiType;
|
||||
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
||||
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
|
||||
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||
import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata;
|
||||
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for CloudLoadBalancers 1.0 API
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudLoadBalancersApiMetadata
|
||||
extends
|
||||
BaseLoadBalancerServiceApiMetadata<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
|
||||
public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 6725672099385580694L;
|
||||
|
||||
public static final TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -51,16 +61,15 @@ public class CloudLoadBalancersApiMetadata
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
extends
|
||||
BaseLoadBalancerServiceApiMetadata.Builder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class);
|
||||
id("cloudloadbalancers")
|
||||
.name("Rackspace Cloud Load Balancers API")
|
||||
.identityName("Username")
|
||||
|
@ -68,9 +77,9 @@ public class CloudLoadBalancersApiMetadata
|
|||
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))
|
||||
.version(OpenStackAuthAsyncClient.VERSION)
|
||||
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
||||
.javaApi(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class)
|
||||
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
|
||||
.contextBuilder(TypeToken.of(CloudLoadBalancersContextBuilder.class));
|
||||
.wrapper(TypeToken.of(LoadBalancerServiceContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +88,7 @@ public class CloudLoadBalancersApiMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudloadbalancers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
||||
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
|
||||
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudLoadBalancersContextBuilder
|
||||
extends
|
||||
LoadBalancerServiceContextBuilder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
|
||||
|
||||
public CloudLoadBalancersContextBuilder(
|
||||
ProviderMetadata<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new CloudLoadBalancersLoadBalancerContextModule());
|
||||
}
|
||||
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new CloudLoadBalancersRestClientModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,6 @@ import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromH
|
|||
import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix;
|
||||
import org.jclouds.cloudloadbalancers.reference.RackspaceConstants;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
|
@ -64,7 +63,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class CloudLoadBalancersRestClientModule extends
|
||||
RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {
|
||||
|
|
|
@ -22,9 +22,9 @@ import java.util.Date;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.Node;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
||||
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
|
||||
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;
|
||||
|
|
|
@ -53,12 +53,12 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
protected void tearDownContext() {
|
||||
for (LoadBalancer lb : lbs) {
|
||||
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
|
||||
assert loadBalancerDeleted.apply(lb) : lb;
|
||||
}
|
||||
super.tearDown();
|
||||
super.tearDownContext();
|
||||
}
|
||||
|
||||
public void testCreateLoadBalancer() throws Exception {
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.Collections;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
|
||||
import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
|
|
@ -26,16 +26,16 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.Node;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
|
@ -137,7 +137,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
|||
|
||||
@Override
|
||||
@AfterGroups(groups = "live")
|
||||
protected void tearDown() {
|
||||
protected void tearDownContext() {
|
||||
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
||||
LoadBalancer lb = entry.getKey();
|
||||
LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion());
|
||||
|
@ -147,6 +147,6 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
|||
}
|
||||
assert loadBalancerDeleted.apply(lb) : lb;
|
||||
}
|
||||
super.tearDown();
|
||||
super.tearDownContext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
package org.jclouds.cloudloadbalancers.functions;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.Node;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.jclouds.cloudloadbalancers.functions;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
|||
import org.jclouds.cloudloadbalancers.reference.Region;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.internal.ClassMethodArgs;
|
||||
import org.jclouds.location.config.LocationModule;
|
||||
import org.jclouds.openstack.filters.AuthenticateRequest;
|
||||
|
@ -71,7 +70,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsync
|
|||
}
|
||||
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule {
|
||||
@Override
|
||||
protected void installLocations() {
|
||||
|
@ -127,7 +125,7 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsync
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
protected ApiMetadata createApiMetadata() {
|
||||
return new CloudLoadBalancersApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.cloudloadbalancers.internal;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.apis.BaseContextLiveTest;
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||
|
@ -30,11 +31,10 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseContextLiveTest;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
@ -42,9 +42,7 @@ import com.google.inject.Injector;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseCloudLoadBalancersClientLiveTest
|
||||
extends
|
||||
BaseContextLiveTest<LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> {
|
||||
public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest<LoadBalancerServiceContext> {
|
||||
|
||||
public BaseCloudLoadBalancersClientLiveTest() {
|
||||
provider = "cloudloadbalancers";
|
||||
|
@ -63,7 +61,7 @@ public class BaseCloudLoadBalancersClientLiveTest
|
|||
@Override
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
lbContext = context.getProviderSpecificContext();
|
||||
lbContext = context.unwrap();
|
||||
|
||||
client = lbContext.getApi();
|
||||
|
||||
|
@ -76,10 +74,9 @@ public class BaseCloudLoadBalancersClientLiveTest
|
|||
injector.injectMembers(loadBalancerDeleted);
|
||||
}
|
||||
|
||||
@AfterGroups(groups = "live")
|
||||
protected void tearDown() {
|
||||
if (lbContext != null)
|
||||
lbContext.close();
|
||||
@Override
|
||||
protected TypeToken<LoadBalancerServiceContext> contextType() {
|
||||
return TypeToken.of(LoadBalancerServiceContext.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,20 +22,30 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
|
||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for CloudServers 1.0 API
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudServersApiMetadata
|
||||
extends
|
||||
BaseComputeServiceApiMetadata<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
|
||||
public class CloudServersApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 6725672099385580694L;
|
||||
|
||||
public static final TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -50,16 +60,15 @@ public class CloudServersApiMetadata
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
extends
|
||||
BaseComputeServiceApiMetadata.Builder<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
super(CloudServersClient.class, CloudServersAsyncClient.class);
|
||||
id("cloudservers")
|
||||
.name("Rackspace Cloud Servers API")
|
||||
.identityName("Username")
|
||||
|
@ -67,9 +76,9 @@ public class CloudServersApiMetadata
|
|||
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))
|
||||
.version(OpenStackAuthAsyncClient.VERSION)
|
||||
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
||||
.javaApi(CloudServersClient.class, CloudServersAsyncClient.class)
|
||||
.defaultProperties(CloudServersApiMetadata.defaultProperties())
|
||||
.contextBuilder(TypeToken.of(CloudServersContextBuilder.class));
|
||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +87,7 @@ public class CloudServersApiMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(CloudServersApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudservers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
|
||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudServersContextBuilder
|
||||
extends
|
||||
ComputeServiceContextBuilder<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
|
||||
|
||||
public CloudServersContextBuilder(
|
||||
ProviderMetadata<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new CloudServersComputeServiceContextModule());
|
||||
}
|
||||
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new CloudServersRestClientModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -22,8 +22,6 @@ import java.util.Map;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudservers.CloudServersAsyncClient;
|
||||
import org.jclouds.cloudservers.CloudServersClient;
|
||||
import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage;
|
||||
import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem;
|
||||
import org.jclouds.cloudservers.compute.functions.FlavorToHardware;
|
||||
|
@ -55,12 +53,8 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudServersComputeServiceContextModule
|
||||
extends
|
||||
ComputeServiceAdapterContextModule<CloudServersClient, CloudServersAsyncClient, Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
|
||||
public CloudServersComputeServiceContextModule() {
|
||||
super(CloudServersClient.class, CloudServersAsyncClient.class);
|
||||
}
|
||||
public class CloudServersComputeServiceContextModule extends
|
||||
ComputeServiceAdapterContextModule<Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.cloudservers.CloudServersClient;
|
|||
import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
|
@ -53,7 +52,6 @@ import com.google.inject.Provides;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class CloudServersRestClientModule extends RestClientModule<CloudServersClient, CloudServersAsyncClient> {
|
||||
|
||||
public CloudServersRestClientModule() {
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.jclouds.cloudservers.options.ListOptions;
|
|||
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.http.functions.ReturnFalseOn404;
|
||||
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
||||
|
@ -890,7 +889,6 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
|
||||
|
||||
@Provides
|
||||
|
@ -909,7 +907,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
protected String provider = "cloudservers";
|
||||
|
||||
@Override
|
||||
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
protected ApiMetadata createApiMetadata() {
|
||||
return new CloudServersApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.jclouds.cloudservers.domain.ServerStatus;
|
|||
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
||||
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
||||
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
|
@ -72,9 +71,7 @@ import com.google.inject.Injector;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
|
||||
public class CloudServersClientLiveTest
|
||||
extends
|
||||
BaseComputeServiceContextLiveTest<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>> {
|
||||
public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||
|
||||
public CloudServersClientLiveTest() {
|
||||
provider = "cloudservers";
|
||||
|
|
|
@ -22,9 +22,6 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.cloudservers.CloudServersAsyncClient;
|
||||
import org.jclouds.cloudservers.CloudServersClient;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
|
@ -40,9 +37,7 @@ import com.google.inject.Module;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
|
||||
public class CloudServersComputeServiceLiveTest
|
||||
extends
|
||||
BaseComputeServiceLiveTest<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>> {
|
||||
public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
|
||||
public CloudServersComputeServiceLiveTest() {
|
||||
provider = "cloudservers";
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.cloudservers.CloudServersApiMetadata;
|
|||
import org.jclouds.cloudservers.CloudServersClient;
|
||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.openstack.filters.AddTimestampQuery;
|
||||
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule;
|
||||
import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest;
|
||||
|
@ -49,7 +48,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
protected ApiMetadata createApiMetadata() {
|
||||
return new CloudServersApiMetadata();
|
||||
}
|
||||
|
||||
|
@ -81,7 +80,6 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
|
|||
}
|
||||
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,19 +24,28 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
|
||||
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for the Cloud Sigma API
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudSigmaApiMetadata
|
||||
extends
|
||||
BaseComputeServiceApiMetadata<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
|
||||
public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 6725672099385580694L;
|
||||
|
||||
public static final TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -51,8 +60,8 @@ public class CloudSigmaApiMetadata
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
|
||||
// passwords are set post-boot, so auth failures are possible
|
||||
// from a race condition applying the password set script
|
||||
|
@ -61,11 +70,10 @@ public class CloudSigmaApiMetadata
|
|||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
extends
|
||||
BaseComputeServiceApiMetadata.Builder<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
|
||||
id("cloudsigma")
|
||||
.name("CloudSigma API")
|
||||
.identityName("Email")
|
||||
|
@ -74,8 +82,8 @@ public class CloudSigmaApiMetadata
|
|||
.version("1.0")
|
||||
.defaultEndpoint("https://api.cloudsigma.com")
|
||||
.defaultProperties(CloudSigmaApiMetadata.defaultProperties())
|
||||
.javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class)
|
||||
.contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class));
|
||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +92,7 @@ public class CloudSigmaApiMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(CloudSigmaApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudsigma;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
|
||||
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudSigmaContextBuilder
|
||||
extends
|
||||
ComputeServiceContextBuilder<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
|
||||
|
||||
public CloudSigmaContextBuilder(
|
||||
ProviderMetadata<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new CloudSigmaComputeServiceContextModule());
|
||||
}
|
||||
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new CloudSigmaRestClientModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
|
||||
import org.jclouds.cloudsigma.CloudSigmaClient;
|
||||
import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
|
||||
import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl;
|
||||
|
@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudSigmaComputeServiceContextModule
|
||||
extends
|
||||
ComputeServiceAdapterContextModule<CloudSigmaClient, CloudSigmaAsyncClient, ServerInfo, Hardware, DriveInfo, Location> {
|
||||
|
||||
public CloudSigmaComputeServiceContextModule() {
|
||||
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
|
||||
}
|
||||
public class CloudSigmaComputeServiceContextModule extends
|
||||
ComputeServiceAdapterContextModule<ServerInfo, Hardware, DriveInfo, Location> {
|
||||
|
||||
@Override
|
||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.jclouds.cloudsigma.domain.DriveInfo;
|
|||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.ImageBuilder;
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OperatingSystem.Builder;
|
||||
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
||||
import org.jclouds.compute.domain.OperatingSystem.Builder;
|
||||
import org.jclouds.domain.Location;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
|
|
@ -33,14 +33,13 @@ import org.jclouds.cloudsigma.domain.ServerMetrics;
|
|||
import org.jclouds.cloudsigma.functions.BaseDriveToMap;
|
||||
import org.jclouds.cloudsigma.functions.DriveDataToMap;
|
||||
import org.jclouds.cloudsigma.functions.MapToDevices;
|
||||
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
|
||||
import org.jclouds.cloudsigma.functions.MapToDriveMetrics;
|
||||
import org.jclouds.cloudsigma.functions.MapToNICs;
|
||||
import org.jclouds.cloudsigma.functions.MapToServerMetrics;
|
||||
import org.jclouds.cloudsigma.functions.ServerToMap;
|
||||
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
|
||||
import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
|
@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> {
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -648,7 +648,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
protected ApiMetadata createApiMetadata() {
|
||||
return new CloudSigmaApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.jclouds.cloudsigma.domain.VLANInfo;
|
|||
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
||||
import org.jclouds.cloudsigma.predicates.DriveClaimed;
|
||||
import org.jclouds.cloudsigma.util.Servers;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
|
@ -71,9 +70,7 @@ import com.google.inject.Guice;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest")
|
||||
public class CloudSigmaClientLiveTest
|
||||
extends
|
||||
BaseComputeServiceContextLiveTest<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>> {
|
||||
public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||
|
||||
public CloudSigmaClientLiveTest() {
|
||||
provider = "cloudsigma";
|
||||
|
@ -92,7 +89,7 @@ public class CloudSigmaClientLiveTest
|
|||
@Override
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
cloudSigmaContext = context.getProviderSpecificContext();
|
||||
cloudSigmaContext = context.unwrap();
|
||||
|
||||
client = cloudSigmaContext.getApi();
|
||||
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudsigma.compute;
|
||||
|
||||
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
|
||||
import org.jclouds.cloudsigma.CloudSigmaClient;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||
|
@ -34,9 +31,7 @@ import com.google.inject.Module;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live")
|
||||
public class CloudSigmaComputeServiceLiveTest
|
||||
extends
|
||||
BaseComputeServiceLiveTest<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>> {
|
||||
public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
|
||||
public CloudSigmaComputeServiceLiveTest() {
|
||||
provider = "cloudsigma";
|
||||
|
|
|
@ -22,9 +22,14 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
|
||||
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api.
|
||||
|
@ -43,8 +48,14 @@ import com.google.common.reflect.TypeToken;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata>
|
||||
{
|
||||
public class CloudStackApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -3936131452958663245L;
|
||||
|
||||
public static final TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -59,17 +70,18 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudSt
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
||||
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
extends BaseComputeServiceApiMetadata.Builder<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> {
|
||||
extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
super(CloudStackClient.class, CloudStackAsyncClient.class);
|
||||
id("cloudstack")
|
||||
.name("Citrix CloudStack API")
|
||||
.identityName("API Key")
|
||||
|
@ -77,10 +89,9 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudSt
|
|||
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))
|
||||
.defaultEndpoint("http://localhost:8080/client/api")
|
||||
.version("2.2")
|
||||
.wrapper(TypeToken.of(CloudStackContext.class))
|
||||
.defaultProperties(CloudStackApiMetadata.defaultProperties())
|
||||
.javaApi(CloudStackClient.class, CloudStackAsyncClient.class)
|
||||
.context(TypeToken.of(CloudStackContext.class))
|
||||
.contextBuilder(TypeToken.of(CloudStackContextBuilder.class));
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,7 +100,7 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudSt
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(CloudStackApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ import com.google.inject.ImplementedBy;
|
|||
*
|
||||
*/
|
||||
@ImplementedBy(CloudStackContextImpl.class)
|
||||
public interface CloudStackContext extends ComputeServiceContext<CloudStackClient, CloudStackAsyncClient> {
|
||||
public interface CloudStackContext extends ComputeServiceContext {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext();
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudstack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
|
||||
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudStackContextBuilder extends
|
||||
ComputeServiceContextBuilder<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> {
|
||||
|
||||
public CloudStackContextBuilder(
|
||||
ProviderMetadata<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new CloudStackRestClientModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new CloudStackComputeServiceContextModule());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public Properties getOverrides() {
|
||||
return overrides;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest;
|
|||
import org.jclouds.rest.Binder;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -30,7 +30,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware;
|
||||
import org.jclouds.cloudstack.compute.functions.TemplateToImage;
|
||||
|
@ -87,13 +86,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudStackComputeServiceContextModule
|
||||
extends
|
||||
ComputeServiceAdapterContextModule<CloudStackClient, CloudStackAsyncClient, VirtualMachine, ServiceOffering, Template, Zone> {
|
||||
|
||||
public CloudStackComputeServiceContextModule() {
|
||||
super(CloudStackClient.class, CloudStackAsyncClient.class);
|
||||
}
|
||||
public class CloudStackComputeServiceContextModule extends
|
||||
ComputeServiceAdapterContextModule<VirtualMachine, ServiceOffering, Template, Zone> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
|
@ -33,8 +33,8 @@ import org.jclouds.cloudstack.domain.OSType;
|
|||
import org.jclouds.cloudstack.domain.Template;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OperatingSystem.Builder;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.domain.OperatingSystem.Builder;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.util.ComputeServiceUtils;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
|
|
@ -63,8 +63,8 @@ import com.google.common.base.Supplier;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,11 +27,11 @@ import java.util.Set;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.Account.State;
|
||||
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.domain.Account.State;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.config;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in CloudStack connections.
|
||||
|
|
|
@ -123,7 +123,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
|||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
|
@ -155,7 +154,6 @@ import com.google.inject.name.Named;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ package org.jclouds.cloudstack.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,8 +26,8 @@ import javax.ws.rs.QueryParam;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.filters.AuthenticationFilter;
|
||||
import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions;
|
||||
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.util.Set;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions;
|
||||
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions;
|
||||
|
|
|
@ -38,8 +38,8 @@ import org.jclouds.logging.Logger;
|
|||
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.jclouds.json.internal.GsonWrapper;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
||||
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
|
@ -45,6 +43,8 @@ import org.jclouds.cloudstack.domain.TemplateExtraction;
|
|||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.Volume;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.internal;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -34,32 +35,32 @@ import org.jclouds.compute.ComputeService;
|
|||
import org.jclouds.compute.Utils;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class CloudStackContextImpl extends ComputeServiceContextImpl<CloudStackClient, CloudStackAsyncClient> implements
|
||||
CloudStackContext {
|
||||
private final RestContext<CloudStackClient,CloudStackAsyncClient> providerSpecificContext;
|
||||
public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext {
|
||||
private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
|
||||
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
|
||||
|
||||
@Inject
|
||||
public CloudStackContextImpl(ComputeService computeService, Map<String, Credentials> credentialStore, Utils utils,
|
||||
RestContext<CloudStackClient,CloudStackAsyncClient> providerSpecificContext,
|
||||
public CloudStackContextImpl(@Provider Closeable wrapped, @Provider TypeToken<? extends Closeable> wrappedType,
|
||||
ComputeService computeService, Map<String, Credentials> credentialStore, Utils utils,
|
||||
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
|
||||
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
|
||||
super(computeService, credentialStore, utils, providerSpecificContext);
|
||||
this.providerSpecificContext=providerSpecificContext;
|
||||
super(wrapped, wrappedType, computeService, credentialStore, utils);
|
||||
this.domainContext = domainContext;
|
||||
this.globalContext = globalContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContext<CloudStackClient,CloudStackAsyncClient> getProviderSpecificContext() {
|
||||
return providerSpecificContext;
|
||||
public RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext() {
|
||||
return unwrap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.jclouds.cloudstack.predicates;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.Account.Type;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.domain.Account.Type;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.ApiKeyPair;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
|
||||
/**
|
||||
* @author Andrei Savu
|
||||
|
@ -62,12 +62,12 @@ public class ApiKeyPairs {
|
|||
overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||
overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials");
|
||||
|
||||
context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata())
|
||||
context = ContextBuilder.newBuilder(new CloudStackApiMetadata())
|
||||
.endpoint(checkNotNull(endpoint, "endpoint").toASCIIString())
|
||||
.credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password)
|
||||
.overrides(overrides).build();
|
||||
.overrides(overrides).build(CloudStackContext.class);
|
||||
|
||||
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
|
||||
CloudStackClient client = context.getProviderSpecificContext().getApi();
|
||||
Set<Account> listOfAccounts = client.getAccountClient().listAccounts();
|
||||
|
||||
domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain;
|
||||
|
|
|
@ -53,8 +53,8 @@ import org.jclouds.cloudstack.suppliers.GetCurrentUser;
|
|||
import org.jclouds.cloudstack.suppliers.NetworksForCurrentUser;
|
||||
import org.jclouds.cloudstack.suppliers.ZoneIdToZoneSupplier;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||
import org.jclouds.compute.ComputeTestUtils;
|
||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
|
||||
import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
|
||||
|
@ -102,7 +102,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
|||
@Override
|
||||
protected void configure() {
|
||||
bindProperties(binder(), setupProperties());
|
||||
bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity());
|
||||
bind(String.class).annotatedWith(Identity.class).toInstance(identity);
|
||||
bind(new TypeLiteral<Supplier<User>>() {
|
||||
}).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON);
|
||||
bind(new TypeLiteral<Supplier<Map<Long, Network>>>() {
|
||||
|
|
|
@ -18,12 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.compute;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -37,8 +33,7 @@ import com.google.inject.Module;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", enabled = true, singleThreaded = true)
|
||||
public class CloudStackComputeServiceLiveTest extends
|
||||
BaseComputeServiceLiveTest<CloudStackClient, CloudStackAsyncClient, CloudStackContext> {
|
||||
public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
public CloudStackComputeServiceLiveTest() {
|
||||
provider = "cloudstack";
|
||||
}
|
||||
|
@ -48,11 +43,6 @@ public class CloudStackComputeServiceLiveTest extends
|
|||
return new SshjSshClientModule();
|
||||
}
|
||||
|
||||
public void testAssignability() throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
RestContext<CloudStackClient, CloudStackAsyncClient> tmContext = context.getProviderSpecificContext();
|
||||
}
|
||||
|
||||
// cloudstack does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.jclouds.cloudstack.CloudStackApiMetadata;
|
|||
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
@ -37,7 +36,6 @@ import com.google.inject.Module;
|
|||
*/
|
||||
public abstract class BaseCloudStackAsyncClientTest<T> extends BaseAsyncClientTest<T> {
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public static class CloudStackRestClientModuleExtension extends CloudStackRestClientModule {
|
||||
|
||||
|
@ -55,7 +53,7 @@ public abstract class BaseCloudStackAsyncClientTest<T> extends BaseAsyncClientTe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ProviderMetadata<?, ?, ?, ?> createProviderMetadata() {
|
||||
protected ProviderMetadata createProviderMetadata() {
|
||||
return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(),
|
||||
"http://localhost:8080/client/api");
|
||||
}
|
||||
|
|
|
@ -73,8 +73,7 @@ import com.google.inject.Module;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseCloudStackClientLiveTest extends
|
||||
BaseComputeServiceContextLiveTest<CloudStackClient, CloudStackAsyncClient, CloudStackContext> {
|
||||
public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||
protected String domainAdminIdentity;
|
||||
protected String domainAdminCredential;
|
||||
protected String globalAdminIdentity;
|
||||
|
@ -195,13 +194,13 @@ public class BaseCloudStackClientLiveTest extends
|
|||
public void setupContext() {
|
||||
super.setupContext();
|
||||
computeClient = context.getComputeService();
|
||||
cloudStackContext = context.getProviderSpecificContext();
|
||||
cloudStackContext = context.unwrap();
|
||||
client = cloudStackContext.getApi();
|
||||
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
|
||||
|
||||
domainAdminEnabled = setupDomainAdminProperties() != null;
|
||||
if (domainAdminEnabled) {
|
||||
domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules());
|
||||
domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()).unwrap();
|
||||
domainAdminContext = domainAdminComputeContext.getDomainContext();
|
||||
domainAdminClient = domainAdminContext.getApi();
|
||||
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
|
||||
|
@ -210,7 +209,7 @@ public class BaseCloudStackClientLiveTest extends
|
|||
|
||||
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
||||
if (globalAdminEnabled) {
|
||||
globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules());
|
||||
globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()).unwrap();
|
||||
globalAdminContext = globalAdminComputeContext.getGlobalContext();
|
||||
globalAdminClient = globalAdminContext.getApi();
|
||||
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
|
||||
|
|
|
@ -47,7 +47,7 @@ public abstract class BaseCloudStackRestClientExpectTest<S> extends BaseRestClie
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
protected ApiMetadata createApiMetadata() {
|
||||
return new CloudStackApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
}
|
||||
|
||||
private void checkAuthAsUser(ApiKeyPair keyPair) {
|
||||
ComputeServiceContext<?, ?> context = createContext(credentialsAsProperties(keyPair), setupModules());
|
||||
ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules());
|
||||
|
||||
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
|
||||
Set<Account> accounts = client.getAccountClient().listAccounts();
|
||||
|
|
|
@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
|
|||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jclouds.cloudstack.domain.OSType;
|
||||
import org.jclouds.cloudstack.options.ListOSTypesOptions;
|
||||
|
|
|
@ -35,11 +35,11 @@ import javax.annotation.Nullable;
|
|||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.JobResult;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
|
||||
import org.jclouds.cloudstack.domain.Network;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
|
||||
import org.jclouds.cloudstack.predicates.LoadBalancerRuleActive;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
|
|
|
@ -22,13 +22,13 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.IntegrationTestAsyncClient;
|
||||
import org.jclouds.http.IntegrationTestClient;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
|
||||
import org.jclouds.rest.internal.ContextBuilder;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
|
|
@ -24,14 +24,14 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.Status;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.cloudstack.domain.Template;
|
||||
import org.jclouds.cloudstack.domain.TemplateExtraction;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.Status;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
|
|
@ -22,9 +22,9 @@ import java.util.Set;
|
|||
|
||||
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.domain.Account.State;
|
||||
import org.jclouds.cloudstack.domain.Account.Type;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
|
|
|
@ -28,9 +28,9 @@ import static org.testng.Assert.fail;
|
|||
import org.jclouds.cloudstack.AsyncJobException;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.Status;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
||||
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
|
|
@ -25,73 +25,68 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.apis.ApiType;
|
||||
import org.jclouds.apis.internal.BaseApiMetadata;
|
||||
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for Amazon's CloudWatch api.
|
||||
*
|
||||
* <h3>note</h3>
|
||||
* <p/>
|
||||
* This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that
|
||||
* children can add additional methods not declared here, such as new features
|
||||
* from AWS.
|
||||
* <p/>
|
||||
*
|
||||
* This class is not setup to allow a different context than {@link RestContext}
|
||||
* . By doing so, it reduces the type complexity.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudWatchApiMetadata<S extends CloudWatchClient, A extends CloudWatchAsyncClient> extends
|
||||
BaseRestApiMetadata<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
|
||||
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>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder<S, A> toBuilder() {
|
||||
return new Builder<S, A>(getApi(), getAsyncApi()).fromApiMetadata(this);
|
||||
public Builder toBuilder() {
|
||||
return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
|
||||
}
|
||||
|
||||
public CloudWatchApiMetadata() {
|
||||
this(new Builder<CloudWatchClient, CloudWatchAsyncClient>(CloudWatchClient.class, CloudWatchAsyncClient.class));
|
||||
this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected CloudWatchApiMetadata(Builder<?, ?> builder) {
|
||||
protected CloudWatchApiMetadata(Builder builder) {
|
||||
super(Builder.class.cast(builder));
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
Properties properties = BaseApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder<S extends CloudWatchClient, A extends CloudWatchAsyncClient> extends
|
||||
BaseRestApiMetadata.Builder<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder(Class<S> client, Class<A> asyncClient) {
|
||||
protected Builder(Class<?> client, Class<?> asyncClient) {
|
||||
super(client, asyncClient);
|
||||
id("cloudwatch")
|
||||
.type(ApiType.MONITOR)
|
||||
.name("Amazon CloudWatch Api")
|
||||
.identityName("Access Key ID")
|
||||
.credentialName("Secret Access Key")
|
||||
.version(CloudWatchAsyncClient.VERSION)
|
||||
.defaultProperties(CloudWatchApiMetadata.defaultProperties())
|
||||
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"))
|
||||
.defaultEndpoint("https://monitoring.us-east-1.amazonaws.com")
|
||||
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"));
|
||||
.defaultProperties(CloudWatchApiMetadata.defaultProperties())
|
||||
.defaultModule(CloudWatchRestClientModule.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudWatchApiMetadata<S, A> build() {
|
||||
return new CloudWatchApiMetadata<S, A>(this);
|
||||
public CloudWatchApiMetadata build() {
|
||||
return new CloudWatchApiMetadata(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<S, A> fromApiMetadata(CloudWatchApiMetadata<S, A> in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudwatch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextBuilder;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link MonitoringContext} or {@link Injector} instances based on the
|
||||
* most commonly requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or
|
||||
* Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default
|
||||
* {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
|
||||
* installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see MonitoringContext
|
||||
*/
|
||||
public class CloudWatchContextBuilder<S extends CloudWatchClient, A extends CloudWatchAsyncClient>
|
||||
extends RestContextBuilder<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
|
||||
|
||||
public CloudWatchContextBuilder(ProviderMetadata<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public CloudWatchContextBuilder(CloudWatchApiMetadata<S, A> apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new CloudWatchRestClientModule());
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudwatch.config;
|
|||
import org.jclouds.aws.config.FormSigningRestClientModule;
|
||||
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
|
||||
import org.jclouds.cloudwatch.CloudWatchClient;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +28,6 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchClient, CloudWatchAsyncClient> {
|
||||
public CloudWatchRestClientModule() {
|
||||
|
|
|
@ -18,19 +18,22 @@
|
|||
*/
|
||||
package org.jclouds.cloudwatch;
|
||||
|
||||
import org.jclouds.apis.ApiType;
|
||||
import org.jclouds.apis.internal.BaseRestApiMetadataTest;
|
||||
import org.jclouds.Wrapper;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test(groups = "unit", testName = "CloudWatchApiMetadataTest")
|
||||
public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest {
|
||||
|
||||
// no monitoring abstraction, yet
|
||||
public CloudWatchApiMetadataTest() {
|
||||
super(new CloudWatchApiMetadata(), ApiType.MONITOR);
|
||||
super(new CloudWatchApiMetadata(), ImmutableSet.<TypeToken<? extends Wrapper>> of());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
|
|||
import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.config.LocationModule;
|
||||
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
||||
|
@ -91,7 +90,6 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy
|
|||
};
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule {
|
||||
|
||||
|
@ -123,9 +121,8 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy
|
|||
return new TestMonitoringRestClientModule();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||
public ApiMetadata createApiMetadata() {
|
||||
return new CloudWatchApiMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,15 +24,17 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.apis.BaseContextLiveTest;
|
||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||
import org.jclouds.cloudwatch.domain.Statistics;
|
||||
import org.jclouds.cloudwatch.domain.Unit;
|
||||
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseContextLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code CloudWatchClient}
|
||||
*
|
||||
|
@ -67,4 +69,9 @@ public class CloudWatchClientLiveTest extends BaseContextLiveTest<RestContext<Cl
|
|||
|
||||
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeToken<RestContext<CloudWatchClient, CloudWatchAsyncClient>> contextType() {
|
||||
return CloudWatchApiMetadata.CONTEXT_TOKEN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,16 +23,28 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||
import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule;
|
||||
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for Apache Deltacloud API
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
|
||||
public class DeltacloudApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 6725672099385580694L;
|
||||
|
||||
public static final TypeToken<RestContext<DeltacloudClient, DeltacloudAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<DeltacloudClient, DeltacloudAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -47,13 +59,14 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<Deltacl
|
|||
super(builder);
|
||||
}
|
||||
|
||||
protected static Properties defaultProperties() {
|
||||
return BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||
public static Properties defaultProperties() {
|
||||
return BaseRestApiMetadata.defaultProperties();
|
||||
}
|
||||
|
||||
public static class Builder extends BaseComputeServiceApiMetadata.Builder<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
super(DeltacloudClient.class, DeltacloudAsyncClient.class);
|
||||
id("deltacloud")
|
||||
.name("Apache Deltacloud API")
|
||||
.identityName("Username")
|
||||
|
@ -61,8 +74,9 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<Deltacl
|
|||
.documentation(URI.create("http://deltacloud.apache.org/api.html"))
|
||||
.version("0.3.0")
|
||||
.defaultEndpoint("http://localhost:3001/api")
|
||||
.javaApi(DeltacloudClient.class, DeltacloudAsyncClient.class)
|
||||
.contextBuilder(TypeToken.of(DeltacloudContextBuilder.class));
|
||||
.defaultProperties(DeltacloudApiMetadata.defaultProperties())
|
||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,11 +85,11 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<Deltacl
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(DeltacloudApiMetadata in) {
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -36,9 +36,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection;
|
|||
import org.jclouds.deltacloud.domain.HardwareProfile;
|
||||
import org.jclouds.deltacloud.domain.Image;
|
||||
import org.jclouds.deltacloud.domain.Instance;
|
||||
import org.jclouds.deltacloud.domain.Instance.State;
|
||||
import org.jclouds.deltacloud.domain.Realm;
|
||||
import org.jclouds.deltacloud.domain.Transition;
|
||||
import org.jclouds.deltacloud.domain.Instance.State;
|
||||
import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete;
|
||||
import org.jclouds.deltacloud.options.CreateInstanceOptions;
|
||||
import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler;
|
||||
|
|
|
@ -27,9 +27,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection;
|
|||
import org.jclouds.deltacloud.domain.HardwareProfile;
|
||||
import org.jclouds.deltacloud.domain.Image;
|
||||
import org.jclouds.deltacloud.domain.Instance;
|
||||
import org.jclouds.deltacloud.domain.Instance.State;
|
||||
import org.jclouds.deltacloud.domain.Realm;
|
||||
import org.jclouds.deltacloud.domain.Transition;
|
||||
import org.jclouds.deltacloud.domain.Instance.State;
|
||||
import org.jclouds.deltacloud.options.CreateInstanceOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.deltacloud;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule;
|
||||
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DeltacloudContextBuilder
|
||||
extends
|
||||
ComputeServiceContextBuilder<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
|
||||
|
||||
public DeltacloudContextBuilder(
|
||||
ProviderMetadata<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> providerMetadata) {
|
||||
super(providerMetadata);
|
||||
}
|
||||
|
||||
public DeltacloudContextBuilder(DeltacloudApiMetadata apiMetadata) {
|
||||
super(apiMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new DeltacloudComputeServiceContextModule());
|
||||
}
|
||||
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new DeltacloudRestClientModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -21,8 +21,6 @@ package org.jclouds.deltacloud.compute.config;
|
|||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.deltacloud.DeltacloudAsyncClient;
|
||||
import org.jclouds.deltacloud.DeltacloudClient;
|
||||
import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage;
|
||||
import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware;
|
||||
import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata;
|
||||
|
@ -40,13 +38,8 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DeltacloudComputeServiceContextModule
|
||||
extends
|
||||
ComputeServiceAdapterContextModule<DeltacloudClient, DeltacloudAsyncClient, Instance, HardwareProfile, org.jclouds.deltacloud.domain.Image, Realm> {
|
||||
|
||||
public DeltacloudComputeServiceContextModule() {
|
||||
super(DeltacloudClient.class, DeltacloudAsyncClient.class);
|
||||
}
|
||||
public class DeltacloudComputeServiceContextModule extends
|
||||
ComputeServiceAdapterContextModule<Instance, HardwareProfile, org.jclouds.deltacloud.domain.Image, Realm> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue