merged latest

This commit is contained in:
Adrian Cole 2012-04-17 16:49:45 -07:00
commit 48ff7d882c
1457 changed files with 21940 additions and 21088 deletions

View File

@ -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);

View File

@ -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.identity>FIXME</test.atmos.identity> <test.atmos.identity>FIXME</test.atmos.identity>

View File

@ -18,50 +18,86 @@
*/ */
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.atmos.blobstore.config.AtmosBlobStoreContextModule;
import org.jclouds.apis.BaseApiMetadata; import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for 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 BaseRestApiMetadata {
public AtmosApiMetadata() { /** The serialVersionUID */
this(builder() private static final long serialVersionUID = 8067252472547486854L;
.id("atmos")
.type(ApiType.BLOBSTORE) public static final TypeToken<RestContext<AtmosClient, AtmosAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<AtmosClient, AtmosAsyncClient>>() {
.name("EMC's Atmos API") private static final long serialVersionUID = -5070937833892503232L;
.identityName("Subtenant ID (UID)") };
.credentialName("Shared Secret")
.documentation(URI.create("https://community.emc.com/docs/DOC-10508")));
private static Builder builder() {
return new Builder();
} }
// 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> { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(AtmosClient.class, AtmosAsyncClient.class);
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")
.defaultProperties(AtmosApiMetadata.defaultProperties())
.wrapper(TypeToken.of(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class));
}
@Override @Override
public AtmosApiMetadata build() { public AtmosApiMetadata build() {
return new AtmosApiMetadata(this); return new AtmosApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -1,62 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.atmos;
import java.util.List;
import java.util.Properties;
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Creates {@link AtmosBlobStoreContext} or {@link Injector} instances based on the most commonly
* requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole, Andrew Newdigate
* @see AtmosBlobStoreContext
*/
public class AtmosContextBuilder extends
BlobStoreContextBuilder<AtmosClient, AtmosAsyncClient> {
public AtmosContextBuilder(Properties props) {
super(AtmosClient.class, AtmosAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new AtmosBlobStoreContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new AtmosRestClientModule());
}
}

View File

@ -33,8 +33,8 @@ import org.jclouds.rest.Binder;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -52,7 +52,7 @@ public class BindUserMetadataToHeaders implements Binder, Function<UserMetadata,
@Override @Override
public Map<String, String> apply(UserMetadata md) { public Map<String, String> apply(UserMetadata md) {
Builder<String, String> headers = ImmutableMap.<String, String> builder(); Builder<String, String> headers = ImmutableMap.builder();
if (md.getMetadata().size() > 0) { if (md.getMetadata().size() > 0) {
String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getMetadata()); String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getMetadata());
headers.put("x-emc-meta", header); headers.put("x-emc-meta", header);

View File

@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.atmos.AtmosAsyncClient;
import org.jclouds.atmos.AtmosClient; import org.jclouds.atmos.AtmosClient;
import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore; import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore;
import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner; import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner;
@ -31,10 +30,8 @@ import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.AsyncBlobStore;
import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.attr.ConsistencyModel;
import org.jclouds.blobstore.config.BlobStoreMapModule; import org.jclouds.blobstore.config.BlobStoreMapModule;
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
@ -43,7 +40,6 @@ import com.google.common.cache.LoadingCache;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Scopes; import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/** /**
* Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound. * Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound.
@ -58,8 +54,6 @@ public class AtmosBlobStoreContextModule extends AbstractModule {
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON); bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON);
bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON);
bind(BlobStoreContext.class).to(new TypeLiteral<BlobStoreContextImpl<AtmosClient, AtmosAsyncClient>>() {
}).in(Scopes.SINGLETON);
bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class); bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class);
bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class); bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class);
} }

View File

@ -19,8 +19,8 @@
package org.jclouds.atmos.blobstore.functions; package org.jclouds.atmos.blobstore.functions;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;

View File

@ -32,7 +32,6 @@ import org.jclouds.date.DateService;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -50,7 +49,6 @@ import com.google.inject.Provides;
* @author Adrian Cole * @author Adrian Cole
*/ */
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> { public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> {
public AtmosRestClientModule() { public AtmosRestClientModule() {
super(AtmosClient.class, AtmosAsyncClient.class); super(AtmosClient.class, AtmosAsyncClient.class);

View File

@ -51,8 +51,8 @@ import org.jclouds.util.Strings2;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
/** /**
* Signs the EMC Atmos Online Storage request. * Signs the EMC Atmos Online Storage request.

View File

@ -33,9 +33,9 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap.Builder;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -74,7 +74,7 @@ public class ParseUserMetadataFromHeaders implements Function<HttpResponse, User
// TODO: change to guava // TODO: change to guava
private Map<String, String> getMetaMap(String meta) { private Map<String, String> getMetaMap(String meta) {
Builder<String, String> metaMap = ImmutableMap.<String, String> builder(); Builder<String, String> metaMap = ImmutableMap.builder();
for (String entry : Splitter.on(", ").split(meta)) { for (String entry : Splitter.on(", ").split(meta)) {
String[] entrySplit = entry.split("="); String[] entrySplit = entry.split("=");
metaMap.put(entrySplit[0], entrySplit[1]); metaMap.put(entrySplit[0], entrySplit[1]);

View File

@ -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());
} }
} }

View File

@ -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;
@ -42,17 +42,14 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
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.functions.ParseURIFromListOrLocationHeaderIf20x; 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 +65,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;
@ -322,7 +319,6 @@ public class AtmosAsyncClientTest extends RestClientTest<AtmosAsyncClient> {
return new TestAtmosRestClientModule(); return new TestAtmosRestClientModule();
} }
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule { private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override @Override
@ -339,10 +335,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);
} }
} }

View File

@ -57,7 +57,7 @@ import com.google.common.collect.Sets;
public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
public AtmosClient getApi() { public AtmosClient getApi() {
return (AtmosClient) context.getProviderSpecificContext().getApi(); return context.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi();
} }
private static final class HeadMatches implements Runnable { private static final class HeadMatches implements Runnable {

View File

@ -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;
@ -31,11 +32,8 @@ import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.blobstore.domain.Blob.Factory;
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.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 +49,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;
@ -129,7 +127,6 @@ public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosAsyncClient>
return new TestAtmosRestClientModule(); return new TestAtmosRestClientModule();
} }
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule { private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override @Override
@ -144,8 +141,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();
} }
} }

View File

@ -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.ContextBuilder;
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.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,8 +41,12 @@ import com.google.inject.Module;
public class AtmosBlobStoreModuleTest { public class AtmosBlobStoreModuleTest {
Injector createInjector() { Injector createInjector() {
return new RestContextFactory().createContextBuilder("atmos", "uid", "key", return ContextBuilder
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

View File

@ -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";
}
} }

View File

@ -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

View File

@ -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";
}
} }

View File

@ -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)

View File

@ -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

View File

@ -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);

View File

@ -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 {

View File

@ -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";
}
} }

View File

@ -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));
}
}

View File

@ -24,29 +24,27 @@ 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.ContextBuilder;
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.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.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;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
@ -98,19 +96,17 @@ public class SignRequestTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
Injector injector = new RestContextFactory() Injector injector = ContextBuilder
.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);
} }
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule { private static final class TestAtmosRestClientModule extends AtmosRestClientModule {

View File

@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals;
import java.io.File; import java.io.File;
import org.jclouds.atmos.domain.AtmosObject; import org.jclouds.atmos.domain.AtmosObject;
import org.jclouds.atmos.domain.AtmosObject.Factory;
import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.SystemMetadata;
import org.jclouds.atmos.domain.UserMetadata; import org.jclouds.atmos.domain.UserMetadata;
import org.jclouds.atmos.domain.AtmosObject.Factory;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.Guice; import com.google.inject.Guice;

View File

@ -69,7 +69,7 @@ public class ParseDirectoryListFromContentAndHeadersTest extends BaseHandlerTest
} }
protected Set<DirectoryEntry> values() { protected Set<DirectoryEntry> values() {
Builder<DirectoryEntry> expected = ImmutableSet.<DirectoryEntry>builder(); Builder<DirectoryEntry> expected = ImmutableSet.builder();
expected.add(new DirectoryEntry("4980cdb2a411106a04a4538c92a1b204ad92077de6e3", FileType.DIRECTORY, expected.add(new DirectoryEntry("4980cdb2a411106a04a4538c92a1b204ad92077de6e3", FileType.DIRECTORY,
"adriancole-blobstore-2096685753")); "adriancole-blobstore-2096685753"));
expected.add(new DirectoryEntry("4980cdb2a410105404980d99e53a0504ad93939e7dc3", FileType.DIRECTORY, expected.add(new DirectoryEntry("4980cdb2a410105404980d99e53a0504ad93939e7dc3", FileType.DIRECTORY,

View File

@ -20,48 +20,71 @@ package org.jclouds.byon;
import java.net.URI; import java.net.URI;
import org.jclouds.JcloudsVersion;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType; import org.jclouds.apis.internal.BaseApiMetadata;
import org.jclouds.apis.BaseApiMetadata; import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.YamlNodeStoreModule;
import org.jclouds.compute.ComputeServiceContext;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/** /**
* 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 { public class BYONApiMetadata extends BaseApiMetadata {
public BYONApiMetadata() { /** The serialVersionUID */
this(builder() private static final long serialVersionUID = -4059125995177393819L;
.id("byon")
.type(ApiType.COMPUTE) @Override
.name("Bring Your Own Node (BYON) API") public Builder toBuilder() {
.identityName("Unused") return new Builder().fromApiMetadata(this);
.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> { public static class Builder extends BaseApiMetadata.Builder {
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())
.wrapper(ComputeServiceContext.class)
.defaultModules(ImmutableSet.<Class<? extends Module>>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class));
}
@Override @Override
public BYONApiMetadata build() { public BYONApiMetadata build() {
return new BYONApiMetadata(this); return new BYONApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -1,65 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.byon;
import java.util.List;
import java.util.Properties;
import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.ConfiguresNodeStore;
import org.jclouds.byon.config.YamlNodeStoreModule;
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
@SuppressWarnings("rawtypes")
public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder<Supplier> {
public BYONComputeServiceContextBuilder(Properties props) {
super(Supplier.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new BYONComputeServiceContextModule());
addNodeStoreModuleIfNotPresent(modules);
}
protected void addNodeStoreModuleIfNotPresent(List<Module> modules) {
if (!Iterables.any(modules, new Predicate<Module>() {
public boolean apply(Module input) {
return input.getClass().isAnnotationPresent(ConfiguresNodeStore.class);
}
})) {
addNodeStoreModule(modules);
}
}
protected void addNodeStoreModule(List<Module> modules) {
modules.add(new YamlNodeStoreModule());
}
}

View File

@ -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);
}
}

View File

@ -21,9 +21,6 @@ package org.jclouds.byon.config;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import javax.inject.Singleton;
import org.jclouds.byon.Node;
import org.jclouds.byon.internal.BYONComputeServiceAdapter; import org.jclouds.byon.internal.BYONComputeServiceAdapter;
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule; import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
@ -36,27 +33,17 @@ import org.jclouds.location.Provider;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@SuppressWarnings("unchecked")
@SingleThreaded @SingleThreaded
public class BYONComputeServiceContextModule extends public class BYONComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule {
JCloudsNativeComputeServiceAdapterContextModule<Supplier, Supplier> {
public BYONComputeServiceContextModule() { public BYONComputeServiceContextModule() {
super(Supplier.class, Supplier.class, BYONComputeServiceAdapter.class); super(BYONComputeServiceAdapter.class);
}
@Provides
@Singleton
Supplier provideApi(Supplier<LoadingCache<String, Node>> in) {
return in;
} }
@Override @Override
@ -68,6 +55,7 @@ public class BYONComputeServiceContextModule extends
}).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class); }).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class);
bind(new TypeLiteral<Function<URI, InputStream>>() { bind(new TypeLiteral<Function<URI, InputStream>>() {
}).to(SupplyFromProviderURIOrNodesProperty.class); }).to(SupplyFromProviderURIOrNodesProperty.class);
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>(){}); install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
});
} }
} }

