dealt with a myriad of config issues causing chef build to fail

This commit is contained in:
adriancole 2013-04-10 12:18:35 -07:00
parent 14479e1404
commit 9cd432ed86
4 changed files with 30 additions and 34 deletions

View File

@ -29,6 +29,7 @@ import static org.jclouds.crypto.Pems.privateKeySpec;
import java.io.IOException;
import java.security.PrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -36,6 +37,10 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.chef.domain.Client;
import org.jclouds.chef.functions.BootstrapConfigForGroup;
import org.jclouds.chef.functions.ClientForGroup;
import org.jclouds.chef.functions.RunListForGroup;
import org.jclouds.chef.handlers.ChefApiErrorRetryHandler;
import org.jclouds.chef.handlers.ChefErrorHandler;
import org.jclouds.crypto.Crypto;
@ -43,6 +48,7 @@ import org.jclouds.crypto.Pems;
import org.jclouds.date.DateService;
import org.jclouds.date.TimeStamp;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.JsonBall;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.annotation.ClientError;
@ -184,6 +190,24 @@ public class BaseChefRestClientModule<S, A> extends RestClientModule<S, A> {
}
}
@Provides
@Singleton
CacheLoader<String, List<String>> runListForGroup(RunListForGroup runListForGroup) {
return CacheLoader.from(runListForGroup);
}
@Provides
@Singleton
CacheLoader<String, ? extends JsonBall> bootstrapConfigForGroup(BootstrapConfigForGroup bootstrapConfigForGroup) {
return CacheLoader.from(bootstrapConfigForGroup);
}
@Provides
@Singleton
CacheLoader<String, Client> groupToClient(ClientForGroup clientForGroup) {
return CacheLoader.from(clientForGroup);
}
@Override
protected void bindErrorHandlers() {
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ChefErrorHandler.class);

View File

