mirror of https://github.com/apache/jclouds.git
vcloud related changes for Issue 826
This commit is contained in:
parent
65336339e5
commit
dc78a443de
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* 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.vcloud;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface VCloudVersionsClient {
|
||||||
|
|
||||||
|
SortedMap<String, URI> getSupportedVersions();
|
||||||
|
}
|
|
@ -1,51 +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.vcloud.compute.config;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.domain.LocationScope;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.endpoints.VDC;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public final class IsDefaultVDC implements Predicate<Location> {
|
|
||||||
private final ReferenceType defaultVDC;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
|
|
||||||
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Location input) {
|
|
||||||
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "isDefaultVDC()";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -48,7 +48,7 @@ public class VCloudComputeServiceContextModule
|
||||||
super.configure();
|
super.configure();
|
||||||
install(new VCloudComputeServiceDependenciesModule());
|
install(new VCloudComputeServiceDependenciesModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
// CIM ostype does not include version info
|
// CIM ostype does not include version info
|
||||||
@Override
|
@Override
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||||
|
|
|
@ -18,16 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.config;
|
package org.jclouds.vcloud.compute.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.collect.Iterables.find;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.collect.Memoized;
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -56,11 +51,9 @@ import org.jclouds.vcloud.functions.VAppTemplatesInOrg;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,8 +80,6 @@ public class VCloudComputeServiceDependenciesModule extends AbstractModule {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(new TypeLiteral<Supplier<Location>>() {
|
|
||||||
}).to(DefaultVDC.class).in(Scopes.SINGLETON);
|
|
||||||
bind(new TypeLiteral<ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location>>() {
|
bind(new TypeLiteral<ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location>>() {
|
||||||
}).to(VCloudComputeServiceAdapter.class);
|
}).to(VCloudComputeServiceAdapter.class);
|
||||||
|
|
||||||
|
@ -121,23 +112,4 @@ public class VCloudComputeServiceDependenciesModule extends AbstractModule {
|
||||||
return new NetworkConfig(network.getName(), network.getHref(), defaultFenceMode);
|
return new NetworkConfig(network.getName(), network.getHref(), defaultFenceMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public static class DefaultVDC implements Supplier<Location> {
|
|
||||||
private final Supplier<Set<? extends Location>> locationsSupplier;
|
|
||||||
private final IsDefaultVDC isDefaultVDC;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
|
|
||||||
this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
|
|
||||||
this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location get() {
|
|
||||||
return find(locationsSupplier.get(), isDefaultVDC);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.jclouds.vcloud.TaskInErrorStateException;
|
||||||
import org.jclouds.vcloud.TaskStillRunningException;
|
import org.jclouds.vcloud.TaskStillRunningException;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
|
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
|
@ -75,20 +74,18 @@ public class VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp,
|
||||||
protected final Supplier<Map<String, Org>> nameToOrg;
|
protected final Supplier<Map<String, Org>> nameToOrg;
|
||||||
protected final Supplier<Set<VAppTemplate>> templates;
|
protected final Supplier<Set<VAppTemplate>> templates;
|
||||||
protected final Function<VAppTemplate, Envelope> templateToEnvelope;
|
protected final Function<VAppTemplate, Envelope> templateToEnvelope;
|
||||||
protected final Supplier<Set<? extends Location>> locations;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudComputeServiceAdapter(VCloudClient client, Predicate<URI> successTester,
|
protected VCloudComputeServiceAdapter(VCloudClient client, Predicate<URI> successTester,
|
||||||
InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter,
|
InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter,
|
||||||
Supplier<Map<String, Org>> nameToOrg, VAppTemplatesSupplier templates,
|
Supplier<Map<String, Org>> nameToOrg, VAppTemplatesSupplier templates,
|
||||||
Function<VAppTemplate, Envelope> templateToEnvelope, OrgAndVDCToLocationSupplier locations) {
|
Function<VAppTemplate, Envelope> templateToEnvelope) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.successTester = checkNotNull(successTester, "successTester");
|
this.successTester = checkNotNull(successTester, "successTester");
|
||||||
this.booter = checkNotNull(booter, "booter");
|
this.booter = checkNotNull(booter, "booter");
|
||||||
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
||||||
this.templates = checkNotNull(templates, "templates");
|
this.templates = checkNotNull(templates, "templates");
|
||||||
this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope");
|
this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope");
|
||||||
this.locations = checkNotNull(locations, "locations");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -154,10 +151,10 @@ public class VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Location> listLocations() {
|
public Iterable<Location> listLocations() {
|
||||||
return (Iterable<Location>) locations.get();
|
// Not using the adapter to determine locations
|
||||||
|
return ImmutableSet.<Location>of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.base.Predicates.notNull;
|
import static com.google.common.base.Predicates.notNull;
|
||||||
import static com.google.common.base.Suppliers.compose;
|
import static com.google.common.base.Suppliers.compose;
|
||||||
import static com.google.common.base.Throwables.propagate;
|
|
||||||
import static com.google.common.collect.Iterables.concat;
|
import static com.google.common.collect.Iterables.concat;
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static com.google.common.collect.Iterables.getLast;
|
import static com.google.common.collect.Iterables.getLast;
|
||||||
|
@ -31,6 +30,7 @@ import static com.google.common.collect.Maps.transformValues;
|
||||||
import static com.google.common.collect.Maps.uniqueIndex;
|
import static com.google.common.collect.Maps.uniqueIndex;
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
|
|
||||||
|
@ -38,9 +38,6 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -54,9 +51,10 @@ import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
import org.jclouds.http.annotation.ClientError;
|
||||||
import org.jclouds.http.annotation.Redirection;
|
import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
|
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
||||||
|
import org.jclouds.location.suppliers.LocationsSupplier;
|
||||||
import org.jclouds.ovf.Envelope;
|
import org.jclouds.ovf.Envelope;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.AsyncClientFactory;
|
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.config.RestClientModule;
|
import org.jclouds.rest.config.RestClientModule;
|
||||||
|
@ -65,6 +63,7 @@ import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudToken;
|
import org.jclouds.vcloud.VCloudToken;
|
||||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
||||||
|
import org.jclouds.vcloud.VCloudVersionsClient;
|
||||||
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
|
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
|
||||||
import org.jclouds.vcloud.compute.functions.ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException;
|
import org.jclouds.vcloud.compute.functions.ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException;
|
||||||
import org.jclouds.vcloud.domain.Catalog;
|
import org.jclouds.vcloud.domain.Catalog;
|
||||||
|
@ -103,14 +102,18 @@ import org.jclouds.vcloud.functions.OrgsForNames;
|
||||||
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
|
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
|
||||||
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
|
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
|
||||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||||
|
import org.jclouds.vcloud.internal.VCloudLoginClient;
|
||||||
import org.jclouds.vcloud.loaders.OVFLoader;
|
import org.jclouds.vcloud.loaders.OVFLoader;
|
||||||
import org.jclouds.vcloud.loaders.VAppTemplateLoader;
|
import org.jclouds.vcloud.loaders.VAppTemplateLoader;
|
||||||
|
import org.jclouds.vcloud.location.DefaultVDC;
|
||||||
|
import org.jclouds.vcloud.location.OrgAndVDCToLocationSupplier;
|
||||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||||
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
@ -118,6 +121,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,28 +148,16 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
super(VCloudClient.class, VCloudAsyncClient.class, DELEGATE_MAP);
|
super(VCloudClient.class, VCloudAsyncClient.class, DELEGATE_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
protected VCloudLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
|
|
||||||
return factory.create(VCloudLoginAsyncClient.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
AtomicReference<AuthorizationException> authException, final VCloudLoginAsyncClient login) {
|
AtomicReference<AuthorizationException> authException, final VCloudLoginClient login) {
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||||
new Supplier<VCloudSession>() {
|
new Supplier<VCloudSession>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VCloudSession get() {
|
public VCloudSession get() {
|
||||||
try {
|
return login.login();
|
||||||
return login.login().get(10, TimeUnit.SECONDS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
propagate(e);
|
|
||||||
assert false : e;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -178,9 +170,6 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
|
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
|
||||||
});
|
});
|
||||||
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
|
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
|
||||||
// Ensures we don't retry on authorization failures
|
|
||||||
bind(new TypeLiteral<AtomicReference<AuthorizationException>>() {
|
|
||||||
}).toInstance(new AtomicReference<AuthorizationException>());
|
|
||||||
installDefaultVCloudEndpointsModule();
|
installDefaultVCloudEndpointsModule();
|
||||||
bind(new TypeLiteral<Function<ReferenceType, Location>>() {
|
bind(new TypeLiteral<Function<ReferenceType, Location>>() {
|
||||||
}).to(new TypeLiteral<FindLocationForResource>() {
|
}).to(new TypeLiteral<FindLocationForResource>() {
|
||||||
|
@ -203,24 +192,25 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() {
|
bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() {
|
||||||
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
|
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
bindCacheLoaders();
|
bindCacheLoaders();
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<VAppTemplate, String>>() {
|
bind(new TypeLiteral<Function<VAppTemplate, String>>() {
|
||||||
}).annotatedWith(Network.class).to(new TypeLiteral<DefaultNetworkNameInTemplate>() {
|
}).annotatedWith(Network.class).to(new TypeLiteral<DefaultNetworkNameInTemplate>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<VAppTemplate, Envelope>>() {
|
bind(new TypeLiteral<Function<VAppTemplate, Envelope>>() {
|
||||||
}).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
|
}).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
|
||||||
});
|
});
|
||||||
|
bindClientAndAsyncClient(binder(), VCloudVersionsClient.class, VCloudVersionsAsyncClient.class);
|
||||||
|
bindClientAndAsyncClient(binder(), VCloudLoginClient.class, VCloudLoginAsyncClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void bindCacheLoaders() {
|
protected void bindCacheLoaders() {
|
||||||
bind(new TypeLiteral<CacheLoader<URI, VAppTemplate>>() {
|
bind(new TypeLiteral<CacheLoader<URI, VAppTemplate>>() {
|
||||||
}).to(new TypeLiteral<VAppTemplateLoader>() {
|
}).to(new TypeLiteral<VAppTemplateLoader>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
bind(new TypeLiteral<CacheLoader<URI, Envelope>>() {
|
bind(new TypeLiteral<CacheLoader<URI, Envelope>>() {
|
||||||
}).to(new TypeLiteral<OVFLoader>() {
|
}).to(new TypeLiteral<OVFLoader>() {
|
||||||
});
|
});
|
||||||
|
@ -257,9 +247,20 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@OrgList
|
@OrgList
|
||||||
URI provideOrgListURI(Supplier<VCloudSession> sessionSupplier) {
|
protected Supplier<URI> provideOrgListURI(Supplier<VCloudSession> sessionSupplier) {
|
||||||
VCloudSession session = sessionSupplier.get();
|
return Suppliers.compose(new Function<VCloudSession, URI>() {
|
||||||
return URI.create(getLast(session.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org"));
|
|
||||||
|
@Override
|
||||||
|
public URI apply(VCloudSession arg0) {
|
||||||
|
return URI.create(getLast(arg0.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "orgListURI()";
|
||||||
|
}
|
||||||
|
|
||||||
|
}, sessionSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -381,13 +382,22 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@org.jclouds.vcloud.endpoints.VCloudLogin
|
@org.jclouds.vcloud.endpoints.VCloudLogin
|
||||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
protected Supplier<URI> provideAuthenticationURI(final VCloudVersionsClient versionService,
|
||||||
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
|
@Named(PROPERTY_API_VERSION) final String version) {
|
||||||
TimeoutException {
|
return new Supplier<URI>() {
|
||||||
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
|
|
||||||
checkState(versions.size() > 0, "No versions present");
|
@Override
|
||||||
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
public URI get() {
|
||||||
return versions.get(version);
|
SortedMap<String, URI> versions = versionService.getSupportedVersions();
|
||||||
|
checkState(versions.size() > 0, "No versions present");
|
||||||
|
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
||||||
|
return versions.get(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "login()";
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -407,12 +417,6 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
protected VCloudVersionsAsyncClient provideVCloudVersions(AsyncClientFactory factory) {
|
|
||||||
return factory.create(VCloudVersionsAsyncClient.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
|
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
|
||||||
|
@ -518,14 +522,13 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>>(
|
||||||
authException, seconds, supplier);
|
authException, seconds, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode){
|
protected FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
|
||||||
return FenceMode.fromValue(fenceMode);
|
return FenceMode.fromValue(fenceMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected LoadingCache<URI, VAppTemplate> vAppTemplates(CacheLoader<URI, VAppTemplate> vAppTemplates) {
|
protected LoadingCache<URI, VAppTemplate> vAppTemplates(CacheLoader<URI, VAppTemplate> vAppTemplates) {
|
||||||
|
@ -537,11 +540,18 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
protected LoadingCache<URI, Envelope> envelopes(CacheLoader<URI, Envelope> envelopes) {
|
protected LoadingCache<URI, Envelope> envelopes(CacheLoader<URI, Envelope> envelopes) {
|
||||||
return CacheBuilder.newBuilder().build(envelopes);
|
return CacheBuilder.newBuilder().build(envelopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindErrorHandlers() {
|
protected void bindErrorHandlers() {
|
||||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseVCloudErrorFromHttpResponse.class);
|
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseVCloudErrorFromHttpResponse.class);
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
|
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
|
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installLocations() {
|
||||||
|
super.installLocations();
|
||||||
|
bind(ImplicitLocationSupplier.class).to(DefaultVDC.class).in(Scopes.SINGLETON);
|
||||||
|
bind(LocationsSupplier.class).to(OrgAndVDCToLocationSupplier.class).in(Scopes.SINGLETON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/**
|
||||||
|
* 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.vcloud.internal;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.vcloud.domain.VCloudSession;
|
||||||
|
|
||||||
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface VCloudLoginClient {
|
||||||
|
|
||||||
|
VCloudSession login();
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
* 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.vcloud.location;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.collect.Iterables.find;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
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 org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.endpoints.VDC;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class DefaultVDC implements ImplicitLocationSupplier {
|
||||||
|
private final Supplier<Set<? extends Location>> locationsSupplier;
|
||||||
|
private final IsDefaultVDC isDefaultVDC;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
|
||||||
|
this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
|
||||||
|
this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location get() {
|
||||||
|
return find(locationsSupplier.get(), isDefaultVDC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public static class IsDefaultVDC implements Predicate<Location> {
|
||||||
|
private final ReferenceType defaultVDC;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
|
||||||
|
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Location input) {
|
||||||
|
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "isDefaultVDC()";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.suppliers;
|
package org.jclouds.vcloud.location;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.location.Iso3166;
|
import org.jclouds.location.Iso3166;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.location.suppliers.JustProvider;
|
import org.jclouds.location.suppliers.LocationsSupplier;
|
||||||
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
|
||||||
|
@ -45,20 +46,21 @@ import com.google.common.collect.ImmutableSet.Builder;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgAndVDCToLocationSupplier extends JustProvider {
|
public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier {
|
||||||
|
|
||||||
private final Supplier<Map<String, ReferenceType>> orgNameToResource;
|
private final Supplier<Map<String, ReferenceType>> orgNameToResource;
|
||||||
private final Supplier<Map<String, Org>> orgNameToVDCResource;
|
private final Supplier<Map<String, Org>> orgNameToVDCResource;
|
||||||
private final Map<String, Set<String>> isoCodesById;
|
private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
||||||
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
|
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
|
||||||
Supplier<Map<String, Org>> orgNameToVDCResource, @Iso3166 Map<String, Set<String>> isoCodesById) {
|
Supplier<Map<String, Org>> orgNameToVDCResource,
|
||||||
|
@Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
|
||||||
super(providerName, endpoint, isoCodes);
|
super(providerName, endpoint, isoCodes);
|
||||||
this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
|
this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
|
||||||
this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
|
this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
|
||||||
this.isoCodesById = checkNotNull(isoCodesById, "isoCodesById");
|
this.isoCodesByIdSupplier = checkNotNull(isoCodesByIdSupplier, "isoCodesByIdSupplier");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,21 +73,21 @@ public class OrgAndVDCToLocationSupplier extends JustProvider {
|
||||||
Location provider = Iterables.getOnlyElement(super.get());
|
Location provider = Iterables.getOnlyElement(super.get());
|
||||||
if (orgNameToResource.get().size() == 0)
|
if (orgNameToResource.get().size() == 0)
|
||||||
return locations.add(provider);
|
return locations.add(provider);
|
||||||
else
|
Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
|
||||||
for (ReferenceType org : orgNameToResource.get().values()) {
|
for (ReferenceType org : orgNameToResource.get().values()) {
|
||||||
LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(
|
LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString())
|
||||||
org.getHref().toASCIIString()).description((org.getName())).parent(provider);
|
.description((org.getName())).parent(provider);
|
||||||
if (isoCodesById.containsKey(org.getHref().toASCIIString()))
|
if (isoCodesById.containsKey(org.getHref().toASCIIString()))
|
||||||
builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()));
|
builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get());
|
||||||
Location orgL = builder.build();
|
Location orgL = builder.build();
|
||||||
for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
|
for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
|
||||||
builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
|
builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
|
||||||
(vdc.getName())).parent(orgL);
|
(vdc.getName())).parent(orgL);
|
||||||
if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
|
if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
|
||||||
builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()));
|
builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get());
|
||||||
locations.add(builder.build());
|
locations.add(builder.build());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
|
@ -73,12 +69,6 @@ public class VCloudVersionsAsyncClientTest extends RestClientTest<VCloudVersions
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Timeout(duration = 10, timeUnit = TimeUnit.SECONDS)
|
|
||||||
public interface VCloudVersionsClient {
|
|
||||||
|
|
||||||
SortedMap<String, URI> getSupportedVersions();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<VCloudVersionsClient, VCloudVersionsAsyncClient> createContextSpec() {
|
public RestContextSpec<VCloudVersionsClient, VCloudVersionsAsyncClient> createContextSpec() {
|
||||||
return contextSpec("test", "http://localhost:8080", "1", "", "", "identity", "credential",
|
return contextSpec("test", "http://localhost:8080", "1", "", "", "identity", "credential",
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.location.suppliers.JustProvider;
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest;
|
import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.rest.RestContextSpec;
|
import org.jclouds.rest.RestContextSpec;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
import org.jclouds.vcloud.VCloudVersionsClient;
|
||||||
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
||||||
import org.jclouds.vcloud.domain.AllocationModel;
|
import org.jclouds.vcloud.domain.AllocationModel;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
|
@ -134,8 +134,8 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
public static class VCloudRestClientModuleExtension extends VCloudRestClientModule {
|
public static class VCloudRestClientModuleExtension extends VCloudRestClientModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, String version) {
|
protected Supplier<URI> provideAuthenticationURI(VCloudVersionsClient versionService, String version) {
|
||||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login");
|
return Suppliers.ofInstance(URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -165,7 +165,7 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
AtomicReference<AuthorizationException> authException, final VCloudLoginAsyncClient login) {
|
AtomicReference<AuthorizationException> authException, final VCloudLoginClient login) {
|
||||||
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,22 +24,21 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.filters.BasicAuthentication;
|
import org.jclouds.http.filters.BasicAuthentication;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.RestContextSpec;
|
import org.jclouds.rest.RestContextSpec;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.vcloud.domain.VCloudSession;
|
|
||||||
import org.jclouds.vcloud.endpoints.VCloudLogin;
|
import org.jclouds.vcloud.endpoints.VCloudLogin;
|
||||||
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -92,18 +91,13 @@ public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudLoginAsyncC
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Provides
|
@Provides
|
||||||
@VCloudLogin
|
@VCloudLogin
|
||||||
URI provideURI(@Provider URI uri) {
|
Supplier<URI> provideURI(@Provider URI uri) {
|
||||||
return uri;
|
return Suppliers.ofInstance(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Timeout(duration = 10, timeUnit = TimeUnit.SECONDS)
|
|
||||||
public interface VCloudLoginClient {
|
|
||||||
|
|
||||||
VCloudSession login();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<VCloudLoginClient, VCloudLoginAsyncClient> createContextSpec() {
|
public RestContextSpec<VCloudLoginClient, VCloudLoginAsyncClient> createContextSpec() {
|
||||||
|
|
Loading…
Reference in New Issue