View File

@ -33,9 +33,9 @@ import org.yaml.snakeyaml.constructor.Constructor;
import com.google.common.base.Function; import com.google.common.base.Function;
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.ImmutableMap.Builder;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
/** /**
@ -130,7 +130,7 @@ public class YamlNode {
public InputStream apply(YamlNode in) { public InputStream apply(YamlNode in) {
if (in == null) if (in == null)
return null; return null;
Builder<String, Object> prettier = ImmutableMap.<String, Object> builder(); Builder<String, Object> prettier = ImmutableMap.builder();
if (in.id != null) if (in.id != null)
prettier.put("id", in.id); prettier.put("id", in.id);
if (in.name != null) if (in.name != null)

View File

@ -42,8 +42,8 @@ import com.google.common.base.Predicates;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.common.util.concurrent.UncheckedExecutionException;
/** /**

View File

@ -81,8 +81,7 @@ public class SupplyFromProviderURIOrNodesProperty implements Supplier<InputStrea
return input.toURL().openStream(); return input.toURL().openStream();
} catch (IOException e) { } catch (IOException e) {
logger.error(e, "URI could not be read: %s", url); logger.error(e, "URI could not be read: %s", url);
Throwables.propagate(e); throw Throwables.propagate(e);
return null;
} }
} }

View File

@ -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());
} }
} }

View File

@ -24,11 +24,11 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Map.Entry;
import org.jclouds.ContextBuilder;
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;
@ -72,9 +72,9 @@ 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).modules(
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of( ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build(
new SshjSshClientModule(), new Log4JLoggingModule()), contextProperties); ComputeServiceContext.class);
} }
public void testCanRunCommandAsCurrentUser() throws Exception { public void testCanRunCommandAsCurrentUser() throws Exception {

View File

@ -23,13 +23,11 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.expectedProvider
import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled; 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 org.jclouds.ContextBuilder;
import java.util.Properties; import org.jclouds.byon.config.BYONComputeServiceContextModule;
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;
@ -40,7 +38,9 @@ import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/** /**
* *
@ -51,36 +51,31 @@ public class BYONComputeServiceTest {
@Test @Test
public void testNodesParseNodeMap() throws Exception { public void testNodesParseNodeMap() throws Exception {
assertNodesParse( assertNodesParse("foo", ContextBuilder.newBuilder(
"foo", new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build())
.endpoint("foo").modules(
ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of( ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of(
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))); NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build(
ComputeServiceContext.class));
} }
@Test @Test
public void testNodesParseWithFileUrl() throws Exception { public void testNodesParseWithFileUrl() throws Exception {
assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ImmutableSet.<Module> of()); assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
"file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class));
} }
@Test @Test
public void testNodesParseWithClasspathUrl() throws Exception { public void testNodesParseWithClasspathUrl() throws Exception {
assertNodesParse("classpath:///test1.yaml", ImmutableSet.<Module> of()); assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
"classpath:///test1.yaml").build(ComputeServiceContext.class));
} }
private void assertNodesParse(String endpoint, Iterable<Module> modules) { private void assertNodesParse(String endpoint, ComputeServiceContext context) {
ComputeServiceContext context = null;
try { try {
Location providerLocation = expectedProviderLocationFromResource(endpoint); Location providerLocation = expectedProviderLocationFromResource(endpoint);
Properties props = new Properties(); Supplier<LoadingCache<String, Node>> supplier = supplier(context);
props.setProperty("byon.endpoint", endpoint);
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", modules, props);
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
@SuppressWarnings("unchecked")
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
.getApi();
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
assertEquals(supplier.get().asMap(), assertEquals(supplier.get().asMap(),
@ -99,16 +94,9 @@ public class BYONComputeServiceTest {
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(new BYONApiMetadata()).endpoint(endpoint).build(ComputeServiceContext.class);
props.setProperty("byon.endpoint", endpoint);
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(),
props);
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); Supplier<LoadingCache<String, Node>> supplier = supplier(context);
@SuppressWarnings("unchecked")
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
.getApi();
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
assertEquals(supplier.get().asMap(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST2.getId(), assertEquals(supplier.get().asMap(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST2.getId(),
@ -145,4 +133,11 @@ public class BYONComputeServiceTest {
context.close(); context.close();
} }
} }
private Supplier<LoadingCache<String, Node>> supplier(ComputeServiceContext context) {
Supplier<LoadingCache<String, Node>> supplier = context.utils().injector().getInstance(
Key.get(new TypeLiteral<Supplier<LoadingCache<String, Node>>>() {
}));
return supplier;
}
} }

View File

@ -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 />
@ -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>

View File

@ -18,51 +18,84 @@
*/ */
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.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * 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 BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 820062881469203616L;
public CloudFilesApiMetadata() { public static final TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>>() {
this(builder() private static final long serialVersionUID = -5070937833892503232L;
.id("cloudfiles") };
.type(ApiType.BLOBSTORE)
.name("Rackspace Cloud Files API") private static Builder builder() {
.identityName("Username") return new Builder();
.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> { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(CloudFilesClient.class, CloudFilesAsyncClient.class);
id("cloudfiles")
.name("Rackspace Cloud Files API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION)
.defaultProperties(CloudFilesApiMetadata.defaultProperties())
.wrapper(TypeToken.of(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));
}
@Override @Override
public CloudFilesApiMetadata build() { public CloudFilesApiMetadata build() {
return new CloudFilesApiMetadata(this); return new CloudFilesApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -1,61 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.cloudfiles;
import java.util.List;
import java.util.Properties;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Creates {@link CloudFilesBlobStoreContext} or {@link Injector} instances based on the most
* commonly requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole, Andrew Newdigate
* @see CloudFilesBlobStoreContext
*/
public class CloudFilesContextBuilder extends BlobStoreContextBuilder<CloudFilesClient, CloudFilesAsyncClient> {
public CloudFilesContextBuilder(Properties props) {
super(CloudFilesClient.class, CloudFilesAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudFilesBlobStoreContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new CloudFilesRestClientModule());
}
}

View File

@ -28,7 +28,6 @@ import org.jclouds.cloudfiles.CDNManagement;
import org.jclouds.cloudfiles.CloudFilesAsyncClient; import org.jclouds.cloudfiles.CloudFilesAsyncClient;
import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.cloudfiles.CloudFilesClient;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -53,7 +52,6 @@ import com.google.inject.Provides;
* @author Adrian Cole * @author Adrian Cole
*/ */
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> { public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> {
public CloudFilesRestClientModule() { public CloudFilesRestClientModule() {

View File

@ -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());
} }
} }

View File

@ -41,9 +41,13 @@ 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 context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
} }
@Override @Override

View File

@ -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

View File

@ -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";
}
} }