@ -20,22 +20,10 @@ package org.jclouds.chef.config;
import static org.jclouds.reflect.Reflection2.typeToken;
import java.util.List;
import javax.inject.Singleton;
import org.jclouds.chef.ChefApi;
import org.jclouds.chef.ChefAsyncApi;
import org.jclouds.chef.domain.Client;
import org.jclouds.chef.functions.BootstrapConfigForGroup;
import org.jclouds.chef.functions.ClientForGroup;
import org.jclouds.chef.functions.RunListForGroup;
import org.jclouds.domain.JsonBall;
import org.jclouds.rest.ConfiguresRestClient;
import com.google.common.cache.CacheLoader;
import com.google.inject.Provides;
/**
* Configures the Chef connection.
*
@ -48,22 +36,4 @@ public class ChefRestClientModule extends BaseChefRestClientModule<ChefApi, Chef
super(typeToken(ChefApi.class), typeToken(ChefAsyncApi.class));
}
@Provides
@Singleton
CacheLoader<String, List<String>> runListForGroup(RunListForGroup runListForGroup) {
return CacheLoader.from(runListForGroup);
}
@Provides
@Singleton
CacheLoader<String, ? extends JsonBall> bootstrapConfigForGroup(BootstrapConfigForGroup bootstrapConfigForGroup) {
return CacheLoader.from(bootstrapConfigForGroup);
}
@Provides
@Singleton
CacheLoader<String, Client> groupToClient(ClientForGroup clientForGroup) {
return CacheLoader.from(clientForGroup);
}
}

View File

@ -19,7 +19,7 @@
package org.jclouds.chef.test.config;
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
import static org.jclouds.rest.config.BinderUtils.bindBlockingApi;
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncApi;
import java.io.IOException;
import java.security.PrivateKey;
@ -44,6 +44,7 @@ import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.crypto.Crypto;
import org.jclouds.domain.JsonBall;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.SyncToAsyncHttpInvocationModule;
import org.jclouds.rest.config.RestModule;
import com.google.common.base.Optional;
@ -66,10 +67,11 @@ public class TransientChefApiModule extends AbstractModule {
@Override
protected void configure() {
install(new RestModule());
install(new SyncToAsyncHttpInvocationModule());
bind(ChefAsyncApi.class).to(TransientChefAsyncApi.class).asEagerSingleton();
// forward all requests from TransientChefApi to ChefAsyncApi. needs above
// binding as cannot proxy a class
bindBlockingApi(binder(), TransientChefApi.class, ChefAsyncApi.class);
bindSyncToAsyncApi(binder(), TransientChefApi.class, ChefAsyncApi.class);
bind(ChefApi.class).to(TransientChefApi.class);
bind(LocalAsyncBlobStore.class).annotatedWith(Names.named("databags"))

View File

@ -31,12 +31,12 @@ import com.google.common.collect.ImmutableMap;
*
* @author Ignasi Barrera
*/
public abstract class BaseChefApiExectTest<S> extends BaseRestApiExpectTest<S> {
public abstract class BaseChefApiExpectTest<S> extends BaseRestApiExpectTest<S> {
public static final String PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAyb2ZJJqGm0KKR+8nfQJNsSd+F9tXNMV7CfOcW6jsqs8EZgiV\nR09hD1IYOj4YqM0qJONlgyg4xRWewdSG7QTPj1lJpVAida9sXy2+kzyagZA1Am0O\nZcbqb5hoeIDgcX+eDa79s0u0DomjcfO9EKhvHLBz+zM+3QqPRkPV8nYTbfs+HjVz\nzOU6D1B0XR3+IPZZl2AnWs2d0qhnStHcDUvnRVQ0P482YwN9VgceOZtpPz0DCKEJ\n5Tx5STub8k0/zt/VAMHQafLSuQMLd2s4ZLuOZptN//uAsTmxireqd37z+8ZTdBbJ\n8LEpJ+iCXuSfm5aUh7iw6oxvToY2AL53+jK2UQIDAQABAoIBAQDA88B3i/xWn0vX\nBVxFamCYoecuNjGwXXkSyZew616A+EOCu47bh4aTurdFbYL0YFaAtaWvzlaN2eHg\nDb+HDuTefE29+WkcGk6SshPmiz5T0XOCAICWw6wSVDkHmGwS4jZvbAFm7W8nwGk9\nYhxgxFiRngswJZFopOLoF5WXs2td8guIYNslMpo7tu50iFnBHwKO2ZsPAk8t9nnS\nxlDavKruymEmqHCr3+dtio5eaenJcp3fjoXBQOKUk3ipII29XRB8NqeCVV/7Kxwq\nckqOBEbRwBclckyIbD+RiAgKvOelORjEiE9R42vuqvxRA6k9kd9o7utlX0AUtpEn\n3gZc6LepAoGBAP9ael5Y75+sK2JJUNOOhO8ae45cdsilp2yI0X+UBaSuQs2+dyPp\nkpEHAxd4pmmSvn/8c9TlEZhr+qYbABXVPlDncxpIuw2Ajbk7s/S4XaSKsRqpXL57\nzj/QOqLkRk8+OVV9q6lMeQNqLtEj1u6JPviX70Ro+FQtRttNOYbfdP/fAoGBAMpA\nXjR5woV5sUb+REg9vEuYo8RSyOarxqKFCIXVUNsLOx+22+AK4+CQpbueWN7jotrl\nYD6uT6svWi3AAC7kiY0UI/fjVPRCUi8tVoQUE0TaU5VLITaYOB+W/bBaDE4M9560\n1NuDWO90baA5dfU44iuzva02rGJXK9+nS3o8nk/PAoGBALOL6djnDe4mwAaG6Jco\ncd4xr8jkyPzCRZuyBCSBbwphIUXLc7hDprPky064ncJD1UDmwIdkXd/fpMkg2QmA\n/CUk6LEFjMisqHojOaCL9gQZJPhLN5QUN2x1PJWGjs1vQh8Tkx0iUUCOa8bQPXNR\n+34OTsW6TUna4CSZAycLfhffAoGBAIggVsefBCvuQkF0NeUhmDCRZfhnd8y55RHR\n1HCvqKIlpv+rhcX/zmyBLuteopYyRJRsOiE2FW00i8+rIPRu4Z3Q5nybx7w3PzV9\noHN5R5baE9OyI4KpZWztpYYitZF67NcnAvVULHHOvVJQGnKYfLHJYmrJF7GA1ojM\nAuMdFbjFAoGAPxUhxwFy8gaqBahKUEZn4F81HFP5ihGhkT4QL6AFPO2e+JhIGjuR\n27+85hcFqQ+HHVtFsm81b/a+R7P4UuCRgc8eCjxQMoJ1Xl4n7VbjPbHMnIN0Ryvd\nO4ZpWDWYnCO021JTOUUOJ4J/y0416Bvkw0z59y7sNX7wDBBHHbK/XCc=\n-----END RSA PRIVATE KEY-----\n";
protected SignedHeaderAuth signedHeaderAuth;
public BaseChefApiExectTest() {
public BaseChefApiExpectTest() {
credential = PRIVATE_KEY;
signedHeaderAuth = createInjector(Functions.forMap(ImmutableMap.<HttpRequest, HttpResponse> of()),
createModule(), setupProperties()).getInstance(SignedHeaderAuth.class);