mirror of https://github.com/apache/jclouds.git
Issue 306: tasks list and catalog by name
This commit is contained in:
parent
00d661740a
commit
b0050eeeeb
|
@ -28,8 +28,6 @@ import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
|
@ -64,6 +62,8 @@ import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
import org.jclouds.vcloud.domain.VDC;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
|
import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint;
|
||||||
|
import org.jclouds.vcloud.functions.OrgNameAndTasksListNameToEndpoint;
|
||||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||||
import org.jclouds.vcloud.functions.VAppIdToUri;
|
import org.jclouds.vcloud.functions.VAppIdToUri;
|
||||||
|
@ -127,6 +127,7 @@ public interface VCloudAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#getDefaultCatalog
|
* @see VCloudClient#getDefaultCatalog
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
|
||||||
@Consumes(CATALOG_XML)
|
@Consumes(CATALOG_XML)
|
||||||
|
@ -136,6 +137,7 @@ public interface VCloudAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#getCatalog
|
* @see VCloudClient#getCatalog
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/catalog/{catalogId}")
|
@Path("/catalog/{catalogId}")
|
||||||
|
@ -144,6 +146,17 @@ public interface VCloudAsyncClient {
|
||||||
@Consumes(CATALOG_XML)
|
@Consumes(CATALOG_XML)
|
||||||
ListenableFuture<? extends Catalog> getCatalog(@PathParam("catalogId") String catalogId);
|
ListenableFuture<? extends Catalog> getCatalog(@PathParam("catalogId") String catalogId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VCloudClient#getCatalogInOrg
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(CatalogHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Consumes(CATALOG_XML)
|
||||||
|
ListenableFuture<? extends Catalog> getCatalogInOrg(
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#getVAppTemplate
|
* @see VCloudClient#getVAppTemplate
|
||||||
*/
|
*/
|
||||||
|
@ -180,6 +193,7 @@ public interface VCloudAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#getDefaultVDC
|
* @see VCloudClient#getDefaultVDC
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
@XMLResponseParser(VDCHandler.class)
|
@XMLResponseParser(VDCHandler.class)
|
||||||
|
@ -209,18 +223,10 @@ public interface VCloudAsyncClient {
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudClient#getVDC(URI)
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@XMLResponseParser(VDCHandler.class)
|
|
||||||
@Consumes(VDC_XML)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vDCId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#getTasksList
|
* @see VCloudClient#getTasksList
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/tasksList/{tasksListId}")
|
@Path("/tasksList/{tasksListId}")
|
||||||
|
@ -229,9 +235,21 @@ public interface VCloudAsyncClient {
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends TasksList> getTasksList(@PathParam("tasksListId") String tasksListId);
|
ListenableFuture<? extends TasksList> getTasksList(@PathParam("tasksListId") String tasksListId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VCloudClient#getTasksListInOrg
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Consumes(TASKSLIST_XML)
|
||||||
|
@XMLResponseParser(TasksListHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends TasksList> getTasksListInOrg(
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String orgName,
|
||||||
|
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#getDefaultTasksList
|
* @see VCloudClient#getDefaultTasksList
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
|
||||||
@Consumes(TASKSLIST_XML)
|
@Consumes(TASKSLIST_XML)
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud;
|
package org.jclouds.vcloud;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
@ -51,7 +50,7 @@ public interface VCloudClient {
|
||||||
Organization getDefaultOrganization();
|
Organization getDefaultOrganization();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Please use #getOrganizationByName
|
* Please use #getOrganizationNamed
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
Organization getOrganization(String orgId);
|
Organization getOrganization(String orgId);
|
||||||
|
@ -65,10 +64,20 @@ public interface VCloudClient {
|
||||||
*/
|
*/
|
||||||
Organization getOrganizationNamed(String name);
|
Organization getOrganizationNamed(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use #getCatalogInOrg(null, null)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
Catalog getDefaultCatalog();
|
Catalog getDefaultCatalog();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use #getCatalogInOrg
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
Catalog getCatalog(String catalogId);
|
Catalog getCatalog(String catalogId);
|
||||||
|
|
||||||
|
Catalog getCatalogInOrg(String orgName, String catalogName);
|
||||||
|
|
||||||
CatalogItem getCatalogItem(String catalogItemId);
|
CatalogItem getCatalogItem(String catalogItemId);
|
||||||
|
|
||||||
VAppTemplate getVAppTemplate(String vAppTemplateId);
|
VAppTemplate getVAppTemplate(String vAppTemplateId);
|
||||||
|
@ -76,19 +85,31 @@ public interface VCloudClient {
|
||||||
Network getNetwork(String networkId);
|
Network getNetwork(String networkId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* please use {@link #getVDC(URI)}
|
* please use {@link #getVDCInOrg}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
VDC getVDC(String vDCId);
|
VDC getVDC(String vDCId);
|
||||||
|
|
||||||
VDC getVDCInOrg(String orgName, String vdcName);
|
VDC getVDCInOrg(String orgName, String vdcName);
|
||||||
|
|
||||||
VDC getVDC(URI vdc);
|
/**
|
||||||
|
* Please use #getVDCInOrg(null, null)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
VDC getDefaultVDC();
|
VDC getDefaultVDC();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use #getTasksListInOrg
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
TasksList getTasksList(String tasksListId);
|
TasksList getTasksList(String tasksListId);
|
||||||
|
|
||||||
|
TasksList getTasksListInOrg(String orgName, String tasksListName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use #getTasksListInOrg(null, null)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
TasksList getDefaultTasksList();
|
TasksList getDefaultTasksList();
|
||||||
|
|
||||||
Task deployVApp(String vAppId);
|
Task deployVApp(String vAppId);
|
||||||
|
|
|
@ -30,8 +30,8 @@ import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.endpoints.VDC;
|
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -43,12 +43,12 @@ import com.google.common.collect.Sets;
|
||||||
public class OrgAndVDCToLocationProvider implements Provider<Set<? extends Location>> {
|
public class OrgAndVDCToLocationProvider implements Provider<Set<? extends Location>> {
|
||||||
private final String providerName;
|
private final String providerName;
|
||||||
private final Supplier<Map<String, NamedResource>> orgNameToResource;
|
private final Supplier<Map<String, NamedResource>> orgNameToResource;
|
||||||
private final Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCResource;
|
private final Supplier<Map<String, Organization>> orgNameToVDCResource;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OrgAndVDCToLocationProvider(@org.jclouds.rest.annotations.Provider String providerName,
|
OrgAndVDCToLocationProvider(@org.jclouds.rest.annotations.Provider String providerName,
|
||||||
@Org Supplier<Map<String, NamedResource>> orgNameToResource,
|
@Org Supplier<Map<String, NamedResource>> orgNameToResource,
|
||||||
@VDC Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCResource) {
|
Supplier<Map<String, Organization>> orgNameToVDCResource) {
|
||||||
this.providerName = providerName;
|
this.providerName = providerName;
|
||||||
this.orgNameToResource = orgNameToResource;
|
this.orgNameToResource = orgNameToResource;
|
||||||
this.orgNameToVDCResource = orgNameToVDCResource;
|
this.orgNameToVDCResource = orgNameToVDCResource;
|
||||||
|
@ -61,7 +61,7 @@ public class OrgAndVDCToLocationProvider implements Provider<Set<? extends Locat
|
||||||
|
|
||||||
for (NamedResource org : orgNameToResource.get().values()) {
|
for (NamedResource org : orgNameToResource.get().values()) {
|
||||||
Location orgL = new VCloudLocation(org, provider);
|
Location orgL = new VCloudLocation(org, provider);
|
||||||
for (NamedResource vdc : orgNameToVDCResource.get().get(org.getName()).values()) {
|
for (NamedResource vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
|
||||||
locations.add(new VCloudLocation(vdc, orgL));
|
locations.add(new VCloudLocation(vdc, orgL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,14 +82,15 @@ import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A extends VCloudAsyncClient> extends
|
public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A extends VCloudAsyncClient> extends
|
||||||
RestClientModule<S, A> {
|
RestClientModule<S, A> {
|
||||||
|
|
||||||
public BaseVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
public BaseVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||||
super(syncClientType, asyncClientType);
|
super(syncClientType, asyncClientType);
|
||||||
|
@ -110,7 +111,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Predicate<String> successTester(TaskSuccess success,
|
protected Predicate<String> successTester(TaskSuccess success,
|
||||||
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
||||||
return new RetryablePredicate<String>(success, completed);
|
return new RetryablePredicate<String>(success, completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,20 +139,20 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Singleton
|
@Singleton
|
||||||
@VDC
|
@VDC
|
||||||
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
final @VDC Supplier<Map<String, Map<String, NamedResource>>> orgToVDCSupplier) {
|
final Supplier<Map<String, Organization>> orgToVDCSupplier) {
|
||||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, String>>(authException, seconds,
|
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, String>>(authException, seconds,
|
||||||
new Supplier<Map<String, String>>() {
|
new Supplier<Map<String, String>>() {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> get() {
|
public Map<String, String> get() {
|
||||||
Map<String, String> returnVal = Maps.newLinkedHashMap();
|
Map<String, String> returnVal = Maps.newLinkedHashMap();
|
||||||
for (Entry<String, Map<String, NamedResource>> orgr : orgToVDCSupplier.get().entrySet()) {
|
for (Entry<String, Organization> orgr : orgToVDCSupplier.get().entrySet()) {
|
||||||
for (String vdc : orgr.getValue().keySet()) {
|
for (String vdc : orgr.getValue().getVDCs().keySet()) {
|
||||||
returnVal.put(vdc, orgr.getKey());
|
returnVal.put(vdc, orgr.getKey());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return returnVal;
|
|
||||||
}
|
}
|
||||||
});
|
return returnVal;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,55 +177,54 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
final VCloudLoginAsyncClient login) {
|
final VCloudLoginAsyncClient login) {
|
||||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||||
new Supplier<VCloudSession>() {
|
new Supplier<VCloudSession>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VCloudSession get() {
|
public VCloudSession get() {
|
||||||
try {
|
try {
|
||||||
return login.login().get(10, TimeUnit.SECONDS);
|
return login.login().get(10, TimeUnit.SECONDS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
assert false : e;
|
assert false : e;
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@VDC
|
protected Supplier<Map<String, Organization>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
protected Supplier<Map<String, Map<String, NamedResource>>> provideOrgToVDCCache(
|
final OrganizationMapSupplier supplier) {
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToVDCSupplier supplier) {
|
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Organization>>(authException,
|
||||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, NamedResource>>>(
|
seconds, new Supplier<Map<String, Organization>>() {
|
||||||
authException, seconds, new Supplier<Map<String, Map<String, NamedResource>>>() {
|
@Override
|
||||||
@Override
|
public Map<String, Organization> get() {
|
||||||
public Map<String, Map<String, NamedResource>> get() {
|
return supplier.get();
|
||||||
return supplier.get();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class OrgNameToVDCSupplier implements Supplier<Map<String, Map<String, NamedResource>>> {
|
public static class OrganizationMapSupplier implements Supplier<Map<String, Organization>> {
|
||||||
protected final Supplier<VCloudSession> sessionSupplier;
|
protected final Supplier<VCloudSession> sessionSupplier;
|
||||||
private final VCloudClient client;
|
private final VCloudClient client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OrgNameToVDCSupplier(Supplier<VCloudSession> sessionSupplier, VCloudClient client) {
|
protected OrganizationMapSupplier(Supplier<VCloudSession> sessionSupplier, VCloudClient client) {
|
||||||
this.sessionSupplier = sessionSupplier;
|
this.sessionSupplier = sessionSupplier;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, NamedResource>> get() {
|
public Map<String, Organization> get() {
|
||||||
Map<String, Map<String, NamedResource>> returnVal = Maps.newLinkedHashMap();
|
Map<String, Organization> returnVal = Maps.newLinkedHashMap();
|
||||||
for (String orgName : sessionSupplier.get().getOrgs().keySet()) {
|
for (String orgName : sessionSupplier.get().getOrgs().keySet()) {
|
||||||
returnVal.put(orgName, client.getOrganizationNamed(orgName).getVDCs());
|
returnVal.put(orgName, client.getOrganizationNamed(orgName));
|
||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
@ -235,8 +235,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Singleton
|
@Singleton
|
||||||
@org.jclouds.vcloud.endpoints.VCloudLogin
|
@org.jclouds.vcloud.endpoints.VCloudLogin
|
||||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
||||||
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
|
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
|
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
|
||||||
checkState(versions.size() > 0, "No versions present");
|
checkState(versions.size() > 0, "No versions present");
|
||||||
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
||||||
|
@ -296,7 +295,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Organization provideOrganization(VCloudClient discovery) throws ExecutionException, TimeoutException,
|
protected Organization provideOrganization(VCloudClient discovery) throws ExecutionException, TimeoutException,
|
||||||
InterruptedException {
|
InterruptedException {
|
||||||
if (authException.get() != null)
|
if (authException.get() != null)
|
||||||
throw authException.get();
|
throw authException.get();
|
||||||
try {
|
try {
|
||||||
|
@ -327,7 +326,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Network
|
@Network
|
||||||
@Singleton
|
@Singleton
|
||||||
protected URI provideDefaultNetwork(VCloudClient client) throws InterruptedException, ExecutionException,
|
protected URI provideDefaultNetwork(VCloudClient client) throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
if (authException.get() != null)
|
if (authException.get() != null)
|
||||||
throw authException.get();
|
throw authException.get();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
|
import org.jclouds.vcloud.endpoints.Catalog;
|
||||||
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
|
||||||
|
private final Supplier<Map<String, Organization>> orgMap;
|
||||||
|
private final String defaultOrg;
|
||||||
|
private final URI defaultUri;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, Organization>> orgMap, @Org String defaultOrg,
|
||||||
|
@Catalog URI defaultUri) {
|
||||||
|
this.orgMap = orgMap;
|
||||||
|
this.defaultOrg = defaultOrg;
|
||||||
|
this.defaultUri = defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public URI apply(Object from) {
|
||||||
|
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
|
||||||
|
Object org = Iterables.get(orgCatalog, 0);
|
||||||
|
Object catalog = Iterables.get(orgCatalog, 1);
|
||||||
|
if (org == null && catalog == null)
|
||||||
|
return defaultUri;
|
||||||
|
else if (org == null)
|
||||||
|
org = defaultOrg;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, NamedResource> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();
|
||||||
|
|
||||||
|
return catalog == null ? Iterables.getLast(catalogs.values()).getLocation() : catalogs.get(catalog)
|
||||||
|
.getLocation();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
|
import org.jclouds.vcloud.endpoints.TasksList;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class OrgNameAndTasksListNameToEndpoint implements Function<Object, URI> {
|
||||||
|
private final Supplier<Map<String, Organization>> orgMap;
|
||||||
|
private final String defaultOrg;
|
||||||
|
private final URI defaultUri;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public OrgNameAndTasksListNameToEndpoint(Supplier<Map<String, Organization>> orgMap, @Org String defaultOrg,
|
||||||
|
@TasksList URI defaultUri) {
|
||||||
|
this.orgMap = orgMap;
|
||||||
|
this.defaultOrg = defaultOrg;
|
||||||
|
this.defaultUri = defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public URI apply(Object from) {
|
||||||
|
Iterable<Object> orgTasksList = (Iterable<Object>) checkNotNull(from, "args");
|
||||||
|
Object org = Iterables.get(orgTasksList, 0);
|
||||||
|
Object tasksList = Iterables.get(orgTasksList, 1);
|
||||||
|
if (org == null && tasksList == null)
|
||||||
|
return defaultUri;
|
||||||
|
else if (org == null)
|
||||||
|
org = defaultOrg;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, NamedResource> tasksLists = checkNotNull(orgMap.get().get(org)).getTasksLists();
|
||||||
|
return tasksList == null ? Iterables.getLast(tasksLists.values()).getLocation() : tasksLists.get(tasksList)
|
||||||
|
.getLocation();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new NoSuchElementException(org + "/" + tasksList + " not found in " + orgMap.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.endpoints.VDC;
|
import org.jclouds.vcloud.endpoints.VDC;
|
||||||
|
|
||||||
|
@ -41,13 +42,13 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
||||||
private final Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCEndpoint;
|
private final Supplier<Map<String, Organization>> orgNameToVDCEndpoint;
|
||||||
private final String defaultOrg;
|
private final String defaultOrg;
|
||||||
private final URI defaultUri;
|
private final URI defaultUri;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameAndVDCNameToEndpoint(@VDC Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCEndpoint,
|
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, Organization>> orgNameToVDCEndpoint, @Org String defaultOrg,
|
||||||
@Org String defaultOrg, @VDC URI defaultUri) {
|
@VDC URI defaultUri) {
|
||||||
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
||||||
this.defaultOrg = defaultOrg;
|
this.defaultOrg = defaultOrg;
|
||||||
this.defaultUri = defaultUri;
|
this.defaultUri = defaultUri;
|
||||||
|
@ -64,7 +65,7 @@ public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
||||||
org = defaultOrg;
|
org = defaultOrg;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, NamedResource> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org));
|
Map<String, NamedResource> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();
|
||||||
|
|
||||||
return vdc == null ? Iterables.getLast(vdcs.values()).getLocation() : vdcs.get(vdc).getLocation();
|
return vdc == null ? Iterables.getLast(vdcs.values()).getLocation() : vdcs.get(vdc).getLocation();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.jclouds.vcloud.config.VCloudRestClientModule;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
import org.jclouds.vcloud.domain.Organization;
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||||
|
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||||
|
@ -331,6 +332,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("getCatalogInOrg", String.class, String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "org", "catalog");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog/1 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class);
|
Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class);
|
||||||
HttpRequest request = processor.createRequest(method, "2");
|
HttpRequest request = processor.createRequest(method, "2");
|
||||||
|
@ -463,22 +479,6 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
|
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
|
||||||
HttpRequest request = processor.createRequest(method);
|
HttpRequest request = processor.createRequest(method);
|
||||||
|
@ -509,6 +509,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetTasksListInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("getTasksListInOrg", String.class, String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "org", "tasksList");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/tasksList/1 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class);
|
Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class);
|
||||||
HttpRequest request = processor.createRequest(method, 1);
|
HttpRequest request = processor.createRequest(method, 1);
|
||||||
|
@ -715,7 +730,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
bind(OrgNameToVDCSupplier.class).to(TestOrgNameToVDCSupplier.class);
|
bind(OrganizationMapSupplier.class).to(TestOrganizationMapSupplier.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -781,17 +796,23 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class TestOrgNameToVDCSupplier extends OrgNameToVDCSupplier {
|
public static class TestOrganizationMapSupplier extends OrganizationMapSupplier {
|
||||||
@Inject
|
@Inject
|
||||||
protected TestOrgNameToVDCSupplier() {
|
protected TestOrganizationMapSupplier() {
|
||||||
super(null, null);
|
super(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, NamedResource>> get() {
|
public Map<String, Organization> get() {
|
||||||
return ImmutableMap.<String, Map<String, NamedResource>> of("org", ImmutableMap.<String, NamedResource> of(
|
return ImmutableMap.<String, Organization> of("org", new OrganizationImpl("1", "org", URI
|
||||||
"vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
|
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), ImmutableMap.<String, NamedResource> of(
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))));
|
"catalog", new NamedResourceImpl("1", "catalog", VCloudMediaType.CATALOG_XML, URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||||
|
.<String, NamedResource> of("vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||||
|
.<String, NamedResource> of("tasksList", new NamedResourceImpl("1", "tasksList",
|
||||||
|
VCloudMediaType.TASKSLIST_XML, URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOrganization() throws Exception {
|
public void testOrganization() throws Exception {
|
||||||
Organization response = connection.getDefaultOrganization();
|
Organization response = connection.getOrganizationNamed(null);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getName());
|
assertNotNull(response.getName());
|
||||||
assert response.getCatalogs().size() >= 1;
|
assert response.getCatalogs().size() >= 1;
|
||||||
|
@ -66,17 +66,17 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCatalog() throws Exception {
|
public void testCatalog() throws Exception {
|
||||||
Catalog response = connection.getDefaultCatalog();
|
Catalog response = connection.getCatalogInOrg(null, null);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getId());
|
assertNotNull(response.getId());
|
||||||
assertNotNull(response.getName());
|
assertNotNull(response.getName());
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
assertEquals(connection.getCatalog(response.getId()), response);
|
assertEquals(connection.getCatalogInOrg(null, response.getName()), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetNetwork() throws Exception {
|
public void testGetNetwork() throws Exception {
|
||||||
VDC response = connection.getDefaultVDC();
|
VDC response = connection.getVDCInOrg(null, null);
|
||||||
for (NamedResource resource : response.getAvailableNetworks().values()) {
|
for (NamedResource resource : response.getAvailableNetworks().values()) {
|
||||||
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
|
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
|
||||||
Network item = connection.getNetwork(resource.getId());
|
Network item = connection.getNetwork(resource.getId());
|
||||||
|
@ -87,7 +87,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetCatalogItem() throws Exception {
|
public void testGetCatalogItem() throws Exception {
|
||||||
Catalog response = connection.getDefaultCatalog();
|
Catalog response = connection.getCatalogInOrg(null, null);
|
||||||
for (NamedResource resource : response.values()) {
|
for (NamedResource resource : response.values()) {
|
||||||
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.getCatalogItem(resource.getId());
|
CatalogItem item = connection.getCatalogItem(resource.getId());
|
||||||
|
@ -103,7 +103,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVAppTemplate() throws Exception {
|
public void testGetVAppTemplate() throws Exception {
|
||||||
Catalog response = connection.getDefaultCatalog();
|
Catalog response = connection.getCatalogInOrg(null, null);
|
||||||
for (NamedResource resource : response.values()) {
|
for (NamedResource resource : response.values()) {
|
||||||
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.getCatalogItem(resource.getId());
|
CatalogItem item = connection.getCatalogItem(resource.getId());
|
||||||
|
@ -116,7 +116,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultVDC() throws Exception {
|
public void testDefaultVDC() throws Exception {
|
||||||
VDC response = connection.getDefaultVDC();
|
VDC response = connection.getVDCInOrg(null, null);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getId());
|
assertNotNull(response.getId());
|
||||||
assertNotNull(response.getName());
|
assertNotNull(response.getName());
|
||||||
|
@ -128,7 +128,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultTasksList() throws Exception {
|
public void testDefaultTasksList() throws Exception {
|
||||||
org.jclouds.vcloud.domain.TasksList response = connection.getDefaultTasksList();
|
org.jclouds.vcloud.domain.TasksList response = connection.getTasksListInOrg(null, null);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getId());
|
assertNotNull(response.getId());
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
|
@ -138,7 +138,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTask() throws Exception {
|
public void testGetTask() throws Exception {
|
||||||
org.jclouds.vcloud.domain.TasksList response = connection.getDefaultTasksList();
|
org.jclouds.vcloud.domain.TasksList response = connection.getTasksListInOrg(null, null);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
assertNotNull(response.getTasks());
|
assertNotNull(response.getTasks());
|
||||||
|
@ -150,7 +150,7 @@ public class VCloudClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVApp() throws Exception {
|
public void testGetVApp() throws Exception {
|
||||||
VDC response = connection.getDefaultVDC();
|
VDC response = connection.getVDCInOrg(null, null);
|
||||||
for (NamedResource item : response.getResourceEntities().values()) {
|
for (NamedResource item : response.getResourceEntities().values()) {
|
||||||
if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
|
if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
|
||||||
VApp app = connection.getVApp(item.getId());
|
VApp app = connection.getVApp(item.getId());
|
||||||
|
|
|
@ -109,12 +109,14 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
@Deprecated
|
||||||
@Endpoint(Org.class)
|
@Endpoint(Org.class)
|
||||||
@Consumes(ORG_XML)
|
@Consumes(ORG_XML)
|
||||||
@XMLResponseParser(TerremarkOrgHandler.class)
|
@XMLResponseParser(TerremarkOrgHandler.class)
|
||||||
ListenableFuture<? extends TerremarkOrganization> getDefaultOrganization();
|
ListenableFuture<? extends TerremarkOrganization> getDefaultOrganization();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
@Deprecated
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/org/{orgId}")
|
@Path("/org/{orgId}")
|
||||||
@XMLResponseParser(TerremarkOrgHandler.class)
|
@XMLResponseParser(TerremarkOrgHandler.class)
|
||||||
|
|
|
@ -46,9 +46,11 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface TerremarkVCloudClient extends VCloudClient {
|
public interface TerremarkVCloudClient extends VCloudClient {
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
TerremarkOrganization getDefaultOrganization();
|
TerremarkOrganization getDefaultOrganization();
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
TerremarkOrganization getOrganization(String orgId);
|
TerremarkOrganization getOrganization(String orgId);
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
import org.jclouds.vcloud.domain.Organization;
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||||
|
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||||
|
@ -571,7 +572,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class);
|
bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class);
|
||||||
bind(OrgNameToVDCSupplier.class).to(TestOrgNameToVDCSupplier.class);
|
bind(OrganizationMapSupplier.class).to(TestOrganizationMapSupplier.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -646,17 +647,23 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class TestOrgNameToVDCSupplier extends OrgNameToVDCSupplier {
|
public static class TestOrganizationMapSupplier extends OrganizationMapSupplier {
|
||||||
@Inject
|
@Inject
|
||||||
protected TestOrgNameToVDCSupplier() {
|
protected TestOrganizationMapSupplier() {
|
||||||
super(null, null);
|
super(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, NamedResource>> get() {
|
public Map<String, Organization> get() {
|
||||||
return ImmutableMap.<String, Map<String, NamedResource>> of("org", ImmutableMap.<String, NamedResource> of(
|
return ImmutableMap.<String, Organization> of("org", new OrganizationImpl("1", "org", URI
|
||||||
"vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
|
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), ImmutableMap.<String, NamedResource> of(
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))));
|
"catalog", new NamedResourceImpl("1", "catalog", VCloudMediaType.CATALOG_XML, URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||||
|
.<String, NamedResource> of("vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||||
|
.<String, NamedResource> of("tasksList", new NamedResourceImpl("1", "tasksList",
|
||||||
|
VCloudMediaType.TASKSLIST_XML, URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue