savvis related changes for Issue 826

This commit is contained in:
Adrian Cole 2012-02-02 07:39:01 -08:00
parent 44329eceaf
commit 6dfe726dfa
3 changed files with 14 additions and 7 deletions

View File

@ -33,13 +33,11 @@ import org.jclouds.savvis.vpdc.compute.functions.NetworkToLocation;
import org.jclouds.savvis.vpdc.compute.functions.VMSpecToHardware;
import org.jclouds.savvis.vpdc.compute.functions.VMToNodeMetadata;
import org.jclouds.savvis.vpdc.compute.strategy.VPDCComputeServiceAdapter;
import org.jclouds.savvis.vpdc.compute.suppliers.FirstNetwork;
import org.jclouds.savvis.vpdc.domain.Network;
import org.jclouds.savvis.vpdc.domain.VM;
import org.jclouds.savvis.vpdc.domain.VMSpec;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
@ -72,7 +70,7 @@ public class VPDCComputeServiceContextModule extends
}).to(VMSpecToHardware.class);
bind(new TypeLiteral<Function<Network, Location>>() {
}).to(NetworkToLocation.class);
bind(new TypeLiteral<Supplier<Location>>() {
}).to(FirstNetwork.class);
// to have the compute service adapter override default locations
install(new LocationsFromComputeServiceAdapterModule<VM, VMSpec, CIMOperatingSystem, Network>(){});
}
}

View File

@ -41,6 +41,7 @@ import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.json.Json;
import org.jclouds.location.Provider;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.AsyncClientFactory;
import org.jclouds.rest.AuthorizationException;
@ -61,6 +62,7 @@ import org.jclouds.savvis.vpdc.features.VMClient;
import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler;
import org.jclouds.savvis.vpdc.internal.LoginAsyncClient;
import org.jclouds.savvis.vpdc.internal.VCloudToken;
import org.jclouds.savvis.vpdc.location.FirstNetwork;
import org.jclouds.savvis.vpdc.predicates.TaskSuccess;
import org.jclouds.util.Strings2;
@ -70,6 +72,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/**
@ -164,4 +167,9 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(VPDCErrorHandler.class);
}
@Override
protected void installLocations() {
super.installLocations();
bind(ImplicitLocationSupplier.class).to(FirstNetwork.class).in(Scopes.SINGLETON);
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.savvis.vpdc.compute.suppliers;
package org.jclouds.savvis.vpdc.location;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.find;
@ -29,6 +29,7 @@ import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@ -39,7 +40,7 @@ import com.google.common.base.Supplier;
*
*/
@Singleton
public class FirstNetwork implements Supplier<Location> {
public class FirstNetwork implements ImplicitLocationSupplier {
@Singleton
public static final class IsNetwork implements Predicate<Location> {
@Override