View File

@ -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";
}
} }

View File

@ -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";
}
} }

View File

@ -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";
}
} }

View File

@ -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";
}
} }

View File

@ -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";
}
} }

View File

@ -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";
}
} }

View File

@ -19,50 +19,80 @@
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.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.apis.BaseApiMetadata; import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Rackspace Cloud 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 BaseRestApiMetadata {
public CloudLoadBalancersApiMetadata() { /** The serialVersionUID */
this(builder() private static final long serialVersionUID = 6725672099385580694L;
.id("cloudloadbalancers")
.type(ApiType.LOADBALANCER) public static final TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>>() {
.name("Rackspace Cloud Load Balancers API") private static final long serialVersionUID = -5070937833892503232L;
.identityName("Username") };
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")));
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
} }
// 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> { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class);
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")
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
.wrapper(TypeToken.of(LoadBalancerServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
}
@Override @Override
public CloudLoadBalancersApiMetadata build() { public CloudLoadBalancersApiMetadata build() {
return new CloudLoadBalancersApiMetadata(this); return new CloudLoadBalancersApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -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.cloudloadbalancers;
import java.util.List;
import java.util.Properties;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudLoadBalancersContextBuilder extends
LoadBalancerServiceContextBuilder<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {
public CloudLoadBalancersContextBuilder(Properties props) {
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudLoadBalancersLoadBalancerContextModule());
}
protected void addClientModule(List<Module> modules) {
modules.add(new CloudLoadBalancersRestClientModule());
}
}

View File

@ -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);
}
}

