mirror of https://github.com/apache/jclouds.git
Issue 280: ported more organization code from 0.8 -> 1.0
This commit is contained in:
parent
80da64b65c
commit
72a0bb58a7
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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 domain;
|
||||
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Establishes a context with a VCloud endpoint.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class)
|
||||
@RequestFilters(BasicAuthentication.class)
|
||||
public interface VCloudExpressLoginAsyncClient {
|
||||
|
||||
/**
|
||||
* This request returns a token to use in subsequent requests. After ten minutes of inactivity,
|
||||
* the token expires and you have to request a new token with this call.
|
||||
*/
|
||||
@POST
|
||||
@ResponseParser(ParseLoginResponseFromHeaders.class)
|
||||
@Consumes(VCloudExpressMediaType.ORGLIST_XML)
|
||||
ListenableFuture<VCloudSession> login();
|
||||
}
|
|
@ -17,9 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.internal;
|
||||
|
||||
import java.util.Map;
|
||||
package domain;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
|
@ -28,10 +26,8 @@ import org.jclouds.http.filters.BasicAuthentication;
|
|||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.VCloudToken;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -47,20 +43,12 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@RequestFilters(BasicAuthentication.class)
|
||||
public interface VCloudLoginAsyncClient {
|
||||
|
||||
public interface VCloudSession {
|
||||
@VCloudToken
|
||||
String getVCloudToken();
|
||||
|
||||
@Org
|
||||
Map<String, NamedResource> getOrgs();
|
||||
}
|
||||
|
||||
/**
|
||||
* This request returns a token to use in subsequent requests. After ten minutes of inactivity,
|
||||
* the token expires and you have to request a new token with this call.
|
||||
*/
|
||||
@POST
|
||||
@ResponseParser(ParseLoginResponseFromHeaders.class)
|
||||
@Consumes(VCloudExpressMediaType.ORGLIST_XML)
|
||||
@Consumes(VCloudMediaType.ORGLIST_XML)
|
||||
ListenableFuture<VCloudSession> login();
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.internal;
|
||||
package domain;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.SortedMap;
|
|
@ -27,14 +27,10 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.compute.LoadBalancerService;
|
||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
|
||||
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
|
||||
import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier;
|
||||
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
|
||||
import org.jclouds.vcloud.domain.VAppStatus;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
@ -50,7 +46,7 @@ import com.google.inject.util.Providers;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
|
||||
public abstract class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
|
||||
|
||||
@VisibleForTesting
|
||||
static final Map<VAppStatus, NodeState> vAppStatusToNodeState = ImmutableMap.<VAppStatus, NodeState> builder().put(
|
||||
|
@ -74,16 +70,6 @@ public class CommonVCloudComputeServiceContextModule extends BaseComputeServiceC
|
|||
bind(LoadBalancerService.class).toProvider(Providers.<LoadBalancerService> of(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Image>> getSourceImageSupplier(Injector injector) {
|
||||
return injector.getInstance(VCloudImageSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Location>> getSourceLocationSupplier(Injector injector) {
|
||||
return injector.getInstance(OrgAndVDCToLocationSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
|
||||
return injector.getInstance(StaticSizeSupplier.class);
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
|
||||
package org.jclouds.vcloud.compute.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
|
@ -28,6 +31,7 @@ import org.jclouds.compute.strategy.ListNodesStrategy;
|
|||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
|
@ -37,7 +41,11 @@ import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
|
|||
import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
|
||||
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
@ -65,4 +73,15 @@ public class VCloudComputeServiceContextModule extends CommonVCloudComputeServic
|
|||
bind(GetNodeMetadataStrategy.class).to(VCloudGetNodeMetadataStrategy.class);
|
||||
bind(RebootNodeStrategy.class).to(VCloudRebootNodeStrategy.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Location>> getSourceLocationSupplier(Injector injector) {
|
||||
return injector.getInstance(OrgAndVDCToLocationSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Image>> getSourceImageSupplier(Injector injector) {
|
||||
return injector.getInstance(VCloudImageSupplier.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
|
||||
package org.jclouds.vcloud.compute.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
|
@ -28,6 +31,7 @@ import org.jclouds.compute.strategy.ListNodesStrategy;
|
|||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
|
@ -37,7 +41,11 @@ import org.jclouds.vcloud.compute.strategy.VCloudExpressDestroyNodeStrategy;
|
|||
import org.jclouds.vcloud.compute.strategy.VCloudExpressGetNodeMetadataStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressRebootNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.suppliers.OrganizationAndVDCToLocationSupplier;
|
||||
import org.jclouds.vcloud.compute.suppliers.VCloudExpressImageSupplier;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
@ -66,4 +74,14 @@ public class VCloudExpressComputeServiceContextModule extends CommonVCloudComput
|
|||
bind(RebootNodeStrategy.class).to(VCloudExpressRebootNodeStrategy.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Location>> getSourceLocationSupplier(Injector injector) {
|
||||
return injector.getInstance(OrganizationAndVDCToLocationSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Image>> getSourceImageSupplier(Injector injector) {
|
||||
return injector.getInstance(VCloudExpressImageSupplier.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.functions;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.functions.AllCatalogItemsInOrg;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ImagesInOrg implements Function<Org, Iterable<? extends Image>> {
|
||||
|
||||
private final AllCatalogItemsInOrg allCatalogItemsInOrg;
|
||||
private final Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems;
|
||||
private final Provider<ImageForVAppTemplate> imageForVAppTemplateProvider;
|
||||
|
||||
@Inject
|
||||
ImagesInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
|
||||
Provider<ImageForVAppTemplate> imageForVAppTemplateProvider,
|
||||
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems) {
|
||||
this.imageForVAppTemplateProvider = imageForVAppTemplateProvider;
|
||||
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
|
||||
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Image> apply(Org from) {
|
||||
Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
|
||||
Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
|
||||
return Iterables.transform(vAppTemplates, imageForVAppTemplateProvider.get().withParent(from));
|
||||
}
|
||||
|
||||
}
|
|
@ -30,8 +30,7 @@ import org.jclouds.domain.LocationScope;
|
|||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -43,12 +42,12 @@ import com.google.common.collect.Sets;
|
|||
public class OrgAndVDCToLocationSupplier implements Supplier<Set<? extends Location>> {
|
||||
private final String providerName;
|
||||
private final Supplier<Map<String, NamedResource>> orgNameToResource;
|
||||
private final Supplier<Map<String, ? extends Organization>> orgNameToVDCResource;
|
||||
private final Supplier<Map<String, ? extends Org>> orgNameToVDCResource;
|
||||
|
||||
@Inject
|
||||
OrgAndVDCToLocationSupplier(@org.jclouds.rest.annotations.Provider String providerName,
|
||||
@Org Supplier<Map<String, NamedResource>> orgNameToResource,
|
||||
Supplier<Map<String, ? extends Organization>> orgNameToVDCResource) {
|
||||
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, NamedResource>> orgNameToResource,
|
||||
Supplier<Map<String, ? extends Org>> orgNameToVDCResource) {
|
||||
this.providerName = providerName;
|
||||
this.orgNameToResource = orgNameToResource;
|
||||
this.orgNameToVDCResource = orgNameToVDCResource;
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.suppliers;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrganizationAndVDCToLocationSupplier implements Supplier<Set<? extends Location>> {
|
||||
private final String providerName;
|
||||
private final Supplier<Map<String, NamedResource>> orgNameToResource;
|
||||
private final Supplier<Map<String, ? extends Organization>> orgNameToVDCResource;
|
||||
|
||||
@Inject
|
||||
OrganizationAndVDCToLocationSupplier(@org.jclouds.rest.annotations.Provider String providerName,
|
||||
@Org Supplier<Map<String, NamedResource>> orgNameToResource,
|
||||
Supplier<Map<String, ? extends Organization>> orgNameToVDCResource) {
|
||||
this.providerName = providerName;
|
||||
this.orgNameToResource = orgNameToResource;
|
||||
this.orgNameToVDCResource = orgNameToVDCResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends Location> get() {
|
||||
Location provider = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
|
||||
Set<Location> locations = Sets.newLinkedHashSet();
|
||||
|
||||
for (NamedResource org : orgNameToResource.get().values()) {
|
||||
Location orgL = new VCloudLocation(org, provider);
|
||||
for (NamedResource vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
|
||||
locations.add(new VCloudLocation(vdc, orgL));
|
||||
}
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.suppliers;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Sets.newLinkedHashSet;
|
||||
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.compute.functions.ImagesInOrganization;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VCloudExpressImageSupplier implements Supplier<Set<? extends Image>> {
|
||||
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
||||
private final Supplier<Map<String, ? extends Organization>> orgMap;
|
||||
private final ImagesInOrganization imagesInOrganization;
|
||||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
VCloudExpressImageSupplier(Supplier<Map<String, ? extends Organization>> orgMap, ImagesInOrganization imagesInOrganization,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.orgMap = checkNotNull(orgMap, "orgMap");
|
||||
this.imagesInOrganization = checkNotNull(imagesInOrganization, "imagesInOrganization");
|
||||
this.executor = checkNotNull(executor, "executor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends Image> get() {
|
||||
Iterable<? extends Organization> orgs = checkNotNull(orgMap.get().values(), "orgs");
|
||||
Iterable<Iterable<? extends Image>> images = transformParallel(orgs,
|
||||
new Function<Organization, Future<Iterable<? extends Image>>>() {
|
||||
|
||||
@Override
|
||||
public Future<Iterable<? extends Image>> apply(final Organization from) {
|
||||
checkNotNull(from, "org");
|
||||
return executor.submit(new Callable<Iterable<? extends Image>>() {
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Image> call() throws Exception {
|
||||
return imagesInOrganization.apply(from);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}, executor, null, logger, "images in " + orgs);
|
||||
return newLinkedHashSet(concat(images));
|
||||
}
|
||||
}
|
|
@ -39,8 +39,8 @@ import org.jclouds.Constants;
|
|||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.compute.functions.ImagesInOrganization;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.compute.functions.ImagesInOrg;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -55,32 +55,32 @@ public class VCloudImageSupplier implements Supplier<Set<? extends Image>> {
|
|||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
||||
private final Supplier<Map<String, ? extends Organization>> orgMap;
|
||||
private final ImagesInOrganization imagesInOrganization;
|
||||
private final Supplier<Map<String, ? extends Org>> orgMap;
|
||||
private final ImagesInOrg imagesInOrg;
|
||||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
VCloudImageSupplier(Supplier<Map<String, ? extends Organization>> orgMap, ImagesInOrganization imagesInOrganization,
|
||||
VCloudImageSupplier(Supplier<Map<String, ? extends Org>> orgMap, ImagesInOrg imagesInOrg,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.orgMap = checkNotNull(orgMap, "orgMap");
|
||||
this.imagesInOrganization = checkNotNull(imagesInOrganization, "imagesInOrganization");
|
||||
this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg");
|
||||
this.executor = checkNotNull(executor, "executor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends Image> get() {
|
||||
Iterable<? extends Organization> orgs = checkNotNull(orgMap.get().values(), "orgs");
|
||||
Iterable<? extends Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
|
||||
Iterable<Iterable<? extends Image>> images = transformParallel(orgs,
|
||||
new Function<Organization, Future<Iterable<? extends Image>>>() {
|
||||
new Function<Org, Future<Iterable<? extends Image>>>() {
|
||||
|
||||
@Override
|
||||
public Future<Iterable<? extends Image>> apply(final Organization from) {
|
||||
public Future<Iterable<? extends Image>> apply(final Org from) {
|
||||
checkNotNull(from, "org");
|
||||
return executor.submit(new Callable<Iterable<? extends Image>>() {
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Image> call() throws Exception {
|
||||
return imagesInOrganization.apply(from);
|
||||
return imagesInOrg.apply(from);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.jclouds.vcloud.config;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.get;
|
||||
import static com.google.common.collect.Maps.newLinkedHashMap;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
|
@ -31,6 +32,7 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEO
|
|||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -39,6 +41,7 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.AsyncClientFactory;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
|
@ -49,6 +52,7 @@ import org.jclouds.vcloud.domain.CatalogItem;
|
|||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.functions.VCloudExpressAllCatalogItemsInCatalog;
|
||||
|
@ -57,7 +61,6 @@ import org.jclouds.vcloud.functions.VCloudExpressAllVDCsInOrganization;
|
|||
import org.jclouds.vcloud.functions.VCloudExpressOrganizationsForNames;
|
||||
import org.jclouds.vcloud.functions.VCloudExpressOrganizatonsForLocations;
|
||||
import org.jclouds.vcloud.functions.VCloudExpressVAppTemplatesForCatalogItems;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.predicates.VCloudExpressTaskSuccess;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -67,16 +70,17 @@ import com.google.inject.Injector;
|
|||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudExpressLoginAsyncClient;
|
||||
|
||||
/**
|
||||
* Configures the VCloud authentication service connection, including logging
|
||||
* and http transport.
|
||||
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressClient, A extends VCloudExpressAsyncClient>
|
||||
extends CommonVCloudRestClientModule<S, A> {
|
||||
extends CommonVCloudRestClientModule<S, A> {
|
||||
|
||||
public BaseVCloudExpressRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
|
@ -135,7 +139,7 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
|
||||
@Override
|
||||
protected Predicate<URI> successTester(Injector injector,
|
||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
||||
return new RetryablePredicate<URI>(injector.getInstance(VCloudExpressTaskSuccess.class), completed);
|
||||
}
|
||||
|
||||
|
@ -143,20 +147,20 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
@Singleton
|
||||
@org.jclouds.vcloud.endpoints.VDC
|
||||
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final Supplier<Map<String, ? extends Organization>> orgToVDCSupplier) {
|
||||
final Supplier<Map<String, ? extends Organization>> orgToVDCSupplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, String>>(authException, seconds,
|
||||
new Supplier<Map<String, String>>() {
|
||||
@Override
|
||||
public Map<String, String> get() {
|
||||
Map<String, String> returnVal = newLinkedHashMap();
|
||||
for (Entry<String, ? extends Organization> orgr : orgToVDCSupplier.get().entrySet()) {
|
||||
for (String vdc : orgr.getValue().getVDCs().keySet()) {
|
||||
returnVal.put(vdc, orgr.getKey());
|
||||
new Supplier<Map<String, String>>() {
|
||||
@Override
|
||||
public Map<String, String> get() {
|
||||
Map<String, String> returnVal = newLinkedHashMap();
|
||||
for (Entry<String, ? extends Organization> orgr : orgToVDCSupplier.get().entrySet()) {
|
||||
for (String vdc : orgr.getValue().getVDCs().keySet()) {
|
||||
returnVal.put(vdc, orgr.getKey());
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -179,15 +183,15 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, ? extends Organization>> provideOrgMapCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationMapSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationMapSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ? extends Organization>>(
|
||||
authException, seconds, new Supplier<Map<String, ? extends Organization>>() {
|
||||
@Override
|
||||
public Map<String, ? extends Organization> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
authException, seconds, new Supplier<Map<String, ? extends Organization>>() {
|
||||
@Override
|
||||
public Map<String, ? extends Organization> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
@ -197,7 +201,7 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
|
||||
@Inject
|
||||
protected OrganizationMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
||||
Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames) {
|
||||
Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames) {
|
||||
this.sessionSupplier = sessionSupplier;
|
||||
this.organizationsForNames = organizationsForNames;
|
||||
}
|
||||
|
@ -210,13 +214,13 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
|
||||
@Singleton
|
||||
public static class OrganizationCatalogSupplier implements
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
|
||||
protected final Supplier<Map<String, ? extends Organization>> orgSupplier;
|
||||
private final Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrganization;
|
||||
|
||||
@Inject
|
||||
protected OrganizationCatalogSupplier(Supplier<Map<String, ? extends Organization>> orgSupplier,
|
||||
Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrganization) {
|
||||
Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrganization) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allCatalogsInOrganization = allCatalogsInOrganization;
|
||||
}
|
||||
|
@ -224,57 +228,58 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return transformValues(
|
||||
transformValues(orgSupplier.get(), allCatalogsInOrganization),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
|
||||
transformValues(orgSupplier.get(), allCatalogsInOrganization),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> provideOrganizationCatalogItemMapSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>(
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationVDCSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationVDCSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>(
|
||||
authException, seconds, new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationVDCSupplier implements
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
|
||||
protected final Supplier<Map<String, ? extends Organization>> orgSupplier;
|
||||
private final Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrganization;
|
||||
|
||||
@Inject
|
||||
protected OrganizationVDCSupplier(Supplier<Map<String, ? extends Organization>> orgSupplier,
|
||||
Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrganization) {
|
||||
Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrganization) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allVDCsInOrganization = allVDCsInOrganization;
|
||||
}
|
||||
|
@ -282,29 +287,29 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return transformValues(
|
||||
transformValues(orgSupplier.get(), allVDCsInOrganization),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
transformValues(orgSupplier.get(), allVDCsInOrganization),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationCatalogItemSupplier implements
|
||||
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
|
||||
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
|
||||
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
|
||||
private final Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
|
||||
|
||||
@Inject
|
||||
protected OrganizationCatalogItemSupplier(
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
|
||||
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
|
||||
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
||||
this.catalogSupplier = catalogSupplier;
|
||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||
}
|
||||
|
@ -312,39 +317,67 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return transformValues(
|
||||
catalogSupplier.get(),
|
||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
|
||||
catalogSupplier.get(),
|
||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends CatalogItem>> apply(
|
||||
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return transformValues(
|
||||
from,
|
||||
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends CatalogItem>> apply(
|
||||
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return transformValues(
|
||||
from,
|
||||
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
||||
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Map<String, ? extends CatalogItem> apply(
|
||||
org.jclouds.vcloud.domain.Catalog from) {
|
||||
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> provideOrganizationCatalogItemSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogItemSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogItemSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>(
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected VCloudExpressLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
|
||||
return factory.create(VCloudExpressLoginAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudExpressLoginAsyncClient login) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||
new Supplier<VCloudSession>() {
|
||||
|
||||
@Override
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.jclouds.vcloud.config;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.get;
|
||||
import static com.google.common.collect.Maps.newLinkedHashMap;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
|
@ -31,6 +32,7 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEO
|
|||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -39,6 +41,7 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.AsyncClientFactory;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
|
@ -49,6 +52,7 @@ import org.jclouds.vcloud.domain.CatalogItem;
|
|||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog;
|
||||
|
@ -57,7 +61,6 @@ import org.jclouds.vcloud.functions.AllVDCsInOrg;
|
|||
import org.jclouds.vcloud.functions.OrgsForLocations;
|
||||
import org.jclouds.vcloud.functions.OrgsForNames;
|
||||
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -67,16 +70,17 @@ import com.google.inject.Injector;
|
|||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudLoginAsyncClient;
|
||||
|
||||
/**
|
||||
* Configures the VCloud authentication service connection, including logging
|
||||
* and http transport.
|
||||
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A extends VCloudAsyncClient> extends
|
||||
CommonVCloudRestClientModule<S, A> {
|
||||
CommonVCloudRestClientModule<S, A> {
|
||||
|
||||
public BaseVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
|
@ -135,7 +139,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
|
||||
@Override
|
||||
protected Predicate<URI> successTester(Injector injector,
|
||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
||||
return new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), completed);
|
||||
}
|
||||
|
||||
|
@ -143,20 +147,20 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
@Singleton
|
||||
@org.jclouds.vcloud.endpoints.VDC
|
||||
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final Supplier<Map<String, ? extends Org>> orgToVDCSupplier) {
|
||||
final Supplier<Map<String, ? extends Org>> orgToVDCSupplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, String>>(authException, seconds,
|
||||
new Supplier<Map<String, String>>() {
|
||||
@Override
|
||||
public Map<String, String> get() {
|
||||
Map<String, String> returnVal = newLinkedHashMap();
|
||||
for (Entry<String, ? extends Org> orgr : orgToVDCSupplier.get().entrySet()) {
|
||||
for (String vdc : orgr.getValue().getVDCs().keySet()) {
|
||||
returnVal.put(vdc, orgr.getKey());
|
||||
new Supplier<Map<String, String>>() {
|
||||
@Override
|
||||
public Map<String, String> get() {
|
||||
Map<String, String> returnVal = newLinkedHashMap();
|
||||
for (Entry<String, ? extends Org> orgr : orgToVDCSupplier.get().entrySet()) {
|
||||
for (String vdc : orgr.getValue().getVDCs().keySet()) {
|
||||
returnVal.put(vdc, orgr.getKey());
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -179,15 +183,15 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, ? extends Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final OrgMapSupplier supplier) {
|
||||
final OrgMapSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ? extends Org>>(authException,
|
||||
seconds, new Supplier<Map<String, ? extends Org>>() {
|
||||
@Override
|
||||
public Map<String, ? extends Org> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
seconds, new Supplier<Map<String, ? extends Org>>() {
|
||||
@Override
|
||||
public Map<String, ? extends Org> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
@ -197,7 +201,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
|
||||
@Inject
|
||||
protected OrgMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
||||
Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames) {
|
||||
Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames) {
|
||||
this.sessionSupplier = sessionSupplier;
|
||||
this.organizationsForNames = organizationsForNames;
|
||||
}
|
||||
|
@ -210,13 +214,13 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
|
||||
@Singleton
|
||||
public static class OrgCatalogSupplier implements
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
|
||||
protected final Supplier<Map<String, ? extends Org>> orgSupplier;
|
||||
private final Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg;
|
||||
|
||||
@Inject
|
||||
protected OrgCatalogSupplier(Supplier<Map<String, ? extends Org>> orgSupplier,
|
||||
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg) {
|
||||
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allCatalogsInOrg = allCatalogsInOrg;
|
||||
}
|
||||
|
@ -224,57 +228,58 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return transformValues(
|
||||
transformValues(orgSupplier.get(), allCatalogsInOrg),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
|
||||
transformValues(orgSupplier.get(), allCatalogsInOrg),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> provideOrgCatalogItemMapSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>(
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>(
|
||||
authException, seconds, new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrgVDCSupplier implements
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
|
||||
protected final Supplier<Map<String, ? extends Org>> orgSupplier;
|
||||
private final Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg;
|
||||
|
||||
@Inject
|
||||
protected OrgVDCSupplier(Supplier<Map<String, ? extends Org>> orgSupplier,
|
||||
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg) {
|
||||
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allVDCsInOrg = allVDCsInOrg;
|
||||
}
|
||||
|
@ -282,29 +287,29 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return transformValues(
|
||||
transformValues(orgSupplier.get(), allVDCsInOrg),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
transformValues(orgSupplier.get(), allVDCsInOrg),
|
||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
@Override
|
||||
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
|
||||
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
|
||||
return uniqueIndex(from, name);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrgCatalogItemSupplier implements
|
||||
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
|
||||
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
|
||||
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
|
||||
private final Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
|
||||
|
||||
@Inject
|
||||
protected OrgCatalogItemSupplier(
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
|
||||
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
|
||||
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
||||
this.catalogSupplier = catalogSupplier;
|
||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||
}
|
||||
|
@ -312,39 +317,40 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return transformValues(
|
||||
catalogSupplier.get(),
|
||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
|
||||
catalogSupplier.get(),
|
||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends CatalogItem>> apply(
|
||||
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return transformValues(
|
||||
from,
|
||||
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends CatalogItem>> apply(
|
||||
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
|
||||
return transformValues(
|
||||
from,
|
||||
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
||||
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Map<String, ? extends CatalogItem> apply(
|
||||
org.jclouds.vcloud.domain.Catalog from) {
|
||||
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> provideOrgCatalogItemSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogItemSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogItemSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>(
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -353,4 +359,31 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
protected URI provideDefaultTasksList(Org org) {
|
||||
return org.getTasksList().getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected VCloudLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
|
||||
return factory.create(VCloudLoginAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudLoginAsyncClient login) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||
new Supplier<VCloudSession>() {
|
||||
|
||||
@Override
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.vcloud.config;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Iterables.getLast;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
|
@ -58,13 +57,11 @@ import org.jclouds.rest.config.RestClientModule;
|
|||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
import org.jclouds.vcloud.VCloudToken;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.Catalog;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
|
@ -72,9 +69,10 @@ import com.google.common.base.Supplier;
|
|||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Configures the VCloud authentication service connection, including logging
|
||||
* and http transport.
|
||||
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -98,7 +96,7 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
@Provides
|
||||
@Singleton
|
||||
protected abstract Predicate<URI> successTester(Injector injector,
|
||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed);
|
||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed);
|
||||
|
||||
@VCloudToken
|
||||
@Provides
|
||||
|
@ -124,27 +122,27 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
@Org
|
||||
@Singleton
|
||||
protected Supplier<Map<String, NamedResource>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final OrgNameToOrgSupplier supplier) {
|
||||
final OrgNameToOrgSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, NamedResource>>(authException,
|
||||
seconds, new Supplier<Map<String, NamedResource>>() {
|
||||
@Override
|
||||
public Map<String, NamedResource> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
seconds, new Supplier<Map<String, NamedResource>>() {
|
||||
@Override
|
||||
public Map<String, NamedResource> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>(
|
||||
authException, seconds, new Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
@Override
|
||||
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
authException, seconds, new Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
@Override
|
||||
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
|
||||
return supplier.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
@ -159,24 +157,24 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
@Override
|
||||
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
|
||||
return uniqueIndex(
|
||||
concat(transform(
|
||||
orgVDCMap.get().values(),
|
||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.VDC>, Iterable<? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
concat(transform(
|
||||
orgVDCMap.get().values(),
|
||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.VDC>, Iterable<? extends org.jclouds.vcloud.domain.VDC>>() {
|
||||
|
||||
@Override
|
||||
public Iterable<? extends org.jclouds.vcloud.domain.VDC> apply(
|
||||
Map<String, ? extends org.jclouds.vcloud.domain.VDC> from) {
|
||||
return from.values();
|
||||
}
|
||||
@Override
|
||||
public Iterable<? extends org.jclouds.vcloud.domain.VDC> apply(
|
||||
Map<String, ? extends org.jclouds.vcloud.domain.VDC> from) {
|
||||
return from.values();
|
||||
}
|
||||
|
||||
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
|
||||
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
|
||||
|
||||
@Override
|
||||
public URI apply(org.jclouds.vcloud.domain.VDC from) {
|
||||
return from.getId();
|
||||
}
|
||||
@Override
|
||||
public URI apply(org.jclouds.vcloud.domain.VDC from) {
|
||||
return from.getId();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -192,27 +190,6 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
|
||||
protected AtomicReference<AuthorizationException> authException = new AtomicReference<AuthorizationException>();
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudLoginAsyncClient login) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||
new Supplier<VCloudSession>() {
|
||||
|
||||
@Override
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
final static Function<NamedResource, String> name = new Function<NamedResource, String>() {
|
||||
|
||||
@Override
|
||||
|
@ -226,7 +203,8 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
@Singleton
|
||||
@org.jclouds.vcloud.endpoints.VCloudLogin
|
||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
||||
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
|
||||
checkState(versions.size() > 0, "No versions present");
|
||||
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
||||
|
@ -250,12 +228,6 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected VCloudLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
|
||||
return factory.create(VCloudLoginAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected VCloudVersionsAsyncClient provideVCloudVersions(AsyncClientFactory factory) {
|
||||
|
@ -266,7 +238,7 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
@Catalog
|
||||
@Singleton
|
||||
protected String provideCatalogName(
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogs) {
|
||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogs) {
|
||||
return getLast(getLast(catalogs.get().values()).keySet());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.domain;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface VCloudSession {
|
||||
String getVCloudToken();
|
||||
|
||||
Map<String, NamedResource> getOrgs();
|
||||
}
|
|
@ -37,8 +37,8 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.vcloud.VCloudToken;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.xml.OrgListHandler;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
|
|
@ -51,15 +51,13 @@ import org.jclouds.util.Utils;
|
|||
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.internal.CatalogImpl;
|
||||
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
|
@ -79,6 +77,9 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudLoginAsyncClient;
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudAsyncClient}
|
||||
*
|
||||
|
@ -89,16 +90,16 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp");
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||
|
@ -108,19 +109,20 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
}
|
||||
|
||||
public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp", processorCount(1).memory(
|
||||
512).disk(1024).inNetwork(URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")));
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor
|
||||
.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp",
|
||||
processorCount(1).memory(512).disk(1024).inNetwork(
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp-cpumemdisk.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||
|
@ -131,26 +133,26 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
||||
.disk(1024).inNetwork(URI.create("https://vcenterprise.bluelock.com/network/1990")));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
||||
.disk(1024).inNetwork(URI.create("https://vcenterprise.bluelock.com/network/1990")));
|
||||
}
|
||||
|
||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp");
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")),
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||
|
@ -161,17 +163,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server", new CloneVAppOptions()
|
||||
.deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server",
|
||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")),
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||
|
@ -183,7 +185,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getOrg", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||
|
@ -214,7 +216,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getCatalog", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||
|
@ -245,7 +247,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getNetwork", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/2"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/2"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||
|
@ -261,7 +263,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||
|
@ -276,7 +278,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, String.class,
|
||||
String.class);
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "item");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1");
|
||||
|
@ -292,7 +294,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
|
||||
String.class, String.class);
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "template");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
|
||||
|
@ -309,7 +311,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||
|
@ -382,7 +384,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
|
@ -398,7 +400,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getTasksList", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||
|
@ -429,7 +431,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("deployVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -445,7 +447,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
|
@ -461,10 +463,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("undeployVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -478,7 +480,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -494,10 +496,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("powerOnVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -511,10 +513,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("powerOffVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -528,10 +530,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testReset() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("resetVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -545,10 +547,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testSuspend() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("suspendVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -562,10 +564,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testShutdown() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("shutdownVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -579,7 +581,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -595,7 +597,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -637,7 +639,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public static class VCloudRestClientModuleExtension extends VCloudRestClientModule {
|
||||
@Override
|
||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
||||
@Named(PROPERTY_API_VERSION) String version) {
|
||||
@Named(PROPERTY_API_VERSION) String version) {
|
||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login");
|
||||
}
|
||||
|
||||
|
@ -663,11 +665,6 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<NamedResource> provideOrgs(Supplier<VCloudSession> cache, @Named(PROPERTY_IDENTITY) String user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultTasksList(Org org) {
|
||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/taskslist");
|
||||
|
@ -685,13 +682,13 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
@Override
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudLoginAsyncClient login) {
|
||||
final VCloudLoginAsyncClient login) {
|
||||
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
||||
|
||||
@Override
|
||||
public Map<String, NamedResource> getOrgs() {
|
||||
return ImmutableMap.<String, NamedResource> of("org", new NamedResourceImpl("org",
|
||||
VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")));
|
||||
VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -712,18 +709,41 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
}
|
||||
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
|
||||
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
|
||||
return Suppliers
|
||||
.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of(
|
||||
"org",
|
||||
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new VDCImpl("vdc", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "description", null, null, null,
|
||||
null, null, ImmutableMap.<String, NamedResource> of("vapp", new NamedResourceImpl("vapp",
|
||||
"application/vnd.vmware.vcloud.vApp+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), "network",
|
||||
new NamedResourceImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), null))));
|
||||
ImmutableMap
|
||||
.<String, org.jclouds.vcloud.domain.VDC> of(
|
||||
"vdc",
|
||||
new VDCImpl(
|
||||
"vdc",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||
"description",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
ImmutableMap
|
||||
.<String, NamedResource> of(
|
||||
"vapp",
|
||||
new NamedResourceImpl(
|
||||
"vapp",
|
||||
"application/vnd.vmware.vcloud.vApp+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")),
|
||||
"network",
|
||||
new NamedResourceImpl(
|
||||
"network",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))),
|
||||
null))));
|
||||
|
||||
}
|
||||
|
||||
|
@ -737,15 +757,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
@Override
|
||||
public Map<String, Org> get() {
|
||||
return ImmutableMap.<String, Org> of("org", new OrgImpl("org", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "description", ImmutableMap
|
||||
.<String, NamedResource> of("catalog", new NamedResourceImpl("catalog", VCloudMediaType.CATALOG_XML,
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
|
||||
.<String, NamedResource> of("vdc", new NamedResourceImpl("vdc", VCloudMediaType.VDC_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap
|
||||
.<String, NamedResource> of("network", new NamedResourceImpl("network", VCloudMediaType.NETWORK_XML,
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))), new NamedResourceImpl(
|
||||
"tasksList", VCloudMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"))));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "description", ImmutableMap
|
||||
.<String, NamedResource> of("catalog", new NamedResourceImpl("catalog",
|
||||
VCloudMediaType.CATALOG_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
|
||||
.<String, NamedResource> of("vdc", new NamedResourceImpl("vdc", VCloudMediaType.VDC_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap
|
||||
.<String, NamedResource> of("network", new NamedResourceImpl("network",
|
||||
VCloudMediaType.NETWORK_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))),
|
||||
new NamedResourceImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,15 +780,32 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
|
||||
return ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of(
|
||||
"org",
|
||||
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "description", ImmutableMap
|
||||
.<String, NamedResource> of("item", new NamedResourceImpl("item",
|
||||
"application/vnd.vmware.vcloud.catalogItem+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), "template",
|
||||
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))))));
|
||||
ImmutableMap
|
||||
.<String, org.jclouds.vcloud.domain.Catalog> of(
|
||||
"catalog",
|
||||
new CatalogImpl(
|
||||
"catalog",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"),
|
||||
"description",
|
||||
ImmutableMap
|
||||
.<String, NamedResource> of(
|
||||
"item",
|
||||
new NamedResourceImpl(
|
||||
"item",
|
||||
"application/vnd.vmware.vcloud.catalogItem+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
|
||||
"template",
|
||||
new NamedResourceImpl(
|
||||
"template",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -778,18 +817,35 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||
"org", ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||
"catalog", ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of("template",
|
||||
new CatalogItemImpl("template", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description",
|
||||
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
|
||||
ImmutableMap.<String, String> of()))));
|
||||
return ImmutableMap
|
||||
.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||
"org",
|
||||
ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||
"catalog",
|
||||
ImmutableMap
|
||||
.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
||||
"template",
|
||||
new CatalogItemImpl(
|
||||
"template",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"),
|
||||
"description",
|
||||
new NamedResourceImpl(
|
||||
"template",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
|
||||
ImmutableMap.<String, String> of()))));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<NamedResource> provideOrgs(Supplier<VCloudSession> cache, String user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.jclouds.util.Utils;
|
|||
import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.internal.CatalogImpl;
|
||||
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
|
@ -58,9 +59,6 @@ import org.jclouds.vcloud.domain.internal.OrganizationImpl;
|
|||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
|
@ -80,6 +78,9 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudExpressLoginAsyncClient;
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudExpressAsyncClient}
|
||||
*
|
||||
|
@ -746,7 +747,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
@Override
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudLoginAsyncClient login) {
|
||||
final VCloudExpressLoginAsyncClient login) {
|
||||
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|||
import org.jclouds.vcloud.VCloudLoginLiveTest.VCloudLoginClient;
|
||||
import org.jclouds.vcloud.endpoints.VCloudLogin;
|
||||
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
|
@ -45,16 +44,18 @@ import com.google.inject.Module;
|
|||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudExpressLoginAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudLogin}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.VCloudLoginTest")
|
||||
public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudLoginAsyncClient> {
|
||||
public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudExpressLoginAsyncClient> {
|
||||
|
||||
public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudLoginAsyncClient.class.getMethod("login");
|
||||
Method method = VCloudExpressLoginAsyncClient.class.getMethod("login");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1");
|
||||
|
@ -76,8 +77,8 @@ public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudLoginAsyncC
|
|||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<VCloudLoginAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<VCloudLoginAsyncClient>>() {
|
||||
protected TypeLiteral<RestAnnotationProcessor<VCloudExpressLoginAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<VCloudExpressLoginAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -100,8 +101,8 @@ public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudLoginAsyncC
|
|||
}
|
||||
|
||||
@Override
|
||||
public ContextSpec<VCloudLoginClient, VCloudLoginAsyncClient> createContextSpec() {
|
||||
public ContextSpec<VCloudLoginClient, VCloudExpressLoginAsyncClient> createContextSpec() {
|
||||
return contextSpec("test", "http://localhost:8080/login", "1", "identity", "credential", VCloudLoginClient.class,
|
||||
VCloudLoginAsyncClient.class);
|
||||
VCloudExpressLoginAsyncClient.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,8 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory.ContextSpec;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.VCloudLogin;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -45,6 +44,8 @@ import com.google.inject.AbstractModule;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import domain.VCloudExpressLoginAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudLogin}
|
||||
*
|
||||
|
@ -53,11 +54,11 @@ import com.google.inject.Provides;
|
|||
@Test(groups = "live", testName = "vcloud.VCloudLoginLiveTest")
|
||||
public class VCloudLoginLiveTest {
|
||||
|
||||
private RestContext<VCloudLoginClient, VCloudLoginAsyncClient> context;
|
||||
private RestContext<VCloudLoginClient, VCloudExpressLoginAsyncClient> context;
|
||||
|
||||
@Test
|
||||
public void testLogin() throws Exception {
|
||||
VCloudLoginAsyncClient authentication = context.getAsyncApi();
|
||||
VCloudExpressLoginAsyncClient authentication = context.getAsyncApi();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
VCloudSession response = authentication.login().get(45, TimeUnit.SECONDS);
|
||||
assertNotNull(response);
|
||||
|
@ -80,8 +81,8 @@ public class VCloudLoginLiveTest {
|
|||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
||||
|
||||
ContextSpec<VCloudLoginClient, VCloudLoginAsyncClient> contextSpec = contextSpec("test", endpoint, "1", identity,
|
||||
credential, VCloudLoginClient.class, VCloudLoginAsyncClient.class);
|
||||
ContextSpec<VCloudLoginClient, VCloudExpressLoginAsyncClient> contextSpec = contextSpec("test", endpoint, "1", identity,
|
||||
credential, VCloudLoginClient.class, VCloudExpressLoginAsyncClient.class);
|
||||
|
||||
context = createContextBuilder(
|
||||
contextSpec,
|
||||
|
|
|
@ -31,12 +31,13 @@ import org.jclouds.rest.RestClientTest;
|
|||
import org.jclouds.rest.RestContextFactory.ContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.vcloud.VCloudVersionsLiveTest.VCloudVersionsClient;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudVersions}
|
||||
*
|
||||
|
|
|
@ -34,13 +34,14 @@ import org.jclouds.concurrent.config.ExecutorServiceModule;
|
|||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory.ContextSpec;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudVersions}
|
||||
*
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
|
@ -41,11 +41,10 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.hostingdotcom.config.HostingDotComVCloudRestClientModule;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -53,6 +52,8 @@ import com.google.common.base.Supplier;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code HostingDotComVCloudAsyncClient}
|
||||
*
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.util.Utils;
|
|||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressAsyncClient;
|
||||
|
|
|
@ -49,10 +49,9 @@ import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExt
|
|||
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrganizationCatalogSupplier;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressAsyncClientTest.TerremarkVCloudRestClientModuleExtension.TestOrgNameToKeysListSupplier;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressAsyncClientTest.TerremarkVCloudRestClientModuleExtension.TestTerremarkOrganizationMapSupplier;
|
||||
|
@ -77,6 +76,8 @@ import com.google.common.base.Supplier;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TerremarkECloudAsyncClient}
|
||||
*
|
||||
|
|
|
@ -54,11 +54,10 @@ import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExt
|
|||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.config.TerremarkVCloudExpressRestClientModule;
|
||||
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||
|
@ -88,6 +87,8 @@ import com.google.common.collect.Maps;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TerremarkVCloudExpressAsyncClient}
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue