Issue 878: cloudstack locations are zones, not regions

This commit is contained in:
Adrian Cole 2012-03-20 11:35:49 -07:00
parent 14da16232e
commit 489777e872
1 changed files with 27 additions and 17 deletions

View File

@ -18,17 +18,13 @@
*/ */
package org.jclouds.cloudstack.config; package org.jclouds.cloudstack.config;
import com.google.common.base.Function; import static com.google.common.base.Throwables.propagate;
import com.google.common.base.Supplier; import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import java.util.Map;
import com.google.common.cache.LoadingCache; import java.util.concurrent.ExecutionException;
import com.google.common.collect.ImmutableMap; import java.util.concurrent.TimeUnit;
import com.google.inject.Inject;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.cloudstack.CloudStackAsyncClient; import org.jclouds.cloudstack.CloudStackAsyncClient;
import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackClient;
@ -133,18 +129,26 @@ import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.location.Provider; import org.jclouds.location.Provider;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.config.BinderUtils; import org.jclouds.rest.config.BinderUtils;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
import java.util.Map; import com.google.common.base.Function;
import java.util.concurrent.ExecutionException; import com.google.common.base.Supplier;
import java.util.concurrent.TimeUnit; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import static com.google.common.base.Throwables.propagate; import com.google.common.cache.LoadingCache;
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
/** /**
* Configures the cloudstack connection. * Configures the cloudstack connection.
@ -241,6 +245,12 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
super.configure(); super.configure();
} }
@Override
protected void installLocations() {
super.installLocations();
bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
}
@Override @Override
protected void bindErrorHandlers() { protected void bindErrorHandlers() {
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CloudStackErrorHandler.class); bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CloudStackErrorHandler.class);