View File

@ -37,7 +37,6 @@ import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromH
import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix; import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix;
import org.jclouds.cloudloadbalancers.reference.RackspaceConstants; import org.jclouds.cloudloadbalancers.reference.RackspaceConstants;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -64,7 +63,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudLoadBalancersRestClientModule extends public class CloudLoadBalancersRestClientModule extends
RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> { RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {

View File

@ -22,9 +22,9 @@ import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer; import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

View File

@ -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());
} }
} }

View File

@ -22,8 +22,8 @@ import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes; import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;

View File

@ -46,19 +46,19 @@ 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());
} }
@Override @Override
protected void tearDown() { protected void tearDownContext() {
for (LoadBalancer lb : lbs) { for (LoadBalancer lb : lbs) {
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId()); client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
assert loadBalancerDeleted.apply(lb) : lb; assert loadBalancerDeleted.apply(lb) : lb;
} }
super.tearDown(); super.tearDownContext();
} }
public void testCreateLoadBalancer() throws Exception { public void testCreateLoadBalancer() throws Exception {

View File

@ -24,8 +24,8 @@ import java.util.Collections;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.NodeRequest; import org.jclouds.cloudloadbalancers.domain.NodeRequest;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition; import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition;
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;

View File

@ -26,16 +26,16 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
import org.jclouds.cloudloadbalancers.domain.NodeRequest; import org.jclouds.cloudloadbalancers.domain.NodeRequest;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -137,7 +137,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
@Override @Override
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { protected void tearDownContext() {
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) { for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
LoadBalancer lb = entry.getKey(); LoadBalancer lb = entry.getKey();
LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion()); LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion());
@ -147,6 +147,6 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
} }
assert loadBalancerDeleted.apply(lb) : lb; assert loadBalancerDeleted.apply(lb) : lb;
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -19,9 +19,9 @@
package org.jclouds.cloudloadbalancers.functions; package org.jclouds.cloudloadbalancers.functions;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion; import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;

