mirror of https://github.com/apache/jclouds.git
refactor PropertiesBuilder and related types into ApiMetadata and ProviderMetadata, and update all usage
This commit is contained in:
parent
70d179b3c7
commit
23cb01f977
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.tools.ant.taskdefs.compute;
|
package org.jclouds.tools.ant.taskdefs.compute;
|
||||||
|
|
||||||
import static org.jclouds.rest.RestContextFactory.getPropertiesFromResource;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
@ -73,13 +71,13 @@ public class ComputeTaskUtils {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public ComputeServiceContext load(URI from) {
|
public ComputeServiceContext load(URI from) {
|
||||||
Properties props = getPropertiesFromResource("/rest.properties");
|
Properties props = new Properties();
|
||||||
props.putAll(projectProvider.get().getProperties());
|
props.putAll(projectProvider.get().getProperties());
|
||||||
// adding the properties to the factory will allow us to pass
|
// adding the properties to the factory will allow us to pass
|
||||||
// alternate endpoints
|
// alternate endpoints
|
||||||
String provider = from.getHost();
|
String provider = from.getHost();
|
||||||
Credentials creds = Credentials.parse(from);
|
Credentials creds = Credentials.parse(from);
|
||||||
return new ComputeServiceContextFactory(props).createContext(provider, creds.identity, creds.credential,
|
return new ComputeServiceContextFactory().createContext(provider, creds.identity, creds.credential,
|
||||||
ImmutableSet.of((Module) new AntLoggingModule(projectProvider.get(),
|
ImmutableSet.of((Module) new AntLoggingModule(projectProvider.get(),
|
||||||
ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()), props);
|
ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()), props);
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.initializer>org.jclouds.atmos.blobstore.integration.AtmosStorageTestInitializer</test.initializer>
|
<test.atmos.endpoint>https://accesspoint.atmosonline.com</test.atmos.endpoint>
|
||||||
<test.atmos.endpoint>https://accesspoint.atmos.com</test.atmos.endpoint>
|
|
||||||
<test.atmos.api-version>1.3.0</test.atmos.api-version>
|
<test.atmos.api-version>1.3.0</test.atmos.api-version>
|
||||||
<test.atmos.build-version></test.atmos.build-version>
|
<test.atmos.build-version></test.atmos.build-version>
|
||||||
<test.atmos.identity>FIXME</test.atmos.identity>
|
<test.atmos.identity>FIXME</test.atmos.identity>
|
||||||
|
|
|
@ -18,50 +18,75 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmos;
|
package org.jclouds.atmos;
|
||||||
|
|
||||||
|
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||||
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for EMC's Atmos API.
|
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class AtmosApiMetadata extends BaseApiMetadata {
|
public class AtmosApiMetadata
|
||||||
|
extends
|
||||||
public AtmosApiMetadata() {
|
BaseBlobStoreApiMetadata<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
|
||||||
this(builder()
|
private static Builder builder() {
|
||||||
.id("atmos")
|
return new Builder();
|
||||||
.type(ApiType.BLOBSTORE)
|
|
||||||
.name("EMC's Atmos API")
|
|
||||||
.identityName("Subtenant ID (UID)")
|
|
||||||
.credentialName("Shared Secret")
|
|
||||||
.documentation(URI.create("https://community.emc.com/docs/DOC-10508")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
@Override
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
public Builder toBuilder() {
|
||||||
// concrete due to serviceLoader
|
return builder().fromApiMetadata(this);
|
||||||
protected AtmosApiMetadata(Builder<?> builder) {
|
}
|
||||||
|
|
||||||
|
public AtmosApiMetadata() {
|
||||||
|
this(builder());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AtmosApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseBlobStoreApiMetadata.Builder.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> {
|
||||||
|
protected Builder() {
|
||||||
|
id("atmos")
|
||||||
|
.name("EMC's Atmos API")
|
||||||
|
.identityName("Subtenant ID (UID)")
|
||||||
|
.credentialName("Shared Secret")
|
||||||
|
.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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AtmosApiMetadata build() {
|
public AtmosApiMetadata build() {
|
||||||
return new AtmosApiMetadata(this);
|
return new AtmosApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(AtmosApiMetadata in) {
|
||||||
}
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
@Override
|
}
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,35 +19,45 @@
|
||||||
package org.jclouds.atmos;
|
package org.jclouds.atmos;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
|
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
|
||||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||||
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link AtmosBlobStoreContext} or {@link Injector} instances based on the most commonly
|
* Creates {@link AtmosStoreContext} or {@link Injector} instances based on
|
||||||
* requested arguments.
|
* the most commonly requested arguments.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
* Note that Threadsafe objects will be bound as singletons to the Injector or
|
||||||
|
* Context provided.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p/>
|
* <p/>
|
||||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
* If no <code>Module</code>s are specified, the default
|
||||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
* {@link JDKLoggingModule logging} and
|
||||||
|
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
|
||||||
|
* installed.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole, Andrew Newdigate
|
* @author Adrian Cole, Andrew Newdigate
|
||||||
* @see AtmosBlobStoreContext
|
* @see AtmosStoreContext
|
||||||
*/
|
*/
|
||||||
public class AtmosContextBuilder extends
|
public class AtmosContextBuilder
|
||||||
BlobStoreContextBuilder<AtmosClient, AtmosAsyncClient> {
|
extends
|
||||||
|
BlobStoreContextBuilder<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> {
|
||||||
|
|
||||||
public AtmosContextBuilder(Properties props) {
|
public AtmosContextBuilder(
|
||||||
super(AtmosClient.class, AtmosAsyncClient.class, props);
|
ProviderMetadata<AtmosClient, AtmosAsyncClient, BlobStoreContext<AtmosClient, AtmosAsyncClient>, AtmosApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AtmosContextBuilder(AtmosApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
private final LoadingCache<String, Boolean> isPublic;
|
private final LoadingCache<String, Boolean> isPublic;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async, AtmosClient sync,
|
@Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async, AtmosClient sync,
|
||||||
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
private final LoadingCache<String, Boolean> isPublic;
|
private final LoadingCache<String, Boolean> isPublic;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, AtmosClient sync, ObjectToBlob object2Blob,
|
@Memoized Supplier<Set<? extends Location>> locations, AtmosClient sync, ObjectToBlob object2Blob,
|
||||||
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmos;
|
package org.jclouds.atmos;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "AtmosApiMetadataTest")
|
@Test(groups = "unit", testName = "AtmosApiMetadataTest")
|
||||||
public class AtmosApiMetadataTest extends BaseApiMetadataTest {
|
public class AtmosApiMetadataTest extends BaseBlobStoreApiMetadataTest {
|
||||||
|
|
||||||
public AtmosApiMetadataTest() {
|
public AtmosApiMetadataTest() {
|
||||||
super(new AtmosApiMetadata(), ApiType.BLOBSTORE);
|
super(new AtmosApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.atmos.blobstore.functions.BlobToObject;
|
import org.jclouds.atmos.blobstore.functions.BlobToObject;
|
||||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||||
import org.jclouds.atmos.domain.AtmosObject;
|
import org.jclouds.atmos.domain.AtmosObject;
|
||||||
|
@ -47,12 +47,10 @@ import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -68,7 +66,7 @@ import com.google.inject.TypeLiteral;
|
||||||
*/
|
*/
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
@Test(groups = "unit", testName = "AtmosAsyncClientTest")
|
@Test(groups = "unit", testName = "AtmosAsyncClientTest")
|
||||||
public class AtmosAsyncClientTest extends RestClientTest<AtmosAsyncClient> {
|
public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient> {
|
||||||
|
|
||||||
private BlobToObject blobToObject;
|
private BlobToObject blobToObject;
|
||||||
|
|
||||||
|
@ -339,10 +337,8 @@ public class AtmosAsyncClientTest extends RestClientTest<AtmosAsyncClient> {
|
||||||
protected String provider = "atmos";
|
protected String provider = "atmos";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
public ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
Properties props = new Properties();
|
return new AtmosApiMetadata();
|
||||||
props.setProperty(provider + ".endpoint", "https://accesspoint.atmosonline.com");
|
|
||||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@ package org.jclouds.atmos.blobstore;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
import org.jclouds.atmos.AtmosApiMetadata;
|
||||||
import org.jclouds.atmos.AtmosAsyncClient;
|
import org.jclouds.atmos.AtmosAsyncClient;
|
||||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||||
import org.jclouds.atmos.filters.SignRequest;
|
import org.jclouds.atmos.filters.SignRequest;
|
||||||
|
@ -33,9 +34,7 @@ import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -51,7 +50,7 @@ import com.google.inject.TypeLiteral;
|
||||||
*/
|
*/
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
@Test(groups = "unit", testName = "AtmosBlobRequestSignerTest")
|
@Test(groups = "unit", testName = "AtmosBlobRequestSignerTest")
|
||||||
public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosAsyncClient> {
|
public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncClient> {
|
||||||
|
|
||||||
private BlobRequestSigner signer;
|
private BlobRequestSigner signer;
|
||||||
private Factory blobFactory;
|
private Factory blobFactory;
|
||||||
|
@ -144,8 +143,8 @@ public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosAsyncClient>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
public ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
return new RestContextFactory().createContextSpec("atmos", "identity", "credential", new Properties());
|
return new AtmosApiMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,14 @@ package org.jclouds.atmos.blobstore.config;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.jclouds.atmos.AtmosApiMetadata;
|
||||||
import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
|
import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
|
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||||
import org.jclouds.logging.config.NullLoggingModule;
|
import org.jclouds.logging.config.NullLoggingModule;
|
||||||
import org.jclouds.rest.BaseRestClientTest.MockModule;
|
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -40,15 +41,19 @@ import com.google.inject.Module;
|
||||||
public class AtmosBlobStoreModuleTest {
|
public class AtmosBlobStoreModuleTest {
|
||||||
|
|
||||||
Injector createInjector() {
|
Injector createInjector() {
|
||||||
return new RestContextFactory().createContextBuilder("atmos", "uid", "key",
|
return BlobStoreContextBuilder
|
||||||
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
|
.newBuilder(new AtmosApiMetadata())
|
||||||
|
.credentials("uid", "key")
|
||||||
|
.modules(
|
||||||
|
ImmutableSet.<Module> of(new MockModule(),new NullLoggingModule()))
|
||||||
|
.buildInjector();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testContextImpl() {
|
void testContextImpl() {
|
||||||
|
|
||||||
Injector injector = createInjector();
|
Injector injector = createInjector();
|
||||||
BlobStoreContext handler = injector.getInstance(BlobStoreContext.class);
|
BlobStoreContext<?, ?> handler = injector.getInstance(BlobStoreContext.class);
|
||||||
assertEquals(handler.getClass(), BlobStoreContextImpl.class);
|
assertEquals(handler.getClass(), BlobStoreContextImpl.class);
|
||||||
ContainsValueInListStrategy valueList = injector
|
ContainsValueInListStrategy valueList = injector
|
||||||
.getInstance(ContainsValueInListStrategy.class);
|
.getInstance(ContainsValueInListStrategy.class);
|
||||||
|
|
|
@ -27,5 +27,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public class AtmosBlobSignerLiveTest extends BaseBlobSignerLiveTest {
|
public class AtmosBlobSignerLiveTest extends BaseBlobSignerLiveTest {
|
||||||
|
public AtmosBlobSignerLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
|
public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
|
||||||
|
public AtmosContainerIntegrationLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void testListContainerMaxResults() throws InterruptedException {
|
public void testListContainerMaxResults() throws InterruptedException {
|
||||||
// Not currently working
|
// Not currently working
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public class AtmosContainerLiveTest extends BaseContainerLiveTest {
|
public class AtmosContainerLiveTest extends BaseContainerLiveTest {
|
||||||
|
public AtmosContainerLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class AtmosInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
|
public class AtmosInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
|
||||||
|
public AtmosInputStreamMapIntegrationLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
|
|
|
@ -35,7 +35,9 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest {
|
public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest {
|
||||||
|
public AtmosIntegrationLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
@DataProvider(name = "delete")
|
@DataProvider(name = "delete")
|
||||||
// no unicode support
|
// no unicode support
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,9 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public class AtmosLiveTest extends BaseBlobLiveTest {
|
public class AtmosLiveTest extends BaseBlobLiveTest {
|
||||||
|
public AtmosLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
protected void checkMD5(String container, String name, byte[] md5) {
|
protected void checkMD5(String container, String name, byte[] md5) {
|
||||||
// atmos does not support content-md5 yet
|
// atmos does not support content-md5 yet
|
||||||
assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
||||||
|
|
|
@ -30,7 +30,9 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class AtmosMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
|
public class AtmosMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
|
||||||
|
public AtmosMapIntegrationLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
// NO support for Content-MD5, so contains cannot work
|
// NO support for Content-MD5, so contains cannot work
|
||||||
public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class AtmosServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
|
public class AtmosServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
|
||||||
|
public AtmosServiceIntegrationLiveTest() {
|
||||||
|
provider = "atmos";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +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.blobstore.integration;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
|
||||||
import org.jclouds.blobstore.BlobStoreContextFactory;
|
|
||||||
import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class AtmosTestInitializer extends TransientBlobStoreTestInitializer {
|
|
||||||
public AtmosTestInitializer() {
|
|
||||||
provider = "synaptic";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion,
|
|
||||||
String buildVersion, String app, String identity, String credential) throws IOException {
|
|
||||||
return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule,
|
|
||||||
new Log4JLoggingModule()), setupProperties(endpoint, apiVersion, buildVersion, identity, credential));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,20 +24,19 @@ import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.atmos.config.AtmosRestClientModule;
|
import org.jclouds.atmos.config.AtmosRestClientModule;
|
||||||
import org.jclouds.atmos.reference.AtmosHeaders;
|
import org.jclouds.atmos.reference.AtmosHeaders;
|
||||||
|
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.logging.config.NullLoggingModule;
|
import org.jclouds.logging.config.NullLoggingModule;
|
||||||
import org.jclouds.rest.BaseRestClientTest.MockModule;
|
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -98,13 +97,12 @@ public class SignRequestTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
protected void createFilter() {
|
protected void createFilter() {
|
||||||
Injector injector = new RestContextFactory()
|
Injector injector = BlobStoreContextBuilder
|
||||||
.createContextBuilder(
|
.newBuilder("atmos")
|
||||||
"atmos",
|
.credentials(UID, KEY)
|
||||||
UID,
|
.modules(
|
||||||
KEY,
|
ImmutableSet.<Module> of(new MockModule(), new TestAtmosRestClientModule(), new NullLoggingModule()))
|
||||||
ImmutableSet.<Module> of(new MockModule(), new TestAtmosRestClientModule(),
|
.buildInjector();
|
||||||
new NullLoggingModule()), new Properties()).buildInjector();
|
|
||||||
|
|
||||||
filter = injector.getInstance(SignRequest.class);
|
filter = injector.getInstance(SignRequest.class);
|
||||||
|
|
||||||
|
|
|
@ -19,49 +19,74 @@
|
||||||
package org.jclouds.byon;
|
package org.jclouds.byon;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.JcloudsVersion;
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for jclouds BYON API
|
* Implementation of {@link ApiMetadata} for jclouds BYON API
|
||||||
*
|
*
|
||||||
|
* <h3>note</h3>
|
||||||
|
*
|
||||||
|
* This class is not setup to allow a subclasses to override the type of api,
|
||||||
|
* asyncapi, or context. This is an optimization for s.
|
||||||
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BYONApiMetadata extends BaseApiMetadata {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public class BYONApiMetadata extends BaseComputeServiceApiMetadata<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
|
||||||
|
|
||||||
public BYONApiMetadata() {
|
@Override
|
||||||
this(builder()
|
public Builder toBuilder() {
|
||||||
.id("byon")
|
return new Builder().fromApiMetadata(this);
|
||||||
.type(ApiType.COMPUTE)
|
|
||||||
.name("Bring Your Own Node (BYON) API")
|
|
||||||
.identityName("Unused")
|
|
||||||
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
public BYONApiMetadata() {
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
this(new Builder());
|
||||||
// concrete due to serviceLoader
|
}
|
||||||
protected BYONApiMetadata(Builder<?> builder) {
|
|
||||||
|
protected BYONApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
return BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends BaseComputeServiceApiMetadata.Builder<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
id("byon")
|
||||||
|
.name("Bring Your Own Node (BYON) API")
|
||||||
|
.identityName("Unused")
|
||||||
|
.defaultIdentity("foo")
|
||||||
|
.defaultCredential("bar")
|
||||||
|
.defaultEndpoint("file://byon.yaml")
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BYONApiMetadata build() {
|
public BYONApiMetadata build() {
|
||||||
return new BYONApiMetadata(this);
|
return new BYONApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(BYONApiMetadata in) {
|
||||||
}
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,12 +19,13 @@
|
||||||
package org.jclouds.byon;
|
package org.jclouds.byon;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.byon.config.BYONComputeServiceContextModule;
|
import org.jclouds.byon.config.BYONComputeServiceContextModule;
|
||||||
import org.jclouds.byon.config.ConfiguresNodeStore;
|
import org.jclouds.byon.config.ConfiguresNodeStore;
|
||||||
import org.jclouds.byon.config.YamlNodeStoreModule;
|
import org.jclouds.byon.config.YamlNodeStoreModule;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -36,10 +37,15 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder<Supplier> {
|
public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder<Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> {
|
||||||
|
|
||||||
public BYONComputeServiceContextBuilder(Properties props) {
|
public BYONComputeServiceContextBuilder(
|
||||||
super(Supplier.class, props);
|
ProviderMetadata<Supplier, Supplier, ComputeServiceContext<Supplier, Supplier>, BYONApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,48 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds properties used in byon Clients
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class BYONPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "1.0");
|
|
||||||
properties.setProperty(PROPERTY_IDENTITY, "foo");
|
|
||||||
properties.setProperty(PROPERTY_CREDENTIAL, "bar");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BYONPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.byon;
|
package org.jclouds.byon;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "BYONApiMetadataTest")
|
@Test(groups = "unit", testName = "BYONApiMetadataTest")
|
||||||
public class BYONApiMetadataTest extends BaseApiMetadataTest {
|
public class BYONApiMetadataTest extends BaseComputeServiceApiMetadataTest {
|
||||||
|
|
||||||
public BYONApiMetadataTest() {
|
public BYONApiMetadataTest() {
|
||||||
super(new BYONApiMetadata(), ApiType.COMPUTE);
|
super(new BYONApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,10 @@ import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.internal.ContextBuilder;
|
||||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
|
@ -49,7 +49,7 @@ import com.google.inject.Module;
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BYONComputeServiceLiveTest {
|
public class BYONComputeServiceLiveTest {
|
||||||
|
|
||||||
private ComputeServiceContext context;
|
private ComputeServiceContext<?, ?> context;
|
||||||
|
|
||||||
@BeforeClass(groups = "live")
|
@BeforeClass(groups = "live")
|
||||||
public void setup() throws FileNotFoundException, IOException {
|
public void setup() throws FileNotFoundException, IOException {
|
||||||
|
@ -72,9 +72,8 @@ public class BYONComputeServiceLiveTest {
|
||||||
.append("\n");
|
.append("\n");
|
||||||
|
|
||||||
contextProperties.setProperty("byon.nodes", nodes.toString());
|
contextProperties.setProperty("byon.nodes", nodes.toString());
|
||||||
|
context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties)
|
||||||
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
.modules(ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build();
|
||||||
new SshjSshClientModule(), new Log4JLoggingModule()), contextProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCanRunCommandAsCurrentUser() throws Exception {
|
public void testCanRunCommandAsCurrentUser() throws Exception {
|
||||||
|
|
|
@ -24,15 +24,15 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.byon.config.CacheNodeStoreModule;
|
import org.jclouds.byon.config.CacheNodeStoreModule;
|
||||||
import org.jclouds.byon.functions.NodesFromYamlTest;
|
import org.jclouds.byon.functions.NodesFromYamlTest;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
import org.jclouds.rest.AnonymousProviderMetadata;
|
||||||
|
import org.jclouds.rest.internal.ContextBuilder;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -68,13 +68,13 @@ public class BYONComputeServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertNodesParse(String endpoint, Iterable<Module> modules) {
|
private void assertNodesParse(String endpoint, Iterable<Module> modules) {
|
||||||
ComputeServiceContext context = null;
|
ComputeServiceContext<?, ?> context = null;
|
||||||
try {
|
try {
|
||||||
Location providerLocation = expectedProviderLocationFromResource(endpoint);
|
Location providerLocation = expectedProviderLocationFromResource(endpoint);
|
||||||
|
|
||||||
Properties props = new Properties();
|
context = ContextBuilder.newBuilder(
|
||||||
props.setProperty("byon.endpoint", endpoint);
|
AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint))
|
||||||
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", modules, props);
|
.modules(modules).build();
|
||||||
|
|
||||||
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
||||||
|
|
||||||
|
@ -96,13 +96,11 @@ public class BYONComputeServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNodesWithLocations() {
|
public void testNodesWithLocations() {
|
||||||
ComputeServiceContext context = null;
|
ComputeServiceContext<?, ?> context = null;
|
||||||
try {
|
try {
|
||||||
String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath();
|
String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath();
|
||||||
Properties props = new Properties();
|
context = ContextBuilder.newBuilder(
|
||||||
props.setProperty("byon.endpoint", endpoint);
|
AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build();
|
||||||
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(),
|
|
||||||
props);
|
|
||||||
|
|
||||||
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.initializer>org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer</test.initializer>
|
|
||||||
<test.cloudfiles.endpoint>https://auth.api.rackspacecloud.com</test.cloudfiles.endpoint>
|
<test.cloudfiles.endpoint>https://auth.api.rackspacecloud.com</test.cloudfiles.endpoint>
|
||||||
<test.cloudfiles.api-version>1.0</test.cloudfiles.api-version>
|
<test.cloudfiles.api-version>1.0</test.cloudfiles.api-version>
|
||||||
<test.cloudfiles.build-version></test.cloudfiles.build-version>
|
<test.cloudfiles.build-version></test.cloudfiles.build-version>
|
||||||
|
@ -107,7 +106,6 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<test.initializer>${test.initializer}</test.initializer>
|
|
||||||
<jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url>
|
<jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url>
|
||||||
<jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5>
|
<jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5>
|
||||||
<test.cloudfiles.endpoint>${test.cloudfiles.endpoint}</test.cloudfiles.endpoint>
|
<test.cloudfiles.endpoint>${test.cloudfiles.endpoint}</test.cloudfiles.endpoint>
|
||||||
|
|
|
@ -18,51 +18,75 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudfiles;
|
package org.jclouds.cloudfiles;
|
||||||
|
|
||||||
|
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||||
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata;
|
||||||
|
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
|
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
|
||||||
*
|
*
|
||||||
* @author Dan Lo Bianco
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudFilesApiMetadata extends BaseApiMetadata {
|
public class CloudFilesApiMetadata
|
||||||
|
extends
|
||||||
public CloudFilesApiMetadata() {
|
BaseBlobStoreApiMetadata<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
|
||||||
this(builder()
|
private static Builder builder() {
|
||||||
.id("cloudfiles")
|
return new Builder();
|
||||||
.type(ApiType.BLOBSTORE)
|
|
||||||
.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")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
@Override
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
public Builder toBuilder() {
|
||||||
// concrete due to serviceLoader
|
return builder().fromApiMetadata(this);
|
||||||
protected CloudFilesApiMetadata(Builder<?> builder) {
|
}
|
||||||
|
|
||||||
|
public CloudFilesApiMetadata() {
|
||||||
|
this(builder());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CloudFilesApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseBlobStoreApiMetadata.Builder.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> {
|
||||||
|
protected Builder() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudFilesApiMetadata build() {
|
public CloudFilesApiMetadata build() {
|
||||||
return new CloudFilesApiMetadata(this);
|
return new CloudFilesApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(CloudFilesApiMetadata in) {
|
||||||
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,34 +19,45 @@
|
||||||
package org.jclouds.cloudfiles;
|
package org.jclouds.cloudfiles;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
||||||
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
|
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
|
||||||
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
|
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link CloudFilesBlobStoreContext} or {@link Injector} instances based on the most
|
* Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on
|
||||||
* commonly requested arguments.
|
* the most commonly requested arguments.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
* Note that Threadsafe objects will be bound as singletons to the Injector or
|
||||||
|
* Context provided.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p/>
|
* <p/>
|
||||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
* If no <code>Module</code>s are specified, the default
|
||||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
* {@link JDKLoggingModule logging} and
|
||||||
|
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
|
||||||
|
* installed.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole, Andrew Newdigate
|
* @author Adrian Cole, Andrew Newdigate
|
||||||
* @see CloudFilesBlobStoreContext
|
* @see CloudFilesStoreContext
|
||||||
*/
|
*/
|
||||||
public class CloudFilesContextBuilder extends BlobStoreContextBuilder<CloudFilesClient, CloudFilesAsyncClient> {
|
public class CloudFilesContextBuilder
|
||||||
|
extends
|
||||||
|
BlobStoreContextBuilder<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> {
|
||||||
|
|
||||||
public CloudFilesContextBuilder(Properties props) {
|
public CloudFilesContextBuilder(
|
||||||
super(CloudFilesClient.class, CloudFilesAsyncClient.class, props);
|
ProviderMetadata<CloudFilesClient, CloudFilesAsyncClient, BlobStoreContext<CloudFilesClient, CloudFilesAsyncClient>, CloudFilesApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore {
|
||||||
private final EnableCDNAndCache enableCDNAndCache;
|
private final EnableCDNAndCache enableCDNAndCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, CloudFilesClient sync, CloudFilesAsyncClient async,
|
@Memoized Supplier<Set<? extends Location>> locations, CloudFilesClient sync, CloudFilesAsyncClient async,
|
||||||
ContainerToResourceMetadata container2ResourceMd,
|
ContainerToResourceMetadata container2ResourceMd,
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore {
|
||||||
private EnableCDNAndCache enableCDNAndCache;
|
private EnableCDNAndCache enableCDNAndCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
|
@Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
|
||||||
ContainerToResourceMetadata container2ResourceMd,
|
ContainerToResourceMetadata container2ResourceMd,
|
||||||
BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
|
BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudfiles;
|
package org.jclouds.cloudfiles;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "CloudFilesApiMetadataTest")
|
@Test(groups = "unit", testName = "CloudFilesApiMetadataTest")
|
||||||
public class CloudFilesApiMetadataTest extends BaseApiMetadataTest {
|
public class CloudFilesApiMetadataTest extends BaseBlobStoreApiMetadataTest {
|
||||||
|
|
||||||
public CloudFilesApiMetadataTest() {
|
public CloudFilesApiMetadataTest() {
|
||||||
super(new CloudFilesApiMetadata(), ApiType.BLOBSTORE);
|
super(new CloudFilesApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,10 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest<CloudFilesClient> {
|
public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest<CloudFilesClient> {
|
||||||
|
|
||||||
|
public CloudFilesClientLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudFilesClient getApi() {
|
public CloudFilesClient getApi() {
|
||||||
return (CloudFilesClient) context.getProviderSpecificContext().getApi();
|
return (CloudFilesClient) context.getProviderSpecificContext().getApi();
|
||||||
|
|
|
@ -28,6 +28,10 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
|
public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
|
||||||
|
public CloudFilesBlobIntegrationLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkContentDisposition(Blob blob, String contentDisposition) {
|
protected void checkContentDisposition(Blob blob, String contentDisposition) {
|
||||||
assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob
|
assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob
|
||||||
|
|
|
@ -27,5 +27,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest {
|
public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest {
|
||||||
|
public CloudFilesBlobLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudFilesBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
|
public class CloudFilesBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
|
||||||
|
public CloudFilesBlobMapIntegrationLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,5 +27,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
|
public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
|
||||||
|
public CloudFilesBlobSignerLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudFilesContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
|
public class CloudFilesContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
|
||||||
|
public CloudFilesContainerIntegrationLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public class CloudFilesContainerLiveTest extends BaseContainerLiveTest {
|
public class CloudFilesContainerLiveTest extends BaseContainerLiveTest {
|
||||||
|
public CloudFilesContainerLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudFilesInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
|
public class CloudFilesInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
|
||||||
|
public CloudFilesInputStreamMapIntegrationLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
|
public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
|
||||||
|
public CloudFilesServiceIntegrationLiveTest(){
|
||||||
|
provider = "cloudfiles";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,50 +19,71 @@
|
||||||
package org.jclouds.cloudloadbalancers;
|
package org.jclouds.cloudloadbalancers;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.apis.ApiType;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||||
|
import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata;
|
||||||
|
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Rackspace Cloud Load Balancers API
|
* Implementation of {@link ApiMetadata} for CloudLoadBalancers 1.0 API
|
||||||
*
|
*
|
||||||
* @author Dan Lo Bianco
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudLoadBalancersApiMetadata extends BaseApiMetadata {
|
public class CloudLoadBalancersApiMetadata
|
||||||
|
extends
|
||||||
|
BaseLoadBalancerServiceApiMetadata<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
|
||||||
|
|
||||||
public CloudLoadBalancersApiMetadata() {
|
@Override
|
||||||
this(builder()
|
public Builder toBuilder() {
|
||||||
.id("cloudloadbalancers")
|
return new Builder().fromApiMetadata(this);
|
||||||
.type(ApiType.LOADBALANCER)
|
|
||||||
.name("Rackspace Cloud Load Balancers API")
|
|
||||||
.identityName("Username")
|
|
||||||
.credentialName("API Key")
|
|
||||||
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
public CloudLoadBalancersApiMetadata() {
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
this(new Builder());
|
||||||
// concrete due to serviceLoader
|
}
|
||||||
protected CloudLoadBalancersApiMetadata(Builder<?> builder) {
|
|
||||||
|
protected CloudLoadBalancersApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties();
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder
|
||||||
|
extends
|
||||||
|
BaseLoadBalancerServiceApiMetadata.Builder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
id("cloudloadbalancers")
|
||||||
|
.name("Rackspace Cloud Load Balancers API")
|
||||||
|
.identityName("Username")
|
||||||
|
.credentialName("API Key")
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudLoadBalancersApiMetadata build() {
|
public CloudLoadBalancersApiMetadata build() {
|
||||||
return new CloudLoadBalancersApiMetadata(this);
|
return new CloudLoadBalancersApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) {
|
||||||
}
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,11 +19,12 @@
|
||||||
package org.jclouds.cloudloadbalancers;
|
package org.jclouds.cloudloadbalancers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
||||||
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
|
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
|
||||||
|
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||||
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
|
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -31,11 +32,17 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudLoadBalancersContextBuilder extends
|
public class CloudLoadBalancersContextBuilder
|
||||||
LoadBalancerServiceContextBuilder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {
|
extends
|
||||||
|
LoadBalancerServiceContextBuilder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> {
|
||||||
|
|
||||||
public CloudLoadBalancersContextBuilder(Properties props) {
|
public CloudLoadBalancersContextBuilder(
|
||||||
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class, props);
|
ProviderMetadata<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient, LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>, CloudLoadBalancersApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,44 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds properties used inRackspace Cloud Load Balancers Clients
|
|
||||||
*
|
|
||||||
* @author Dan Lo Bianco
|
|
||||||
*/
|
|
||||||
public class CloudLoadBalancersPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "1.0");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudLoadBalancersPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudloadbalancers;
|
package org.jclouds.cloudloadbalancers;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest")
|
@Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest")
|
||||||
public class CloudLoadBalancersApiMetadataTest extends BaseApiMetadataTest {
|
public class CloudLoadBalancersApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest {
|
||||||
|
|
||||||
public CloudLoadBalancersApiMetadataTest() {
|
public CloudLoadBalancersApiMetadataTest() {
|
||||||
super(new CloudLoadBalancersApiMetadata(), ApiType.LOADBALANCER);
|
super(new CloudLoadBalancersApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
|
||||||
private Set<LoadBalancer> lbs = Sets.newLinkedHashSet();
|
private Set<LoadBalancer> lbs = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
super.setupClient();
|
super.setupContext();
|
||||||
assertEquals(client.getConfiguredRegions(), Arrays.asList(regions));
|
assertEquals(client.getConfiguredRegions(), Arrays.asList(regions));
|
||||||
Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
|
Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,10 @@ import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder;
|
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder;
|
|
||||||
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
||||||
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
|
|
||||||
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
|
|
||||||
import org.jclouds.cloudloadbalancers.reference.Region;
|
import org.jclouds.cloudloadbalancers.reference.Region;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -48,13 +46,10 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge
|
||||||
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
|
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
|
||||||
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -62,7 +57,7 @@ import com.google.inject.Provides;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClientTest<T> {
|
public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsyncClientTest<T> {
|
||||||
|
|
||||||
protected String provider;
|
protected String provider;
|
||||||
|
|
||||||
|
@ -131,15 +126,9 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* this is only here as "cloudloadbalancers" is not in rest.properties
|
|
||||||
*/
|
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
return RestContextFactory.<LoadBalancerClient, LoadBalancerAsyncClient> contextSpec(provider, "https://auth",
|
return new CloudLoadBalancersApiMetadata();
|
||||||
"1.0", "", "", "identity", "credential", LoadBalancerClient.class, LoadBalancerAsyncClient.class,
|
|
||||||
(Class) CloudLoadBalancersPropertiesBuilder.class, (Class) CloudLoadBalancersContextBuilder.class,
|
|
||||||
ImmutableSet.<Module> of());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudloadbalancers.internal;
|
package org.jclouds.cloudloadbalancers.internal;
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||||
|
@ -26,32 +25,33 @@ import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||||
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
|
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
|
||||||
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted;
|
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted;
|
||||||
import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory;
|
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.BaseRestClientLiveTest;
|
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.rest.internal.BaseContextLiveTest;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest {
|
public class BaseCloudLoadBalancersClientLiveTest
|
||||||
|
extends
|
||||||
|
BaseContextLiveTest<LoadBalancerServiceContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> {
|
||||||
|
|
||||||
public BaseCloudLoadBalancersClientLiveTest() {
|
public BaseCloudLoadBalancersClientLiveTest() {
|
||||||
provider = "cloudloadbalancers";
|
provider = "cloudloadbalancers";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CloudLoadBalancersClient client;
|
protected CloudLoadBalancersClient client;
|
||||||
protected RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> context;
|
protected RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> lbContext;
|
||||||
protected String[] regions = {};
|
protected String[] regions = {};
|
||||||
protected Predicate<IPSocket> socketTester;
|
protected Predicate<IPSocket> socketTester;
|
||||||
protected RetryablePredicate<LoadBalancer> loadBalancerActive;
|
protected RetryablePredicate<LoadBalancer> loadBalancerActive;
|
||||||
|
@ -59,15 +59,13 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
|
||||||
|
|
||||||
protected Injector injector;
|
protected Injector injector;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
|
@Override
|
||||||
|
public void setupContext() {
|
||||||
|
super.setupContext();
|
||||||
|
lbContext = context.getProviderSpecificContext();
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
client = lbContext.getApi();
|
||||||
public void setupClient() {
|
|
||||||
setupCredentials();
|
|
||||||
Properties overrides = setupProperties();
|
|
||||||
context = new LoadBalancerServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
|
||||||
overrides).getProviderSpecificContext();
|
|
||||||
|
|
||||||
client = context.getApi();
|
|
||||||
|
|
||||||
injector = Guice.createInjector(new Log4JLoggingModule());
|
injector = Guice.createInjector(new Log4JLoggingModule());
|
||||||
loadBalancerActive = new RetryablePredicate<LoadBalancer>(new LoadBalancerActive(client), 300, 1, 1,
|
loadBalancerActive = new RetryablePredicate<LoadBalancer>(new LoadBalancerActive(client), 300, 1, 1,
|
||||||
|
@ -80,8 +78,8 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if (context != null)
|
if (lbContext != null)
|
||||||
context.close();
|
lbContext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,50 +19,70 @@
|
||||||
package org.jclouds.cloudservers;
|
package org.jclouds.cloudservers;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||||
|
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Rackspace Cloud Servers API
|
* Implementation of {@link ApiMetadata} for CloudServers 1.0 API
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudServersApiMetadata extends BaseApiMetadata {
|
public class CloudServersApiMetadata
|
||||||
|
extends
|
||||||
|
BaseComputeServiceApiMetadata<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
|
||||||
|
|
||||||
public CloudServersApiMetadata() {
|
@Override
|
||||||
this(builder()
|
public Builder toBuilder() {
|
||||||
.id("cloudservers")
|
return new Builder().fromApiMetadata(this);
|
||||||
.type(ApiType.COMPUTE)
|
|
||||||
.name("Rackspace Cloud Servers API")
|
|
||||||
.identityName("Username")
|
|
||||||
.credentialName("API Key")
|
|
||||||
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
public CloudServersApiMetadata() {
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
this(new Builder());
|
||||||
// concrete due to serviceLoader
|
}
|
||||||
protected CloudServersApiMetadata(Builder<?> builder) {
|
|
||||||
|
protected CloudServersApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder
|
||||||
|
extends
|
||||||
|
BaseComputeServiceApiMetadata.Builder<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
id("cloudservers")
|
||||||
|
.name("Rackspace Cloud Servers API")
|
||||||
|
.identityName("Username")
|
||||||
|
.credentialName("API Key")
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudServersApiMetadata build() {
|
public CloudServersApiMetadata build() {
|
||||||
return new CloudServersApiMetadata(this);
|
return new CloudServersApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(CloudServersApiMetadata in) {
|
||||||
}
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,35 +19,30 @@
|
||||||
package org.jclouds.cloudservers;
|
package org.jclouds.cloudservers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
|
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
|
||||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link CloudServersComputeServiceContext} 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
|
* @author Adrian Cole
|
||||||
* @see CloudServersComputeServiceContext
|
|
||||||
*/
|
*/
|
||||||
public class CloudServersContextBuilder extends
|
public class CloudServersContextBuilder
|
||||||
ComputeServiceContextBuilder<CloudServersClient, CloudServersAsyncClient> {
|
extends
|
||||||
|
ComputeServiceContextBuilder<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> {
|
||||||
|
|
||||||
public CloudServersContextBuilder(Properties props) {
|
public CloudServersContextBuilder(
|
||||||
super(CloudServersClient.class, CloudServersAsyncClient.class, props);
|
ProviderMetadata<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>, CloudServersApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +50,6 @@ public class CloudServersContextBuilder extends
|
||||||
modules.add(new CloudServersComputeServiceContextModule());
|
modules.add(new CloudServersComputeServiceContextModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addClientModule(List<Module> modules) {
|
protected void addClientModule(List<Module> modules) {
|
||||||
modules.add(new CloudServersRestClientModule());
|
modules.add(new CloudServersRestClientModule());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
import org.jclouds.openstack.OpenStackAuthAsyncClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Dan Lo Bianco
|
|
||||||
*/
|
|
||||||
public class CloudServersPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION);
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudServersPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudservers;
|
package org.jclouds.cloudservers;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "CloudServersApiMetadataTest")
|
@Test(groups = "unit", testName = "CloudServersApiMetadataTest")
|
||||||
public class CloudServersApiMetadataTest extends BaseApiMetadataTest {
|
public class CloudServersApiMetadataTest extends BaseComputeServiceApiMetadataTest {
|
||||||
|
|
||||||
public CloudServersApiMetadataTest() {
|
public CloudServersApiMetadataTest() {
|
||||||
super(new CloudServersApiMetadata(), ApiType.COMPUTE);
|
super(new CloudServersApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import java.util.Properties;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||||
import org.jclouds.cloudservers.domain.BackupSchedule;
|
import org.jclouds.cloudservers.domain.BackupSchedule;
|
||||||
import org.jclouds.cloudservers.domain.DailyBackup;
|
import org.jclouds.cloudservers.domain.DailyBackup;
|
||||||
|
@ -60,14 +61,12 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge
|
||||||
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
|
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
|
||||||
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -84,7 +83,7 @@ import com.google.inject.TypeLiteral;
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||||
// surefire
|
// surefire
|
||||||
@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest")
|
@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest")
|
||||||
public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyncClient> {
|
public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServersAsyncClient> {
|
||||||
private static final Class<? extends ListOptions[]> listOptionsVarargsClass = new ListOptions[] {}.getClass();
|
private static final Class<? extends ListOptions[]> listOptionsVarargsClass = new ListOptions[] {}.getClass();
|
||||||
private static final Class<? extends CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
|
private static final Class<? extends CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
|
||||||
.getClass();
|
.getClass();
|
||||||
|
@ -910,8 +909,8 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
|
||||||
protected String provider = "cloudservers";
|
protected String provider = "cloudservers";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties());
|
return new CloudServersApiMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.UndeclaredThrowableException;
|
import java.lang.reflect.UndeclaredThrowableException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -45,19 +44,17 @@ import org.jclouds.cloudservers.domain.ServerStatus;
|
||||||
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
||||||
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
||||||
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
||||||
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
@ -66,10 +63,8 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudServersClient}
|
* Tests behavior of {@code CloudServersClient}
|
||||||
|
@ -77,7 +72,10 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
|
||||||
public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest {
|
public class CloudServersClientLiveTest
|
||||||
|
extends
|
||||||
|
BaseComputeServiceContextLiveTest<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>> {
|
||||||
|
|
||||||
public CloudServersClientLiveTest() {
|
public CloudServersClientLiveTest() {
|
||||||
provider = "cloudservers";
|
provider = "cloudservers";
|
||||||
}
|
}
|
||||||
|
@ -86,15 +84,11 @@ public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
protected SshClient.Factory sshFactory;
|
protected SshClient.Factory sshFactory;
|
||||||
protected Predicate<IPSocket> socketTester;
|
protected Predicate<IPSocket> socketTester;
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
public void setupClient() {
|
@Override
|
||||||
setupCredentials();
|
public void setupContext() {
|
||||||
Properties overrides = setupProperties();
|
super.setupContext();
|
||||||
|
Injector injector = context.utils().injector();
|
||||||
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides)
|
|
||||||
.buildInjector();
|
|
||||||
|
|
||||||
client = injector.getInstance(CloudServersClient.class);
|
client = injector.getInstance(CloudServersClient.class);
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||||
|
|
|
@ -24,11 +24,10 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.jclouds.cloudservers.CloudServersAsyncClient;
|
import org.jclouds.cloudservers.CloudServersAsyncClient;
|
||||||
import org.jclouds.cloudservers.CloudServersClient;
|
import org.jclouds.cloudservers.CloudServersClient;
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -41,7 +40,10 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
|
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
|
||||||
public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class CloudServersComputeServiceLiveTest
|
||||||
|
extends
|
||||||
|
BaseComputeServiceLiveTest<CloudServersClient, CloudServersAsyncClient, ComputeServiceContext<CloudServersClient, CloudServersAsyncClient>> {
|
||||||
|
|
||||||
public CloudServersComputeServiceLiveTest() {
|
public CloudServersComputeServiceLiveTest() {
|
||||||
provider = "cloudservers";
|
provider = "cloudservers";
|
||||||
}
|
}
|
||||||
|
@ -51,12 +53,6 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
|
||||||
return new SshjSshClientModule();
|
return new SshjSshClientModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAssignability() throws Exception {
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
RestContext<CloudServersClient, CloudServersAsyncClient> tmContext = new ComputeServiceContextFactory()
|
|
||||||
.createContext(provider, identity, credential).getProviderSpecificContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String task) throws IOException {
|
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String task) throws IOException {
|
||||||
super.checkNodes(nodes, group, task);
|
super.checkNodes(nodes, group, task);
|
||||||
|
|
|
@ -23,9 +23,9 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
import org.jclouds.cloudservers.CloudServersApiMetadata;
|
||||||
import org.jclouds.cloudservers.CloudServersClient;
|
import org.jclouds.cloudservers.CloudServersClient;
|
||||||
import org.jclouds.cloudservers.CloudServersContextBuilder;
|
|
||||||
import org.jclouds.cloudservers.CloudServersPropertiesBuilder;
|
|
||||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
@ -49,12 +49,16 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupRestProperties() {
|
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
|
return new CloudServersApiMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Properties setupProperties() {
|
||||||
Properties overrides = new Properties();
|
Properties overrides = new Properties();
|
||||||
overrides.setProperty(PROPERTY_REGIONS, "US");
|
overrides.setProperty(PROPERTY_REGIONS, "US");
|
||||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||||
overrides.setProperty(provider + ".contextbuilder", CloudServersContextBuilder.class.getName());
|
|
||||||
overrides.setProperty(provider + ".propertiesbuilder", CloudServersPropertiesBuilder.class.getName());
|
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,51 +18,77 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudsigma;
|
package org.jclouds.cloudsigma;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for the Cloud Sigma API
|
* Implementation of {@link ApiMetadata} for the Cloud Sigma API
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudSigmaApiMetadata extends BaseApiMetadata {
|
public class CloudSigmaApiMetadata
|
||||||
|
extends
|
||||||
|
BaseComputeServiceApiMetadata<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
|
||||||
|
|
||||||
public CloudSigmaApiMetadata() {
|
@Override
|
||||||
this(builder()
|
public Builder toBuilder() {
|
||||||
.id("cloudsigma")
|
return new Builder().fromApiMetadata(this);
|
||||||
.type(ApiType.COMPUTE)
|
|
||||||
.name("CloudSigma API")
|
|
||||||
.identityName("Email")
|
|
||||||
.credentialName("Password")
|
|
||||||
.documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
public CloudSigmaApiMetadata() {
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
this(new Builder());
|
||||||
// concrete due to serviceLoader
|
}
|
||||||
protected CloudSigmaApiMetadata(Builder<?> builder) {
|
|
||||||
|
protected CloudSigmaApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseComputeServiceApiMetadata.Builder.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
|
||||||
|
properties.setProperty("jclouds.ssh.max-retries", "7");
|
||||||
|
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder
|
||||||
|
extends
|
||||||
|
BaseComputeServiceApiMetadata.Builder<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
id("cloudsigma")
|
||||||
|
.name("CloudSigma API")
|
||||||
|
.identityName("Email")
|
||||||
|
.credentialName("Password")
|
||||||
|
.documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api"))
|
||||||
|
.version("1.0")
|
||||||
|
.defaultEndpoint("https://api.cloudsigma.com")
|
||||||
|
.defaultProperties(CloudSigmaApiMetadata.defaultProperties())
|
||||||
|
.javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class)
|
||||||
|
.contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudSigmaApiMetadata build() {
|
public CloudSigmaApiMetadata build() {
|
||||||
return new CloudSigmaApiMetadata(this);
|
return new CloudSigmaApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(CloudSigmaApiMetadata in) {
|
||||||
}
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,11 +19,12 @@
|
||||||
package org.jclouds.cloudsigma;
|
package org.jclouds.cloudsigma;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
|
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
|
||||||
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
|
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -31,10 +32,17 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudSigmaContextBuilder extends ComputeServiceContextBuilder<CloudSigmaClient, CloudSigmaAsyncClient> {
|
public class CloudSigmaContextBuilder
|
||||||
|
extends
|
||||||
|
ComputeServiceContextBuilder<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> {
|
||||||
|
|
||||||
public CloudSigmaContextBuilder(Properties props) {
|
public CloudSigmaContextBuilder(
|
||||||
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class, props);
|
ProviderMetadata<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>, CloudSigmaApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,50 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds properties used in CloudSigma Clients
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class CloudSigmaPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "1.0");
|
|
||||||
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
|
|
||||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
|
||||||
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudSigmaPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudsigma;
|
package org.jclouds.cloudsigma;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest")
|
@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest")
|
||||||
public class CloudSigmaApiMetadataTest extends BaseApiMetadataTest {
|
public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest {
|
||||||
|
|
||||||
public CloudSigmaApiMetadataTest() {
|
public CloudSigmaApiMetadataTest() {
|
||||||
super(new CloudSigmaApiMetadata(), ApiType.COMPUTE);
|
super(new CloudSigmaApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
|
import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
|
||||||
import org.jclouds.cloudsigma.domain.CreateDriveRequest;
|
import org.jclouds.cloudsigma.domain.CreateDriveRequest;
|
||||||
import org.jclouds.cloudsigma.domain.Drive;
|
import org.jclouds.cloudsigma.domain.Drive;
|
||||||
|
@ -44,12 +44,10 @@ import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.filters.BasicAuthentication;
|
import org.jclouds.http.filters.BasicAuthentication;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -64,7 +62,7 @@ import com.google.inject.TypeLiteral;
|
||||||
*/
|
*/
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
@Test(groups = "unit", testName = "CloudSigmaAsyncClientTest")
|
@Test(groups = "unit", testName = "CloudSigmaAsyncClientTest")
|
||||||
public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncClient> {
|
public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsyncClient> {
|
||||||
|
|
||||||
public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = CloudSigmaAsyncClient.class.getMethod("getProfileInfo");
|
Method method = CloudSigmaAsyncClient.class.getMethod("getProfileInfo");
|
||||||
|
@ -243,7 +241,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
|
||||||
// for example, using basic authentication, we should get "only one"
|
// for example, using basic authentication, we should get "only one"
|
||||||
// header
|
// header
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
// TODO: insert expected response class, which probably extends ParseJson
|
// TODO: insert expected response class, which probably extends ParseJson
|
||||||
|
@ -413,7 +411,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
|
||||||
// for example, using basic authentication, we should get "only one"
|
// for example, using basic authentication, we should get "only one"
|
||||||
// header
|
// header
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
// TODO: insert expected response class, which probably extends ParseJson
|
// TODO: insert expected response class, which probably extends ParseJson
|
||||||
|
@ -456,7 +454,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
|
||||||
// for example, using basic authentication, we should get "only one"
|
// for example, using basic authentication, we should get "only one"
|
||||||
// header
|
// header
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
// TODO: insert expected response class, which probably extends ParseJson
|
// TODO: insert expected response class, which probably extends ParseJson
|
||||||
|
@ -562,7 +560,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
|
||||||
// for example, using basic authentication, we should get "only one"
|
// for example, using basic authentication, we should get "only one"
|
||||||
// header
|
// header
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
// TODO: insert expected response class, which probably extends ParseJson
|
// TODO: insert expected response class, which probably extends ParseJson
|
||||||
|
@ -650,9 +648,8 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<CloudSigmaClient, CloudSigmaAsyncClient> createContextSpec() {
|
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
Properties props = new Properties();
|
return new CloudSigmaApiMetadata();
|
||||||
props.setProperty("cloudsigma.endpoint", "https://api.cloudsigma.com");
|
|
||||||
return new RestContextFactory().createContextSpec("cloudsigma", "foo", "bar", props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -44,12 +43,10 @@ import org.jclouds.cloudsigma.domain.VLANInfo;
|
||||||
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
||||||
import org.jclouds.cloudsigma.predicates.DriveClaimed;
|
import org.jclouds.cloudsigma.predicates.DriveClaimed;
|
||||||
import org.jclouds.cloudsigma.util.Servers;
|
import org.jclouds.cloudsigma.util.Servers;
|
||||||
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
@ -67,7 +64,6 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudSigmaClient}
|
* Tests behavior of {@code CloudSigmaClient}
|
||||||
|
@ -75,7 +71,10 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest")
|
||||||
public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
|
public class CloudSigmaClientLiveTest
|
||||||
|
extends
|
||||||
|
BaseComputeServiceContextLiveTest<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>> {
|
||||||
|
|
||||||
public CloudSigmaClientLiveTest() {
|
public CloudSigmaClientLiveTest() {
|
||||||
provider = "cloudsigma";
|
provider = "cloudsigma";
|
||||||
}
|
}
|
||||||
|
@ -84,28 +83,25 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
protected int maxDriveImageTime = 300;
|
protected int maxDriveImageTime = 300;
|
||||||
protected String vncPassword = "Il0veVNC";
|
protected String vncPassword = "Il0veVNC";
|
||||||
protected CloudSigmaClient client;
|
protected CloudSigmaClient client;
|
||||||
protected RestContext<CloudSigmaClient, CloudSigmaAsyncClient> context;
|
protected RestContext<CloudSigmaClient, CloudSigmaAsyncClient> cloudSigmaContext;
|
||||||
protected Predicate<IPSocket> socketTester;
|
protected Predicate<IPSocket> socketTester;
|
||||||
|
|
||||||
protected Predicate<DriveInfo> driveNotClaimed;
|
protected Predicate<DriveInfo> driveNotClaimed;
|
||||||
protected ComputeServiceContext computeContext;
|
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
public void setupClient() {
|
@Override
|
||||||
setupCredentials();
|
public void setupContext() {
|
||||||
Properties overrides = setupProperties();
|
super.setupContext();
|
||||||
computeContext = new ComputeServiceContextFactory().createContext(provider,
|
cloudSigmaContext = context.getProviderSpecificContext();
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides);
|
|
||||||
context = computeContext.getProviderSpecificContext();
|
|
||||||
|
|
||||||
client = context.getApi();
|
client = cloudSigmaContext.getApi();
|
||||||
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
||||||
1, TimeUnit.SECONDS);
|
1, TimeUnit.SECONDS);
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), maxDriveImageTime, 1,
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), maxDriveImageTime, 1,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
|
||||||
if (Strings.emptyToNull(imageId) == null) {
|
if (Strings.emptyToNull(imageId) == null) {
|
||||||
imageId = computeContext.getComputeService().templateBuilder().build().getImage().getId();
|
imageId = context.getComputeService().templateBuilder().build().getImage().getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +255,7 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
String prefix2 = prefix + "2";
|
String prefix2 = prefix + "2";
|
||||||
vlan = client.renameVLAN(vlan.getUuid(), prefix2);
|
vlan = client.renameVLAN(vlan.getUuid(), prefix2);
|
||||||
assertEquals(vlan.getName(),prefix2);
|
assertEquals(vlan.getName(), prefix2);
|
||||||
} finally {
|
} finally {
|
||||||
client.destroyVLAN(id);
|
client.destroyVLAN(id);
|
||||||
}
|
}
|
||||||
|
@ -354,7 +350,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
|
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
|
||||||
|
|
||||||
client.shutdownServer(server.getUuid());
|
client.shutdownServer(server.getUuid());
|
||||||
// behavior on shutdown depends on how your server OS is set up to respond to an ACPI power
|
// behavior on shutdown depends on how your server OS is set up to respond
|
||||||
|
// to an ACPI power
|
||||||
// button signal
|
// button signal
|
||||||
assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
|
assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
|
||||||
server.getUuid()).getStatus() == ServerStatus.STOPPED);
|
server.getUuid()).getStatus() == ServerStatus.STOPPED);
|
||||||
|
@ -415,8 +412,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
client.destroyServer(server.getUuid());
|
client.destroyServer(server.getUuid());
|
||||||
if (server != null)
|
if (server != null)
|
||||||
client.destroyDrive(drive.getUuid());
|
client.destroyDrive(drive.getUuid());
|
||||||
if (context != null)
|
if (cloudSigmaContext != null)
|
||||||
context.close();
|
cloudSigmaContext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -444,10 +441,7 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
protected void prepareDrive() {
|
protected void prepareDrive() {
|
||||||
client.destroyDrive(drive.getUuid());
|
client.destroyDrive(drive.getUuid());
|
||||||
drive = client.cloneDrive(imageId, drive.getName(),
|
drive = client.cloneDrive(imageId, drive.getName(),
|
||||||
new CloneDriveOptions()
|
new CloneDriveOptions().size(driveSize).tags("cat:mouse", "monkey:banana"));
|
||||||
.size(driveSize)
|
|
||||||
.tags("cat:mouse", "monkey:banana")
|
|
||||||
);
|
|
||||||
// Block until the async clone operation has completed.
|
// Block until the async clone operation has completed.
|
||||||
assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
|
assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudsigma.compute;
|
package org.jclouds.cloudsigma.compute;
|
||||||
|
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
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.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -31,7 +34,10 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class CloudSigmaComputeServiceLiveTest
|
||||||
|
extends
|
||||||
|
BaseComputeServiceLiveTest<CloudSigmaClient, CloudSigmaAsyncClient, ComputeServiceContext<CloudSigmaClient, CloudSigmaAsyncClient>> {
|
||||||
|
|
||||||
public CloudSigmaComputeServiceLiveTest() {
|
public CloudSigmaComputeServiceLiveTest() {
|
||||||
provider = "cloudsigma";
|
provider = "cloudsigma";
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,50 +19,81 @@
|
||||||
package org.jclouds.cloudstack;
|
package org.jclouds.cloudstack;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Citrix CloudStack API
|
* Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack 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/>
|
||||||
|
*
|
||||||
|
* As this is a popular api, we also allow overrides for type {@code C}
|
||||||
|
* (context). This allows subtypes to add in new feature groups or extensions,
|
||||||
|
* not present in the base api. For example, you could make a subtype for
|
||||||
|
* context, that exposes admin operations.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudStackApiMetadata extends BaseApiMetadata {
|
public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata>
|
||||||
|
{
|
||||||
|
|
||||||
public CloudStackApiMetadata() {
|
@Override
|
||||||
this(builder()
|
public Builder toBuilder() {
|
||||||
.id("cloudstack")
|
return new Builder().fromApiMetadata(this);
|
||||||
.type(ApiType.COMPUTE)
|
|
||||||
.name("Citrix CloudStack API")
|
|
||||||
.identityName("API Key")
|
|
||||||
.credentialName("Secret Key")
|
|
||||||
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
public CloudStackApiMetadata() {
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
this(new Builder());
|
||||||
// concrete due to serviceLoader
|
}
|
||||||
protected CloudStackApiMetadata(Builder<?> builder) {
|
|
||||||
|
protected CloudStackApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseComputeServiceApiMetadata.Builder.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> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
id("cloudstack")
|
||||||
|
.name("Citrix CloudStack API")
|
||||||
|
.identityName("API Key")
|
||||||
|
.credentialName("Secret Key")
|
||||||
|
.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")
|
||||||
|
.defaultProperties(CloudStackApiMetadata.defaultProperties())
|
||||||
|
.javaApi(CloudStackClient.class, CloudStackAsyncClient.class)
|
||||||
|
.context(TypeToken.of(CloudStackContext.class))
|
||||||
|
.contextBuilder(TypeToken.of(CloudStackContextBuilder.class));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudStackApiMetadata build() {
|
public CloudStackApiMetadata build() {
|
||||||
return new CloudStackApiMetadata(this);
|
return new CloudStackApiMetadata(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
@Override
|
||||||
return new ConcreteBuilder();
|
public Builder fromApiMetadata(CloudStackApiMetadata in) {
|
||||||
}
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,9 +31,8 @@ import com.google.inject.ImplementedBy;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(CloudStackContextImpl.class)
|
@ImplementedBy(CloudStackContextImpl.class)
|
||||||
public interface CloudStackContext extends ComputeServiceContext {
|
public interface CloudStackContext extends ComputeServiceContext<CloudStackClient, CloudStackAsyncClient> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext();
|
RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext();
|
||||||
|
|
||||||
|
|
|
@ -23,24 +23,26 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
|
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
|
||||||
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
||||||
import org.jclouds.cloudstack.internal.CloudStackContextImpl;
|
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudStackContextBuilder extends ComputeServiceContextBuilder<CloudStackClient, CloudStackAsyncClient> {
|
public class CloudStackContextBuilder extends
|
||||||
|
ComputeServiceContextBuilder<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> {
|
||||||
|
|
||||||
public CloudStackContextBuilder(Properties props) {
|
public CloudStackContextBuilder(
|
||||||
super(CloudStackClient.class, CloudStackAsyncClient.class, props);
|
ProviderMetadata<CloudStackClient, CloudStackAsyncClient, CloudStackContext, CloudStackApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) {
|
||||||
protected void addContextModule(List<Module> modules) {
|
super(apiMetadata);
|
||||||
modules.add(new CloudStackComputeServiceContextModule());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +51,13 @@ public class CloudStackContextBuilder extends ComputeServiceContextBuilder<Cloud
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudStackContext buildComputeServiceContext() {
|
protected void addContextModule(List<Module> modules) {
|
||||||
return buildInjector().getInstance(CloudStackContextImpl.class);
|
modules.add(new CloudStackComputeServiceContextModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public Properties getOverrides() {
|
||||||
|
return overrides;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds properties used in cloudstack Clients
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class CloudStackPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:8080/client/api");
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "2.2");
|
|
||||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
|
||||||
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudStackPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.config;
|
package org.jclouds.cloudstack.config;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties and constants used in CloudStack connections.
|
* Configuration properties and constants used in CloudStack connections.
|
||||||
|
@ -28,7 +28,7 @@ import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
public interface CloudStackProperties {
|
public interface CloudStackProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of credentials specified during {@link ComputeServiceContextFactory#createContext}. If
|
* Type of credentials specified during {@link ComputeServiceContextBuilder#overrides}. If
|
||||||
* {@link CredentialType#API_ACCESS_KEY_CREDENTIALS}, the request signing is used. If
|
* {@link CredentialType#API_ACCESS_KEY_CREDENTIALS}, the request signing is used. If
|
||||||
* {@link CredentialType#PASSWORD_CREDENTIALS}, login will happen and a session will be
|
* {@link CredentialType#PASSWORD_CREDENTIALS}, login will happen and a session will be
|
||||||
* persisted.
|
* persisted.
|
||||||
|
|
|
@ -57,7 +57,6 @@ public class CloudStackContextImpl extends ComputeServiceContextImpl<CloudStackC
|
||||||
this.globalContext = globalContext;
|
this.globalContext = globalContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public RestContext<CloudStackClient,CloudStackAsyncClient> getProviderSpecificContext() {
|
public RestContext<CloudStackClient,CloudStackAsyncClient> getProviderSpecificContext() {
|
||||||
return providerSpecificContext;
|
return providerSpecificContext;
|
||||||
|
|
|
@ -26,24 +26,19 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||||
import org.jclouds.cloudstack.CloudStackClient;
|
import org.jclouds.cloudstack.CloudStackClient;
|
||||||
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
import org.jclouds.cloudstack.domain.Account;
|
import org.jclouds.cloudstack.domain.Account;
|
||||||
import org.jclouds.cloudstack.domain.ApiKeyPair;
|
import org.jclouds.cloudstack.domain.ApiKeyPair;
|
||||||
import org.jclouds.cloudstack.domain.User;
|
import org.jclouds.cloudstack.domain.User;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrei Savu
|
* @author Andrei Savu
|
||||||
*/
|
*/
|
||||||
public class ApiKeyPairs {
|
public class ApiKeyPairs {
|
||||||
|
|
||||||
private final static String PROVIDER = "cloudstack";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the API key pair for a given CloudStack user
|
* Retrieve the API key pair for a given CloudStack user
|
||||||
*
|
*
|
||||||
|
@ -60,10 +55,17 @@ public class ApiKeyPairs {
|
||||||
*/
|
*/
|
||||||
public static ApiKeyPair loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
|
public static ApiKeyPair loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
|
||||||
URI endpoint, String username, String password, String domain) {
|
URI endpoint, String username, String password, String domain) {
|
||||||
ComputeServiceContext context = null;
|
CloudStackContext context = null;
|
||||||
try {
|
try {
|
||||||
context = new ComputeServiceContextFactory(setupRestProperties()).
|
Properties overrides = new Properties();
|
||||||
createContext(PROVIDER, ImmutableSet.<Module>of(), setupProperties(endpoint, username, password, domain));
|
overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
||||||
|
overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||||
|
overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials");
|
||||||
|
|
||||||
|
context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata())
|
||||||
|
.endpoint(checkNotNull(endpoint, "endpoint").toASCIIString())
|
||||||
|
.credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password)
|
||||||
|
.overrides(overrides).build();
|
||||||
|
|
||||||
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
|
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
|
||||||
Set<Account> listOfAccounts = client.getAccountClient().listAccounts();
|
Set<Account> listOfAccounts = client.getAccountClient().listAccounts();
|
||||||
|
@ -85,23 +87,4 @@ public class ApiKeyPairs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Properties setupRestProperties() {
|
|
||||||
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Properties setupProperties(URI endpoint, String username, String password, String domain) {
|
|
||||||
Properties overrides = new Properties();
|
|
||||||
|
|
||||||
overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
|
||||||
overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
|
||||||
|
|
||||||
overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials");
|
|
||||||
|
|
||||||
overrides.put(PROVIDER + ".endpoint", checkNotNull(endpoint, "endpoint").toASCIIString());
|
|
||||||
overrides.put(PROVIDER + ".identity",
|
|
||||||
String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")));
|
|
||||||
overrides.put(PROVIDER + ".credential", checkNotNull(password, "password"));
|
|
||||||
|
|
||||||
return overrides;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack;
|
package org.jclouds.cloudstack;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "CloudStackApiMetadataTest")
|
@Test(groups = "unit", testName = "CloudStackApiMetadataTest")
|
||||||
public class CloudStackApiMetadataTest extends BaseApiMetadataTest {
|
public class CloudStackApiMetadataTest extends BaseComputeServiceApiMetadataTest {
|
||||||
|
|
||||||
public CloudStackApiMetadataTest() {
|
public CloudStackApiMetadataTest() {
|
||||||
super(new CloudStackApiMetadata(), ApiType.COMPUTE);
|
super(new CloudStackApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ import static com.google.inject.name.Names.bindProperties;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -97,21 +95,21 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
Map<String, Credentials> credentialStore = Maps.newLinkedHashMap();
|
Map<String, Credentials> credentialStore = Maps.newLinkedHashMap();
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
super.setupClient();
|
super.setupContext();
|
||||||
Module module = new AbstractModule() {
|
Module module = new AbstractModule() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bindProperties(binder(), setupProperties());
|
bindProperties(binder(), setupProperties());
|
||||||
bind(String.class).annotatedWith(Identity.class).toInstance(identity);
|
bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity());
|
||||||
bind(new TypeLiteral<Supplier<User>>() {
|
bind(new TypeLiteral<Supplier<User>>() {
|
||||||
}).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON);
|
}).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON);
|
||||||
bind(new TypeLiteral<Supplier<Map<Long, Network>>>() {
|
bind(new TypeLiteral<Supplier<Map<Long, Network>>>() {
|
||||||
}).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON);
|
}).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON);
|
||||||
bind(new TypeLiteral<Map<String, Credentials>>() {
|
bind(new TypeLiteral<Map<String, Credentials>>() {
|
||||||
}).toInstance(credentialStore);
|
}).toInstance(credentialStore);
|
||||||
bind(CloudStackClient.class).toInstance(context.getApi());
|
bind(CloudStackClient.class).toInstance(cloudStackContext.getApi());
|
||||||
bind(new TypeLiteral<Map<NetworkType, ? extends OptionsConverter>>() {}).
|
bind(new TypeLiteral<Map<NetworkType, ? extends OptionsConverter>>() {}).
|
||||||
toInstance(new CloudStackComputeServiceContextModule().optionsConverters());
|
toInstance(new CloudStackComputeServiceContextModule().optionsConverters());
|
||||||
bind(Long.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance(60L);
|
bind(Long.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance(60L);
|
||||||
|
@ -141,15 +139,10 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
CloudStackComputeServiceAdapter.class);
|
CloudStackComputeServiceAdapter.class);
|
||||||
|
|
||||||
keyPairName = prefix + "-adapter-test-keypair";
|
keyPairName = prefix + "-adapter-test-keypair";
|
||||||
try {
|
keyPair = ComputeTestUtils.setupKeyPair();
|
||||||
keyPair = ComputeTestUtils.setupKeyPair();
|
|
||||||
|
|
||||||
client.getSSHKeyPairClient().deleteSSHKeyPair(keyPairName);
|
client.getSSHKeyPairClient().deleteSSHKeyPair(keyPairName);
|
||||||
client.getSSHKeyPairClient().registerSSHKeyPair(keyPairName, keyPair.get("public"));
|
client.getSSHKeyPairClient().registerSSHKeyPair(keyPairName, keyPair.get("public"));
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
fail("Unable to create keypair", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -164,7 +157,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
public void testCreateNodeWithGroupEncodedIntoName() throws InterruptedException {
|
public void testCreateNodeWithGroupEncodedIntoName() throws InterruptedException {
|
||||||
String group = prefix + "-foo";
|
String group = prefix + "-foo";
|
||||||
String name = group + "-node-" + new Random().nextInt();
|
String name = group + "-node-" + new Random().nextInt();
|
||||||
Template template = computeContext.getComputeService().templateBuilder().build();
|
Template template = context.getComputeService().templateBuilder().build();
|
||||||
|
|
||||||
if (!client
|
if (!client
|
||||||
.getTemplateClient()
|
.getTemplateClient()
|
||||||
|
|
|
@ -20,15 +20,14 @@ package org.jclouds.cloudstack.compute;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||||
import org.jclouds.cloudstack.CloudStackClient;
|
import org.jclouds.cloudstack.CloudStackClient;
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +37,8 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = true, singleThreaded = true)
|
@Test(groups = "live", enabled = true, singleThreaded = true)
|
||||||
public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class CloudStackComputeServiceLiveTest extends
|
||||||
|
BaseComputeServiceLiveTest<CloudStackClient, CloudStackAsyncClient, CloudStackContext> {
|
||||||
public CloudStackComputeServiceLiveTest() {
|
public CloudStackComputeServiceLiveTest() {
|
||||||
provider = "cloudstack";
|
provider = "cloudstack";
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,7 @@ public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest
|
||||||
|
|
||||||
public void testAssignability() throws Exception {
|
public void testAssignability() throws Exception {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
RestContext<CloudStackClient, CloudStackAsyncClient> tmContext = new ComputeServiceContextFactory(
|
RestContext<CloudStackClient, CloudStackAsyncClient> tmContext = context.getProviderSpecificContext();
|
||||||
setupRestProperties()).createContext(provider, identity, credential, ImmutableSet.<Module> of(),
|
|
||||||
setupProperties()).getProviderSpecificContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cloudstack does not support metadata
|
// cloudstack does not support metadata
|
||||||
|
|
|
@ -90,9 +90,9 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
Network network = null;
|
Network network = null;
|
||||||
Set<? extends NodeMetadata> nodes = null;
|
Set<? extends NodeMetadata> nodes = null;
|
||||||
try {
|
try {
|
||||||
assert computeContext.getComputeService().listAssignableLocations().size() > 0;
|
assert context.getComputeService().listAssignableLocations().size() > 0;
|
||||||
|
|
||||||
Template template = computeContext.getComputeService().templateBuilder().build();
|
Template template = context.getComputeService().templateBuilder().build();
|
||||||
|
|
||||||
// get the zone we are launching into
|
// get the zone we are launching into
|
||||||
long zoneId = Long.parseLong(template.getLocation().getId());
|
long zoneId = Long.parseLong(template.getLocation().getId());
|
||||||
|
@ -102,7 +102,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
// find a network offering that supports vlans in our zone
|
// find a network offering that supports vlans in our zone
|
||||||
long offeringId = get(
|
long offeringId = get(
|
||||||
context.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId();
|
cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId();
|
||||||
|
|
||||||
// create an arbitrary network
|
// create an arbitrary network
|
||||||
network = domainAdminContext.getApi()
|
network = domainAdminContext.getApi()
|
||||||
|
@ -115,7 +115,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
template.getOptions().as(CloudStackTemplateOptions.class).networkId(network.getId());
|
template.getOptions().as(CloudStackTemplateOptions.class).networkId(network.getId());
|
||||||
|
|
||||||
// launch the VM
|
// launch the VM
|
||||||
nodes = computeContext.getComputeService().createNodesInGroup(group, 1, template);
|
nodes = context.getComputeService().createNodesInGroup(group, 1, template);
|
||||||
|
|
||||||
assert nodes.size() > 0;
|
assert nodes.size() > 0;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
|
nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
|
||||||
} finally {
|
} finally {
|
||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
computeContext.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
||||||
if (network != null)
|
if (network != null)
|
||||||
domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId());
|
domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId());
|
||||||
}
|
}
|
||||||
|
@ -143,14 +143,14 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
SshKeyPair keyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName);
|
SshKeyPair keyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName);
|
||||||
|
|
||||||
String group = prefix + "-windows-test";
|
String group = prefix + "-windows-test";
|
||||||
Template template = computeContext.getComputeService().templateBuilder()
|
Template template = context.getComputeService().templateBuilder()
|
||||||
.imageId("290").locationId("1")
|
.imageId("290").locationId("1")
|
||||||
.options(new CloudStackTemplateOptions().setupStaticNat(false).keyPair(keyPairName))
|
.options(new CloudStackTemplateOptions().setupStaticNat(false).keyPair(keyPairName))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
NodeMetadata node = null;
|
NodeMetadata node = null;
|
||||||
try {
|
try {
|
||||||
node = getOnlyElement(computeContext.getComputeService()
|
node = getOnlyElement(context.getComputeService()
|
||||||
.createNodesInGroup(group, 1, template));
|
.createNodesInGroup(group, 1, template));
|
||||||
|
|
||||||
String encryptedPassword = client.getVirtualMachineClient()
|
String encryptedPassword = client.getVirtualMachineClient()
|
||||||
|
@ -165,7 +165,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
computeContext.getComputeService().destroyNode(node.getId());
|
context.getComputeService().destroyNode(node.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,25 +20,22 @@ package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Properties;
|
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
|
||||||
import org.jclouds.cloudstack.CloudStackClient;
|
|
||||||
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
|
||||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
import org.jclouds.rest.AnonymousProviderMetadata;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public abstract class BaseCloudStackAsyncClientTest<T> extends RestClientTest<T> {
|
public abstract class BaseCloudStackAsyncClientTest<T> extends BaseAsyncClientTest<T> {
|
||||||
|
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
|
@ -58,10 +55,9 @@ public abstract class BaseCloudStackAsyncClientTest<T> extends RestClientTest<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<CloudStackClient, CloudStackAsyncClient> createContextSpec() {
|
protected ProviderMetadata<?, ?, ?, ?> createProviderMetadata() {
|
||||||
Properties props = new Properties();
|
return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(),
|
||||||
props.setProperty("cloudstack.endpoint", "http://localhost:8080/client/api");
|
"http://localhost:8080/client/api");
|
||||||
return new RestContextFactory().createContextSpec("cloudstack", "apiKey", "secretKey", props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import static com.google.common.base.Strings.emptyToNull;
|
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static com.google.common.collect.Iterables.get;
|
import static com.google.common.collect.Iterables.get;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -50,11 +49,9 @@ import org.jclouds.cloudstack.predicates.UserPredicates;
|
||||||
import org.jclouds.cloudstack.predicates.VirtualMachineDestroyed;
|
import org.jclouds.cloudstack.predicates.VirtualMachineDestroyed;
|
||||||
import org.jclouds.cloudstack.predicates.VirtualMachineRunning;
|
import org.jclouds.cloudstack.predicates.VirtualMachineRunning;
|
||||||
import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult;
|
import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult;
|
||||||
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
@ -76,7 +73,8 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
public class BaseCloudStackClientLiveTest extends
|
||||||
|
BaseComputeServiceContextLiveTest<CloudStackClient, CloudStackAsyncClient, CloudStackContext> {
|
||||||
protected String domainAdminIdentity;
|
protected String domainAdminIdentity;
|
||||||
protected String domainAdminCredential;
|
protected String domainAdminCredential;
|
||||||
protected String globalAdminIdentity;
|
protected String globalAdminIdentity;
|
||||||
|
@ -87,12 +85,13 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupCredentials() {
|
protected Properties setupProperties() {
|
||||||
super.setupCredentials();
|
Properties overrides = super.setupProperties();
|
||||||
domainAdminIdentity = emptyToNull(System.getProperty("test." + provider + ".domainAdminIdentity"));
|
domainAdminIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".domainAdminIdentity");
|
||||||
domainAdminCredential = emptyToNull(System.getProperty("test." + provider + ".domainAdminCredential"));
|
domainAdminCredential = setIfTestSystemPropertyPresent(overrides, provider + ".domainAdminCredential");
|
||||||
globalAdminIdentity = emptyToNull(System.getProperty("test." + provider + ".globalAdminIdentity"));
|
globalAdminIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".globalAdminIdentity");
|
||||||
globalAdminCredential = emptyToNull(System.getProperty("test." + provider + ".globalAdminCredential"));
|
globalAdminCredential = setIfTestSystemPropertyPresent(overrides, provider + ".globalAdminCredential");
|
||||||
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Properties setupDomainAdminProperties() {
|
protected Properties setupDomainAdminProperties() {
|
||||||
|
@ -146,9 +145,8 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
protected String prefix = System.getProperty("user.name");
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
|
||||||
protected CloudStackContext computeContext;
|
|
||||||
protected ComputeService computeClient;
|
protected ComputeService computeClient;
|
||||||
protected RestContext<CloudStackClient, CloudStackAsyncClient> context;
|
protected RestContext<CloudStackClient, CloudStackAsyncClient> cloudStackContext;
|
||||||
protected CloudStackClient client;
|
protected CloudStackClient client;
|
||||||
protected CloudStackClient adminClient;
|
protected CloudStackClient adminClient;
|
||||||
protected User user;
|
protected User user;
|
||||||
|
@ -192,23 +190,18 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
public void setupClient() {
|
@Override
|
||||||
setupCredentials();
|
public void setupContext() {
|
||||||
|
super.setupContext();
|
||||||
computeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()).
|
computeClient = context.getComputeService();
|
||||||
createContext(provider, ImmutableSet.<Module> of(
|
cloudStackContext = context.getProviderSpecificContext();
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), setupProperties()));
|
client = cloudStackContext.getApi();
|
||||||
computeClient = computeContext.getComputeService();
|
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
|
||||||
context = computeContext.getProviderSpecificContext();
|
|
||||||
client = context.getApi();
|
|
||||||
user = verifyCurrentUserIsOfType(context, Account.Type.USER);
|
|
||||||
|
|
||||||
domainAdminEnabled = setupDomainAdminProperties() != null;
|
domainAdminEnabled = setupDomainAdminProperties() != null;
|
||||||
if (domainAdminEnabled) {
|
if (domainAdminEnabled) {
|
||||||
domainAdminComputeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()).
|
domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules());
|
||||||
createContext(provider, ImmutableSet.<Module> of(
|
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), setupDomainAdminProperties()));
|
|
||||||
domainAdminContext = domainAdminComputeContext.getDomainContext();
|
domainAdminContext = domainAdminComputeContext.getDomainContext();
|
||||||
domainAdminClient = domainAdminContext.getApi();
|
domainAdminClient = domainAdminContext.getApi();
|
||||||
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
|
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
|
||||||
|
@ -217,16 +210,14 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
||||||
if (globalAdminEnabled) {
|
if (globalAdminEnabled) {
|
||||||
globalAdminComputeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()).
|
globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules());
|
||||||
createContext(provider, ImmutableSet.<Module> of(
|
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), setupGlobalAdminProperties()));
|
|
||||||
globalAdminContext = globalAdminComputeContext.getGlobalContext();
|
globalAdminContext = globalAdminComputeContext.getGlobalContext();
|
||||||
globalAdminClient = globalAdminContext.getApi();
|
globalAdminClient = globalAdminContext.getApi();
|
||||||
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
|
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
|
||||||
adminClient = globalAdminContext.getApi();
|
adminClient = globalAdminContext.getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
injector = Guice.createInjector(new SshjSshClientModule(), new Log4JLoggingModule());
|
injector = Guice.createInjector(setupModules());
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, 1, TimeUnit.SECONDS);
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, 1, TimeUnit.SECONDS);
|
||||||
injector.injectMembers(socketTester);
|
injector.injectMembers(socketTester);
|
||||||
|
@ -251,6 +242,11 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
injector.injectMembers(reuseOrAssociate);
|
injector.injectMembers(reuseOrAssociate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module getSshModule() {
|
||||||
|
return new SshjSshClientModule();
|
||||||
|
}
|
||||||
|
|
||||||
protected static User verifyCurrentUserIsOfType(
|
protected static User verifyCurrentUserIsOfType(
|
||||||
RestContext<? extends CloudStackClient, ? extends CloudStackAsyncClient> context, Account.Type type) {
|
RestContext<? extends CloudStackClient, ? extends CloudStackAsyncClient> context, Account.Type type) {
|
||||||
Iterable<User> users = Iterables.concat(context.getApi().getAccountClient().listAccounts());
|
Iterable<User> users = Iterables.concat(context.getApi().getAccountClient().listAccounts());
|
||||||
|
@ -272,8 +268,8 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if (context != null)
|
if (cloudStackContext != null)
|
||||||
context.close();
|
cloudStackContext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,16 +24,15 @@ import java.net.URI;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.logging.config.NullLoggingModule;
|
import org.jclouds.rest.internal.BaseRestClientExpectTest;
|
||||||
import org.jclouds.rest.BaseRestClientExpectTest;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,11 +46,15 @@ public abstract class BaseCloudStackRestClientExpectTest<S> extends BaseRestClie
|
||||||
provider = "cloudstack";
|
provider = "cloudstack";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
|
return new CloudStackApiMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public S createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
public S createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
||||||
return clientFrom(CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties())
|
return (S) clientFrom(createInjector(fn, module, props).getInstance(CloudStackContext.class));
|
||||||
.createContext(provider, "identity", "credential", ImmutableSet.<Module> of(new ExpectModule(fn),
|
|
||||||
new NullLoggingModule(), module), props)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract S clientFrom(CloudStackContext context);
|
protected abstract S clientFrom(CloudStackContext context);
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private boolean networksDisabled;
|
private boolean networksDisabled;
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = "live")
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
super.setupClient();
|
super.setupContext();
|
||||||
prefix += "rule";
|
prefix += "rule";
|
||||||
try {
|
try {
|
||||||
network = find(client.getNetworkClient().listNetworks(), Predicates.and(supportsPortForwarding(),
|
network = find(client.getNetworkClient().listNetworks(), Predicates.and(supportsPortForwarding(),
|
||||||
|
|
|
@ -33,15 +33,9 @@ import org.jclouds.cloudstack.domain.Account;
|
||||||
import org.jclouds.cloudstack.domain.ApiKeyPair;
|
import org.jclouds.cloudstack.domain.ApiKeyPair;
|
||||||
import org.jclouds.cloudstack.domain.User;
|
import org.jclouds.cloudstack.domain.User;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.crypto.CryptoStreams;
|
import org.jclouds.crypto.CryptoStreams;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobaUserClient}
|
* Tests behavior of {@code GlobaUserClient}
|
||||||
*/
|
*/
|
||||||
|
@ -89,9 +83,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAuthAsUser(ApiKeyPair keyPair) {
|
private void checkAuthAsUser(ApiKeyPair keyPair) {
|
||||||
ComputeServiceContext context = new ComputeServiceContextFactory(setupRestProperties()).
|
ComputeServiceContext<?, ?> context = createContext(credentialsAsProperties(keyPair), setupModules());
|
||||||
createContext(provider, ImmutableSet.<Module>of(
|
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), credentialsAsProperties(keyPair));
|
|
||||||
|
|
||||||
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
|
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
|
||||||
Set<Account> accounts = client.getAccountClient().listAccounts();
|
Set<Account> accounts = client.getAccountClient().listAccounts();
|
||||||
|
|
|
@ -66,8 +66,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private boolean networksDisabled;
|
private boolean networksDisabled;
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = "live")
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
super.setupClient();
|
super.setupContext();
|
||||||
|
|
||||||
loadBalancerRuleActive = new RetryablePredicate<LoadBalancerRule>(new LoadBalancerRuleActive(client), 60, 1, 1,
|
loadBalancerRuleActive = new RetryablePredicate<LoadBalancerRule>(new LoadBalancerRuleActive(client), 60, 1, 1,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private Zone zone;
|
private Zone zone;
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = "live")
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
super.setupClient();
|
super.setupContext();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
zone = find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
|
zone = find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
|
||||||
|
@ -104,7 +104,7 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
final NetworkOffering offering;
|
final NetworkOffering offering;
|
||||||
try {
|
try {
|
||||||
offering = get(
|
offering = get(
|
||||||
context.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zone.getId())), 0);
|
cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zone.getId())), 0);
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
Logger.getAnonymousLogger().log(Level.SEVERE, "VLAN networks not supported, skipping test");
|
Logger.getAnonymousLogger().log(Level.SEVERE, "VLAN networks not supported, skipping test");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions;
|
||||||
import org.jclouds.cloudstack.options.ListServiceOfferingsOptions;
|
import org.jclouds.cloudstack.options.ListServiceOfferingsOptions;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +66,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
// This bug is present both in 2.2.8 and 2.2.12
|
// This bug is present both in 2.2.8 and 2.2.12
|
||||||
assertTrue("2.2.8".equals(apiVersion) || "2.2.12".equals(apiVersion));
|
assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(cloudStackContext.getApiVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateContextUsingUserAndPasswordAuthentication() {
|
public void testCreateContextUsingUserAndPasswordAuthentication() {
|
||||||
|
String endpoint = cloudStackContext.getEndpoint().toASCIIString();
|
||||||
assert globalAdminEnabled;
|
assert globalAdminEnabled;
|
||||||
|
|
||||||
Account testAccount = null;
|
Account testAccount = null;
|
||||||
|
@ -74,6 +75,7 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(expectedExceptions = AuthorizationException.class)
|
@Test(expectedExceptions = AuthorizationException.class)
|
||||||
public void testTryToGetApiKeypairWithWrongCredentials() {
|
public void testTryToGetApiKeypairWithWrongCredentials() {
|
||||||
|
String endpoint = cloudStackContext.getEndpoint().toASCIIString();
|
||||||
ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
|
ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
|
||||||
URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", "");
|
URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
String extractUrl = extract.getUrl();
|
String extractUrl = extract.getUrl();
|
||||||
assertNotNull(extractUrl);
|
assertNotNull(extractUrl);
|
||||||
URI uri = new URI(URLDecoder.decode(extractUrl, "utf-8"));
|
URI uri = new URI(URLDecoder.decode(extractUrl, "utf-8"));
|
||||||
assertTrue(context.utils().http().exists(uri), "does not exist: " + uri);
|
assertTrue(cloudStackContext.utils().http().exists(uri), "does not exist: " + uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
|
||||||
|
|
||||||
assertRequestLineEquals(
|
assertRequestLineEquals(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
"GET http://localhost:8080/client/api?response=json&command=listZones&apiKey=apiKey&signature=hNz838u4Z1ofz9vRaqYo9GDv1Io%3D HTTP/1.1");
|
"GET http://localhost:8080/client/api?response=json&command=listZones&apiKey=identity&signature=wLSqVlxuiLXZcHi9IoSAwXNRGFs%3D HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,17 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.IntegrationTestAsyncClient;
|
import org.jclouds.http.IntegrationTestAsyncClient;
|
||||||
import org.jclouds.http.IntegrationTestClient;
|
import org.jclouds.http.IntegrationTestClient;
|
||||||
import org.jclouds.logging.config.NullLoggingModule;
|
import org.jclouds.logging.config.NullLoggingModule;
|
||||||
import org.jclouds.rest.BaseRestClientTest.MockModule;
|
import org.jclouds.rest.AnonymousProviderMetadata;
|
||||||
import org.jclouds.rest.RequestSigner;
|
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
|
||||||
import org.jclouds.rest.RestContextBuilder;
|
import org.jclouds.rest.internal.ContextBuilder;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,22 +44,18 @@ import com.google.inject.Module;
|
||||||
// surefire
|
// surefire
|
||||||
@Test(groups = "unit", testName = "QuerySignerTest")
|
@Test(groups = "unit", testName = "QuerySignerTest")
|
||||||
public class QuerySignerTest {
|
public class QuerySignerTest {
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
public static final Injector INJECTOR = ContextBuilder
|
||||||
public static final RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> DUMMY_SPEC = new RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient>("cloudstack",
|
.newBuilder(
|
||||||
"http://localhost:8080/client/api", "2.2", "", "", "apiKey", "secretKey", IntegrationTestClient.class, IntegrationTestAsyncClient.class,
|
AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class,
|
||||||
PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(),
|
"http://localhost:8080/client/api"))
|
||||||
new NullLoggingModule(), new AbstractModule() {
|
.credentials("apiKey", "secretKey")
|
||||||
@Override
|
.apiVersion("2.2")
|
||||||
protected void configure() {
|
.modules(ImmutableList.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
|
||||||
bind(RequestSigner.class).to(QuerySigner.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreateStringToSign() {
|
void testCreateStringToSign() {
|
||||||
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector()
|
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
||||||
.getInstance(QuerySigner.class);
|
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
filter.createStringToSign(HttpRequest.builder().method("GET")
|
filter.createStringToSign(HttpRequest.builder().method("GET")
|
||||||
|
@ -72,8 +65,7 @@ public class QuerySignerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFilter() {
|
void testFilter() {
|
||||||
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector()
|
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
||||||
.getInstance(QuerySigner.class);
|
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
filter.filter(
|
filter.filter(
|
||||||
|
@ -85,8 +77,7 @@ public class QuerySignerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFilterTwice() {
|
void testFilterTwice() {
|
||||||
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector()
|
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
||||||
.getInstance(QuerySigner.class);
|
|
||||||
HttpRequest request = HttpRequest.builder().method("GET")
|
HttpRequest request = HttpRequest.builder().method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build();
|
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = "live")
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
super.setupClient();
|
super.setupContext();
|
||||||
prefix += "nat";
|
prefix += "nat";
|
||||||
try {
|
try {
|
||||||
network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsStaticNAT());
|
network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsStaticNAT());
|
||||||
|
|
|
@ -18,50 +18,83 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudwatch;
|
package org.jclouds.cloudwatch;
|
||||||
|
|
||||||
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||||
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.apis.ApiType;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.apis.internal.BaseApiMetadata;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Amazon's CloudWatch api.
|
* 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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudWatchApiMetadata extends BaseApiMetadata {
|
public class CloudWatchApiMetadata<S extends CloudWatchClient, A extends CloudWatchAsyncClient> extends
|
||||||
|
BaseRestApiMetadata<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder<S, A> toBuilder() {
|
||||||
|
return new Builder<S, A>(getApi(), getAsyncApi()).fromApiMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
public CloudWatchApiMetadata() {
|
public CloudWatchApiMetadata() {
|
||||||
this(builder()
|
this(new Builder<CloudWatchClient, CloudWatchAsyncClient>(CloudWatchClient.class, CloudWatchAsyncClient.class));
|
||||||
.id("cloudwatch")
|
|
||||||
.type(ApiType.MONITOR)
|
|
||||||
.name("Amazon CloudWatch Api")
|
|
||||||
.identityName("Access Key ID")
|
|
||||||
.credentialName("Secret Access Key")
|
|
||||||
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
@SuppressWarnings("unchecked")
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
protected CloudWatchApiMetadata(Builder<?, ?> builder) {
|
||||||
// concrete due to serviceLoader
|
super(Builder.class.cast(builder));
|
||||||
protected CloudWatchApiMetadata(Builder<?> builder) {
|
|
||||||
super(builder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
Properties properties = BaseApiMetadata.Builder.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>> {
|
||||||
|
|
||||||
|
protected Builder(Class<S> client, Class<A> 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())
|
||||||
|
.defaultEndpoint("https://monitoring.us-east-1.amazonaws.com")
|
||||||
|
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudWatchApiMetadata build() {
|
public CloudWatchApiMetadata<S, A> build() {
|
||||||
return new CloudWatchApiMetadata(this);
|
return new CloudWatchApiMetadata<S, A>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder<S, A> fromApiMetadata(CloudWatchApiMetadata<S, A> in) {
|
||||||
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
|
||||||
return new ConcreteBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -19,33 +19,42 @@
|
||||||
package org.jclouds.cloudwatch;
|
package org.jclouds.cloudwatch;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextBuilder;
|
import org.jclouds.rest.RestContextBuilder;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link MonitoringContext} or {@link Injector} instances based on the most commonly requested
|
* Creates {@link MonitoringContext} or {@link Injector} instances based on the
|
||||||
* arguments.
|
* most commonly requested arguments.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
* Note that Threadsafe objects will be bound as singletons to the Injector or
|
||||||
|
* Context provided.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p/>
|
* <p/>
|
||||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
* If no <code>Module</code>s are specified, the default
|
||||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
* {@link JDKLoggingModule logging} and
|
||||||
|
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
|
||||||
|
* installed.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see MonitoringContext
|
* @see MonitoringContext
|
||||||
*/
|
*/
|
||||||
public class CloudWatchContextBuilder extends RestContextBuilder<CloudWatchClient, CloudWatchAsyncClient> {
|
public class CloudWatchContextBuilder<S extends CloudWatchClient, A extends CloudWatchAsyncClient>
|
||||||
|
extends RestContextBuilder<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> {
|
||||||
|
|
||||||
public CloudWatchContextBuilder(Properties props) {
|
public CloudWatchContextBuilder(ProviderMetadata<S, A, RestContext<S, A>, CloudWatchApiMetadata<S, A>> providerMetadata) {
|
||||||
super(CloudWatchClient.class, CloudWatchAsyncClient.class, props);
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudWatchContextBuilder(CloudWatchApiMetadata<S, A> apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,53 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds properties used in Cloud Watch Clients
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
|
||||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION);
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudWatchPropertiesBuilder() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudWatchPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,15 +19,16 @@
|
||||||
package org.jclouds.cloudwatch;
|
package org.jclouds.cloudwatch;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.apis.ApiType;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
import org.jclouds.apis.internal.BaseRestApiMetadataTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Test(groups = "unit", testName = "CloudWatchApiMetadataTest")
|
@Test(groups = "unit", testName = "CloudWatchApiMetadataTest")
|
||||||
public class CloudWatchApiMetadataTest extends BaseApiMetadataTest {
|
public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest {
|
||||||
|
|
||||||
public CloudWatchApiMetadataTest() {
|
public CloudWatchApiMetadataTest() {
|
||||||
super(new CloudWatchApiMetadata(), ApiType.MONITOR);
|
super(new CloudWatchApiMetadata(), ApiType.MONITOR);
|
||||||
|
|
|
@ -26,11 +26,11 @@ import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
|
||||||
|
@ -44,9 +44,7 @@ import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.location.config.LocationModule;
|
import org.jclouds.location.config.LocationModule;
|
||||||
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Suppliers2;
|
import org.jclouds.util.Suppliers2;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -64,7 +62,7 @@ import com.google.inject.TypeLiteral;
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||||
// surefire
|
// surefire
|
||||||
@Test(groups = "unit", testName = "CloudWatchAsyncClientTest")
|
@Test(groups = "unit", testName = "CloudWatchAsyncClientTest")
|
||||||
public class CloudWatchAsyncClientTest extends RestClientTest<CloudWatchAsyncClient> {
|
public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsyncClient> {
|
||||||
|
|
||||||
public void testRegisterInstancesWithMeasure() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRegisterInstancesWithMeasure() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Date date = new Date(10000000l);
|
Date date = new Date(10000000l);
|
||||||
|
@ -125,11 +123,10 @@ public class CloudWatchAsyncClientTest extends RestClientTest<CloudWatchAsyncCli
|
||||||
return new TestMonitoringRestClientModule();
|
return new TestMonitoringRestClientModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
public ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
Properties props = new Properties();
|
return new CloudWatchApiMetadata();
|
||||||
props.setProperty("cloudwatch.endpoint", "https://monitoring.us-east-1.amazonaws.com");
|
|
||||||
return new RestContextFactory().createContextSpec("cloudwatch", "identity", "credential", props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,45 +22,34 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||||
import org.jclouds.cloudwatch.domain.Statistics;
|
import org.jclouds.cloudwatch.domain.Statistics;
|
||||||
import org.jclouds.cloudwatch.domain.Unit;
|
import org.jclouds.cloudwatch.domain.Unit;
|
||||||
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
|
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.rest.BaseRestClientLiveTest;
|
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.internal.BaseContextLiveTest;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudWatchClient}
|
* Tests behavior of {@code CloudWatchClient}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true)
|
||||||
public class CloudWatchClientLiveTest extends BaseRestClientLiveTest {
|
public class CloudWatchClientLiveTest extends BaseContextLiveTest<RestContext<CloudWatchClient, CloudWatchAsyncClient>> {
|
||||||
public CloudWatchClientLiveTest() {
|
public CloudWatchClientLiveTest() {
|
||||||
provider = "cloudwatch";
|
provider = "cloudwatch";
|
||||||
}
|
}
|
||||||
|
|
||||||
private CloudWatchClient client;
|
private CloudWatchClient client;
|
||||||
private RestContext<CloudWatchClient, CloudWatchAsyncClient> context;
|
|
||||||
|
|
||||||
|
@Override
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
setupCredentials();
|
super.setupContext();
|
||||||
Properties overrides = setupProperties();
|
|
||||||
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
|
||||||
overrides);
|
|
||||||
client = context.getApi();
|
client = context.getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,15 +62,9 @@ public class CloudWatchClientLiveTest extends BaseRestClientLiveTest {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days
|
cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days
|
||||||
|
|
||||||
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(
|
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(region, "CPUUtilization", "AWS/EC2",
|
||||||
region, "CPUUtilization", "AWS/EC2", cal.getTime(), new Date(), 180, Statistics.AVERAGE,
|
cal.getTime(), new Date(), 180, Statistics.AVERAGE, GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT));
|
||||||
GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT));
|
|
||||||
|
|
||||||
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
|
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
|
||||||
public void shutdown() {
|
|
||||||
context.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,50 +19,63 @@
|
||||||
package org.jclouds.deltacloud;
|
package org.jclouds.deltacloud;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.apis.BaseApiMetadata;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link ApiMetadata} for Apache Deltacloud API
|
* Implementation of {@link ApiMetadata} for Apache Deltacloud API
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DeltacloudApiMetadata extends BaseApiMetadata {
|
public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
|
||||||
|
|
||||||
public DeltacloudApiMetadata() {
|
@Override
|
||||||
this(builder()
|
public Builder toBuilder() {
|
||||||
.id("deltacloud")
|
return new Builder().fromApiMetadata(this);
|
||||||
.type(ApiType.COMPUTE)
|
|
||||||
.name("Apache Deltacloud API")
|
|
||||||
.identityName("Username")
|
|
||||||
.credentialName("Password")
|
|
||||||
.documentation(URI.create("http://deltacloud.apache.org/api.html")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are so that we can reuse builders, toString, hashCode, etc.
|
public DeltacloudApiMetadata() {
|
||||||
// we have to set concrete classes here, as our base class cannot be
|
this(new Builder());
|
||||||
// concrete due to serviceLoader
|
}
|
||||||
protected DeltacloudApiMetadata(Builder<?> builder) {
|
|
||||||
|
protected DeltacloudApiMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
protected static Properties defaultProperties() {
|
||||||
|
return BaseComputeServiceApiMetadata.Builder.defaultProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends BaseComputeServiceApiMetadata.Builder<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
id("deltacloud")
|
||||||
|
.name("Apache Deltacloud API")
|
||||||
|
.identityName("Username")
|
||||||
|
.credentialName("Password")
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeltacloudApiMetadata build() {
|
||||||
|
return new DeltacloudApiMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder fromApiMetadata(DeltacloudApiMetadata in) {
|
||||||
|
super.fromApiMetadata(in);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DeltacloudApiMetadata build() {
|
|
||||||
return new DeltacloudApiMetadata(this);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcreteBuilder builder() {
|
|
||||||
return new ConcreteBuilder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConcreteBuilder toBuilder() {
|
|
||||||
return builder().fromApiMetadata(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,11 +19,12 @@
|
||||||
package org.jclouds.deltacloud;
|
package org.jclouds.deltacloud;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule;
|
import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule;
|
||||||
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
|
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -31,10 +32,17 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DeltacloudContextBuilder extends ComputeServiceContextBuilder<DeltacloudClient, DeltacloudAsyncClient> {
|
public class DeltacloudContextBuilder
|
||||||
|
extends
|
||||||
|
ComputeServiceContextBuilder<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> {
|
||||||
|
|
||||||
public DeltacloudContextBuilder(Properties props) {
|
public DeltacloudContextBuilder(
|
||||||
super(DeltacloudClient.class, DeltacloudAsyncClient.class, props);
|
ProviderMetadata<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>, DeltacloudApiMetadata> providerMetadata) {
|
||||||
|
super(providerMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeltacloudContextBuilder(DeltacloudApiMetadata apiMetadata) {
|
||||||
|
super(apiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,46 +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 static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds properties used in deltacloud Clients
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class DeltacloudPropertiesBuilder extends PropertiesBuilder {
|
|
||||||
@Override
|
|
||||||
protected Properties defaultProperties() {
|
|
||||||
Properties properties = super.defaultProperties();
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "0.3.0");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:3001/api");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeltacloudPropertiesBuilder(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,8 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.deltacloud;
|
package org.jclouds.deltacloud;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
|
||||||
import org.jclouds.apis.BaseApiMetadataTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "DeltacloudApiMetadataTest")
|
@Test(groups = "unit", testName = "DeltacloudApiMetadataTest")
|
||||||
public class DeltacloudApiMetadataTest extends BaseApiMetadataTest {
|
public class DeltacloudApiMetadataTest extends BaseComputeServiceApiMetadataTest {
|
||||||
|
|
||||||
public DeltacloudApiMetadataTest() {
|
public DeltacloudApiMetadataTest() {
|
||||||
super(new DeltacloudApiMetadata(), ApiType.COMPUTE);
|
super(new DeltacloudApiMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
|
import org.jclouds.deltacloud.config.DeltacloudRestClientModule;
|
||||||
import org.jclouds.deltacloud.domain.DeltacloudCollection;
|
import org.jclouds.deltacloud.domain.DeltacloudCollection;
|
||||||
import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete;
|
import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete;
|
||||||
|
@ -46,12 +46,10 @@ import org.jclouds.http.filters.BasicAuthentication;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.functions.ReturnEmptyMultimapOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptyMultimapOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -67,9 +65,10 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||||
|
// surefire
|
||||||
@Test(groups = "unit", testName = "DeltacloudAsyncClientTest")
|
@Test(groups = "unit", testName = "DeltacloudAsyncClientTest")
|
||||||
public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncClient> {
|
public class DeltacloudAsyncClientTest extends BaseAsyncClientTest<DeltacloudAsyncClient> {
|
||||||
public void testGetCollections() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetCollections() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("getCollections");
|
Method method = DeltacloudAsyncClient.class.getMethod("getCollections");
|
||||||
HttpRequest httpRequest = processor.createRequest(method);
|
HttpRequest httpRequest = processor.createRequest(method);
|
||||||
|
@ -85,7 +84,7 @@ public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncCli
|
||||||
assertRequestLineEquals(httpRequest, "GET http://localhost:3001/api HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "GET http://localhost:3001/api HTTP/1.1");
|
||||||
// for example, using basic authentication, we should get "only one"
|
// for example, using basic authentication, we should get "only one"
|
||||||
// header
|
// header
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\nAuthorization: Basic Zm9vOmJhcg==\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpRequest, ParseSax.class);
|
assertResponseParserClassEquals(method, httpRequest, ParseSax.class);
|
||||||
|
@ -233,7 +232,7 @@ public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncCli
|
||||||
|
|
||||||
public void testCreateInstance() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateInstance() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
||||||
CreateInstanceOptions[].class);
|
CreateInstanceOptions[].class);
|
||||||
GeneratedHttpRequest<DeltacloudAsyncClient> httpRequest = processor.createRequest(method, "imageId-1");
|
GeneratedHttpRequest<DeltacloudAsyncClient> httpRequest = processor.createRequest(method, "imageId-1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
||||||
|
@ -250,9 +249,9 @@ public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncCli
|
||||||
|
|
||||||
public void testCreateInstanceWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateInstanceWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
||||||
CreateInstanceOptions[].class);
|
CreateInstanceOptions[].class);
|
||||||
GeneratedHttpRequest<DeltacloudAsyncClient> httpRequest = processor.createRequest(method, "imageId-1",
|
GeneratedHttpRequest<DeltacloudAsyncClient> httpRequest = processor.createRequest(method, "imageId-1",
|
||||||
CreateInstanceOptions.Builder.named("foo"));
|
CreateInstanceOptions.Builder.named("foo"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n");
|
||||||
|
@ -268,8 +267,8 @@ public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncCli
|
||||||
|
|
||||||
public void testPerformAction() throws IOException, SecurityException, NoSuchMethodException {
|
public void testPerformAction() throws IOException, SecurityException, NoSuchMethodException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("performAction", HttpRequest.class);
|
Method method = DeltacloudAsyncClient.class.getMethod("performAction", HttpRequest.class);
|
||||||
HttpRequest request = processor.createRequest(method, HttpRequest.builder().method("POST").endpoint(
|
HttpRequest request = processor.createRequest(method,
|
||||||
URI.create("https://delta/instance1/reboot")).build());
|
HttpRequest.builder().method("POST").endpoint(URI.create("https://delta/instance1/reboot")).build());
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://delta/instance1/reboot HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://delta/instance1/reboot HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/xml\n");
|
||||||
|
@ -314,7 +313,8 @@ public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncCli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Supplier<URI> provideHardwareProfileCollection(Supplier<Set<? extends DeltacloudCollection>> collectionSupplier) {
|
protected Supplier<URI> provideHardwareProfileCollection(
|
||||||
|
Supplier<Set<? extends DeltacloudCollection>> collectionSupplier) {
|
||||||
return Suppliers.ofInstance(URI.create("http://localhost:3001/api/profiles"));
|
return Suppliers.ofInstance(URI.create("http://localhost:3001/api/profiles"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,15 +329,13 @@ public class DeltacloudAsyncClientTest extends RestClientTest<DeltacloudAsyncCli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Supplier<URI> provideInstanceStateCollection(Supplier<Set<? extends DeltacloudCollection>> collectionSupplier) {
|
protected Supplier<URI> provideInstanceStateCollection(
|
||||||
|
Supplier<Set<? extends DeltacloudCollection>> collectionSupplier) {
|
||||||
return Suppliers.ofInstance(URI.create("http://localhost:3001/api/instance_states"));
|
return Suppliers.ofInstance(URI.create("http://localhost:3001/api/instance_states"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected ApiMetadata<?, ?, ?, ?> createApiMetadata() {
|
||||||
public RestContextSpec<DeltacloudClient, DeltacloudAsyncClient> createContextSpec() {
|
return new DeltacloudApiMetadata();
|
||||||
Properties props = new Properties();
|
|
||||||
props.setProperty("deltacloud.endpoint", "http://localhost:3001/api");
|
|
||||||
return new RestContextFactory().createContextSpec("deltacloud", "foo", "bar", props);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -150,9 +151,9 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() {
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
protected void tearDownContext() {
|
||||||
testDestroyInstance();
|
testDestroyInstance();
|
||||||
super.tearDown();
|
super.tearDownContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,11 @@ import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.deltacloud.domain.DeltacloudCollection;
|
import org.jclouds.deltacloud.domain.DeltacloudCollection;
|
||||||
import org.jclouds.deltacloud.domain.HardwareProfile;
|
import org.jclouds.deltacloud.domain.HardwareProfile;
|
||||||
import org.jclouds.deltacloud.domain.Image;
|
import org.jclouds.deltacloud.domain.Image;
|
||||||
|
@ -37,13 +36,11 @@ import org.jclouds.deltacloud.domain.Realm;
|
||||||
import org.jclouds.deltacloud.domain.Transition;
|
import org.jclouds.deltacloud.domain.Transition;
|
||||||
import org.jclouds.deltacloud.predicates.InstanceFinished;
|
import org.jclouds.deltacloud.predicates.InstanceFinished;
|
||||||
import org.jclouds.deltacloud.predicates.InstanceRunning;
|
import org.jclouds.deltacloud.predicates.InstanceRunning;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -60,27 +57,24 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "ReadOnlyDeltacloudClientLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "ReadOnlyDeltacloudClientLiveTest")
|
||||||
public class ReadOnlyDeltacloudClientLiveTest extends BaseVersionedServiceLiveTest {
|
public class ReadOnlyDeltacloudClientLiveTest
|
||||||
|
extends
|
||||||
|
BaseComputeServiceContextLiveTest<DeltacloudClient, DeltacloudAsyncClient, ComputeServiceContext<DeltacloudClient, DeltacloudAsyncClient>> {
|
||||||
|
|
||||||
public ReadOnlyDeltacloudClientLiveTest() {
|
public ReadOnlyDeltacloudClientLiveTest() {
|
||||||
provider = "deltacloud";
|
provider = "deltacloud";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DeltacloudClient client;
|
protected DeltacloudClient client;
|
||||||
protected RestContext<DeltacloudClient, DeltacloudAsyncClient> context;
|
|
||||||
|
|
||||||
|
|
||||||
protected Predicate<IPSocket> socketTester;
|
protected Predicate<IPSocket> socketTester;
|
||||||
protected ImmutableMap<State, Predicate<Instance>> stateChanges;
|
protected ImmutableMap<State, Predicate<Instance>> stateChanges;
|
||||||
|
|
||||||
|
@Override
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupClient() {
|
public void setupContext() {
|
||||||
setupCredentials();
|
super.setupContext();
|
||||||
Properties overrides = setupProperties();
|
client = context.getProviderSpecificContext().getApi();
|
||||||
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
|
||||||
overrides).getProviderSpecificContext();
|
|
||||||
|
|
||||||
client = context.getApi();
|
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
||||||
stateChanges = ImmutableMap.<Instance.State, Predicate<Instance>> of(//
|
stateChanges = ImmutableMap.<Instance.State, Predicate<Instance>> of(//
|
||||||
Instance.State.RUNNING, new RetryablePredicate<Instance>(new InstanceRunning(client), 600, 1,
|
Instance.State.RUNNING, new RetryablePredicate<Instance>(new InstanceRunning(client), 600, 1,
|
||||||
|
@ -168,10 +162,9 @@ public class ReadOnlyDeltacloudClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@Override
|
||||||
protected void tearDown() {
|
protected Module getSshModule() {
|
||||||
if (context != null)
|
return new SshjSshClientModule();
|
||||||
context.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue