mirror of https://github.com/apache/jclouds.git
Issue 280: added Org to 1.0 impl as it is incompatible with the 0.8 version
This commit is contained in:
parent
3657e066f4
commit
80da64b65c
|
@ -53,9 +53,9 @@ public class VCloudSessionRefreshLiveTest {
|
|||
|
||||
@Test
|
||||
public void testSessionRefresh() throws Exception {
|
||||
connection.findOrganizationNamed(null);
|
||||
connection.findOrgNamed(null);
|
||||
Thread.sleep(timeOut * 1000);
|
||||
connection.findOrganizationNamed(null);
|
||||
connection.findOrgNamed(null);
|
||||
}
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
|
|
|
@ -19,15 +19,15 @@
|
|||
|
||||
package org.jclouds.vcloud;
|
||||
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOGITEM_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.NETWORK_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.ORG_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.TASK_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.VAPPTEMPLATE_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.VAPP_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.VDC_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -40,7 +40,6 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.predicates.validators.DnsNameValidator;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
|
@ -55,20 +54,19 @@ import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
|||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TasksList;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
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.OrgNameCatalogNameItemNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
@ -94,47 +92,28 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
*/
|
||||
@RequestFilters(SetVCloudTokenCookie.class)
|
||||
public interface VCloudAsyncClient {
|
||||
/**
|
||||
* @see VCloudExpressClient#getDefaultOrganization
|
||||
*/
|
||||
@Deprecated
|
||||
@GET
|
||||
@Endpoint(Org.class)
|
||||
@Consumes(ORG_XML)
|
||||
@XMLResponseParser(OrgHandler.class)
|
||||
ListenableFuture<? extends Organization> getDefaultOrganization();
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getOrganization
|
||||
* @see VCloudClient#getOrg
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(OrgHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Consumes(ORG_XML)
|
||||
ListenableFuture<? extends Organization> getOrganization(@EndpointParam URI orgId);
|
||||
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getOrganizationNamed
|
||||
* @see VCloudClient#getOrgNamed
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(OrgHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Consumes(ORG_XML)
|
||||
ListenableFuture<? extends Organization> findOrganizationNamed(
|
||||
ListenableFuture<? extends Org> findOrgNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getDefaultCatalog
|
||||
*/
|
||||
@Deprecated
|
||||
@GET
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
|
||||
@Consumes(CATALOG_XML)
|
||||
@XMLResponseParser(CatalogHandler.class)
|
||||
ListenableFuture<? extends Catalog> getDefaultCatalog();
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getCatalog
|
||||
* @see VCloudClient#getCatalog
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(CatalogHandler.class)
|
||||
|
@ -143,7 +122,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#findCatalogInOrgNamed
|
||||
* @see VCloudClient#findCatalogInOrgNamed
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(CatalogHandler.class)
|
||||
|
@ -154,7 +133,7 @@ public interface VCloudAsyncClient {
|
|||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getVAppTemplate
|
||||
* @see VCloudClient#getVAppTemplate
|
||||
*/
|
||||
@GET
|
||||
@Consumes(VAPPTEMPLATE_XML)
|
||||
|
@ -163,7 +142,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#findVAppTemplateInOrgCatalogNameds
|
||||
* @see VCloudClient#findVAppTemplateInOrgCatalogNameds
|
||||
*/
|
||||
@GET
|
||||
@Consumes(VAPPTEMPLATE_XML)
|
||||
|
@ -175,7 +154,7 @@ public interface VCloudAsyncClient {
|
|||
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getCatalogItem
|
||||
* @see VCloudClient#getCatalogItem
|
||||
*/
|
||||
@GET
|
||||
@Consumes(CATALOGITEM_XML)
|
||||
|
@ -184,7 +163,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getCatalogItemInOrg
|
||||
* @see VCloudClient#getCatalogItemInOrg
|
||||
*/
|
||||
@GET
|
||||
@Consumes(CATALOGITEM_XML)
|
||||
|
@ -196,7 +175,7 @@ public interface VCloudAsyncClient {
|
|||
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#findNetworkInOrgVDCNamed
|
||||
* @see VCloudClient#findNetworkInOrgVDCNamed
|
||||
*/
|
||||
@GET
|
||||
@Consumes(NETWORK_XML)
|
||||
|
@ -208,7 +187,7 @@ public interface VCloudAsyncClient {
|
|||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getNetwork
|
||||
* @see VCloudClient#getNetwork
|
||||
*/
|
||||
@GET
|
||||
@Consumes(NETWORK_XML)
|
||||
|
@ -217,17 +196,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Network> getNetwork(@EndpointParam URI network);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getDefaultVDC
|
||||
*/
|
||||
@Deprecated
|
||||
@GET
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||
@XMLResponseParser(VDCHandler.class)
|
||||
@Consumes(VDC_XML)
|
||||
ListenableFuture<? extends VDC> getDefaultVDC();
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getVDC(URI)
|
||||
* @see VCloudClient#getVDC(URI)
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(VDCHandler.class)
|
||||
|
@ -236,7 +205,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#findVDCInOrgNamed(String, String)
|
||||
* @see VCloudClient#findVDCInOrgNamed(String, String)
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(VDCHandler.class)
|
||||
|
@ -247,7 +216,7 @@ public interface VCloudAsyncClient {
|
|||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getTasksList
|
||||
* @see VCloudClient#getTasksList
|
||||
*/
|
||||
@GET
|
||||
@Consumes(TASKSLIST_XML)
|
||||
|
@ -256,28 +225,17 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getTasksListInOrg
|
||||
* @see VCloudClient#findTasksListInOrgNamed
|
||||
*/
|
||||
@GET
|
||||
@Consumes(TASKSLIST_XML)
|
||||
@XMLResponseParser(TasksListHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends TasksList> findTasksListInOrgNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName);
|
||||
@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getDefaultTasksList
|
||||
*/
|
||||
@Deprecated
|
||||
@GET
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
|
||||
@Consumes(TASKSLIST_XML)
|
||||
@XMLResponseParser(TasksListHandler.class)
|
||||
ListenableFuture<? extends TasksList> getDefaultTasksList();
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#deployVApp
|
||||
* @see VCloudClient#deployVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -286,14 +244,14 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#deleteVApp
|
||||
* @see VCloudClient#deleteVApp
|
||||
*/
|
||||
@DELETE
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> deleteVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#undeployVApp
|
||||
* @see VCloudClient#undeployVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -302,7 +260,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#powerOnVApp
|
||||
* @see VCloudClient#powerOnVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -311,7 +269,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#powerOffVApp
|
||||
* @see VCloudClient#powerOffVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -320,14 +278,14 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#shutdownVApp
|
||||
* @see VCloudClient#shutdownVApp
|
||||
*/
|
||||
@POST
|
||||
@Path("/power/action/shutdown")
|
||||
ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#resetVApp
|
||||
* @see VCloudClient#resetVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -336,7 +294,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#suspendVApp
|
||||
* @see VCloudClient#suspendVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -345,7 +303,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getTask
|
||||
* @see VCloudClient#getTask
|
||||
*/
|
||||
@GET
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -354,14 +312,14 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#cancelTask
|
||||
* @see VCloudClient#cancelTask
|
||||
*/
|
||||
@POST
|
||||
@Path("/action/cancel")
|
||||
ListenableFuture<Void> cancelTask(@EndpointParam URI taskId);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#findVAppInOrgVDCNamed
|
||||
* @see VCloudClient#findVAppInOrgVDCNamed
|
||||
*/
|
||||
@GET
|
||||
@Consumes(VAPP_XML)
|
||||
|
@ -373,7 +331,7 @@ public interface VCloudAsyncClient {
|
|||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getVApp
|
||||
* @see VCloudClient#getVApp
|
||||
*/
|
||||
@GET
|
||||
@Consumes(VAPP_XML)
|
||||
|
@ -382,7 +340,7 @@ public interface VCloudAsyncClient {
|
|||
ListenableFuture<? extends VApp> getVApp(@EndpointParam URI vApp);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#instantiateVAppTemplateInVDC
|
||||
* @see VCloudClient#instantiateVAppTemplateInVDC
|
||||
*/
|
||||
@POST
|
||||
@Path("action/instantiateVAppTemplate")
|
||||
|
@ -396,7 +354,7 @@ public interface VCloudAsyncClient {
|
|||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#cloneVAppInVDC
|
||||
* @see VCloudClient#cloneVAppInVDC
|
||||
*/
|
||||
@POST
|
||||
@Path("/action/cloneVApp")
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.concurrent.Timeout;
|
|||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TasksList;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
|
@ -42,20 +42,15 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
* Provides access to VCloud resources via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
||||
* @see <a
|
||||
* href="http://communities.vmware.com/community/developer/forums/vcloudapi"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||
public interface VCloudClient {
|
||||
|
||||
/**
|
||||
* Please use {@link #findOrganizationNamed(String)} passing null
|
||||
*/
|
||||
@Deprecated
|
||||
Organization getDefaultOrganization();
|
||||
|
||||
Organization getOrganization(URI orgId);
|
||||
Org getOrg(URI orgId);
|
||||
|
||||
/**
|
||||
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and
|
||||
|
@ -66,13 +61,7 @@ public interface VCloudClient {
|
|||
* @throws NoSuchElementException
|
||||
* if you specified an org name that isn't present
|
||||
*/
|
||||
Organization findOrganizationNamed(@Nullable String name);
|
||||
|
||||
/**
|
||||
* Please use #findCatalogInOrgNamed(null, null)
|
||||
*/
|
||||
@Deprecated
|
||||
Catalog getDefaultCatalog();
|
||||
Org findOrgNamed(@Nullable String name);
|
||||
|
||||
Catalog getCatalog(URI catalogId);
|
||||
|
||||
|
@ -149,21 +138,9 @@ public interface VCloudClient {
|
|||
*/
|
||||
VDC findVDCInOrgNamed(String orgName, String vdcName);
|
||||
|
||||
/**
|
||||
* Please use #findVDCInOrgNamed
|
||||
*/
|
||||
@Deprecated
|
||||
VDC getDefaultVDC();
|
||||
|
||||
TasksList getTasksList(URI tasksListId);
|
||||
|
||||
TasksList findTasksListInOrgNamed(String orgName, String tasksListName);
|
||||
|
||||
/**
|
||||
* Please use #getTasksListInOrg(null, null)
|
||||
*/
|
||||
@Deprecated
|
||||
TasksList getDefaultTasksList();
|
||||
TasksList findTasksListInOrgNamed(String orgName);
|
||||
|
||||
Task deployVApp(URI vAppId);
|
||||
|
||||
|
|
|
@ -63,9 +63,9 @@ import org.jclouds.vcloud.domain.VAppTemplate;
|
|||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
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.OrganizationNameAndCatalogNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrganizationNameAndTasksListNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrganizationNameAndVDCNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||
|
@ -75,7 +75,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||
import org.jclouds.vcloud.xml.NetworkHandler;
|
||||
import org.jclouds.vcloud.xml.OrgHandler;
|
||||
import org.jclouds.vcloud.xml.OrganizationHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
@ -101,14 +101,14 @@ public interface VCloudExpressAsyncClient {
|
|||
@GET
|
||||
@Endpoint(Org.class)
|
||||
@Consumes(ORG_XML)
|
||||
@XMLResponseParser(OrgHandler.class)
|
||||
@XMLResponseParser(OrganizationHandler.class)
|
||||
ListenableFuture<? extends Organization> getDefaultOrganization();
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getOrganization
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(OrgHandler.class)
|
||||
@XMLResponseParser(OrganizationHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Consumes(ORG_XML)
|
||||
ListenableFuture<? extends Organization> getOrganization(@EndpointParam URI orgId);
|
||||
|
@ -117,7 +117,7 @@ public interface VCloudExpressAsyncClient {
|
|||
* @see VCloudExpressClient#getOrganizationNamed
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(OrgHandler.class)
|
||||
@XMLResponseParser(OrganizationHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Consumes(ORG_XML)
|
||||
ListenableFuture<? extends Organization> findOrganizationNamed(
|
||||
|
@ -150,8 +150,8 @@ public interface VCloudExpressAsyncClient {
|
|||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Consumes(CATALOG_XML)
|
||||
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndCatalogNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndCatalogNameToEndpoint.class) String catalogName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getVAppTemplate
|
||||
|
@ -243,8 +243,8 @@ public interface VCloudExpressAsyncClient {
|
|||
@Consumes(VDC_XML)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends VDC> findVDCInOrgNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndVDCNameToEndpoint.class) String vdcName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getTasksList
|
||||
|
@ -263,8 +263,8 @@ public interface VCloudExpressAsyncClient {
|
|||
@XMLResponseParser(TasksListHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends TasksList> findTasksListInOrgNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName);
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndTasksListNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndTasksListNameToEndpoint.class) String tasksListName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#getDefaultTasksList
|
||||
|
|
|
@ -86,7 +86,7 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
|
|||
public Iterable<ComputeMetadata> list() {
|
||||
Set<ComputeMetadata> nodes = Sets.newHashSet();
|
||||
for (String org : orgNameToEndpoint.get().keySet()) {
|
||||
for (NamedResource vdc : client.findOrganizationNamed(org).getVDCs().values()) {
|
||||
for (NamedResource vdc : client.findOrgNamed(org).getVDCs().values()) {
|
||||
for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) {
|
||||
if (validVApp(resource)) {
|
||||
nodes.add(convertVAppToComputeMetadata(vdc, resource));
|
||||
|
@ -111,7 +111,7 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
|
|||
public Iterable<NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) {
|
||||
Set<NodeMetadata> nodes = Sets.newHashSet();
|
||||
for (String org : orgNameToEndpoint.get().keySet()) {
|
||||
for (NamedResource vdc : client.findOrganizationNamed(org).getVDCs().values()) {
|
||||
for (NamedResource vdc : client.findOrgNamed(org).getVDCs().values()) {
|
||||
for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) {
|
||||
if (validVApp(resource) && filter.apply(convertVAppToComputeMetadata(vdc, resource))) {
|
||||
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
|
||||
|
|
|
@ -21,18 +21,27 @@ package org.jclouds.vcloud.config;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.Iterables.get;
|
||||
import static com.google.common.collect.Maps.newLinkedHashMap;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
import static com.google.common.collect.Maps.uniqueIndex;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
|
@ -41,28 +50,33 @@ import org.jclouds.vcloud.domain.NamedResource;
|
|||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.functions.VCloudExpressAllCatalogItemsInCatalog;
|
||||
import org.jclouds.vcloud.functions.VCloudExpressAllCatalogsInOrganization;
|
||||
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;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
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
|
||||
*/
|
||||
@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);
|
||||
|
@ -91,7 +105,8 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Organization provideOrganization(VCloudExpressClient discovery) {
|
||||
if (authException.get() != null)
|
||||
throw authException.get();
|
||||
|
@ -120,7 +135,223 @@ 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);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@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) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Provides
|
||||
@org.jclouds.vcloud.endpoints.VDC
|
||||
@Singleton
|
||||
protected URI provideDefaultVDC(Organization org) {
|
||||
checkState(org.getVDCs().size() > 0, "No vdcs present in org: " + org.getName());
|
||||
return get(org.getVDCs().values(), 0).getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@org.jclouds.vcloud.endpoints.Catalog
|
||||
@Singleton
|
||||
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
|
||||
checkState(org.getCatalogs().size() > 0, "No catalogs present in org: " + org.getName());
|
||||
return get(org.getCatalogs().values(), 0).getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, ? extends Organization>> provideOrgMapCache(
|
||||
@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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationMapSupplier implements Supplier<Map<String, ? extends Organization>> {
|
||||
protected final Supplier<VCloudSession> sessionSupplier;
|
||||
private final Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames;
|
||||
|
||||
@Inject
|
||||
protected OrganizationMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
||||
Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames) {
|
||||
this.sessionSupplier = sessionSupplier;
|
||||
this.organizationsForNames = organizationsForNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends Organization> get() {
|
||||
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationCatalogSupplier implements
|
||||
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) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allCatalogsInOrganization = allCatalogsInOrganization;
|
||||
}
|
||||
|
||||
@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>>() {
|
||||
|
||||
@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) {
|
||||
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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
|
||||
@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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationVDCSupplier implements
|
||||
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) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allVDCsInOrganization = allVDCsInOrganization;
|
||||
}
|
||||
|
||||
@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>>() {
|
||||
|
||||
@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>>>> {
|
||||
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) {
|
||||
this.catalogSupplier = catalogSupplier;
|
||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||
}
|
||||
|
||||
@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>>>() {
|
||||
|
||||
@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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TasksList
|
||||
@Singleton
|
||||
protected URI provideDefaultTasksList(Organization org) {
|
||||
checkState(org.getTasksLists().size() > 0, "No tasks lists present in org: " + org.getName());
|
||||
return get(org.getTasksLists().values(), 0).getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,48 +21,62 @@ package org.jclouds.vcloud.config;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.Iterables.get;
|
||||
import static com.google.common.collect.Maps.newLinkedHashMap;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
import static com.google.common.collect.Maps.uniqueIndex;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog;
|
||||
import org.jclouds.vcloud.functions.AllCatalogsInOrganization;
|
||||
import org.jclouds.vcloud.functions.AllVDCsInOrganization;
|
||||
import org.jclouds.vcloud.functions.AllCatalogsInOrg;
|
||||
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.functions.OrganizatonsForLocations;
|
||||
import org.jclouds.vcloud.functions.OrganizationsForNames;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
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
|
||||
*/
|
||||
@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);
|
||||
|
@ -74,35 +88,23 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
bind(new TypeLiteral<Function<Catalog, Iterable<? extends CatalogItem>>>() {
|
||||
}).to(new TypeLiteral<AllCatalogItemsInCatalog>() {
|
||||
});
|
||||
bind(new TypeLiteral<Function<Organization, Iterable<? extends Catalog>>>() {
|
||||
}).to(new TypeLiteral<AllCatalogsInOrganization>() {
|
||||
bind(new TypeLiteral<Function<Org, Iterable<? extends Catalog>>>() {
|
||||
}).to(new TypeLiteral<AllCatalogsInOrg>() {
|
||||
});
|
||||
bind(new TypeLiteral<Function<Organization, Iterable<? extends VDC>>>() {
|
||||
}).to(new TypeLiteral<AllVDCsInOrganization>() {
|
||||
bind(new TypeLiteral<Function<Org, Iterable<? extends VDC>>>() {
|
||||
}).to(new TypeLiteral<AllVDCsInOrg>() {
|
||||
});
|
||||
bind(new TypeLiteral<Function<Iterable<String>, Iterable<? extends Organization>>>() {
|
||||
}).to(new TypeLiteral<OrganizationsForNames>() {
|
||||
bind(new TypeLiteral<Function<Iterable<String>, Iterable<? extends Org>>>() {
|
||||
}).to(new TypeLiteral<OrgsForNames>() {
|
||||
});
|
||||
bind(new TypeLiteral<Function<Iterable<? extends Location>, Iterable<? extends Organization>>>() {
|
||||
}).to(new TypeLiteral<OrganizatonsForLocations>() {
|
||||
bind(new TypeLiteral<Function<Iterable<? extends Location>, Iterable<? extends Org>>>() {
|
||||
}).to(new TypeLiteral<OrgsForLocations>() {
|
||||
});
|
||||
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>>>() {
|
||||
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Organization provideOrganization(VCloudClient discovery) {
|
||||
if (authException.get() != null)
|
||||
throw authException.get();
|
||||
try {
|
||||
return discovery.findOrganizationNamed(null);
|
||||
} catch (AuthorizationException e) {
|
||||
authException.set(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultNetwork(VCloudClient client) {
|
||||
if (authException.get() != null)
|
||||
|
@ -117,9 +119,238 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Org provideOrg(VCloudClient discovery) {
|
||||
if (authException.get() != null)
|
||||
throw authException.get();
|
||||
try {
|
||||
return discovery.findOrgNamed(null);
|
||||
} catch (AuthorizationException e) {
|
||||
authException.set(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@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) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Provides
|
||||
@org.jclouds.vcloud.endpoints.VDC
|
||||
@Singleton
|
||||
protected URI provideDefaultVDC(Org org) {
|
||||
checkState(org.getVDCs().size() > 0, "No vdcs present in org: " + org.getName());
|
||||
return get(org.getVDCs().values(), 0).getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@org.jclouds.vcloud.endpoints.Catalog
|
||||
@Singleton
|
||||
protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user) {
|
||||
checkState(org.getCatalogs().size() > 0, "No catalogs present in org: " + org.getName());
|
||||
return get(org.getCatalogs().values(), 0).getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, ? extends Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrgMapSupplier implements Supplier<Map<String, ? extends Org>> {
|
||||
protected final Supplier<VCloudSession> sessionSupplier;
|
||||
private final Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames;
|
||||
|
||||
@Inject
|
||||
protected OrgMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
||||
Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames) {
|
||||
this.sessionSupplier = sessionSupplier;
|
||||
this.organizationsForNames = organizationsForNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends Org> get() {
|
||||
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrgCatalogSupplier implements
|
||||
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) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allCatalogsInOrg = allCatalogsInOrg;
|
||||
}
|
||||
|
||||
@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>>() {
|
||||
|
||||
@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) {
|
||||
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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrgVDCSupplier implements
|
||||
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) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allVDCsInOrg = allVDCsInOrg;
|
||||
}
|
||||
|
||||
@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>>() {
|
||||
|
||||
@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>>>> {
|
||||
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) {
|
||||
this.catalogSupplier = catalogSupplier;
|
||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||
}
|
||||
|
||||
@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>>>() {
|
||||
|
||||
@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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TasksList
|
||||
@Singleton
|
||||
protected URI provideDefaultTasksList(Org org) {
|
||||
return org.getTasksList().getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,8 @@ 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.get;
|
||||
import static com.google.common.collect.Iterables.getLast;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.collect.Maps.newLinkedHashMap;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
import static com.google.common.collect.Maps.uniqueIndex;
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
|
@ -38,7 +35,6 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEO
|
|||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
@ -61,14 +57,10 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
import org.jclouds.vcloud.VCloudToken;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.endpoints.Catalog;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.endpoints.VDC;
|
||||
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
|
||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||
|
@ -81,7 +73,8 @@ import com.google.inject.Injector;
|
|||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -105,7 +98,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
|
||||
|
@ -131,48 +124,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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@VDC
|
||||
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
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());
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
|
@ -187,24 +159,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();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -223,39 +195,25 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudLoginAsyncClient login) {
|
||||
final VCloudLoginAsyncClient login) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||
new Supplier<VCloudSession>() {
|
||||
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;
|
||||
}
|
||||
@Override
|
||||
public VCloudSession get() {
|
||||
try {
|
||||
return login.login().get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, ? extends Organization>> provideOrgMapCache(
|
||||
@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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private final static Function<NamedResource, String> name = new Function<NamedResource, String>() {
|
||||
final static Function<NamedResource, String> name = new Function<NamedResource, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(NamedResource from) {
|
||||
|
@ -264,171 +222,11 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
|
||||
};
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationMapSupplier implements Supplier<Map<String, ? extends Organization>> {
|
||||
protected final Supplier<VCloudSession> sessionSupplier;
|
||||
private final Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames;
|
||||
|
||||
@Inject
|
||||
protected OrganizationMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
||||
Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames) {
|
||||
this.sessionSupplier = sessionSupplier;
|
||||
this.organizationsForNames = organizationsForNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends Organization> get() {
|
||||
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationCatalogSupplier implements
|
||||
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) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allCatalogsInOrganization = allCatalogsInOrganization;
|
||||
}
|
||||
|
||||
@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>>() {
|
||||
|
||||
@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) {
|
||||
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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
|
||||
@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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrganizationVDCSupplier implements
|
||||
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) {
|
||||
this.orgSupplier = orgSupplier;
|
||||
this.allVDCsInOrganization = allVDCsInOrganization;
|
||||
}
|
||||
|
||||
@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>>() {
|
||||
|
||||
@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>>>> {
|
||||
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) {
|
||||
this.catalogSupplier = catalogSupplier;
|
||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||
}
|
||||
|
||||
@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>>>() {
|
||||
|
||||
@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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@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);
|
||||
|
@ -464,31 +262,11 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
return factory.create(VCloudVersionsAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected abstract Organization provideOrganization(S client);
|
||||
|
||||
@Provides
|
||||
@VDC
|
||||
@Singleton
|
||||
protected URI provideDefaultVDC(Organization org) {
|
||||
checkState(org.getVDCs().size() > 0, "No vdcs present in org: " + org.getName());
|
||||
return get(org.getVDCs().values(), 0).getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Catalog
|
||||
@Singleton
|
||||
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
|
||||
checkState(org.getCatalogs().size() > 0, "No catalogs present in org: " + org.getName());
|
||||
return get(org.getCatalogs().values(), 0).getId();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@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());
|
||||
}
|
||||
|
||||
|
@ -510,12 +288,4 @@ public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModul
|
|||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TasksList
|
||||
@Singleton
|
||||
protected URI provideDefaultTasksList(Organization org) {
|
||||
checkState(org.getTasksLists().size() > 0, "No tasks lists present in org: " + org.getName());
|
||||
return get(org.getTasksLists().values(), 0).getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* A vCloud organization is a high-level abstraction that provides a unit of
|
||||
* administration for objects and resources. As viewed by a user, an
|
||||
* organization (represented by an Org element) can contain Catalog, Network,
|
||||
* and vDC elements. If there are any queued, running, or recently completed
|
||||
* tasks owned by a member of the organization, it also contains a TasksList
|
||||
* element. As viewed by an administrator, an organization also contains users,
|
||||
* groups, and other information
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ImplementedBy(OrgImpl.class)
|
||||
public interface Org extends NamedResource {
|
||||
|
||||
String getDescription();
|
||||
|
||||
Map<String, NamedResource> getCatalogs();
|
||||
|
||||
Map<String, NamedResource> getVDCs();
|
||||
|
||||
/**
|
||||
* If there are any queued, running, or recently completed tasks owned by a
|
||||
* member of the organization, it also contains a TasksList.
|
||||
*/
|
||||
NamedResource getTasksList();
|
||||
|
||||
Map<String, NamedResource> getNetworks();
|
||||
|
||||
}
|
|
@ -22,27 +22,19 @@ package org.jclouds.vcloud.domain;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
|
||||
import org.jclouds.vcloud.endpoints.Catalog;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.endpoints.VDC;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Org
|
||||
@ImplementedBy(OrganizationImpl.class)
|
||||
public interface Organization extends NamedResource {
|
||||
|
||||
@Catalog
|
||||
Map<String, NamedResource> getCatalogs();
|
||||
|
||||
@VDC
|
||||
Map<String, NamedResource> getVDCs();
|
||||
|
||||
@TasksList
|
||||
Map<String, NamedResource> getTasksLists();
|
||||
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
/**
|
||||
*
|
||||
* 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.internal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
/**
|
||||
* Locations of resources in vCloud
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class OrgImpl implements Org {
|
||||
private final String name;
|
||||
private final URI id;
|
||||
private final String description;
|
||||
private final Map<String, NamedResource> catalogs;
|
||||
private final Map<String, NamedResource> vdcs;
|
||||
private final Map<String, NamedResource> networks;
|
||||
private final NamedResource tasksList;
|
||||
|
||||
public OrgImpl(String name, URI id, String description, Map<String, NamedResource> catalogs,
|
||||
Map<String, NamedResource> vdcs, Map<String, NamedResource> networks, @Nullable NamedResource tasksList) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.description = description;
|
||||
this.catalogs = catalogs;
|
||||
this.vdcs = vdcs;
|
||||
this.networks = networks;
|
||||
this.tasksList = tasksList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, NamedResource> getCatalogs() {
|
||||
return catalogs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, NamedResource> getVDCs() {
|
||||
return vdcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedResource getTasksList() {
|
||||
return tasksList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((networks == null) ? 0 : networks.hashCode());
|
||||
result = prime * result + ((tasksList == null) ? 0 : tasksList.hashCode());
|
||||
result = prime * result + ((vdcs == null) ? 0 : vdcs.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
OrgImpl other = (OrgImpl) obj;
|
||||
if (catalogs == null) {
|
||||
if (other.catalogs != null)
|
||||
return false;
|
||||
} else if (!catalogs.equals(other.catalogs))
|
||||
return false;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (networks == null) {
|
||||
if (other.networks != null)
|
||||
return false;
|
||||
} else if (!networks.equals(other.networks))
|
||||
return false;
|
||||
if (tasksList == null) {
|
||||
if (other.tasksList != null)
|
||||
return false;
|
||||
} else if (!tasksList.equals(other.tasksList))
|
||||
return false;
|
||||
if (vdcs == null) {
|
||||
if (other.vdcs != null)
|
||||
return false;
|
||||
} else if (!vdcs.equals(other.vdcs))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return VCloudMediaType.ORG_XML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NamedResource o) {
|
||||
return (this == o) ? 0 : getId().compareTo(o.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", name=" + name + ", type=" + getType() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, NamedResource> getNetworks() {
|
||||
return networks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
|
@ -25,9 +25,6 @@ import java.util.Map;
|
|||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.endpoints.Catalog;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.endpoints.VDC;
|
||||
|
||||
/**
|
||||
* Locations of resources in vCloud
|
||||
|
@ -42,8 +39,8 @@ public class OrganizationImpl implements Organization {
|
|||
private final Map<String, NamedResource> vdcs;
|
||||
private final Map<String, NamedResource> tasksLists;
|
||||
|
||||
public OrganizationImpl(String name, URI id, Map<String, NamedResource> catalogs,
|
||||
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
|
||||
public OrganizationImpl(String name, URI id, Map<String, NamedResource> catalogs, Map<String, NamedResource> vdcs,
|
||||
Map<String, NamedResource> tasksLists) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.catalogs = catalogs;
|
||||
|
@ -61,20 +58,17 @@ public class OrganizationImpl implements Organization {
|
|||
return id;
|
||||
}
|
||||
|
||||
@Catalog
|
||||
@Override
|
||||
public Map<String, NamedResource> getCatalogs() {
|
||||
return catalogs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@VDC
|
||||
public Map<String, NamedResource> getVDCs() {
|
||||
return vdcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@TasksList
|
||||
public Map<String, NamedResource> getTasksLists() {
|
||||
return tasksLists;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
*
|
||||
* 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 javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class AllCatalogItemsInOrg implements Function<Org, Iterable<? extends CatalogItem>> {
|
||||
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
||||
private final Function<Org, Iterable<? extends Catalog>> allCatalogsInOrg;
|
||||
|
||||
private final Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
|
||||
|
||||
@Inject
|
||||
AllCatalogItemsInOrg(Function<Org, Iterable<? extends Catalog>> allCatalogsInOrg,
|
||||
Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
||||
this.allCatalogsInOrg = allCatalogsInOrg;
|
||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CatalogItem> apply(Org from) {
|
||||
return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
|
||||
new Function<Catalog, Iterable<? extends CatalogItem>>() {
|
||||
@Override
|
||||
public Iterable<? extends CatalogItem> apply(Catalog from) {
|
||||
return allCatalogItemsInCatalog.apply(from);
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
*
|
||||
* 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 org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
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.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class AllCatalogsInOrg implements Function<Org, Iterable<? extends Catalog>> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
||||
private final VCloudAsyncClient aclient;
|
||||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
AllCatalogsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.aclient = aclient;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Catalog> apply(final Org org) {
|
||||
Iterable<Catalog> catalogs = transformParallel(org.getCatalogs().values(),
|
||||
new Function<NamedResource, Future<Catalog>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Future<Catalog> apply(NamedResource from) {
|
||||
return (Future<Catalog>) aclient.getCatalog(from.getId());
|
||||
}
|
||||
|
||||
}, executor, null, logger, "catalogs in " + org.getName());
|
||||
return catalogs;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
*
|
||||
* 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 org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||
|
||||
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.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class AllVDCsInOrg implements Function<Org, Iterable<? extends VDC>> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
||||
private final VCloudAsyncClient aclient;
|
||||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
AllVDCsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.aclient = aclient;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends VDC> apply(final Org org) {
|
||||
|
||||
Iterable<VDC> catalogItems = transformParallel(org.getVDCs().values(),
|
||||
new Function<NamedResource, Future<VDC>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Future<VDC> apply(NamedResource from) {
|
||||
return (Future<VDC>) aclient.getVDC(from.getId());
|
||||
}
|
||||
|
||||
}, executor, null, logger, "vdcs in org " + org.getName());
|
||||
return catalogItems;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,9 +29,8 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.endpoints.Catalog;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -43,13 +42,13 @@ import com.google.common.collect.Iterables;
|
|||
*/
|
||||
@Singleton
|
||||
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, ? extends Organization>> orgMap;
|
||||
private final Supplier<Map<String, ? extends Org>> orgMap;
|
||||
private final String defaultOrg;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, ? extends Organization>> orgMap, @Org String defaultOrg,
|
||||
@Catalog URI defaultUri) {
|
||||
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
|
||||
@org.jclouds.vcloud.endpoints.Org String defaultOrg, @Catalog URI defaultUri) {
|
||||
this.orgMap = orgMap;
|
||||
this.defaultOrg = defaultOrg;
|
||||
this.defaultUri = defaultUri;
|
||||
|
|
|
@ -29,8 +29,7 @@ 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.domain.Org;
|
||||
import org.jclouds.vcloud.endpoints.VDC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -43,13 +42,13 @@ import com.google.common.collect.Iterables;
|
|||
*/
|
||||
@Singleton
|
||||
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, ? extends Organization>> orgNameToVDCEndpoint;
|
||||
private final Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint;
|
||||
private final String defaultOrg;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, ? extends Organization>> orgNameToVDCEndpoint,
|
||||
@Org String defaultOrg, @VDC URI defaultUri) {
|
||||
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint,
|
||||
@org.jclouds.vcloud.endpoints.Org String defaultOrg, @VDC URI defaultUri) {
|
||||
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
||||
this.defaultOrg = defaultOrg;
|
||||
this.defaultUri = defaultUri;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
*
|
||||
* 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.Org;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, ? extends Org>> orgMap;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrgNameToTasksListEndpoint(Supplier<Map<String, ? extends Org>> orgMap, @TasksList URI defaultUri) {
|
||||
this.orgMap = orgMap;
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
||||
|
||||
public URI apply(Object from) {
|
||||
Object org = checkNotNull(from, "args");
|
||||
if (org == null)
|
||||
return defaultUri;
|
||||
|
||||
try {
|
||||
return checkNotNull(orgMap.get().get(org)).getTasksList().getId();
|
||||
} catch (NullPointerException e) {
|
||||
throw new NoSuchElementException(org + " 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.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 OrganizationNameAndCatalogNameToEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, ? extends Organization>> orgMap;
|
||||
private final String defaultOrg;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrganizationNameAndCatalogNameToEndpoint(Supplier<Map<String, ? extends 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()).getId() : catalogs.get(catalog).getId();
|
||||
} catch (NullPointerException e) {
|
||||
throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -42,13 +42,13 @@ import com.google.common.collect.Iterables;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrgNameAndTasksListNameToEndpoint implements Function<Object, URI> {
|
||||
public class OrganizationNameAndTasksListNameToEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, ? extends Organization>> orgMap;
|
||||
private final String defaultOrg;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrgNameAndTasksListNameToEndpoint(Supplier<Map<String, ? extends Organization>> orgMap,
|
||||
public OrganizationNameAndTasksListNameToEndpoint(Supplier<Map<String, ? extends Organization>> orgMap,
|
||||
@Org String defaultOrg, @TasksList URI defaultUri) {
|
||||
this.orgMap = orgMap;
|
||||
this.defaultOrg = defaultOrg;
|
|
@ -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.VDC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrganizationNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, ? extends Organization>> orgNameToVDCEndpoint;
|
||||
private final String defaultOrg;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrganizationNameAndVDCNameToEndpoint(Supplier<Map<String, ? extends Organization>> orgNameToVDCEndpoint,
|
||||
@Org String defaultOrg, @VDC URI defaultUri) {
|
||||
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
||||
this.defaultOrg = defaultOrg;
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public URI apply(Object from) {
|
||||
Iterable<Object> orgVdc = (Iterable<Object>) checkNotNull(from, "args");
|
||||
Object org = Iterables.get(orgVdc, 0);
|
||||
Object vdc = Iterables.get(orgVdc, 1);
|
||||
if (org == null && vdc == null)
|
||||
return defaultUri;
|
||||
else if (org == null)
|
||||
org = defaultOrg;
|
||||
|
||||
try {
|
||||
Map<String, NamedResource> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();
|
||||
return vdc == null ? Iterables.getLast(vdcs.values()).getId() : vdcs.get(vdc).getId();
|
||||
} catch (NullPointerException e) {
|
||||
throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ import org.jclouds.domain.LocationScope;
|
|||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
|
@ -49,8 +49,7 @@ import com.google.common.collect.Sets;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrganizatonsForLocations implements
|
||||
Function<Iterable<? extends Location>, Iterable<? extends Organization>> {
|
||||
public class OrgsForLocations implements Function<Iterable<? extends Location>, Iterable<? extends Org>> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
@ -58,7 +57,7 @@ public class OrganizatonsForLocations implements
|
|||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
OrganizatonsForLocations(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
OrgsForLocations(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.aclient = aclient;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
@ -68,7 +67,7 @@ public class OrganizatonsForLocations implements
|
|||
* parent is region. then, we use a set to extract the unique set.
|
||||
*/
|
||||
@Override
|
||||
public Iterable<? extends Organization> apply(Iterable<? extends Location> from) {
|
||||
public Iterable<? extends Org> apply(Iterable<? extends Location> from) {
|
||||
|
||||
return transformParallel(Sets.newLinkedHashSet(transform(filter(from, new Predicate<Location>() {
|
||||
|
||||
|
@ -84,12 +83,12 @@ public class OrganizatonsForLocations implements
|
|||
return VCloudLocation.class.cast(from.getParent()).getResource().getId();
|
||||
}
|
||||
|
||||
})), new Function<URI, Future<Organization>>() {
|
||||
})), new Function<URI, Future<Org>>() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Future<Organization> apply(URI from) {
|
||||
return (Future<Organization>) aclient.getOrganization(from);
|
||||
public Future<Org> apply(URI from) {
|
||||
return (Future<Org>) aclient.getOrg(from);
|
||||
}
|
||||
|
||||
}, executor, null, logger, "organizations for uris");
|
|
@ -33,7 +33,7 @@ import org.jclouds.Constants;
|
|||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -41,7 +41,7 @@ import com.google.common.base.Function;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrganizationsForNames implements Function<Iterable<String>, Iterable<? extends Organization>> {
|
||||
public class OrgsForNames implements Function<Iterable<String>, Iterable<? extends Org>> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
|
@ -49,19 +49,19 @@ public class OrganizationsForNames implements Function<Iterable<String>, Iterabl
|
|||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
OrganizationsForNames(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
OrgsForNames(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.aclient = aclient;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Organization> apply(Iterable<String> from) {
|
||||
return transformParallel(from, new Function<String, Future<Organization>>() {
|
||||
public Iterable<? extends Org> apply(Iterable<String> from) {
|
||||
return transformParallel(from, new Function<String, Future<Org>>() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Future<Organization> apply(String from) {
|
||||
return (Future<Organization>) aclient.findOrganizationNamed(from);
|
||||
public Future<Org> apply(String from) {
|
||||
return (Future<Org>) aclient.findOrgNamed(from);
|
||||
}
|
||||
|
||||
}, executor, null, logger, "organizations for names");
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.VDC_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||
import static org.jclouds.vcloud.util.Utils.newNamedResource;
|
||||
import static org.jclouds.vcloud.util.Utils.putNamedResource;
|
||||
|
||||
|
@ -29,8 +30,8 @@ import java.util.Map;
|
|||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
@ -39,14 +40,19 @@ import com.google.common.collect.Maps;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
|
||||
public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected NamedResource org;
|
||||
protected Map<String, NamedResource> vdcs = Maps.newLinkedHashMap();
|
||||
protected Map<String, NamedResource> tasksLists = Maps.newLinkedHashMap();
|
||||
protected NamedResource tasksList;
|
||||
protected Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
|
||||
protected Map<String, NamedResource> networks = Maps.newLinkedHashMap();
|
||||
|
||||
public Organization getResult() {
|
||||
return new OrganizationImpl(org.getName(), org.getId(), catalogs, vdcs, tasksLists);
|
||||
private String description;
|
||||
|
||||
public Org getResult() {
|
||||
return new OrgImpl(org.getName(), org.getId(), description, catalogs, vdcs, networks, tasksList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,9 +67,27 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
|
|||
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
|
||||
putNamedResource(catalogs, attributes);
|
||||
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) {
|
||||
putNamedResource(tasksLists, attributes);
|
||||
tasksList = newNamedResource(attributes);
|
||||
} else if (attributes.getValue(typeIndex).equals(NETWORK_XML)) {
|
||||
putNamedResource(networks, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("Description")) {
|
||||
description = currentOrNull();
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
*
|
||||
* 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.xml;
|
||||
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.VDC_XML;
|
||||
import static org.jclouds.vcloud.util.Utils.newNamedResource;
|
||||
import static org.jclouds.vcloud.util.Utils.putNamedResource;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OrganizationHandler extends ParseSax.HandlerWithResult<Organization> {
|
||||
protected NamedResource org;
|
||||
protected Map<String, NamedResource> vdcs = Maps.newLinkedHashMap();
|
||||
protected Map<String, NamedResource> tasksLists = Maps.newLinkedHashMap();
|
||||
protected Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
|
||||
|
||||
public Organization getResult() {
|
||||
return new OrganizationImpl(org.getName(), org.getId(), catalogs, vdcs, tasksLists);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
if (qName.equals("Org")) {
|
||||
org = newNamedResource(attributes);
|
||||
} else if (qName.equals("Link")) {
|
||||
int typeIndex = attributes.getIndex("type");
|
||||
if (typeIndex != -1) {
|
||||
if (attributes.getValue(typeIndex).equals(VDC_XML)) {
|
||||
putNamedResource(vdcs, attributes);
|
||||
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
|
||||
putNamedResource(catalogs, attributes);
|
||||
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) {
|
||||
putNamedResource(tasksLists, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,13 +50,12 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
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.OrganizationImpl;
|
||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
||||
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;
|
||||
|
@ -90,16 +89,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);
|
||||
|
@ -109,20 +108,19 @@ 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);
|
||||
|
@ -133,26 +131,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);
|
||||
|
@ -163,17 +161,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);
|
||||
|
@ -182,25 +180,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDefaultOrganization() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultOrganization");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testOrganization() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getOrganization", URI.class);
|
||||
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");
|
||||
|
@ -213,8 +196,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testFindOrganizationNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("findOrganizationNamed", String.class);
|
||||
public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("findOrgNamed", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
|
||||
|
@ -228,25 +211,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDefaultCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultCatalog");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog 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, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -277,7 +245,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");
|
||||
|
@ -293,7 +261,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");
|
||||
|
@ -308,7 +276,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");
|
||||
|
@ -324,7 +292,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");
|
||||
|
@ -341,7 +309,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");
|
||||
|
@ -354,21 +322,6 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testGetDefaultVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultVDC");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
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");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc");
|
||||
|
@ -429,7 +382,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");
|
||||
|
@ -442,25 +395,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/taskslist 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, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -474,8 +412,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
}
|
||||
|
||||
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "tasksList");
|
||||
Method method = VCloudAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org");
|
||||
|
||||
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");
|
||||
|
@ -491,7 +429,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");
|
||||
|
@ -507,7 +445,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");
|
||||
|
@ -523,10 +461,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);
|
||||
|
||||
|
@ -540,7 +478,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, "");
|
||||
|
@ -556,10 +494,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);
|
||||
|
||||
|
@ -573,10 +511,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);
|
||||
|
||||
|
@ -590,10 +528,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);
|
||||
|
||||
|
@ -607,10 +545,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);
|
||||
|
||||
|
@ -624,10 +562,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);
|
||||
|
||||
|
@ -641,7 +579,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");
|
||||
|
@ -657,7 +595,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, "");
|
||||
|
@ -699,29 +637,29 @@ 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");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
|
||||
protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable<NamedResource> orgs) {
|
||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/org");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideOrgName(@Org Iterable<NamedResource> orgs) {
|
||||
protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable<NamedResource> orgs) {
|
||||
return "org";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
|
||||
protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user) {
|
||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Organization provideOrganization(VCloudClient discovery) {
|
||||
protected Org provideOrg(VCloudClient discovery) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -731,12 +669,12 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultTasksList(Organization org) {
|
||||
protected URI provideDefaultTasksList(Org org) {
|
||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/taskslist");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultVDC(Organization org) {
|
||||
protected URI provideDefaultVDC(Org org) {
|
||||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1");
|
||||
}
|
||||
|
||||
|
@ -747,13 +685,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
|
||||
|
@ -768,138 +706,86 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(OrganizationMapSupplier.class).to(TestOrganizationMapSupplier.class);
|
||||
bind(OrganizationCatalogSupplier.class).to(TestOrganizationCatalogSupplier.class);
|
||||
bind(OrganizationCatalogItemSupplier.class).to(TestOrganizationCatalogItemSupplier.class);
|
||||
bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class);
|
||||
bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class);
|
||||
bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class);
|
||||
}
|
||||
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationVDCSupplier supplier) {
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@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))));
|
||||
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class TestOrganizationMapSupplier extends OrganizationMapSupplier {
|
||||
public static class TestOrgMapSupplier extends OrgMapSupplier {
|
||||
@Inject
|
||||
protected TestOrganizationMapSupplier() {
|
||||
protected TestOrgMapSupplier() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Organization> get() {
|
||||
return ImmutableMap.<String, Organization> of("org", new OrganizationImpl("org", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), 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("tasksList", new NamedResourceImpl("tasksList",
|
||||
VCloudMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")))));
|
||||
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"))));
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class TestOrganizationCatalogSupplier extends OrganizationCatalogSupplier {
|
||||
public static class TestOrgCatalogSupplier extends OrgCatalogSupplier {
|
||||
@Inject
|
||||
protected TestOrganizationCatalogSupplier() {
|
||||
protected TestOrgCatalogSupplier() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@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"))))));
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class TestOrganizationCatalogItemSupplier extends OrganizationCatalogItemSupplier {
|
||||
protected TestOrganizationCatalogItemSupplier() {
|
||||
public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier {
|
||||
protected TestOrgCatalogItemSupplier() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@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()))));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.vcloud.domain.Catalog;
|
|||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
|
@ -56,14 +56,14 @@ public class VCloudClientLiveTest {
|
|||
private String credential;
|
||||
|
||||
@Test
|
||||
public void testOrganization() throws Exception {
|
||||
Organization response = connection.findOrganizationNamed(null);
|
||||
public void testOrg() throws Exception {
|
||||
Org response = connection.findOrgNamed(null);
|
||||
assertNotNull(response);
|
||||
assertNotNull(response.getName());
|
||||
assert response.getCatalogs().size() >= 1;
|
||||
assert response.getTasksLists().size() >= 1;
|
||||
assert response.getTasksList() != null;
|
||||
assert response.getVDCs().size() >= 1;
|
||||
assertEquals(connection.findOrganizationNamed(response.getName()), response);
|
||||
assertEquals(connection.findOrgNamed(response.getName()), response);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -127,7 +127,7 @@ public class VCloudClientLiveTest {
|
|||
|
||||
@Test
|
||||
public void testDefaultTasksList() throws Exception {
|
||||
org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null, null);
|
||||
org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null);
|
||||
assertNotNull(response);
|
||||
assertNotNull(response.getLocation());
|
||||
assertNotNull(response.getTasks());
|
||||
|
@ -136,7 +136,7 @@ public class VCloudClientLiveTest {
|
|||
|
||||
@Test
|
||||
public void testGetTask() throws Exception {
|
||||
org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null, null);
|
||||
org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null);
|
||||
assertNotNull(response);
|
||||
assertNotNull(response.getLocation());
|
||||
assertNotNull(response.getTasks());
|
||||
|
@ -167,7 +167,7 @@ public class VCloudClientLiveTest {
|
|||
setupCredentials();
|
||||
Properties props = new Properties();
|
||||
context = new RestContextFactory().createContext("vcloud", identity, credential, ImmutableSet
|
||||
.<Module> of(new Log4JLoggingModule()), props);
|
||||
.<Module> of(new Log4JLoggingModule()), props);
|
||||
|
||||
connection = context.getApi();
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||
import org.jclouds.vcloud.xml.NetworkHandler;
|
||||
import org.jclouds.vcloud.xml.OrgHandler;
|
||||
import org.jclouds.vcloud.xml.OrganizationHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
@ -191,7 +191,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
||||
assertSaxResponseParserClassEquals(method, OrganizationHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
|
@ -207,7 +207,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
||||
assertSaxResponseParserClassEquals(method, OrganizationHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
@ -222,7 +222,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
||||
assertSaxResponseParserClassEquals(method, OrganizationHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -29,8 +29,8 @@ import java.net.URI;
|
|||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -52,34 +52,22 @@ public class OrgHandlerTest {
|
|||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
|
||||
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "adrian@jclouds.org");
|
||||
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
|
||||
assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog", new NamedResourceImpl(
|
||||
"Miami Environment 1 Catalog", CATALOG_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))));
|
||||
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedResourceImpl(
|
||||
"Miami Environment 1", VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
|
||||
assertEquals(result.getTasksLists(), ImmutableMap.of("Miami Environment 1 Tasks List", new NamedResourceImpl(
|
||||
"Miami Environment 1 Tasks List", TASKSLIST_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32"))));
|
||||
Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "ExampleOrg");
|
||||
assertEquals(result.getDescription(), "Example Corp's Primary Organization.");
|
||||
assertEquals(result.getId(), URI.create("http://vcloud.example.com/api/v1.0/org/5"));
|
||||
assertEquals(result.getCatalogs(), ImmutableMap.of("Main Catalog", new NamedResourceImpl("Main Catalog",
|
||||
CATALOG_XML, URI.create("http://vcloud.example.com/api/v1.0/catalog/32")), "Shared Catalog",
|
||||
new NamedResourceImpl("Shared Catalog", CATALOG_XML, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/catalog/37"))));
|
||||
assertEquals(result.getVDCs(), ImmutableMap.of("ExampleVdc01", new NamedResourceImpl("ExampleVdc01",
|
||||
VCloudMediaType.VDC_XML, URI.create("http://vcloud.example.com/api/v1.0/vdc/5"))));
|
||||
assertEquals(result.getNetworks(), ImmutableMap.of("TestNetwork", new NamedResourceImpl("TestNetwork",
|
||||
VCloudMediaType.NETWORK_XML, URI.create("http://vcloud.example.com/api/v1.0/network/14")),
|
||||
"ProductionNetwork", new NamedResourceImpl("ProductionNetwork", VCloudMediaType.NETWORK_XML, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/network/54"))));
|
||||
assertEquals(result.getTasksList(), new NamedResourceImpl(null, TASKSLIST_XML, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/tasksList/5")));
|
||||
}
|
||||
|
||||
public void testHosting() {
|
||||
InputStream is = getClass().getResourceAsStream("/org-hosting.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "Customer 188849");
|
||||
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
|
||||
assertEquals(result.getCatalogs(), ImmutableMap.of("HMS Shared Catalog", new NamedResourceImpl(
|
||||
"HMS Shared Catalog", CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
|
||||
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", new NamedResourceImpl(
|
||||
"188849 Virtual DataCenter", VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
|
||||
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List",
|
||||
new NamedResourceImpl("188849 Task List", TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
*
|
||||
* 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.xml;
|
||||
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.Organization;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code OrgHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.OrgHandlerTest")
|
||||
public class OrganizationHandlerTest {
|
||||
|
||||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/express/org.xml");
|
||||
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
|
||||
Organization result = (Organization) factory.create(injector.getInstance(OrganizationHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "adrian@jclouds.org");
|
||||
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
|
||||
assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog", new NamedResourceImpl(
|
||||
"Miami Environment 1 Catalog", CATALOG_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))));
|
||||
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedResourceImpl(
|
||||
"Miami Environment 1", VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
|
||||
assertEquals(result.getTasksLists(), ImmutableMap.of("Miami Environment 1 Tasks List", new NamedResourceImpl(
|
||||
"Miami Environment 1 Tasks List", TASKSLIST_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32"))));
|
||||
}
|
||||
|
||||
public void testHosting() {
|
||||
InputStream is = getClass().getResourceAsStream("/express/org-hosting.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
Organization result = (Organization) factory.create(injector.getInstance(OrganizationHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "Customer 188849");
|
||||
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
|
||||
assertEquals(result.getCatalogs(), ImmutableMap.of("HMS Shared Catalog", new NamedResourceImpl(
|
||||
"HMS Shared Catalog", CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
|
||||
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", new NamedResourceImpl(
|
||||
"188849 Virtual DataCenter", VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
|
||||
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List",
|
||||
new NamedResourceImpl("188849 Task List", TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"))));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<Org href="https://services.vcloudexpress.terremark.com/api/v0.8/org/48" name="adrian@jclouds.org" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32" type="application/vnd.vmware.vcloud.vdc+xml" name="Miami Environment 1"/>
|
||||
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1 Catalog"/>
|
||||
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32" type="application/vnd.vmware.vcloud.tasksList+xml" name="Miami Environment 1 Tasks List"/>
|
||||
</Org>
|
|
@ -1,5 +1,24 @@
|
|||
<Org href="https://services.vcloudexpress.terremark.com/api/v0.8/org/48" name="adrian@jclouds.org" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32" type="application/vnd.vmware.vcloud.vdc+xml" name="Miami Environment 1"/>
|
||||
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1 Catalog"/>
|
||||
<Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32" type="application/vnd.vmware.vcloud.tasksList+xml" name="Miami Environment 1 Tasks List"/>
|
||||
<Org name="ExampleOrg" type="application/vnd.vmware.vcloud.org+xml"
|
||||
href="http://vcloud.example.com/api/v1.0/org/5" >
|
||||
<Link type="application/vnd.vmware.vcloud.catalog+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/catalog/32" name="Main Catalog" />
|
||||
<Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/catalog/32/controlAccess" />
|
||||
<Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="controlAccess"
|
||||
href="http://vcloud.example.com/api/v1.0/catalog/32/action/controlAccess" />
|
||||
<Link type="application/vnd.vmware.vcloud.catalog+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/catalog/37" name="Shared Catalog" />
|
||||
<Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/catalog/37/controlAccess" />
|
||||
<Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="controlAccess"
|
||||
href="http://vcloud.example.com/api/v1.0/catalog/37/action/controlAccess" />
|
||||
<Link type="application/vnd.vmware.vcloud.vdc+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/vdc/5" name="ExampleVdc01" />
|
||||
<Link type="application/vnd.vmware.vcloud.tasksList+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/tasksList/5" />
|
||||
<Link type="application/vnd.vmware.vcloud.network+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/network/14" name="TestNetwork" />
|
||||
<Link type="application/vnd.vmware.vcloud.network+xml" rel="down"
|
||||
href="http://vcloud.example.com/api/v1.0/network/54" name="ProductionNetwork" />
|
||||
<Description>Example Corp's Primary Organization.</Description>
|
||||
</Org>
|
|
@ -64,7 +64,7 @@ import org.jclouds.vcloud.domain.VApp;
|
|||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrganizationNameAndVDCNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
@ -198,8 +198,8 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient {
|
|||
@Consumes(VDC_XML)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends VDC> findVDCInOrgNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrganizationNameAndVDCNameToEndpoint.class) String vdcName);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#instantiateVAppTemplateInVDC
|
||||
|
|
|
@ -25,14 +25,14 @@ import static org.jclouds.vcloud.util.Utils.newNamedResource;
|
|||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
||||
import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrganizationImpl;
|
||||
import org.jclouds.vcloud.xml.OrgHandler;
|
||||
import org.jclouds.vcloud.xml.OrganizationHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class TerremarkOrgHandler extends OrgHandler {
|
||||
public class TerremarkOrgHandler extends OrganizationHandler {
|
||||
|
||||
private NamedResource keysList;
|
||||
|
||||
|
|
Loading…
Reference in New Issue