View File

@ -21,8 +21,8 @@ package org.jclouds.cloudloadbalancers.functions;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.BaseSetParserTest;

View File

@ -31,16 +31,13 @@ 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;
import org.jclouds.http.RequiresHttp;
import org.jclouds.internal.ClassMethodArgs; import org.jclouds.internal.ClassMethodArgs;
import org.jclouds.location.config.LocationModule; import org.jclouds.location.config.LocationModule;
import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.filters.AuthenticateRequest;
@ -48,13 +45,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 +56,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;
@ -76,7 +70,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
} }
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule { protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule {
@Override @Override
protected void installLocations() { protected void installLocations() {
@ -131,15 +124,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());
} }
} }

View File

@ -18,40 +18,38 @@
*/ */
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.apis.BaseContextLiveTest;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; 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.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.common.reflect.TypeToken;
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> {
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 +57,13 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
protected Injector injector; protected Injector injector;
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
lbContext = context.unwrap();
@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,
@ -78,10 +74,9 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
injector.injectMembers(loadBalancerDeleted); injector.injectMembers(loadBalancerDeleted);
} }
@AfterGroups(groups = "live") @Override
protected void tearDown() { protected TypeToken<LoadBalancerServiceContext> contextType() {
if (context != null) return TypeToken.of(LoadBalancerServiceContext.class);
context.close();
} }
} }

View File

