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;
import static org.jclouds.rest.RestContextFactory.getPropertiesFromResource;
import java.io.IOException;
import java.net.URI;
import java.util.NoSuchElementException;
@ -73,13 +71,13 @@ public class ComputeTaskUtils {
@SuppressWarnings("unchecked")
@Override
public ComputeServiceContext load(URI from) {
Properties props = getPropertiesFromResource("/rest.properties");
Properties props = new Properties();
props.putAll(projectProvider.get().getProperties());
// adding the properties to the factory will allow us to pass
// alternate endpoints
String provider = from.getHost();
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(),
ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()), props);

View File

@ -34,8 +34,7 @@
<packaging>bundle</packaging>
<properties>
<test.initializer>org.jclouds.atmos.blobstore.integration.AtmosStorageTestInitializer</test.initializer>
<test.atmos.endpoint>https://accesspoint.atmos.com</test.atmos.endpoint>
<test.atmos.endpoint>https://accesspoint.atmosonline.com</test.atmos.endpoint>
<test.atmos.api-version>1.3.0</test.atmos.api-version>
<test.atmos.build-version />
<test.atmos.identity>FIXME</test.atmos.identity>

View File

@ -18,50 +18,86 @@
*/
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.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
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
*/
public class AtmosApiMetadata extends BaseApiMetadata {
public class AtmosApiMetadata extends BaseRestApiMetadata {
public AtmosApiMetadata() {
this(builder()
.id("atmos")
.type(ApiType.BLOBSTORE)
.name("EMC's Atmos API")
.identityName("Subtenant ID (UID)")
.credentialName("Shared Secret")
.documentation(URI.create("https://community.emc.com/docs/DOC-10508")));
/** The serialVersionUID */
private static final long serialVersionUID = 8067252472547486854L;
public static final TypeToken<RestContext<AtmosClient, AtmosAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<AtmosClient, AtmosAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
private static Builder builder() {
return new Builder();
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected AtmosApiMetadata(Builder<?> builder) {
@Override
public Builder toBuilder() {
return builder().fromApiMetadata(this);
}
public AtmosApiMetadata() {
this(builder());
}
protected AtmosApiMetadata(Builder 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
public AtmosApiMetadata build() {
return new AtmosApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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.Joiner;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
/**
* @author Adrian Cole
@ -52,7 +52,7 @@ public class BindUserMetadataToHeaders implements Binder, Function<UserMetadata,
@Override
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) {
String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getMetadata());
headers.put("x-emc-meta", header);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.atmos;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest;
import org.testng.annotations.Test;
/**
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "AtmosApiMetadataTest")
public class AtmosApiMetadataTest extends BaseApiMetadataTest {
public class AtmosApiMetadataTest extends BaseBlobStoreApiMetadataTest {
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.lang.reflect.Method;
import java.util.Properties;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.atmos.blobstore.functions.BlobToObject;
import org.jclouds.atmos.config.AtmosRestClientModule;
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.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.options.GetOptions;
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.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass;
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
@Test(groups = "unit", testName = "AtmosAsyncClientTest")
public class AtmosAsyncClientTest extends RestClientTest<AtmosAsyncClient> {
public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient> {
private BlobToObject blobToObject;
@ -322,7 +319,6 @@ public class AtmosAsyncClientTest extends RestClientTest<AtmosAsyncClient> {
return new TestAtmosRestClientModule();
}
@RequiresHttp
@ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override
@ -339,10 +335,8 @@ public class AtmosAsyncClientTest extends RestClientTest<AtmosAsyncClient> {
protected String provider = "atmos";
@Override
public RestContextSpec<?, ?> createContextSpec() {
Properties props = new Properties();
props.setProperty(provider + ".endpoint", "https://accesspoint.atmosonline.com");
return new RestContextFactory().createContextSpec(provider, "identity", "credential", props);
public ApiMetadata createApiMetadata() {
return new AtmosApiMetadata();
}
}

View File

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

View File

@ -21,8 +21,9 @@ package org.jclouds.atmos.blobstore;
import static org.testng.Assert.assertEquals;
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.config.AtmosRestClientModule;
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.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass;
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
@Test(groups = "unit", testName = "AtmosBlobRequestSignerTest")
public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosAsyncClient> {
public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncClient> {
private BlobRequestSigner signer;
private Factory blobFactory;
@ -129,7 +127,6 @@ public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosAsyncClient>
return new TestAtmosRestClientModule();
}
@RequiresHttp
@ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule {
@Override
@ -144,8 +141,8 @@ public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosAsyncClient>
}
@Override
public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("atmos", "identity", "credential", new Properties());
public ApiMetadata createApiMetadata() {
return new AtmosApiMetadata();
}
}

View File

@ -20,13 +20,14 @@ package org.jclouds.atmos.blobstore.config;
import static org.testng.Assert.assertEquals;
import org.jclouds.ContextBuilder;
import org.jclouds.atmos.AtmosApiMetadata;
import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -40,8 +41,12 @@ import com.google.inject.Module;
public class AtmosBlobStoreModuleTest {
Injector createInjector() {
return new RestContextFactory().createContextBuilder("atmos", "uid", "key",
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
return ContextBuilder
.newBuilder(new AtmosApiMetadata())
.credentials("uid", "key")
.modules(
ImmutableSet.<Module> of(new MockModule(),new NullLoggingModule()))
.buildInjector();
}
@Test

View File

@ -27,5 +27,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class AtmosBlobSignerLiveTest extends BaseBlobSignerLiveTest {
public AtmosBlobSignerLiveTest() {
provider = "atmos";
}
}

View File

@ -31,7 +31,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
public AtmosContainerIntegrationLiveTest() {
provider = "atmos";
}
@Override
public void testListContainerMaxResults() throws InterruptedException {
// Not currently working

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class AtmosContainerLiveTest extends BaseContainerLiveTest {
public AtmosContainerLiveTest() {
provider = "atmos";
}
}

View File

@ -29,6 +29,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
public AtmosInputStreamMapIntegrationLiveTest() {
provider = "atmos";
}
@Override
@Test(enabled = false)

View File

@ -35,7 +35,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "integration", "live" })
public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest {
public AtmosIntegrationLiveTest() {
provider = "atmos";
}
@DataProvider(name = "delete")
// no unicode support
@Override

View File

@ -29,6 +29,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class AtmosLiveTest extends BaseBlobLiveTest {
public AtmosLiveTest() {
provider = "atmos";
}
protected void checkMD5(String container, String name, byte[] md5) {
// atmos does not support content-md5 yet
assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);

View File

@ -30,7 +30,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
public AtmosMapIntegrationLiveTest() {
provider = "atmos";
}
@Override
// NO support for Content-MD5, so contains cannot work
public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException {

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
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.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import org.jclouds.ContextBuilder;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.atmos.reference.AtmosHeaders;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.jclouds.util.Strings2;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.inject.Injector;
import com.google.inject.Module;
@ -98,19 +96,17 @@ public class SignRequestTest {
@BeforeClass
protected void createFilter() {
Injector injector = new RestContextFactory()
.createContextBuilder(
"atmos",
UID,
KEY,
ImmutableSet.<Module> of(new MockModule(), new TestAtmosRestClientModule(),
new NullLoggingModule()), new Properties()).buildInjector();
Injector injector = ContextBuilder
.newBuilder("atmos")
.credentials(UID, KEY)
.modules(
ImmutableSet.<Module> of(new MockModule(), new TestAtmosRestClientModule(), new NullLoggingModule()))
.buildInjector();
filter = injector.getInstance(SignRequest.class);
}
@RequiresHttp
@ConfiguresRestClient
private static final class TestAtmosRestClientModule extends AtmosRestClientModule {

View File

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

View File

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

View File

@ -20,48 +20,71 @@ package org.jclouds.byon;
import java.net.URI;
import org.jclouds.JcloudsVersion;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.apis.internal.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
*
* <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
*/
public class BYONApiMetadata extends BaseApiMetadata {
public BYONApiMetadata() {
this(builder()
.id("byon")
.type(ApiType.COMPUTE)
.name("Bring Your Own Node (BYON) API")
.identityName("Unused")
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")));
/** The serialVersionUID */
private static final long serialVersionUID = -4059125995177393819L;
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected BYONApiMetadata(Builder<?> builder) {
public BYONApiMetadata() {
this(new Builder());
}
protected BYONApiMetadata(Builder 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
public BYONApiMetadata build() {
return new BYONApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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.net.URI;
import javax.inject.Singleton;
import org.jclouds.byon.Node;
import org.jclouds.byon.internal.BYONComputeServiceAdapter;
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
@ -36,27 +33,17 @@ import org.jclouds.location.Provider;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
/**
*
* @author Adrian Cole
*/
@SuppressWarnings("unchecked")
@SingleThreaded
public class BYONComputeServiceContextModule extends
JCloudsNativeComputeServiceAdapterContextModule<Supplier, Supplier> {
public class BYONComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule {
public BYONComputeServiceContextModule() {
super(Supplier.class, Supplier.class, BYONComputeServiceAdapter.class);
}
@Provides
@Singleton
Supplier provideApi(Supplier<LoadingCache<String, Node>> in) {
return in;
super(BYONComputeServiceAdapter.class);
}
@Override
@ -68,6 +55,7 @@ public class BYONComputeServiceContextModule extends
}).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class);
bind(new TypeLiteral<Function<URI, InputStream>>() {
}).to(SupplyFromProviderURIOrNodesProperty.class);
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>(){});
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
});
}
}

View File

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

View File

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

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.byon;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "BYONApiMetadataTest")
public class BYONApiMetadataTest extends BaseApiMetadataTest {
public class BYONApiMetadataTest extends BaseComputeServiceApiMetadataTest {
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.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Map.Entry;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -72,9 +72,9 @@ public class BYONComputeServiceLiveTest {
.append("\n");
contextProperties.setProperty("byon.nodes", nodes.toString());
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
new SshjSshClientModule(), new Log4JLoggingModule()), contextProperties);
context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties).modules(
ImmutableSet.<Module> of(new SshjSshClientModule(), new Log4JLoggingModule())).build(
ComputeServiceContext.class);
}
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.testng.Assert.assertEquals;
import java.net.URI;
import java.util.Properties;
import org.jclouds.ContextBuilder;
import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.CacheNodeStoreModule;
import org.jclouds.byon.functions.NodesFromYamlTest;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.Location;
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.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
*
@ -51,36 +51,31 @@ public class BYONComputeServiceTest {
@Test
public void testNodesParseNodeMap() throws Exception {
assertNodesParse(
"foo",
assertNodesParse("foo", ContextBuilder.newBuilder(
new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build())
.endpoint("foo").modules(
ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of(
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1))));
NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build(
ComputeServiceContext.class));
}
@Test
public void testNodesParseWithFileUrl() throws Exception {
assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ImmutableSet.<Module> of());
assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
"file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class));
}
@Test
public void testNodesParseWithClasspathUrl() throws Exception {
assertNodesParse("classpath:///test1.yaml", ImmutableSet.<Module> of());
assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(
"classpath:///test1.yaml").build(ComputeServiceContext.class));
}
private void assertNodesParse(String endpoint, Iterable<Module> modules) {
ComputeServiceContext context = null;
private void assertNodesParse(String endpoint, ComputeServiceContext context) {
try {
Location providerLocation = expectedProviderLocationFromResource(endpoint);
Properties props = new Properties();
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();
Supplier<LoadingCache<String, Node>> supplier = supplier(context);
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
assertEquals(supplier.get().asMap(),
@ -99,16 +94,9 @@ public class BYONComputeServiceTest {
ComputeServiceContext context = null;
try {
String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath();
Properties props = new Properties();
props.setProperty("byon.endpoint", endpoint);
context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(),
props);
context = ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(endpoint).build(ComputeServiceContext.class);
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
@SuppressWarnings("unchecked")
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
.getApi();
Supplier<LoadingCache<String, Node>> supplier = supplier(context);
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
assertEquals(supplier.get().asMap(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST2.getId(),
@ -145,4 +133,11 @@ public class BYONComputeServiceTest {
context.close();
}
}
private Supplier<LoadingCache<String, Node>> supplier(ComputeServiceContext context) {
Supplier<LoadingCache<String, Node>> supplier = context.utils().injector().getInstance(
Key.get(new TypeLiteral<Supplier<LoadingCache<String, Node>>>() {
}));
return supplier;
}
}

View File

@ -34,7 +34,6 @@
<packaging>bundle</packaging>
<properties>
<test.initializer>org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer</test.initializer>
<test.cloudfiles.endpoint>https://auth.api.rackspacecloud.com</test.cloudfiles.endpoint>
<test.cloudfiles.api-version>1.0</test.cloudfiles.api-version>
<test.cloudfiles.build-version />
@ -107,7 +106,6 @@
</goals>
<configuration>
<systemPropertyVariables>
<test.initializer>${test.initializer}</test.initializer>
<jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url>
<jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5>
<test.cloudfiles.endpoint>${test.cloudfiles.endpoint}</test.cloudfiles.endpoint>

View File

@ -18,51 +18,84 @@
*/
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.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
*
* @author 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() {
this(builder()
.id("cloudfiles")
.type(ApiType.BLOBSTORE)
.name("Rackspace Cloud Files API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")));
public static final TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
private static Builder builder() {
return new Builder();
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudFilesApiMetadata(Builder<?> builder) {
@Override
public Builder toBuilder() {
return builder().fromApiMetadata(this);
}
public CloudFilesApiMetadata() {
this(builder());
}
protected CloudFilesApiMetadata(Builder 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
public CloudFilesApiMetadata build() {
return new CloudFilesApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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.CloudFilesClient;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
@ -53,7 +52,6 @@ import com.google.inject.Provides;
* @author Adrian Cole
*/
@ConfiguresRestClient
@RequiresHttp
public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> {
public CloudFilesRestClientModule() {

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.cloudfiles;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest;
import org.testng.annotations.Test;
/**
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudFilesApiMetadataTest")
public class CloudFilesApiMetadataTest extends BaseApiMetadataTest {
public class CloudFilesApiMetadataTest extends BaseBlobStoreApiMetadataTest {
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")
public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest<CloudFilesClient> {
public CloudFilesClientLiveTest(){
provider = "cloudfiles";
}
@Override
public CloudFilesClient getApi() {
return (CloudFilesClient) context.getProviderSpecificContext().getApi();
return context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
}
@Override

View File

@ -28,6 +28,10 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
public CloudFilesBlobIntegrationLiveTest(){
provider = "cloudfiles";
}
@Override
protected void checkContentDisposition(Blob blob, String contentDisposition) {
assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob

View File

@ -27,5 +27,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest {
public CloudFilesBlobLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
public CloudFilesBlobMapIntegrationLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -27,5 +27,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
public CloudFilesBlobSignerLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
public CloudFilesContainerIntegrationLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class CloudFilesContainerLiveTest extends BaseContainerLiveTest {
public CloudFilesContainerLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
public CloudFilesInputStreamMapIntegrationLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
public CloudFilesServiceIntegrationLiveTest(){
provider = "cloudfiles";
}
}

View File

@ -19,50 +19,80 @@
package org.jclouds.cloudloadbalancers;
import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
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() {
this(builder()
.id("cloudloadbalancers")
.type(ApiType.LOADBALANCER)
.name("Rackspace Cloud Load Balancers API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")));
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudLoadBalancersApiMetadata(Builder<?> builder) {
public CloudLoadBalancersApiMetadata() {
this(new Builder());
}
protected CloudLoadBalancersApiMetadata(Builder 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
public CloudLoadBalancersApiMetadata build() {
return new CloudLoadBalancersApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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.reference.RackspaceConstants;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
@ -64,7 +63,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
*
* @author Adrian Cole
*/
@RequiresHttp
@ConfiguresRestClient
public class CloudLoadBalancersRestClientModule extends
RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {

View File

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

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.cloudloadbalancers;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest")
public class CloudLoadBalancersApiMetadataTest extends BaseApiMetadataTest {
public class CloudLoadBalancersApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest {
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 org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;

View File

@ -46,19 +46,19 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
private Set<LoadBalancer> lbs = Sets.newLinkedHashSet();
@Override
public void setupClient() {
super.setupClient();
public void setupContext() {
super.setupContext();
assertEquals(client.getConfiguredRegions(), Arrays.asList(regions));
Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
}
@Override
protected void tearDown() {
protected void tearDownContext() {
for (LoadBalancer lb : lbs) {
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
assert loadBalancerDeleted.apply(lb) : lb;
}
super.tearDown();
super.tearDownContext();
}
public void testCreateLoadBalancer() throws Exception {

View File

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

View File

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

View File

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

View File

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

View File

@ -31,16 +31,13 @@ import java.util.Properties;
import javax.inject.Singleton;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
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.features.LoadBalancerAsyncClient;
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
import org.jclouds.cloudloadbalancers.reference.Region;
import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.internal.ClassMethodArgs;
import org.jclouds.location.config.LocationModule;
import org.jclouds.openstack.filters.AuthenticateRequest;
@ -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.parse.ParseAuthTest;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.testng.annotations.BeforeClass;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Provides;
@ -62,7 +56,7 @@ import com.google.inject.Provides;
/**
* @author Adrian Cole
*/
public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClientTest<T> {
public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsyncClientTest<T> {
protected String provider;
@ -76,7 +70,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
}
@ConfiguresRestClient
@RequiresHttp
protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule {
@Override
protected void installLocations() {
@ -131,15 +124,9 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
return overrides;
}
/**
* this is only here as "cloudloadbalancers" is not in rest.properties
*/
@SuppressWarnings( { "unchecked", "rawtypes" })
@Override
public RestContextSpec<?, ?> createContextSpec() {
return RestContextFactory.<LoadBalancerClient, LoadBalancerAsyncClient> contextSpec(provider, "https://auth",
"1.0", "", "", "identity", "credential", LoadBalancerClient.class, LoadBalancerAsyncClient.class,
(Class) CloudLoadBalancersPropertiesBuilder.class, (Class) CloudLoadBalancersContextBuilder.class,
ImmutableSet.<Module> of());
protected ApiMetadata createApiMetadata() {
return new CloudLoadBalancersApiMetadata();
}
}

View File

@ -18,40 +18,38 @@
*/
package org.jclouds.cloudloadbalancers.internal;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
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.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.BaseRestClientLiveTest;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
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.Injector;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest {
public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest<LoadBalancerServiceContext> {
public BaseCloudLoadBalancersClientLiveTest() {
provider = "cloudloadbalancers";
}
protected CloudLoadBalancersClient client;
protected RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> context;
protected RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> lbContext;
protected String[] regions = {};
protected Predicate<IPSocket> socketTester;
protected RetryablePredicate<LoadBalancer> loadBalancerActive;
@ -59,15 +57,13 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
protected Injector injector;
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
lbContext = context.unwrap();
@BeforeGroups(groups = "live")
public void setupClient() {
setupCredentials();
Properties overrides = setupProperties();
context = new LoadBalancerServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
overrides).getProviderSpecificContext();
client = context.getApi();
client = lbContext.getApi();
injector = Guice.createInjector(new Log4JLoggingModule());
loadBalancerActive = new RetryablePredicate<LoadBalancer>(new LoadBalancerActive(client), 300, 1, 1,
@ -78,10 +74,9 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
injector.injectMembers(loadBalancerDeleted);
}
@AfterGroups(groups = "live")
protected void tearDown() {
if (context != null)
context.close();
@Override
protected TypeToken<LoadBalancerServiceContext> contextType() {
return TypeToken.of(LoadBalancerServiceContext.class);
}
}

View File

@ -19,50 +19,79 @@
package org.jclouds.cloudservers;
import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
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
*/
public class CloudServersApiMetadata extends BaseApiMetadata {
public class CloudServersApiMetadata extends BaseRestApiMetadata {
public CloudServersApiMetadata() {
this(builder()
.id("cloudservers")
.type(ApiType.COMPUTE)
.name("Rackspace Cloud Servers API")
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")));
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudServersApiMetadata(Builder<?> builder) {
public CloudServersApiMetadata() {
this(new Builder());
}
protected CloudServersApiMetadata(Builder 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
public CloudServersApiMetadata build() {
return new CloudServersApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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 org.jclouds.cloudservers.CloudServersAsyncClient;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage;
import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem;
import org.jclouds.cloudservers.compute.functions.FlavorToHardware;
@ -55,12 +53,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
public class CloudServersComputeServiceContextModule
extends
ComputeServiceAdapterContextModule<CloudServersClient, CloudServersAsyncClient, Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
public CloudServersComputeServiceContextModule() {
super(CloudServersClient.class, CloudServersAsyncClient.class);
}
public class CloudServersComputeServiceContextModule extends
ComputeServiceAdapterContextModule<Server, Flavor, org.jclouds.cloudservers.domain.Image, Location> {
@SuppressWarnings("unchecked")
@Override

View File

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

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.cloudservers;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudServersApiMetadataTest")
public class CloudServersApiMetadataTest extends BaseApiMetadataTest {
public class CloudServersApiMetadataTest extends BaseComputeServiceApiMetadataTest {
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.ws.rs.core.MediaType;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.cloudservers.domain.BackupSchedule;
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.domain.Credentials;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnFalseOn404;
import org.jclouds.http.functions.ReturnTrueIf2xx;
@ -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.parse.ParseAuthTest;
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.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
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
// surefire
@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 CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
.getClass();
@ -891,7 +889,6 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
}
@ConfiguresRestClient
@RequiresHttp
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
@Provides
@ -910,8 +907,8 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
protected String provider = "cloudservers";
@Override
public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties());
protected ApiMetadata createApiMetadata() {
return new CloudServersApiMetadata();
}
@Override

View File

@ -29,7 +29,6 @@ import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.SecureRandom;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
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.WeeklyBackup;
import org.jclouds.cloudservers.options.RebuildServerOptions;
import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.util.Strings2;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups;
@ -66,10 +62,8 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Tests behavior of {@code CloudServersClient}
@ -77,7 +71,8 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest {
public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest {
public CloudServersClientLiveTest() {
provider = "cloudservers";
}
@ -86,15 +81,11 @@ public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest {
protected SshClient.Factory sshFactory;
protected Predicate<IPSocket> socketTester;
@BeforeGroups(groups = { "live" })
public void setupClient() {
setupCredentials();
Properties overrides = setupProperties();
Injector injector = new RestContextFactory().createContextBuilder(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides)
.buildInjector();
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
Injector injector = context.utils().injector();
client = injector.getInstance(CloudServersClient.class);
sshFactory = injector.getInstance(SshClient.Factory.class);
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);

View File

@ -22,13 +22,9 @@ import static org.testng.Assert.assertEquals;
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.internal.BaseComputeServiceLiveTest;
import org.jclouds.domain.LocationScope;
import org.jclouds.rest.RestContext;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test;
@ -42,6 +38,7 @@ import com.google.inject.Module;
*/
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public CloudServersComputeServiceLiveTest() {
provider = "cloudservers";
}
@ -51,12 +48,6 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
return new SshjSshClientModule();
}
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<CloudServersClient, CloudServersAsyncClient> tmContext = new ComputeServiceContextFactory()
.createContext(provider, identity, credential).getProviderSpecificContext();
}
@Override
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String task) throws IOException {
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.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudservers.CloudServersApiMetadata;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.CloudServersContextBuilder;
import org.jclouds.cloudservers.CloudServersPropertiesBuilder;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.RequiresHttp;
import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule;
import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest;
@ -49,12 +48,16 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
}
@Override
protected Properties setupRestProperties() {
protected ApiMetadata createApiMetadata() {
return new CloudServersApiMetadata();
}
@Override
protected Properties setupProperties() {
Properties overrides = new Properties();
overrides.setProperty(PROPERTY_REGIONS, "US");
overrides.setProperty(provider + ".endpoint", endpoint);
overrides.setProperty(provider + ".contextbuilder", CloudServersContextBuilder.class.getName());
overrides.setProperty(provider + ".propertiesbuilder", CloudServersPropertiesBuilder.class.getName());
return overrides;
}
@ -77,7 +80,6 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
}
@ConfiguresRestClient
@RequiresHttp
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
@Override

View File

@ -18,51 +18,85 @@
*/
package org.jclouds.cloudsigma;
import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
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
*
* @author Adrian Cole
*/
public class CloudSigmaApiMetadata extends BaseApiMetadata {
public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public CloudSigmaApiMetadata() {
this(builder()
.id("cloudsigma")
.type(ApiType.COMPUTE)
.name("CloudSigma API")
.identityName("Email")
.credentialName("Password")
.documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api")));
public static final TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudSigmaApiMetadata(Builder<?> builder) {
public CloudSigmaApiMetadata() {
this(new Builder());
}
protected CloudSigmaApiMetadata(Builder 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
public CloudSigmaApiMetadata build() {
return new CloudSigmaApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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
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 (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) {
final float size = (float) cpu / 100;

View File

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

View File

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

View File

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

View File

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

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 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);
addSCSIDevices(from, builder);
addBlockDevices(from, builder);

View File

@ -18,8 +18,7 @@
*/
package org.jclouds.cloudsigma;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadataTest;
import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest")
public class CloudSigmaApiMetadataTest extends BaseApiMetadataTest {
public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest {
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.lang.reflect.Method;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
import org.jclouds.cloudsigma.domain.CreateDriveRequest;
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.filters.BasicAuthentication;
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.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
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
@Test(groups = "unit", testName = "CloudSigmaAsyncClientTest")
public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncClient> {
public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsyncClient> {
public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
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");
// for example, using basic authentication, we should get "only one"
// header
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
assertPayloadEquals(httpRequest, null, null, false);
// 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");
// for example, using basic authentication, we should get "only one"
// header
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
assertPayloadEquals(httpRequest, null, null, false);
// 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");
// for example, using basic authentication, we should get "only one"
// header
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
assertPayloadEquals(httpRequest, null, null, false);
// 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");
// for example, using basic authentication, we should get "only one"
// header
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic Zm9vOmJhcg==\n");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
assertPayloadEquals(httpRequest, null, null, false);
// TODO: insert expected response class, which probably extends ParseJson
@ -650,9 +648,8 @@ public class CloudSigmaAsyncClientTest extends RestClientTest<CloudSigmaAsyncCli
}
@Override
public RestContextSpec<CloudSigmaClient, CloudSigmaAsyncClient> createContextSpec() {
Properties props = new Properties();
props.setProperty("cloudsigma.endpoint", "https://api.cloudsigma.com");
return new RestContextFactory().createContextSpec("cloudsigma", "foo", "bar", props);
protected ApiMetadata createApiMetadata() {
return new CloudSigmaApiMetadata();
}
}

View File

@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
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.predicates.DriveClaimed;
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.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate;
@ -67,7 +63,6 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.inject.Guice;
import com.google.inject.Module;
/**
* Tests behavior of {@code CloudSigmaClient}
@ -75,7 +70,8 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest")
public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest {
public CloudSigmaClientLiveTest() {
provider = "cloudsigma";
}
@ -84,28 +80,25 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
protected int maxDriveImageTime = 300;
protected String vncPassword = "Il0veVNC";
protected CloudSigmaClient client;
protected RestContext<CloudSigmaClient, CloudSigmaAsyncClient> context;
protected RestContext<CloudSigmaClient, CloudSigmaAsyncClient> cloudSigmaContext;
protected Predicate<IPSocket> socketTester;
protected Predicate<DriveInfo> driveNotClaimed;
protected ComputeServiceContext computeContext;
@BeforeGroups(groups = "live")
public void setupClient() {
setupCredentials();
Properties overrides = setupProperties();
computeContext = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides);
context = computeContext.getProviderSpecificContext();
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
cloudSigmaContext = context.unwrap();
client = context.getApi();
client = cloudSigmaContext.getApi();
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
1, TimeUnit.SECONDS);
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), maxDriveImageTime, 1,
TimeUnit.SECONDS);
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";
vlan = client.renameVLAN(vlan.getUuid(), prefix2);
assertEquals(vlan.getName(),prefix2);
assertEquals(vlan.getName(), prefix2);
} finally {
client.destroyVLAN(id);
}
@ -354,7 +347,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
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
assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
server.getUuid()).getStatus() == ServerStatus.STOPPED);
@ -415,8 +409,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
client.destroyServer(server.getUuid());
if (server != null)
client.destroyDrive(drive.getUuid());
if (context != null)
context.close();
if (cloudSigmaContext != null)
cloudSigmaContext.close();
}
@Test
@ -444,10 +438,7 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
protected void prepareDrive() {
client.destroyDrive(drive.getUuid());
drive = client.cloneDrive(imageId, drive.getName(),
new CloneDriveOptions()
.size(driveSize)
.tags("cat:mouse", "monkey:banana")
);
new CloneDriveOptions().size(driveSize).tags("cat:mouse", "monkey:banana"));
// Block until the async clone operation has completed.
assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());

View File

@ -18,9 +18,9 @@
*/
package org.jclouds.cloudsigma.compute;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test;
@ -32,6 +32,7 @@ import com.google.inject.Module;
*/
@Test(groups = "live")
public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public CloudSigmaComputeServiceLiveTest() {
provider = "cloudsigma";
}

View File

@ -19,50 +19,92 @@
package org.jclouds.cloudstack;
import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
import org.jclouds.apis.BaseApiMetadata;
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
* Implementation of {@link ApiMetadata} for Citrix 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
*/
public class CloudStackApiMetadata extends BaseApiMetadata {
public class CloudStackApiMetadata extends BaseRestApiMetadata {
public CloudStackApiMetadata() {
this(builder()
.id("cloudstack")
.type(ApiType.COMPUTE)
.name("Citrix CloudStack API")
.identityName("API Key")
.credentialName("Secret Key")
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")));
/** The serialVersionUID */
private static final long serialVersionUID = -3936131452958663245L;
public static final TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}
// below are so that we can reuse builders, toString, hashCode, etc.
// we have to set concrete classes here, as our base class cannot be
// concrete due to serviceLoader
protected CloudStackApiMetadata(Builder<?> builder) {
public CloudStackApiMetadata() {
this(new Builder());
}
protected CloudStackApiMetadata(Builder 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
public CloudStackApiMetadata build() {
return new CloudStackApiMetadata(this);
}
}
public static ConcreteBuilder builder() {
return new ConcreteBuilder();
}
@Override
public ConcreteBuilder toBuilder() {
return builder().fromApiMetadata(this);
public Builder fromApiMetadata(ApiMetadata in) {
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 com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
/**
*

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,6 @@
*/
package org.jclouds.cloudstack.config;
import org.jclouds.compute.ComputeServiceContextFactory;
/**
* Configuration properties and constants used in CloudStack connections.
@ -28,7 +27,7 @@ import org.jclouds.compute.ComputeServiceContextFactory;
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#PASSWORD_CREDENTIALS}, login will happen and a session will be
* persisted.

View File

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

View File

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

View File

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

View File

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

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