mirror of https://github.com/apache/jclouds.git
softlayer related changes for Issue 826
This commit is contained in:
parent
d225df57e4
commit
32f0de7997
|
@ -25,6 +25,8 @@ import static org.jclouds.softlayer.predicates.ProductPackagePredicates.named;
|
|||
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME;
|
||||
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -36,7 +38,7 @@ import org.jclouds.compute.domain.OsFamily;
|
|||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
||||
import org.jclouds.softlayer.SoftLayerClient;
|
||||
|
@ -87,9 +89,9 @@ public class SoftLayerComputeServiceContextModule
|
|||
}).to(ProductItemsToHardware.class);
|
||||
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
||||
}).to(DatacenterToLocation.class);
|
||||
bind(new TypeLiteral<Supplier<Location>>() {
|
||||
}).to(OnlyLocationOrFirstZone.class);
|
||||
bind(TemplateOptions.class).to(SoftLayerTemplateOptions.class);
|
||||
// to have the compute service adapter override default locations
|
||||
install(new LocationsFromComputeServiceAdapterModule<VirtualGuest, Iterable<ProductItem>, ProductItem, Datacenter>(){});
|
||||
}
|
||||
|
||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||
|
@ -104,8 +106,8 @@ public class SoftLayerComputeServiceContextModule
|
|||
@Provides
|
||||
@Singleton
|
||||
@Memoized
|
||||
public Supplier<ProductPackage> getProductPackage(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final SoftLayerClient client,
|
||||
public Supplier<ProductPackage> getProductPackage(AtomicReference<AuthorizationException> authException,
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final SoftLayerClient client,
|
||||
@Named(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME) final String virtualGuestPackageName) {
|
||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<ProductPackage>(authException, seconds,
|
||||
new Supplier<ProductPackage>() {
|
||||
|
|
|
@ -26,7 +26,7 @@ import static com.google.common.base.Strings.nullToEmpty;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationBuilder;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.location.suppliers.JustProvider;
|
||||
import org.jclouds.location.suppliers.all.JustProvider;
|
||||
import org.jclouds.softlayer.domain.Address;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@ import org.jclouds.http.annotation.ClientError;
|
|||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||
import org.jclouds.location.config.LocationModule;
|
||||
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
||||
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
||||
|
@ -42,6 +45,7 @@ import org.jclouds.softlayer.features.VirtualGuestClient;
|
|||
import org.jclouds.softlayer.handlers.SoftLayerErrorHandler;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Scopes;
|
||||
|
||||
/**
|
||||
* Configures the SoftLayer connection.
|
||||
|
@ -81,4 +85,10 @@ public class SoftLayerRestClientModule extends RestClientModule<SoftLayerClient,
|
|||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(BackoffLimitedRetryHandler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installLocations() {
|
||||
install(new LocationModule());
|
||||
bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.net.URI;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.location.suppliers.JustProvider;
|
||||
import org.jclouds.location.suppliers.all.JustProvider;
|
||||
import org.jclouds.softlayer.domain.Address;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLA
|
|||
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -32,6 +33,7 @@ import org.jclouds.collect.Memoized;
|
|||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
||||
import org.jclouds.softlayer.SoftLayerClient;
|
||||
|
@ -83,9 +85,11 @@ public class BaseSoftLayerClientLiveTest {
|
|||
@Provides
|
||||
@Singleton
|
||||
@Memoized
|
||||
public Supplier<ProductPackage> getProductPackage(SoftLayerClient client,
|
||||
public Supplier<ProductPackage> getProductPackage(AtomicReference<AuthorizationException> authException,
|
||||
SoftLayerClient client,
|
||||
@Named(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME) String virtualGuestPackageName) {
|
||||
return new SoftLayerComputeServiceContextModule().getProductPackage(30, client, virtualGuestPackageName);
|
||||
return new SoftLayerComputeServiceContextModule().getProductPackage(authException, 30, client,
|
||||
virtualGuestPackageName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
Loading…
Reference in New Issue