@ -19,50 +19,79 @@
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.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.apis.BaseApiMetadata; import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Rackspace Cloud 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 BaseRestApiMetadata {
public CloudServersApiMetadata() { /** The serialVersionUID */
this(builder() private static final long serialVersionUID = 6725672099385580694L;
.id("cloudservers")
.type(ApiType.COMPUTE) public static final TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>>() {
.name("Rackspace Cloud Servers API") private static final long serialVersionUID = -5070937833892503232L;
.identityName("Username") };
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))); @Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
} }
// 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> { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(CloudServersClient.class, CloudServersAsyncClient.class);
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")
.defaultProperties(CloudServersApiMetadata.defaultProperties())
.wrapper(TypeToken.of(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class));
}
@Override @Override
public CloudServersApiMetadata build() { public CloudServersApiMetadata build() {
return new CloudServersApiMetadata(this); return new CloudServersApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -1,63 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.cloudservers;
import java.util.List;
import java.util.Properties;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import com.google.inject.Injector;
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
* @see CloudServersComputeServiceContext
*/
public class CloudServersContextBuilder extends
ComputeServiceContextBuilder<CloudServersClient, CloudServersAsyncClient> {
public CloudServersContextBuilder(Properties props) {
super(CloudServersClient.class, CloudServersAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudServersComputeServiceContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new CloudServersRestClientModule());
}
}

View File

@ -22,8 +22,6 @@ import java.util.Map;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudservers.CloudServersAsyncClient;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage; import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage;
import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem; import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem;
import org.jclouds.cloudservers.compute.functions.FlavorToHardware; import org.jclouds.cloudservers.compute.functions.FlavorToHardware;
@ -55,12 +53,8 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudServersComputeServiceContextModule public class CloudServersComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
ComputeServiceAdapterContextModule<CloudServersClient, CloudServersAsyncClient, Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
public CloudServersComputeServiceContextModule() {
super(CloudServersClient.class, CloudServersAsyncClient.class);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override

View File

@ -32,7 +32,6 @@ import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -53,7 +52,6 @@ import com.google.inject.Provides;
* @author Adrian Cole * @author Adrian Cole
*/ */
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
public class CloudServersRestClientModule extends RestClientModule<CloudServersClient, CloudServersAsyncClient> { public class CloudServersRestClientModule extends RestClientModule<CloudServersClient, CloudServersAsyncClient> {
public CloudServersRestClientModule() { public CloudServersRestClientModule() {

View File

@ -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());
} }
} }

View File

@ -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;
@ -49,7 +50,6 @@ import org.jclouds.cloudservers.options.ListOptions;
import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.cloudservers.options.RebuildServerOptions;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnFalseOn404;
import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.ReturnTrueIf2xx;
@ -60,14 +60,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 +82,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();
@ -891,7 +889,6 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
} }
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
@Provides @Provides
@ -910,8 +907,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

View File

@ -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,16 @@ 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.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 +62,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 +71,8 @@ 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 {
public CloudServersClientLiveTest() { public CloudServersClientLiveTest() {
provider = "cloudservers"; provider = "cloudservers";
} }
@ -86,15 +81,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);

View File

@ -22,13 +22,9 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import org.jclouds.cloudservers.CloudServersAsyncClient;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.compute.BaseComputeServiceLiveTest;
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;
@ -42,6 +38,7 @@ import com.google.inject.Module;
*/ */
@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 {
public CloudServersComputeServiceLiveTest() { public CloudServersComputeServiceLiveTest() {
provider = "cloudservers"; provider = "cloudservers";
} }
@ -51,12 +48,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);

View File

@ -23,12 +23,11 @@ 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.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule;
import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest; import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest;
@ -49,12 +48,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;
} }
@ -77,7 +80,6 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
} }
@ConfiguresRestClient @ConfiguresRestClient
@RequiresHttp
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
@Override @Override

View File

@ -18,51 +18,85 @@
*/ */
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.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.apis.BaseApiMetadata; import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for the Cloud Sigma API * Implementation of {@link ApiMetadata} for the Cloud Sigma API
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudSigmaApiMetadata extends BaseApiMetadata { public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public CloudSigmaApiMetadata() { public static final TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
this(builder() private static final long serialVersionUID = -5070937833892503232L;
.id("cloudsigma") };
.type(ApiType.COMPUTE)
.name("CloudSigma API") @Override
.identityName("Email") public Builder toBuilder() {
.credentialName("Password") return new Builder().fromApiMetadata(this);
.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> { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
// passwords are set post-boot, so auth failures are possible
// from a race condition applying the password set script
properties.setProperty("jclouds.ssh.max-retries", "7");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
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())
.wrapper(TypeToken.of(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class));
}
@Override @Override
public CloudSigmaApiMetadata build() { public CloudSigmaApiMetadata build() {
return new CloudSigmaApiMetadata(this); return new CloudSigmaApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -1,49 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.cloudsigma;
import java.util.List;
import java.util.Properties;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContextBuilder;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudSigmaContextBuilder extends ComputeServiceContextBuilder<CloudSigmaClient, CloudSigmaAsyncClient> {
public CloudSigmaContextBuilder(Properties props) {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudSigmaComputeServiceContextModule());
}
protected void addClientModule(List<Module> modules) {
modules.add(new CloudSigmaRestClientModule());
}
}

View File

@ -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);
}
}

View File

@ -140,7 +140,7 @@ public class CloudSigmaComputeServiceAdapter implements
@Override @Override
public Iterable<Hardware> listHardwareProfiles() { public Iterable<Hardware> listHardwareProfiles() {
Builder<Hardware> hardware = ImmutableSet.<Hardware> builder(); Builder<Hardware> hardware = ImmutableSet.builder();
for (double cpu : new double[] { 1000, 5000, 10000, 20000 }) for (double cpu : new double[] { 1000, 5000, 10000, 20000 })
for (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) { for (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) {
final float size = (float) cpu / 100; final float size = (float) cpu / 100;

View File

@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
import org.jclouds.cloudsigma.CloudSigmaClient; import org.jclouds.cloudsigma.CloudSigmaClient;
import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter; import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl; import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl;
@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudSigmaComputeServiceContextModule public class CloudSigmaComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<ServerInfo, Hardware, DriveInfo, Location> {
ComputeServiceAdapterContextModule<CloudSigmaClient, CloudSigmaAsyncClient, ServerInfo, Hardware, DriveInfo, Location> {
public CloudSigmaComputeServiceContextModule() {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
}
@Override @Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {

View File

@ -25,8 +25,8 @@ import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamilyVersion64Bit;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import com.google.common.base.Function; import com.google.common.base.Function;

View File

@ -33,14 +33,13 @@ import org.jclouds.cloudsigma.domain.ServerMetrics;
import org.jclouds.cloudsigma.functions.BaseDriveToMap; import org.jclouds.cloudsigma.functions.BaseDriveToMap;
import org.jclouds.cloudsigma.functions.DriveDataToMap; import org.jclouds.cloudsigma.functions.DriveDataToMap;
import org.jclouds.cloudsigma.functions.MapToDevices; import org.jclouds.cloudsigma.functions.MapToDevices;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.cloudsigma.functions.MapToDriveMetrics; import org.jclouds.cloudsigma.functions.MapToDriveMetrics;
import org.jclouds.cloudsigma.functions.MapToNICs; import org.jclouds.cloudsigma.functions.MapToNICs;
import org.jclouds.cloudsigma.functions.MapToServerMetrics; import org.jclouds.cloudsigma.functions.MapToServerMetrics;
import org.jclouds.cloudsigma.functions.ServerToMap; import org.jclouds.cloudsigma.functions.ServerToMap;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler; import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> { public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> {

View File

@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableSet.Builder;
/** /**
* *

View File

@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableMap.Builder;
public class MapToDriveMetrics implements Function<Map<String, String>, Map<String, ? extends DriveMetrics>> { public class MapToDriveMetrics implements Function<Map<String, String>, Map<String, ? extends DriveMetrics>> {
public Map<String, ? extends DriveMetrics> apply(Map<String, String> from) { public Map<String, ? extends DriveMetrics> apply(Map<String, String> from) {
Builder<String, DriveMetrics> builder = ImmutableMap.<String, DriveMetrics> builder(); Builder<String, DriveMetrics> builder = ImmutableMap.builder();
addIDEDevices(from, builder); addIDEDevices(from, builder);
addSCSIDevices(from, builder); addSCSIDevices(from, builder);
addBlockDevices(from, builder); addBlockDevices(from, builder);

View File

@ -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());
} }
} }

View File

@ -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);
} }
} }

View File

@ -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,9 @@ 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.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 +63,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 +70,8 @@ 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 {
public CloudSigmaClientLiveTest() { public CloudSigmaClientLiveTest() {
provider = "cloudsigma"; provider = "cloudsigma";
} }
@ -84,28 +80,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.unwrap();
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 +252,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 +347,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 +409,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 +438,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());

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.cloudsigma.compute; package org.jclouds.cloudsigma.compute;
import org.jclouds.compute.BaseComputeServiceLiveTest;
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;
@ -32,6 +32,7 @@ import com.google.inject.Module;
*/ */
@Test(groups = "live") @Test(groups = "live")
public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public CloudSigmaComputeServiceLiveTest() { public CloudSigmaComputeServiceLiveTest() {
provider = "cloudsigma"; provider = "cloudsigma";
} }

View File

@ -19,50 +19,92 @@
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.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.apis.BaseApiMetadata; import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/** /**
* Implementation of {@link ApiMetadata} for Citrix 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 BaseRestApiMetadata {
public CloudStackApiMetadata() { /** The serialVersionUID */
this(builder() private static final long serialVersionUID = -3936131452958663245L;
.id("cloudstack")
.type(ApiType.COMPUTE) public static final TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
.name("Citrix CloudStack API") private static final long serialVersionUID = -5070937833892503232L;
.identityName("API Key") };
.credentialName("Secret Key")
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))); @Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
} }
// 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> { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "7");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
public static class Builder
extends BaseRestApiMetadata.Builder {
protected Builder() {
super(CloudStackClient.class, CloudStackAsyncClient.class);
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")
.wrapper(TypeToken.of(CloudStackContext.class))
.defaultProperties(CloudStackApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class));
}
@Override @Override
public CloudStackApiMetadata build() { public CloudStackApiMetadata build() {
return new CloudStackApiMetadata(this); return new CloudStackApiMetadata(this);
} }
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override @Override
public ConcreteBuilder toBuilder() { public Builder fromApiMetadata(ApiMetadata in) {
return builder().fromApiMetadata(this); super.fromApiMetadata(in);
return this;
}
} }
} }

View File

@ -1,55 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.cloudstack;
import java.util.List;
import java.util.Properties;
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.cloudstack.internal.CloudStackContextImpl;
import org.jclouds.compute.ComputeServiceContextBuilder;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudStackContextBuilder extends ComputeServiceContextBuilder<CloudStackClient, CloudStackAsyncClient> {
public CloudStackContextBuilder(Properties props) {
super(CloudStackClient.class, CloudStackAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new CloudStackComputeServiceContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new CloudStackRestClientModule());
}
@Override
public CloudStackContext buildComputeServiceContext() {
return buildInjector().getInstance(CloudStackContextImpl.class);
}
}

View File

@ -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);
}
}

View File

@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder; import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
/** /**
* *

View File

@ -30,7 +30,6 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudstack.CloudStackAsyncClient;
import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware; import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware;
import org.jclouds.cloudstack.compute.functions.TemplateToImage; import org.jclouds.cloudstack.compute.functions.TemplateToImage;
@ -87,13 +86,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudStackComputeServiceContextModule public class CloudStackComputeServiceContextModule extends
extends ComputeServiceAdapterContextModule<VirtualMachine, ServiceOffering, Template, Zone> {
ComputeServiceAdapterContextModule<CloudStackClient, CloudStackAsyncClient, VirtualMachine, ServiceOffering, Template, Zone> {
public CloudStackComputeServiceContextModule() {
super(CloudStackClient.class, CloudStackAsyncClient.class);
}
@Override @Override
protected void configure() { protected void configure() {

View File

@ -33,8 +33,8 @@ import org.jclouds.cloudstack.domain.OSType;
import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.Template;
import org.jclouds.collect.Memoized; import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;

View File

@ -63,8 +63,8 @@ import com.google.common.base.Supplier;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
/** /**
@ -264,7 +264,7 @@ public class CloudStackComputeServiceAdapter implements
} }
public void disableStaticNATOnIPAddresses(Set<Long> ipAddresses) { public void disableStaticNATOnIPAddresses(Set<Long> ipAddresses) {
Builder<Long> jobsToTrack = ImmutableSet.<Long> builder(); Builder<Long> jobsToTrack = ImmutableSet.builder();
for (Long ipAddress : ipAddresses) { for (Long ipAddress : ipAddresses) {
Long disableStaticNAT = client.getNATClient().disableStaticNATOnPublicIP(ipAddress); Long disableStaticNAT = client.getNATClient().disableStaticNATOnPublicIP(ipAddress);
if (disableStaticNAT != null) { if (disableStaticNAT != null) {
@ -276,7 +276,7 @@ public class CloudStackComputeServiceAdapter implements
} }
public Set<Long> deleteIPForwardingRulesForVMAndReturnDistinctIPs(long virtualMachineId) { public Set<Long> deleteIPForwardingRulesForVMAndReturnDistinctIPs(long virtualMachineId) {
Builder<Long> jobsToTrack = ImmutableSet.<Long> builder(); Builder<Long> jobsToTrack = ImmutableSet.builder();
// immutable doesn't permit duplicates // immutable doesn't permit duplicates
Set<Long> ipAddresses = Sets.newLinkedHashSet(); Set<Long> ipAddresses = Sets.newLinkedHashSet();

View File

@ -27,11 +27,11 @@ import java.util.Set;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.Account.State;
import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.FirewallRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.PortForwardingRule; import org.jclouds.cloudstack.domain.PortForwardingRule;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.Account.State;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.cloudstack.config; package org.jclouds.cloudstack.config;
import org.jclouds.compute.ComputeServiceContextFactory;
/** /**
* Configuration properties and constants used in CloudStack connections. * Configuration properties and constants used in CloudStack connections.
@ -28,7 +27,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.

View File

@ -123,7 +123,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
@ -155,7 +154,6 @@ import com.google.inject.name.Named;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> { public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {

View File

@ -21,13 +21,13 @@ package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.Map.Entry;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
@ -108,7 +108,7 @@ public class NetworkService implements Comparable<NetworkService> {
public NetworkService(String name, Map<String, String> capabilities) { public NetworkService(String name, Map<String, String> capabilities) {
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
ImmutableSortedSet.Builder<Capability> internal = ImmutableSortedSet.<Capability> naturalOrder(); ImmutableSortedSet.Builder<Capability> internal = ImmutableSortedSet.naturalOrder();
for (Entry<String, String> capabililty : checkNotNull(capabilities, "capabilities").entrySet()) for (Entry<String, String> capabililty : checkNotNull(capabilities, "capabilities").entrySet())
internal.add(new Capability(capabililty.getKey(), capabililty.getValue())); internal.add(new Capability(capabililty.getKey(), capabililty.getValue()));
this.capabilities = internal.build(); this.capabilities = internal.build();
@ -120,7 +120,7 @@ public class NetworkService implements Comparable<NetworkService> {
public Map<String, String> getCapabilities() { public Map<String, String> getCapabilities() {
// so tests and serialization comes out expected // so tests and serialization comes out expected
Builder<String, String> returnVal = ImmutableSortedMap.<String, String> naturalOrder(); Builder<String, String> returnVal = ImmutableSortedMap.naturalOrder();
for (Capability capability : capabilities) { for (Capability capability : capabilities) {
returnVal.put(capability.name, capability.value); returnVal.put(capability.name, capability.value);
} }

View File

@ -26,8 +26,8 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.filters.AuthenticationFilter;
import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions;
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;

View File

@ -22,8 +22,8 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions;
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions;

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