Issue 830: refactored MediaClient to not require href arg; refactored VmApi, VAppApi, VAppTemplateApi to use urn

This commit is contained in:
Adrian Cole 2012-08-19 18:48:58 -07:00
parent cd0aa72ae1
commit 169006b3ed
53 changed files with 2796 additions and 1679 deletions

View File

@ -43,6 +43,7 @@
<!-- URN format: ex. urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4 --> <!-- URN format: ex. urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4 -->
<test.vcloud-director.catalog-id></test.vcloud-director.catalog-id> <test.vcloud-director.catalog-id></test.vcloud-director.catalog-id>
<test.vcloud-director.media-id></test.vcloud-director.media-id> <test.vcloud-director.media-id></test.vcloud-director.media-id>
<!-- URN format: ex. urn:vcloud:vapptemplate:7212e451-76e1-4631-b2de-ba1dfd8080e4 -->
<test.vcloud-director.vapptemplate-id></test.vcloud-director.vapptemplate-id> <test.vcloud-director.vapptemplate-id></test.vcloud-director.vapptemplate-id>
<!-- URN format: ex. urn:vcloud:network:7212e451-76e1-4631-b2de-ba1dfd8080e4 --> <!-- URN format: ex. urn:vcloud:network:7212e451-76e1-4631-b2de-ba1dfd8080e4 -->
<test.vcloud-director.network-id></test.vcloud-director.network-id> <test.vcloud-director.network-id></test.vcloud-director.network-id>

View File

@ -23,9 +23,12 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.functions.href.CatalogItemURNToHref;
import org.jclouds.vcloud.director.v1_5.functions.href.CatalogURNToHref;
/** /**
* Provides synchronous access to {@link Catalog} objects. * Provides synchronous access to {@link Catalog} objects.
@ -118,12 +121,18 @@ public interface CatalogApi {
* @return synchronous access to {@link Metadata.Readable} features * @return synchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataApi.Readable getMetadataApi(); MetadataApi.Readable getMetadataApi(@EndpointParam(parser = CatalogURNToHref.class) String catalogUrn);
@Delegate
MetadataApi.Readable getMetadataApi(@EndpointParam URI catalogItemHref);
/** /**
* @return synchronous access to {@link Metadata.Writeable} features for CatalogItems * @return synchronous access to {@link Metadata.Writeable} features for CatalogItems
*/ */
@Delegate @Delegate
MetadataApi.Writeable getItemMetadataApi(); MetadataApi.Writeable getItemMetadataApi(@EndpointParam(parser = CatalogItemURNToHref.class) String catalogItemUrn);
@Delegate
MetadataApi.Writeable getItemMetadataApi(@EndpointParam URI catalogItemHref);
} }

View File

@ -151,11 +151,18 @@ public interface CatalogAsyncApi {
* @return asynchronous access to {@link Metadata.Readable} features * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Readable getMetadataApi(); MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = CatalogURNToHref.class) String catalogUrn);
@Delegate
MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI catalogItemHref);
/** /**
* @see CatalogApi#getItemMetadataApi * @see CatalogApi#getItemMetadataApi
*/ */
@Delegate @Delegate
MetadataAsyncApi.Writeable getItemMetadataApi(); MetadataAsyncApi.Writeable getItemMetadataApi(@EndpointParam(parser = CatalogItemURNToHref.class) String catalogItemUrn);
@Delegate
MetadataAsyncApi.Writeable getItemMetadataApi(@EndpointParam URI catalogItemHref);
} }

View File

@ -23,10 +23,13 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.functions.href.MediaURNToHref;
/** /**
* Provides synchronous access to {@link Media}. * Provides synchronous access to {@link Media}.
@ -84,6 +87,9 @@ public interface MediaApi {
* @return synchronous access to {@link Metadata.Writeable} features * @return synchronous access to {@link Metadata.Writeable} features
*/ */
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = MediaURNToHref.class) String mediaUrn);
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI mediaUri);
} }

View File

@ -38,10 +38,12 @@ import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.director.v1_5.functions.href.MediaURNToHref;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -114,5 +116,8 @@ public interface MediaAsyncApi {
* @return asynchronous access to {@link Metadata.Writeable} features * @return asynchronous access to {@link Metadata.Writeable} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = MediaURNToHref.class) String mediaUrn);
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI uri);
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
@ -41,14 +40,14 @@ public interface MetadataApi {
* *
* @return a list of metadata * @return a list of metadata
*/ */
Metadata get(URI uri); Metadata get();
/** /**
* Retrieves a metadata value * Retrieves a metadata value
* *
* @return the metadata value, or null if not found * @return the metadata value, or null if not found
*/ */
MetadataValue getValue(URI uri, String key); MetadataValue getValue(String key);
} }
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
@ -60,7 +59,7 @@ public interface MetadataApi {
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task merge(URI uri, Metadata metadata); Task merge(Metadata metadata);
/** /**
* Sets the metadata for the particular key for the media to the value provided. Note: this * Sets the metadata for the particular key for the media to the value provided. Note: this
@ -69,7 +68,7 @@ public interface MetadataApi {
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task putEntry(URI uri, String key, MetadataValue metadataValue); Task putEntry(String key, MetadataValue metadataValue);
/** /**
* Deletes a metadata entry. * Deletes a metadata entry.
@ -77,7 +76,7 @@ public interface MetadataApi {
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task removeEntry(URI uri, String key); Task removeEntry(String key);
} }
} }

View File

@ -30,7 +30,6 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
@ -38,6 +37,7 @@ import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
@ -48,7 +48,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see MetadataApi * @see MetadataApi
* @author danikov * @author danikov
*/ */
//TODO: take out the endpoint params and supply them in the Delegate calls. // TODO: take out the endpoint params and supply them in the Delegate calls.
public interface MetadataAsyncApi { public interface MetadataAsyncApi {
@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
@ -62,17 +62,17 @@ public interface MetadataAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Metadata> get(@EndpointParam URI metaDataUri); ListenableFuture<Metadata> get();
/** /**
* @see MetadataApi.Readable#getValue(URI, String) * @see MetadataApi.Readable#getValue(String)
*/ */
@GET @GET
@Path("/metadata/{key}") @Path("/metadata/{key}")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<MetadataValue> getValue(@EndpointParam URI metaDataUri, @PathParam("key") String key); ListenableFuture<MetadataValue> getValue(@PathParam("key") String key);
} }
@ -80,18 +80,17 @@ public interface MetadataAsyncApi {
public static interface Writeable extends Readable { public static interface Writeable extends Readable {
/** /**
* @see MetadataApi.Writable#merge(URI, Metadata)) * @see MetadataApi.Writable#merge(Metadata)
*/ */
@POST @POST
@Path("/metadata") @Path("/metadata")
@Consumes(VCloudDirectorMediaType.TASK) @Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA) @Produces(VCloudDirectorMediaType.METADATA)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> merge(@EndpointParam URI metaDataUri, ListenableFuture<Task> merge(@BinderParam(BindToXMLPayload.class) Metadata metadata);
@BinderParam(BindToXMLPayload.class) Metadata metadata);
/** /**
* @see MetadataApi.Writeable#putEntry(URI, String, MetadataEntry)) * @see MetadataApi.Writeable#putEntry(String, MetadataEntry)
*/ */
@PUT @PUT
@Path("/metadata/{key}") @Path("/metadata/{key}")
@ -99,17 +98,17 @@ public interface MetadataAsyncApi {
@Produces(VCloudDirectorMediaType.METADATA_VALUE) @Produces(VCloudDirectorMediaType.METADATA_VALUE)
@JAXBResponseParser @JAXBResponseParser
// TODO: this is rediculous. get rid of the MetadataValue type, as it is only a string! // TODO: this is rediculous. get rid of the MetadataValue type, as it is only a string!
ListenableFuture<Task> putEntry(@EndpointParam URI metaDataUri, @PathParam("key") String key, ListenableFuture<Task> putEntry(@PathParam("key") String key,
@BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue);
/** /**
* @see MetadataApi.Writable#removeEntry(URI, String)) * @see MetadataApi.Writable#removeEntry(String)
*/ */
@DELETE @DELETE
@Path("/metadata/{key}") @Path("/metadata/{key}")
@Consumes(VCloudDirectorMediaType.TASK) @Consumes(VCloudDirectorMediaType.TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> removeEntry(@EndpointParam URI metaDataUri, @PathParam("key") String key); ListenableFuture<Task> removeEntry(@PathParam("key") String key);
} }
} }

View File

@ -23,8 +23,10 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.domain.network.Network;
import org.jclouds.vcloud.director.v1_5.functions.href.NetworkURNToHref;
/** /**
* Provides synchronous access to {@link Network}. * Provides synchronous access to {@link Network}.
@ -48,5 +50,8 @@ public interface NetworkApi {
* @return synchronous access to {@link Metadata.Readable} features * @return synchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataApi.Readable getMetadataApi(); MetadataApi.Readable getMetadataApi(@EndpointParam(parser = NetworkURNToHref.class) String networkUrn);
@Delegate
MetadataApi.Readable getMetadataApi(@EndpointParam URI networkHref);
} }

View File

@ -65,6 +65,9 @@ public interface NetworkAsyncApi {
* @return asynchronous access to {@link Metadata.Readable} features * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Readable getMetadataApi(); MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = NetworkURNToHref.class) String networkUrn);
@Delegate
MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI networkHref);
} }

View File

@ -23,9 +23,11 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.org.Org; import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; import org.jclouds.vcloud.director.v1_5.domain.org.OrgList;
import org.jclouds.vcloud.director.v1_5.functions.href.OrgURNToHref;
/** /**
* Provides synchronous access to {@link Org}. * Provides synchronous access to {@link Org}.
@ -64,5 +66,9 @@ public interface OrgApi {
* @return synchronous access to {@link Metadata.Readable} features * @return synchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataApi.Readable getMetadataApi(); MetadataApi.Readable getMetadataApi(@EndpointParam(parser = OrgURNToHref.class) String orgUrn);
@Delegate
MetadataApi.Readable getMetadataApi(@EndpointParam URI orgHref);
} }

View File

@ -76,5 +76,9 @@ public interface OrgAsyncApi {
* @return asynchronous access to {@link Metadata.Readable} features * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Readable getMetadataApi(); MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = OrgURNToHref.class) String orgUrn);
@Delegate
MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI orgHref);
} }

View File

@ -25,6 +25,7 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.dmtf.ovf.StartupSection;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
@ -36,11 +37,12 @@ import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.functions.href.VAppURNToHref;
/** /**
* Provides synchronous access to {@link VApp} objects. * Provides synchronous access to {@link VApp} objects.
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org, Adrian Cole
* @see VAppAsyncApi * @see VAppAsyncApi
* @version 1.5 * @version 1.5
*/ */
@ -52,33 +54,38 @@ public interface VAppApi {
* *
* The {@link VApp} could be in one of these statuses: * The {@link VApp} could be in one of these statuses:
* <ul> * <ul>
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION FAILED_CREATION(-1)} - * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION
* Transient entity state, e.g., model object is addd but the corresponding VC backing does not * FAILED_CREATION(-1)} - Transient entity state, e.g., model object is addd but the
* exist yet. This is further sub-categorized in the respective entities. * corresponding VC backing does not exist yet. This is further sub-categorized in the respective
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED UNRESOLVED(0)} - * entities.
* Entity is whole, e.g., VM creation is complete and all the required model objects and VC backings are * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED
* created. * UNRESOLVED(0)} - Entity is whole, e.g., VM creation is complete and all the required model
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED RESOLVED(1)} - * objects and VC backings are created.
* Entity is resolved. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#DEPLOYED DEPLOYED(2)} - * RESOLVED(1)} - Entity is resolved.
* Entity is deployed. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#DEPLOYED
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#SUSPENDED SUSPENDED(3)} - * DEPLOYED(2)} - Entity is deployed.
* All VMs of the vApp are suspended. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#SUSPENDED
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_ON POWERED_ON(4)} - * SUSPENDED(3)} - All VMs of the vApp are suspended.
* All VMs of the vApp are powered on. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_ON
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#WAITING_FOR_INPUT WAITING_FOR_INPUT(5)} - * POWERED_ON(4)} - All VMs of the vApp are powered on.
* VM is pending response on a question. * <li>
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN UNKNOWN(6)} - * {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#WAITING_FOR_INPUT
* Entity state could not be retrieved from the inventory, e.g., VM power state is null. * WAITING_FOR_INPUT(5)} - VM is pending response on a question.
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRECOGNIZED UNRECOGNIZED(7)} - * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN
* Entity state was retrieved from the inventory but could not be mapped to an internal state. * UNKNOWN(6)} - Entity state could not be retrieved from the inventory, e.g., VM power state is
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF POWERED_OFF(8)} - * null.
* All VMs of the vApp are powered off. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRECOGNIZED
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#INCONSISTENT_STATE INCONSISTENT_STATE(9)} - * UNRECOGNIZED(7)} - Entity state was retrieved from the inventory but could not be mapped to an
* Apply to VM status, if a vm is {@code POWERED_ON}, or {@code WAITING_FOR_INPUT}, but is * internal state.
* undeployed, it is in an inconsistent state. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} - * POWERED_OFF(8)} - All VMs of the vApp are powered off.
* vApp status is set to {@code MIXED} when the VMs in the vApp are in different power states * <li>
* {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#INCONSISTENT_STATE
* INCONSISTENT_STATE(9)} - Apply to VM status, if a vm is {@code POWERED_ON}, or
* {@code WAITING_FOR_INPUT}, but is undeployed, it is in an inconsistent state.
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)}
* - vApp status is set to {@code MIXED} when the VMs in the vApp are in different power states
* </ul> * </ul>
* *
* <pre> * <pre>
@ -87,7 +94,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
VApp getVApp(URI vAppURI); VApp get(String vAppUrn);
VApp get(URI vAppHref);
/** /**
* Modifies the name/description of a {@link VApp}. * Modifies the name/description of a {@link VApp}.
@ -98,7 +107,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editVApp(URI vAppURI, VApp vApp); Task edit(String vAppUrn, VApp vApp);
Task edit(URI vAppHref, VApp vApp);
/** /**
* Deletes a {@link VApp}. * Deletes a {@link VApp}.
@ -109,7 +120,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task removeVApp(URI vAppURI); Task remove(String vAppUrn);
Task remove(URI vAppHref);
/** /**
* Modifies the control access of a {@link VApp}. * Modifies the control access of a {@link VApp}.
@ -120,16 +133,17 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
ControlAccessParams editControlAccess(URI vAppURI, ControlAccessParams params); ControlAccessParams editControlAccess(String vAppUrn, ControlAccessParams params);
ControlAccessParams editControlAccess(URI vAppHref, ControlAccessParams params);
/** /**
* Deploys a {@link VApp}. * Deploys a {@link VApp}.
* *
* Deployment means allocation of all resource for a vApp/VM like CPU and memory * Deployment means allocation of all resource for a vApp/VM like CPU and memory from a vDC
* from a vDC resource pool. Deploying a vApp automatically deploys all of the * resource pool. Deploying a vApp automatically deploys all of the virtual machines it contains.
* virtual machines it contains. As of version 1.5 the operation supports force * As of version 1.5 the operation supports force customization passed with
* customization passed with {@link DeployVAppParamsType#setForceCustomization(Boolean)} * {@link DeployVAppParamsType#setForceCustomization(Boolean)} parameter.
* parameter.
* *
* <pre> * <pre>
* POST /vApp/{id}/action/deploy * POST /vApp/{id}/action/deploy
@ -137,13 +151,15 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task deploy(URI vAppURI, DeployVAppParams params); Task deploy(String vAppUrn, DeployVAppParams params);
Task deploy(URI vAppHref, DeployVAppParams params);
/** /**
* Discard suspended state of a {@link VApp}. * Discard suspended state of a {@link VApp}.
* *
* Discarding suspended state of a vApp automatically discarded suspended * Discarding suspended state of a vApp automatically discarded suspended states of all of the
* states of all of the virtual machines it contains. * virtual machines it contains.
* *
* <pre> * <pre>
* POST /vApp/{id}/action/discardSuspendedState * POST /vApp/{id}/action/discardSuspendedState
@ -151,15 +167,16 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task discardSuspendedState(URI vAppURI); Task discardSuspendedState(String vAppUrn);
Task discardSuspendedState(URI vAppHref);
/** /**
* Place the {@link VApp} into maintenance mode. * Place the {@link VApp} into maintenance mode.
* *
* While in maintenance mode, a system admin can operate on the vApp as * While in maintenance mode, a system admin can operate on the vApp as usual, but end users are
* usual, but end users are restricted to read-only operations. Any * restricted to read-only operations. Any user-initiated tasks running when the vApp enters
* user-initiated tasks running when the vApp enters maintenance mode will * maintenance mode will continue.
* continue.
* *
* <pre> * <pre>
* POST /vApp/{id}/action/enterMaintenanceMode * POST /vApp/{id}/action/enterMaintenanceMode
@ -167,7 +184,9 @@ public interface VAppApi {
* *
* @since 1.5 * @since 1.5
*/ */
void enterMaintenanceMode(URI vAppURI); void enterMaintenanceMode(String vAppUrn);
void enterMaintenanceMode(URI vAppHref);
/** /**
* Take the {@link VApp} out of maintenance mode. * Take the {@link VApp} out of maintenance mode.
@ -178,17 +197,20 @@ public interface VAppApi {
* *
* @since 1.5 * @since 1.5
*/ */
void exitMaintenanceMode(URI vAppURI); void exitMaintenanceMode(String vAppUrn);
void exitMaintenanceMode(URI vAppHref);
/** /**
* Recompose a {@link VApp} by removing its own VMs and/or adding new ones from other * Recompose a {@link VApp} by removing its own VMs and/or adding new ones from other vApps or
* vApps or vApp templates. * vApp templates.
* *
* To remove VMs you should put their references in elements. The way you add * To remove VMs you should put their references in elements. The way you add VMs is the same as
* VMs is the same as described in compose vApp operation * described in compose vApp operation
* {@link VdcApi#composeVApp(URI, org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams)}. * {@link VdcApi#composeVApp(String, org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams)}.
* The status of vApp will be in {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED} * The status of vApp will be in
* until the recompose task is finished. * {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED} until the
* recompose task is finished.
* *
* <pre> * <pre>
* POST /vApp/{id}/action/recomposeVApp * POST /vApp/{id}/action/recomposeVApp
@ -196,14 +218,16 @@ public interface VAppApi {
* *
* @since 1.0 * @since 1.0
*/ */
Task recompose(URI vAppURI, RecomposeVAppParams params); Task recompose(String vAppUrn, RecomposeVAppParams params);
Task recompose(URI vAppHref, RecomposeVAppParams params);
/** /**
* Undeploy a {@link VApp}. * Undeploy a {@link VApp}.
* *
* Undeployment means deallocation of all resources for a vApp/VM like CPU * Undeployment means deallocation of all resources for a vApp/VM like CPU and memory from a vDC
* and memory from a vDC resource pool. Undeploying a vApp automatically * resource pool. Undeploying a vApp automatically undeploys all of the virtual machines it
* undeploys all of the virtual machines it contains. * contains.
* *
* <pre> * <pre>
* POST /vApp/{id}/action/undeploy * POST /vApp/{id}/action/undeploy
@ -211,13 +235,15 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task undeploy(URI vAppURI, UndeployVAppParams params); Task undeploy(String vAppUrn, UndeployVAppParams params);
Task undeploy(URI vAppHref, UndeployVAppParams params);
/** /**
* Retrieves the control access information for a {@link VApp}. * Retrieves the control access information for a {@link VApp}.
* *
* The vApp could be shared to everyone or could be shared to specific user, * The vApp could be shared to everyone or could be shared to specific user, by editing the
* by editing the control access values. * control access values.
* *
* <pre> * <pre>
* GET /vApp/{id}/controlAccess * GET /vApp/{id}/controlAccess
@ -225,13 +251,16 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
//TODO: revise // TODO: revise
ControlAccessParams getControlAccess(URI vAppURI); ControlAccessParams getAccessControl(String vAppUrn);
ControlAccessParams getAccessControl(URI vAppHref);
/** /**
* Powers off a {@link VApp}. * Powers off a {@link VApp}.
* *
* If the operation is used over a vApp then all VMs are powered off. This operation is allowed only when the vApp/VM is powered on. * If the operation is used over a vApp then all VMs are powered off. This operation is allowed
* only when the vApp/VM is powered on.
* *
* <pre> * <pre>
* POST /vApp/{id}/power/action/powerOff * POST /vApp/{id}/power/action/powerOff
@ -239,13 +268,15 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task powerOff(URI vAppURI); Task powerOff(String vAppUrn);
Task powerOff(URI vAppHref);
/** /**
* Powers on a {@link VApp}. * Powers on a {@link VApp}.
* *
* If the operation is used over a vApp then all VMs are powered on. This * If the operation is used over a vApp then all VMs are powered on. This operation is allowed
* operation is allowed only when the vApp/VM is powered off. * only when the vApp/VM is powered off.
* *
* <pre> * <pre>
* POST /vApp/{id}/power/action/powerOn * POST /vApp/{id}/power/action/powerOn
@ -253,7 +284,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task powerOn(URI vAppURI); Task powerOn(String vAppUrn);
Task powerOn(URI vAppHref);
/** /**
* Reboots a {@link VApp}. * Reboots a {@link VApp}.
@ -266,13 +299,15 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task reboot(URI vAppURI); Task reboot(String vAppUrn);
Task reboot(URI vAppHref);
/** /**
* Resets a {@link VApp}. * Resets a {@link VApp}.
* *
* If the operation is used over a vApp then all VMs are reset. This * If the operation is used over a vApp then all VMs are reset. This operation is allowed only
* operation is allowed only when the vApp/VM is powered on. * when the vApp/VM is powered on.
* *
* <pre> * <pre>
* POST /vApp/{id}/power/action/reset * POST /vApp/{id}/power/action/reset
@ -280,13 +315,15 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task reset(URI vAppURI); Task reset(String vAppUrn);
Task reset(URI vAppHref);
/** /**
* Shuts down a {@link VApp}. * Shuts down a {@link VApp}.
* *
* If the operation is used over a vApp then all VMs are shutdown. This * If the operation is used over a vApp then all VMs are shutdown. This operation is allowed only
* operation is allowed only when the vApp/VM is powered on. * when the vApp/VM is powered on.
* *
* <pre> * <pre>
* POST /vApp/{id}/power/action/shutdown * POST /vApp/{id}/power/action/shutdown
@ -294,13 +331,15 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task shutdown(URI vAppURI); Task shutdown(String vAppUrn);
Task shutdown(URI vAppHref);
/** /**
* Suspends a {@link VApp}. * Suspends a {@link VApp}.
* *
* If the operation is used over a vApp then all VMs are suspended. This * If the operation is used over a vApp then all VMs are suspended. This operation is allowed
* operation is allowed only when the vApp/VM is powered on. * only when the vApp/VM is powered on.
* *
* <pre> * <pre>
* POST /vApp/{id}/power/action/suspend * POST /vApp/{id}/power/action/suspend
@ -308,7 +347,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task suspend(URI vAppURI); Task suspend(String vAppUrn);
Task suspend(URI vAppHref);
/** /**
* Retrieves the lease settings section of a {@link VApp}. * Retrieves the lease settings section of a {@link VApp}.
@ -319,7 +360,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
LeaseSettingsSection getLeaseSettingsSection(URI vAppURI); LeaseSettingsSection getLeaseSettingsSection(String vAppUrn);
LeaseSettingsSection getLeaseSettingsSection(URI vAppHref);
/** /**
* Modifies the lease settings section of a {@link VApp}. * Modifies the lease settings section of a {@link VApp}.
@ -330,7 +373,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editLeaseSettingsSection(URI vAppURI, LeaseSettingsSection section); Task editLeaseSettingsSection(String vAppUrn, LeaseSettingsSection section);
Task editLeaseSettingsSection(URI vAppHref, LeaseSettingsSection section);
/** /**
* Retrieves the network config section of a {@link VApp}. * Retrieves the network config section of a {@link VApp}.
@ -341,7 +386,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
NetworkConfigSection getNetworkConfigSection(URI vAppURI); NetworkConfigSection getNetworkConfigSection(String vAppUrn);
NetworkConfigSection getNetworkConfigSection(URI vAppHref);
/** /**
* Modifies the network config section of a {@link VApp}. * Modifies the network config section of a {@link VApp}.
@ -352,7 +399,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editNetworkConfigSection(URI vAppURI, NetworkConfigSection section); Task editNetworkConfigSection(String vAppUrn, NetworkConfigSection section);
Task editNetworkConfigSection(URI vAppHref, NetworkConfigSection section);
/** /**
* Retrieves the network section of a {@link VApp}. * Retrieves the network section of a {@link VApp}.
@ -363,7 +412,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
NetworkSection getNetworkSection(URI vAppURI); NetworkSection getNetworkSection(String vAppUrn);
NetworkSection getNetworkSection(URI vAppHref);
/** /**
* Retrieves the owner of a {@link VApp}. * Retrieves the owner of a {@link VApp}.
@ -374,7 +425,9 @@ public interface VAppApi {
* *
* @since 1.5 * @since 1.5
*/ */
Owner getOwner(URI vAppURI); Owner getOwner(String vAppUrn);
Owner getOwner(URI vAppHref);
/** /**
* Changes {@link VApp} owner. * Changes {@link VApp} owner.
@ -385,7 +438,9 @@ public interface VAppApi {
* *
* @since 1.5 * @since 1.5
*/ */
void editOwner(URI vAppURI, Owner owner); void editOwner(String vAppUrn, Owner owner);
void editOwner(URI vAppHref, Owner owner);
/** /**
* Retrieves {@link VApp} product sections. * Retrieves {@link VApp} product sections.
@ -396,7 +451,9 @@ public interface VAppApi {
* *
* @since 1.5 * @since 1.5
*/ */
ProductSectionList getProductSections(URI vAppURI); ProductSectionList getProductSections(String vAppUrn);
ProductSectionList getProductSections(URI vAppHref);
/** /**
* Modifies the product section information of a {@link VApp}. * Modifies the product section information of a {@link VApp}.
@ -407,7 +464,9 @@ public interface VAppApi {
* *
* @since 1.5 * @since 1.5
*/ */
Task editProductSections(URI vAppURI, ProductSectionList sectionList); Task editProductSections(String vAppUrn, ProductSectionList sectionList);
Task editProductSections(URI vAppHref, ProductSectionList sectionList);
/** /**
* Retrieves the startup section of a {@link VApp}. * Retrieves the startup section of a {@link VApp}.
@ -418,7 +477,9 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
StartupSection getStartupSection(URI vAppURI); StartupSection getStartupSection(String vAppUrn);
StartupSection getStartupSection(URI vAppHref);
/** /**
* Modifies the startup section of a {@link VApp}. * Modifies the startup section of a {@link VApp}.
@ -429,11 +490,17 @@ public interface VAppApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editStartupSection(URI vAppURI, StartupSection section); Task editStartupSection(String vAppUrn, StartupSection section);
Task editStartupSection(URI vAppHref, StartupSection section);
/** /**
* Synchronous access to {@link VApp} {@link Metadata} features. * Synchronous access to {@link VApp} {@link Metadata} features.
*/ */
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI vAppHref);
} }

View File

@ -50,6 +50,7 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
@ -61,6 +62,7 @@ import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.director.v1_5.functions.href.VAppURNToHref;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -72,31 +74,309 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface VAppAsyncApi { public interface VAppAsyncApi {
/** /**
* @see VAppApi#getVApp(URI) * @see VAppApi#get(String)
*/ */
@GET @GET
@Consumes(VAPP) @Consumes(VAPP)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VApp> getVApp(@EndpointParam URI vAppURI); ListenableFuture<VApp> get(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/** /**
* @see VAppApi#editVApp(URI, VApp) * @see VAppApi#edit(String, VApp)
*/ */
@PUT @PUT
@Produces(VAPP) @Produces(VAPP)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVApp(@EndpointParam URI vAppURI, ListenableFuture<Task> edit(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) VApp vApp); @BinderParam(BindToXMLPayload.class) VApp vApp);
/** /**
* @see VAppApi#removeVApp(URI) * @see VAppApi#remove(String)
*/ */
@DELETE @DELETE
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> removeVApp(@EndpointParam URI vAppURI); ListenableFuture<Task> remove(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#editControlAccess(String, ControlAccessParams)
*/
@POST
@Path("/action/controlAccess")
@Produces(CONTROL_ACCESS)
@Consumes(CONTROL_ACCESS)
@JAXBResponseParser
ListenableFuture<ControlAccessParams> editControlAccess(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) ControlAccessParams params);
/**
* @see VAppApi#deploy(String, DeployVAppParams)
*/
@POST
@Path("/action/deploy")
@Produces(DEPLOY_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> deploy(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) DeployVAppParams params);
/**
* @see VAppApi#discardSuspendedState(String)
*/
@POST
@Path("/action/discardSuspendedState")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> discardSuspendedState(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#enterMaintenanceMode(String)
*/
@POST
@Path("/action/enterMaintenanceMode")
@Consumes
@JAXBResponseParser
ListenableFuture<Void> enterMaintenanceMode(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#exitMaintenanceMode(String)
*/
@POST
@Path("/action/exitMaintenanceMode")
@Consumes
@JAXBResponseParser
ListenableFuture<Void> exitMaintenanceMode(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#recompose(String, RecomposeVAppParams)
*/
@POST
@Path("/action/recomposeVApp")
@Produces(RECOMPOSE_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> recompose(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) RecomposeVAppParams params);
/**
* @see VAppApi#undeploy(String, UndeployVAppParams)
*/
@POST
@Path("/action/undeploy")
@Produces(UNDEPLOY_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> undeploy(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) UndeployVAppParams params);
/**
* @see VAppApi#getAccessControl(String)
*/
@GET
@Path("/controlAccess")
@Consumes(CONTROL_ACCESS)
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ControlAccessParams> getAccessControl(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#powerOff(String)
*/
@POST
@Path("/power/action/powerOff")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> powerOff(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#powerOn(String)
*/
@POST
@Path("/power/action/powerOn")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> powerOn(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#reboot(String)
*/
@POST
@Path("/power/action/powerOff")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> reboot(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#reset(String)
*/
@POST
@Path("/power/action/reset")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> reset(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#shutdown(String)
*/
@POST
@Path("/power/action/shutdown")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> shutdown(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#suspend(String)
*/
@POST
@Path("/power/action/suspend")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> suspend(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#getLeaseSettingsSection(String)
*/
@GET
@Path("/leaseSettingsSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<LeaseSettingsSection> getLeaseSettingsSection(
@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#editLeaseSettingsSection(String, LeaseSettingsSection)
*/
@PUT
@Path("/leaseSettingsSection")
@Produces(LEASE_SETTINGS_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editLeaseSettingsSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection section);
/**
* @see VAppApi#getNetworkConfigSection(String)
*/
@GET
@Path("/networkConfigSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConfigSection> getNetworkConfigSection(
@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#editNetworkConfigSection(String, NetworkConfigSection)
*/
@PUT
@Path("/networkConfigSection")
@Produces(NETWORK_CONFIG_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editNetworkConfigSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) NetworkConfigSection section);
/**
* @see VAppApi#getNetworkSection(String)
*/
@GET
@Path("/networkSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkSection> getNetworkSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#getOwner(String)
*/
@GET
@Path("/owner")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Owner> getOwner(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#editOwner(String, Owner)
*/
@PUT
@Path("/owner")
@Produces(OWNER)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Void> editOwner(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) Owner owner);
/**
* @see VAppApi#getProductSections(String)
*/
@GET
@Path("/productSections")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#editProductSections(String, ProductSectionList)
*/
@PUT
@Path("/productSections")
@Produces(PRODUCT_SECTION_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editProductSections(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) ProductSectionList sectionList);
/**
* @see VAppApi#getStartupSection(String)
*/
@GET
@Path("/startupSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<StartupSection> getStartupSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
/**
* @see VAppApi#editStartupSection(String, StartupSection)
*/
@PUT
@Path("/startupSection")
@Produces(STARTUP_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editStartupSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn,
@BinderParam(BindToXMLPayload.class) StartupSection section);
/**
* @see VAppApi#get(URI)
*/
@GET
@Consumes(VAPP)
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VApp> get(@EndpointParam URI vAppHref);
/**
* @see VAppApi#edit(URI, VApp)
*/
@PUT
@Produces(VAPP)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> edit(@EndpointParam URI vAppHref, @BinderParam(BindToXMLPayload.class) VApp vApp);
/**
* @see VAppApi#remove(URI)
*/
@DELETE
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> remove(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#editControlAccess(URI, ControlAccessParams) * @see VAppApi#editControlAccess(URI, ControlAccessParams)
@ -106,7 +386,7 @@ public interface VAppAsyncApi {
@Produces(CONTROL_ACCESS) @Produces(CONTROL_ACCESS)
@Consumes(CONTROL_ACCESS) @Consumes(CONTROL_ACCESS)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<ControlAccessParams> editControlAccess(@EndpointParam URI vAppURI, ListenableFuture<ControlAccessParams> editControlAccess(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) ControlAccessParams params); @BinderParam(BindToXMLPayload.class) ControlAccessParams params);
/** /**
@ -117,7 +397,7 @@ public interface VAppAsyncApi {
@Produces(DEPLOY_VAPP_PARAMS) @Produces(DEPLOY_VAPP_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> deploy(@EndpointParam URI vAppURI, ListenableFuture<Task> deploy(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) DeployVAppParams params); @BinderParam(BindToXMLPayload.class) DeployVAppParams params);
/** /**
@ -127,7 +407,7 @@ public interface VAppAsyncApi {
@Path("/action/discardSuspendedState") @Path("/action/discardSuspendedState")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> discardSuspendedState(@EndpointParam URI vAppURI); ListenableFuture<Task> discardSuspendedState(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#enterMaintenanceMode(URI) * @see VAppApi#enterMaintenanceMode(URI)
@ -136,7 +416,7 @@ public interface VAppAsyncApi {
@Path("/action/enterMaintenanceMode") @Path("/action/enterMaintenanceMode")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> enterMaintenanceMode(@EndpointParam URI vAppURI); ListenableFuture<Void> enterMaintenanceMode(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#exitMaintenanceMode(URI) * @see VAppApi#exitMaintenanceMode(URI)
@ -145,7 +425,7 @@ public interface VAppAsyncApi {
@Path("/action/exitMaintenanceMode") @Path("/action/exitMaintenanceMode")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> exitMaintenanceMode(@EndpointParam URI vAppURI); ListenableFuture<Void> exitMaintenanceMode(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#recompose(URI, RecomposeVAppParams) * @see VAppApi#recompose(URI, RecomposeVAppParams)
@ -155,7 +435,7 @@ public interface VAppAsyncApi {
@Produces(RECOMPOSE_VAPP_PARAMS) @Produces(RECOMPOSE_VAPP_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> recompose(@EndpointParam URI vAppURI, ListenableFuture<Task> recompose(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) RecomposeVAppParams params); @BinderParam(BindToXMLPayload.class) RecomposeVAppParams params);
/** /**
@ -166,18 +446,18 @@ public interface VAppAsyncApi {
@Produces(UNDEPLOY_VAPP_PARAMS) @Produces(UNDEPLOY_VAPP_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> undeploy(@EndpointParam URI vAppURI, ListenableFuture<Task> undeploy(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) UndeployVAppParams params); @BinderParam(BindToXMLPayload.class) UndeployVAppParams params);
/** /**
* @see VAppApi#getControlAccess(URI) * @see VAppApi#getAccessControl(URI)
*/ */
@GET @GET
@Path("/controlAccess") @Path("/controlAccess")
@Consumes(CONTROL_ACCESS) @Consumes(CONTROL_ACCESS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ControlAccessParams> getControlAccess(@EndpointParam URI vAppURI); ListenableFuture<ControlAccessParams> getAccessControl(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#powerOff(URI) * @see VAppApi#powerOff(URI)
@ -186,7 +466,7 @@ public interface VAppAsyncApi {
@Path("/power/action/powerOff") @Path("/power/action/powerOff")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> powerOff(@EndpointParam URI vAppURI); ListenableFuture<Task> powerOff(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#powerOn(URI) * @see VAppApi#powerOn(URI)
@ -195,7 +475,7 @@ public interface VAppAsyncApi {
@Path("/power/action/powerOn") @Path("/power/action/powerOn")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> powerOn(@EndpointParam URI vAppURI); ListenableFuture<Task> powerOn(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#reboot(URI) * @see VAppApi#reboot(URI)
@ -204,7 +484,7 @@ public interface VAppAsyncApi {
@Path("/power/action/powerOff") @Path("/power/action/powerOff")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> reboot(@EndpointParam URI vAppURI); ListenableFuture<Task> reboot(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#reset(URI) * @see VAppApi#reset(URI)
@ -213,7 +493,7 @@ public interface VAppAsyncApi {
@Path("/power/action/reset") @Path("/power/action/reset")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> reset(@EndpointParam URI vAppURI); ListenableFuture<Task> reset(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#shutdown(URI) * @see VAppApi#shutdown(URI)
@ -222,7 +502,7 @@ public interface VAppAsyncApi {
@Path("/power/action/shutdown") @Path("/power/action/shutdown")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> shutdown(@EndpointParam URI vAppURI); ListenableFuture<Task> shutdown(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#suspend(URI) * @see VAppApi#suspend(URI)
@ -231,7 +511,7 @@ public interface VAppAsyncApi {
@Path("/power/action/suspend") @Path("/power/action/suspend")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> suspend(@EndpointParam URI vAppURI); ListenableFuture<Task> suspend(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#getLeaseSettingsSection(URI) * @see VAppApi#getLeaseSettingsSection(URI)
@ -241,7 +521,7 @@ public interface VAppAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<LeaseSettingsSection> getLeaseSettingsSection(@EndpointParam URI vAppURI); ListenableFuture<LeaseSettingsSection> getLeaseSettingsSection(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#editLeaseSettingsSection(URI, LeaseSettingsSection) * @see VAppApi#editLeaseSettingsSection(URI, LeaseSettingsSection)
@ -251,7 +531,7 @@ public interface VAppAsyncApi {
@Produces(LEASE_SETTINGS_SECTION) @Produces(LEASE_SETTINGS_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editLeaseSettingsSection(@EndpointParam URI vAppURI, ListenableFuture<Task> editLeaseSettingsSection(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection section); @BinderParam(BindToXMLPayload.class) LeaseSettingsSection section);
/** /**
@ -262,7 +542,7 @@ public interface VAppAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConfigSection> getNetworkConfigSection(@EndpointParam URI vAppURI); ListenableFuture<NetworkConfigSection> getNetworkConfigSection(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#editNetworkConfigSection(URI, NetworkConfigSection) * @see VAppApi#editNetworkConfigSection(URI, NetworkConfigSection)
@ -272,7 +552,7 @@ public interface VAppAsyncApi {
@Produces(NETWORK_CONFIG_SECTION) @Produces(NETWORK_CONFIG_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editNetworkConfigSection(@EndpointParam URI vAppURI, ListenableFuture<Task> editNetworkConfigSection(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) NetworkConfigSection section); @BinderParam(BindToXMLPayload.class) NetworkConfigSection section);
/** /**
@ -283,7 +563,7 @@ public interface VAppAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkSection> getNetworkSection(@EndpointParam URI vAppURI); ListenableFuture<NetworkSection> getNetworkSection(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#getOwner(URI) * @see VAppApi#getOwner(URI)
@ -293,7 +573,7 @@ public interface VAppAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Owner> getOwner(@EndpointParam URI vAppURI); ListenableFuture<Owner> getOwner(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#editOwner(URI, Owner) * @see VAppApi#editOwner(URI, Owner)
@ -303,8 +583,7 @@ public interface VAppAsyncApi {
@Produces(OWNER) @Produces(OWNER)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> editOwner(@EndpointParam URI vAppURI, ListenableFuture<Void> editOwner(@EndpointParam URI vAppHref, @BinderParam(BindToXMLPayload.class) Owner owner);
@BinderParam(BindToXMLPayload.class) Owner owner);
/** /**
* @see VAppApi#getProductSections(URI) * @see VAppApi#getProductSections(URI)
@ -314,7 +593,7 @@ public interface VAppAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI vAppURI); ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#editProductSections(URI, ProductSectionList) * @see VAppApi#editProductSections(URI, ProductSectionList)
@ -324,10 +603,9 @@ public interface VAppAsyncApi {
@Produces(PRODUCT_SECTION_LIST) @Produces(PRODUCT_SECTION_LIST)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editProductSections(@EndpointParam URI vAppURI, ListenableFuture<Task> editProductSections(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList);
/** /**
* @see VAppApi#getStartupSection(URI) * @see VAppApi#getStartupSection(URI)
*/ */
@ -336,7 +614,7 @@ public interface VAppAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<StartupSection> getStartupSection(@EndpointParam URI vAppURI); ListenableFuture<StartupSection> getStartupSection(@EndpointParam URI vAppHref);
/** /**
* @see VAppApi#editStartupSection(URI, StartupSection) * @see VAppApi#editStartupSection(URI, StartupSection)
@ -346,12 +624,16 @@ public interface VAppAsyncApi {
@Produces(STARTUP_SECTION) @Produces(STARTUP_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editStartupSection(@EndpointParam URI vAppURI, ListenableFuture<Task> editStartupSection(@EndpointParam URI vAppHref,
@BinderParam(BindToXMLPayload.class) StartupSection section); @BinderParam(BindToXMLPayload.class) StartupSection section);
/** /**
* Asynchronous access to {@link VApp} {@link Metadata} features * Asynchronous access to {@link VApp} {@link Metadata} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn);
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI vAppHref);
} }

View File

@ -24,24 +24,24 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.References;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.functions.href.VAppTemplateURNToHref;
/** /**
* Provides synchronous access to {@link VAppTemplate} objects. * Provides synchronous access to {@link VAppTemplate} objects.
* *
* @author Adam Lowe * @author Adam Lowe, Adrian Cole
* @see org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncApi * @see VAppTemplateAsyncApi
*/ */
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface VAppTemplateApi { public interface VAppTemplateApi {
@ -51,29 +51,36 @@ public interface VAppTemplateApi {
* *
* The vApp could be in one of these statues: * The vApp could be in one of these statues:
* <ul> * <ul>
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION FAILED_CREATION(-1)} - * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION
* Transient entity state, e.g., model object is addd but the corresponding VC backing does not exist yet. This * FAILED_CREATION(-1)} - Transient entity state, e.g., model object is addd but the
* is further sub-categorized in the respective entities. * corresponding VC backing does not exist yet. This is further sub-categorized in the respective
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED UNRESOLVED(0)} - * entities.
* Entity is whole, e.g., VM creation is complete and all the required model objects and VC backings are addd. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED RESOLVED(1)} - * UNRESOLVED(0)} - Entity is whole, e.g., VM creation is complete and all the required model
* Entity is resolved. * objects and VC backings are addd.
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN UNKNOWN(6)} - * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED
* Entity state could not be retrieved from the inventory, e.g., VM power state is null. * RESOLVED(1)} - Entity is resolved.
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF POWERED_OFF(8)} - * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN
* All VMs of the vApp template are powered off. * UNKNOWN(6)} - Entity state could not be retrieved from the inventory, e.g., VM power state is
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} - * null.
* vApp template status is set to {@code MIXED} when the VMs in the vApp are in different power states. * <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF
* POWERED_OFF(8)} - All VMs of the vApp template are powered off.
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)}
* - vApp template status is set to {@code MIXED} when the VMs in the vApp are in different power
* states.
* </ul> * </ul>
* *
* <pre> * <pre>
* GET /vAppTemplate/{id} * GET /vAppTemplate/{id}
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the requested template * @return the requested template
*/ */
VAppTemplate getVAppTemplate(URI templateUri); VAppTemplate get(String templateUrn);
VAppTemplate get(URI templateHref);
/** /**
* Modifies only the name/description of a vApp template. * Modifies only the name/description of a vApp template.
@ -82,12 +89,16 @@ public interface VAppTemplateApi {
* PUT /vAppTemplate/{id} * PUT /vAppTemplate/{id}
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* @param template the template containing the new name and/or description * the String of the template
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned * @param template
* task status in order to check when it is completed. * the template containing the new name and/or description
* @return the task performing the action. This operation is asynchronous and the user should
* monitor the returned task status in order to check when it is completed.
*/ */
Task editVAppTemplate(URI templateUri, VAppTemplate template); Task edit(String templateUrn, VAppTemplate template);
Task edit(URI templateHref, VAppTemplate template);
/** /**
* Deletes a vApp template. * Deletes a vApp template.
@ -96,24 +107,14 @@ public interface VAppTemplateApi {
* DELETE /vAppTemplate/{id} * DELETE /vAppTemplate/{id}
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned * the String of the template
* task status in order to check when it is completed. * @return the task performing the action. This operation is asynchronous and the user should
* monitor the returned task status in order to check when it is completed.
*/ */
Task removeVappTemplate(URI templateUri); Task remove(String templateUrn);
/** Task remove(URI templateHref);
* Consolidates a VM
*
* <pre>
* POST /vAppTemplate/{id}/action/consolidate
* </pre>
*
* @param templateUri the URI of the template
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task consolidateVm(URI templateUri);
/** /**
* Disables the download link to the ovf of a vApp template. * Disables the download link to the ovf of a vApp template.
@ -122,9 +123,12 @@ public interface VAppTemplateApi {
* POST /vAppTemplate/{id}/action/disableDownload * POST /vAppTemplate/{id}/action/disableDownload
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
*/ */
void disableDownload(URI templateUri); void disableDownload(String templateUrn);
void disableDownload(URI templateHref);
/** /**
* Enables downloading of the ovf of a vApp template. * Enables downloading of the ovf of a vApp template.
@ -133,25 +137,14 @@ public interface VAppTemplateApi {
* POST /vAppTemplate/{id}/action/enableDownload * POST /vAppTemplate/{id}/action/enableDownload
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned * the String of the template
* task status in order to check when it is completed. * @return the task performing the action. This operation is asynchronous and the user should
* monitor the returned task status in order to check when it is completed.
*/ */
Task enableDownload(URI templateUri); Task enableDownload(String templateUrn);
/** Task enableDownload(URI templateHref);
* Relocates a virtual machine in a vApp template to a different datastore.
*
* <pre>
* POST /vAppTemplate/{id}/action/relocate
* </pre>
*
* @param templateUri the URI of the template
* @param params contains the reference to the new datastore
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task relocateVm(URI templateUri, RelocateParams params);
/** /**
* Retrieves the customization section of a vApp template. * Retrieves the customization section of a vApp template.
@ -160,36 +153,13 @@ public interface VAppTemplateApi {
* GET /vAppTemplate/{id}/customizationSection * GET /vAppTemplate/{id}/customizationSection
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the customization section * @return the customization section
*/ */
CustomizationSection getCustomizationSection(URI templateUri); CustomizationSection getCustomizationSection(String templateUrn);
/** CustomizationSection getCustomizationSection(URI templateHref);
* Retrieves the Guest Customization Section of a VM
*
* <pre>
* GET /vAppTemplate/{id}/guestCustomizationSection
* </pre>
*
* @param templateUri the URI of the template
* @return the guest customization section
*/
GuestCustomizationSection getGuestCustomizationSection(URI templateUri);
/**
* Modifies the guest customization options of a VM.
*
* <pre>
* PUT /vAppTemplate/{id}/guestCustomizationSection
* </pre>
*
* @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task editGuestCustomizationSection(URI templateUri, GuestCustomizationSection section);
/** /**
* Retrieves the lease settings section of a vApp or vApp template * Retrieves the lease settings section of a vApp or vApp template
@ -198,10 +168,13 @@ public interface VAppTemplateApi {
* GET /vAppTemplate/{id}/leaseSettingsSection * GET /vAppTemplate/{id}/leaseSettingsSection
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the lease settings * @return the lease settings
*/ */
LeaseSettingsSection getLeaseSettingsSection(URI templateUri); LeaseSettingsSection getLeaseSettingsSection(String templateUrn);
LeaseSettingsSection getLeaseSettingsSection(URI templateHref);
/** /**
* Modifies the lease settings section of a vApp or vApp template. * Modifies the lease settings section of a vApp or vApp template.
@ -210,12 +183,16 @@ public interface VAppTemplateApi {
* PUT /vAppTemplate/{id}/leaseSettingsSection * PUT /vAppTemplate/{id}/leaseSettingsSection
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* @param section the new configuration to apply * the String of the template
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned * @param section
* task status in order to check when it is completed. * the new configuration to apply
* @return the task performing the action. This operation is asynchronous and the user should
* monitor the returned task status in order to check when it is completed.
*/ */
Task editLeaseSettingsSection(URI templateUri, LeaseSettingsSection section); Task editLeaseSettingsSection(String templateUrn, LeaseSettingsSection section);
Task editLeaseSettingsSection(URI templateHref, LeaseSettingsSection section);
/** /**
* Retrieves the network config section of a vApp or vApp template. * Retrieves the network config section of a vApp or vApp template.
@ -224,22 +201,13 @@ public interface VAppTemplateApi {
* GET /vAppTemplate/{id}/networkConfigSection * GET /vAppTemplate/{id}/networkConfigSection
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the network config section requested * @return the network config section requested
*/ */
NetworkConfigSection getNetworkConfigSection(URI templateUri); NetworkConfigSection getNetworkConfigSection(String templateUrn);
/** NetworkConfigSection getNetworkConfigSection(URI templateHref);
* Retrieves the network connection section of a VM
*
* <pre>
* GET /vAppTemplate/{id}/networkConnectionSection
* </pre>
*
* @param templateUri the URI of the template
* @return the network connection section requested
*/
NetworkConnectionSection getNetworkConnectionSection(URI templateUri);
/** /**
* Retrieves the network section of a vApp or vApp template. * Retrieves the network section of a vApp or vApp template.
@ -248,26 +216,32 @@ public interface VAppTemplateApi {
* GET /vAppTemplate/{id}/networkSection * GET /vAppTemplate/{id}/networkSection
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the network section requested * @return the network section requested
*/ */
NetworkSection getNetworkSection(URI templateUri); NetworkSection getNetworkSection(String templateUrn);
NetworkSection getNetworkSection(URI templateHref);
/** /**
* Retrieves an OVF descriptor of a vApp template. * Retrieves an OVF descriptor of a vApp template.
* *
* This OVF represents the vApp template as it is, with all vCloud specific information (like mac address, parent * This OVF represents the vApp template as it is, with all vCloud specific information (like mac
* networks, etc). The OVF which could be downloaded by enabling for download will not contain this information. * address, parent networks, etc). The OVF which could be downloaded by enabling for download
* There are no specific states bound to this entity. * will not contain this information. There are no specific states bound to this entity.
* *
* <pre> * <pre>
* GET /vAppTemplate/{id}/ovf * GET /vAppTemplate/{id}/ovf
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the ovf envelope * @return the ovf envelope
*/ */
Envelope getOvf(URI templateUri); Envelope getOvf(String templateUrn);
Envelope getOvf(URI templateHref);
/** /**
* Retrieves vApp template owner. * Retrieves vApp template owner.
@ -276,10 +250,13 @@ public interface VAppTemplateApi {
* GET /vAppTemplate/{id}/owner * GET /vAppTemplate/{id}/owner
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the owner of the vApp template * @return the owner of the vApp template
*/ */
Owner getOwner(URI templateUri); Owner getOwner(String templateUrn);
Owner getOwner(URI templateHref);
/** /**
* Retrieves VAppTemplate/VM product sections * Retrieves VAppTemplate/VM product sections
@ -288,10 +265,13 @@ public interface VAppTemplateApi {
* GET /vAppTemplate/{id}/productSections * GET /vAppTemplate/{id}/productSections
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return the product sections * @return the product sections
*/ */
ProductSectionList getProductSections(URI templateUri); ProductSectionList getProductSections(String templateUrn);
ProductSectionList getProductSections(URI templateHref);
/** /**
* Modifies the product sections of a vApp or vApp template. * Modifies the product sections of a vApp or vApp template.
@ -300,25 +280,35 @@ public interface VAppTemplateApi {
* PUT /vAppTemplate/{id}/productSections * PUT /vAppTemplate/{id}/productSections
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* @return the task performing the action. This operation is asynchronous and the user should monitor the returned * the String of the template
* task status in order to check when it is completed. * @return the task performing the action. This operation is asynchronous and the user should
* monitor the returned task status in order to check when it is completed.
*/ */
Task editProductSections(URI templateUri, ProductSectionList sections); Task editProductSections(String templateUrn, ProductSectionList sections);
Task editProductSections(URI templateHref, ProductSectionList sections);
/** /**
* <pre> * <pre>
* GET /vAppTemplate/{id}/shadowVms * GET /vAppTemplate/{id}/shadowVms
* </pre> * </pre>
* *
* @param templateUri the URI of the template * @param templateUrn
* the String of the template
* @return shadowVM references * @return shadowVM references
*/ */
References getShadowVms(URI templateUri); References getShadowVms(String templateUrn);
References getShadowVms(URI templateHref);
/** /**
* @return synchronous access to {@link Metadata} features * @return synchronous access to {@link Metadata} features
*/ */
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI templateHref);
} }

View File

@ -19,14 +19,11 @@
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OWNER; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OWNER;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.PRODUCT_SECTION_LIST; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.PRODUCT_SECTION_LIST;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_TEMPLATE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE;
@ -49,65 +46,206 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.References;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.director.v1_5.functions.href.VAppTemplateURNToHref;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
* @author Adam Lowe * @author Adam Lowe, Adrian Cole
* @see org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi * @see VAppTemplateApi
*/ */
@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
public interface VAppTemplateAsyncApi { public interface VAppTemplateAsyncApi {
/** /**
* @see VAppTemplateApi#getVAppTemplate(URI) * @see VAppTemplateApi#get(String)
*/ */
@GET @GET
@Consumes(VAPP_TEMPLATE) @Consumes(VAPP_TEMPLATE)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VAppTemplate> getVAppTemplate(@EndpointParam URI reference); ListenableFuture<VAppTemplate> get(@EndpointParam String reference);
/** /**
* @see VAppTemplateApi#editVAppTemplate(URI, VAppTemplate) * @see VAppTemplateApi#edit(String, VAppTemplate)
*/ */
@PUT @PUT
@Produces(VAPP_TEMPLATE) @Produces(VAPP_TEMPLATE)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVAppTemplate(@EndpointParam URI templateURI, ListenableFuture<Task> edit(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn,
@BinderParam(BindToXMLPayload.class) VAppTemplate template); @BinderParam(BindToXMLPayload.class) VAppTemplate template);
/** /**
* @see VAppTemplateApi#removeVappTemplate(URI) * @see VAppTemplateApi#remove(String)
*/ */
@DELETE @DELETE
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> removeVappTemplate(@EndpointParam URI templateUri); ListenableFuture<Task> remove(@EndpointParam String templateUri);
/** /**
* @see VAppTemplateApi#consolidateVm(URI) * @see VAppTemplateApi#disableDownload(String)
*/
@POST
@Path("/action/disableDownload")
@JAXBResponseParser
ListenableFuture<Void> disableDownload(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#enableDownload(String)
*/ */
@POST @POST
@Consumes(TASK) @Consumes(TASK)
@Path("/action/consolidate") @Path("/action/enableDownload")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> consolidateVm(@EndpointParam URI templateURI); ListenableFuture<Task> enableDownload(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#getCustomizationSection(String)
*/
@GET
@Consumes(CUSTOMIZATION_SECTION)
@Path("/customizationSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<CustomizationSection> getCustomizationSection(
@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#getLeaseSettingsSection(String)
*/
@GET
@Consumes(LEASE_SETTINGS_SECTION)
@Path("/leaseSettingsSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<LeaseSettingsSection> getLeaseSettingsSection(
@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#editLeaseSettingsSection(String, LeaseSettingsSection)
*/
@PUT
@Produces(LEASE_SETTINGS_SECTION)
@Consumes(TASK)
@Path("/leaseSettingsSection")
@JAXBResponseParser
ListenableFuture<Task> editLeaseSettingsSection(
@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn,
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection);
/**
* @see VAppTemplateApi#getNetworkConfigSection(String)
*/
@GET
@Consumes(NETWORK_CONFIG_SECTION)
@Path("/networkConfigSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConfigSection> getNetworkConfigSection(
@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#getNetworkSection(String)
*/
@GET
@Consumes(NETWORK_SECTION)
@Path("/networkSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkSection> getNetworkSection(
@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#getOvf(String)
*/
@GET
@Consumes
@Path("/ovf")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Envelope> getOvf(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#getOwnerOfVAppTemplate(String)
*/
@GET
@Consumes(OWNER)
@Path("/owner")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Owner> getOwner(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#getProductSectionsForVAppTemplate(String)
*/
@GET
@Consumes(PRODUCT_SECTION_LIST)
@Path("/productSections")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(
@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#editProductSections(String, ProductSectionList)
*/
@PUT
@Produces(PRODUCT_SECTION_LIST)
@Consumes(TASK)
@Path("/productSections")
@JAXBResponseParser
ListenableFuture<Task> editProductSections(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn,
@BinderParam(BindToXMLPayload.class) ProductSectionList sections);
/**
* @see VAppTemplateApi#getShadowVms(String)
*/
@GET
@Consumes
@Path("/shadowVms")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<References> getShadowVms(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
/**
* @see VAppTemplateApi#get(URI)
*/
@GET
@Consumes(VAPP_TEMPLATE)
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VAppTemplate> get(@EndpointParam URI reference);
/**
* @see VAppTemplateApi#edit(URI, VAppTemplate)
*/
@PUT
@Produces(VAPP_TEMPLATE)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> edit(@EndpointParam URI templateHref,
@BinderParam(BindToXMLPayload.class) VAppTemplate template);
/**
* @see VAppTemplateApi#remove(URI)
*/
@DELETE
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> remove(@EndpointParam URI templateUri);
/** /**
* @see VAppTemplateApi#disableDownload(URI) * @see VAppTemplateApi#disableDownload(URI)
@ -115,27 +253,16 @@ public interface VAppTemplateAsyncApi {
@POST @POST
@Path("/action/disableDownload") @Path("/action/disableDownload")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> disableDownload(@EndpointParam URI templateURI); ListenableFuture<Void> disableDownload(@EndpointParam URI templateHref);
/** /**
* @see VAppTemplateApi#enableDownloadVappTemplate(URI) * @see VAppTemplateApi#enableDownload(URI)
*/ */
@POST @POST
@Consumes(TASK) @Consumes(TASK)
@Path("/action/enableDownload") @Path("/action/enableDownload")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> enableDownload(@EndpointParam URI templateURI); ListenableFuture<Task> enableDownload(@EndpointParam URI templateHref);
/**
* @see VAppTemplateApi#relocateVm(URI, RelocateParams)
*/
@POST
@Produces(RELOCATE_TEMPLATE)
@Consumes(TASK)
@Path("/action/relocate")
@JAXBResponseParser
ListenableFuture<Task> relocateVm(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) RelocateParams params);
/** /**
* @see VAppTemplateApi#getCustomizationSection(URI) * @see VAppTemplateApi#getCustomizationSection(URI)
@ -145,28 +272,7 @@ public interface VAppTemplateAsyncApi {
@Path("/customizationSection") @Path("/customizationSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<CustomizationSection> getCustomizationSection(@EndpointParam URI templateURI); ListenableFuture<CustomizationSection> getCustomizationSection(@EndpointParam URI templateHref);
/**
* @see VAppTemplateApi#getGuestCustomizationSection(URI)
*/
@GET
@Consumes(GUEST_CUSTOMIZATION_SECTION)
@Path("/guestCustomizationSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<GuestCustomizationSection> getGuestCustomizationSection(@EndpointParam URI templateURI);
/**
* @see VAppTemplateApi#editGuestCustomizationSection(URI, org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection)
*/
@PUT
@Produces(GUEST_CUSTOMIZATION_SECTION)
@Consumes(TASK)
@Path("/guestCustomizationSection")
@JAXBResponseParser
ListenableFuture<Task> editGuestCustomizationSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) GuestCustomizationSection section);
/** /**
* @see VAppTemplateApi#getLeaseSettingsSection(URI) * @see VAppTemplateApi#getLeaseSettingsSection(URI)
@ -176,7 +282,7 @@ public interface VAppTemplateAsyncApi {
@Path("/leaseSettingsSection") @Path("/leaseSettingsSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<LeaseSettingsSection> getLeaseSettingsSection(@EndpointParam URI templateURI); ListenableFuture<LeaseSettingsSection> getLeaseSettingsSection(@EndpointParam URI templateHref);
/** /**
* @see VAppTemplateApi#editLeaseSettingsSection(URI, LeaseSettingsSection) * @see VAppTemplateApi#editLeaseSettingsSection(URI, LeaseSettingsSection)
@ -186,19 +292,9 @@ public interface VAppTemplateAsyncApi {
@Consumes(TASK) @Consumes(TASK)
@Path("/leaseSettingsSection") @Path("/leaseSettingsSection")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editLeaseSettingsSection(@EndpointParam URI templateURI, ListenableFuture<Task> editLeaseSettingsSection(@EndpointParam URI templateHref,
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection); @BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection);
/**
* @see VAppTemplateApi#getNetworkConnectionSection(URI)
*/
@GET
@Consumes(NETWORK_CONNECTION_SECTION)
@Path("/networkConnectionSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI templateURI);
/** /**
* @see VAppTemplateApi#getNetworkConfigSection(URI) * @see VAppTemplateApi#getNetworkConfigSection(URI)
*/ */
@ -207,17 +303,7 @@ public interface VAppTemplateAsyncApi {
@Path("/networkConfigSection") @Path("/networkConfigSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConfigSection> getNetworkConfigSection(@EndpointParam URI templateURI); ListenableFuture<NetworkConfigSection> getNetworkConfigSection(@EndpointParam URI templateHref);
/**
* @see VAppTemplateApi#getNetworkConnectionSection(URI)
*/
@GET
@Consumes(NETWORK_CONNECTION_SECTION)
@Path("/networkConnectionSection")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConnectionSection> getVAppTemplateNetworkConnectionSection(@EndpointParam URI templateURI);
/** /**
* @see VAppTemplateApi#getNetworkSection(URI) * @see VAppTemplateApi#getNetworkSection(URI)
@ -227,7 +313,7 @@ public interface VAppTemplateAsyncApi {
@Path("/networkSection") @Path("/networkSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkSection> getNetworkSection(@EndpointParam URI templateURI); ListenableFuture<NetworkSection> getNetworkSection(@EndpointParam URI templateHref);
/** /**
* @see VAppTemplateApi#getOvf(URI) * @see VAppTemplateApi#getOvf(URI)
@ -237,7 +323,7 @@ public interface VAppTemplateAsyncApi {
@Path("/ovf") @Path("/ovf")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Envelope> getOvf(@EndpointParam URI templateURI); ListenableFuture<Envelope> getOvf(@EndpointParam URI templateHref);
/** /**
* @see VAppTemplateApi#getOwnerOfVAppTemplate(URI) * @see VAppTemplateApi#getOwnerOfVAppTemplate(URI)
@ -247,7 +333,7 @@ public interface VAppTemplateAsyncApi {
@Path("/owner") @Path("/owner")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Owner> getOwner(@EndpointParam URI templateURI); ListenableFuture<Owner> getOwner(@EndpointParam URI templateHref);
/** /**
* @see VAppTemplateApi#getProductSectionsForVAppTemplate(URI) * @see VAppTemplateApi#getProductSectionsForVAppTemplate(URI)
@ -257,7 +343,7 @@ public interface VAppTemplateAsyncApi {
@Path("/productSections") @Path("/productSections")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI templateURI); ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI templateHref);
/** /**
* @see VAppTemplateApi#editProductSections(URI, ProductSectionList) * @see VAppTemplateApi#editProductSections(URI, ProductSectionList)
@ -267,7 +353,7 @@ public interface VAppTemplateAsyncApi {
@Consumes(TASK) @Consumes(TASK)
@Path("/productSections") @Path("/productSections")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editProductSections(@EndpointParam URI templateURI, ListenableFuture<Task> editProductSections(@EndpointParam URI templateHref,
@BinderParam(BindToXMLPayload.class) ProductSectionList sections); @BinderParam(BindToXMLPayload.class) ProductSectionList sections);
/** /**
@ -278,11 +364,15 @@ public interface VAppTemplateAsyncApi {
@Path("/shadowVms") @Path("/shadowVms")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<References> getShadowVms(@EndpointParam URI templateURI); ListenableFuture<References> getShadowVms(@EndpointParam URI templateHref);
/** /**
* @return asynchronous access to {@link Metadata} features * @return asynchronous access to {@link Metadata} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn);
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI templateHref);
} }

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VApp;
@ -35,6 +36,7 @@ import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppParams; import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.functions.href.VdcURNToHref;
/** /**
* Provides synchronous access to a vDC. * Provides synchronous access to a vDC.
@ -196,5 +198,9 @@ public interface VdcApi {
* @return synchronous access to {@link Metadata.Readable} features * @return synchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataApi.Readable getMetadataApi(); MetadataApi.Readable getMetadataApi(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn);
@Delegate
MetadataApi.Readable getMetadataApi(@EndpointParam URI vdcHref);
} }

View File

@ -258,6 +258,9 @@ public interface VdcAsyncApi {
* @return asynchronous access to {@link Metadata.Readable} features * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@Delegate @Delegate
MetadataAsyncApi.Readable getMetadataApi(); MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn);
@Delegate
MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI vdcHref);
} }

View File

@ -23,6 +23,8 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket;
@ -41,11 +43,12 @@ import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.functions.href.VmURNToHref;
/** /**
* Provides synchronous access to {@link Vm} objects. * Provides synchronous access to {@link Vm} objects.
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org, Adrian Cole
* @see VmAsyncApi * @see VmAsyncApi
* @version 1.5 * @version 1.5
*/ */
@ -56,25 +59,31 @@ public interface VmApi {
* Retrieves a {@link Vm}. * Retrieves a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#getVApp(URI) * @see VAppApi#get(String)
*/ */
Vm get(URI vmURI); Vm get(String vmUrn);
Vm get(URI vmHref);
/** /**
* Modifies the name/description of a {@link Vm}. * Modifies the name/description of a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#editVApp(URI, VApp) * @see VAppApi#edit(String, VApp)
*/ */
Task edit(URI vmURI, Vm vm); Task edit(String vmUrn, Vm vm);
Task edit(URI vmHref, Vm vm);
/** /**
* Deletes a {@link Vm}. * Deletes a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#removeVApp(URI) * @see VAppApi#remove(String)
*/ */
Task remove(URI vmURI); Task remove(String vmUrn);
Task remove(URI vmHref);
/** /**
* Consolidates a {@link Vm}. * Consolidates a {@link Vm}.
@ -85,23 +94,29 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
Task consolidate(URI vmURI); Task consolidate(String vmUrn);
Task consolidate(URI vmHref);
/** /**
* Deploys a {@link Vm}. * Deploys a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#deploy(URI, DeployVAppParams) * @see VAppApi#deploy(String, DeployVAppParams)
*/ */
Task deploy(URI vmURI, DeployVAppParams params); Task deploy(String vmUrn, DeployVAppParams params);
Task deploy(URI vmHref, DeployVAppParams params);
/** /**
* Discard suspended state of a {@link Vm}. * Discard suspended state of a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#discardSuspendedState(URI) * @see VAppApi#discardSuspendedState(String)
*/ */
Task discardSuspendedState(URI vmURI); Task discardSuspendedState(String vmUrn);
Task discardSuspendedState(URI vmHref);
/** /**
* Installs VMware tools to the virtual machine. * Installs VMware tools to the virtual machine.
@ -114,7 +129,9 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
Task installVMwareTools(URI vmURI); Task installVMwareTools(String vmUrn);
Task installVMwareTools(URI vmHref);
/** /**
* Relocates a {@link Vm}. * Relocates a {@link Vm}.
@ -125,19 +142,23 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
Task relocate(URI vmURI, RelocateParams params); Task relocate(String vmUrn, RelocateParams params);
Task relocate(URI vmHref, RelocateParams params);
/** /**
* Undeploy a {@link Vm}. * Undeploy a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#undeploy(URI, UndeployVAppParams) * @see VAppApi#undeploy(String, UndeployVAppParams)
*/ */
Task undeploy(URI vmURI, UndeployVAppParams params); Task undeploy(String vmUrn, UndeployVAppParams params);
Task undeploy(URI vmHref, UndeployVAppParams params);
/** /**
* Upgrade virtual hardware version of a VM to the highest supported virtual * Upgrade virtual hardware version of a VM to the highest supported virtual hardware version of
* hardware version of provider vDC where the VM locates. * provider vDC where the VM locates.
* *
* <pre> * <pre>
* POST /vApp/{id}/action/upgradeHardwareVersion * POST /vApp/{id}/action/upgradeHardwareVersion
@ -145,55 +166,69 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
Task upgradeHardwareVersion(URI vmURI); Task upgradeHardwareVersion(String vmUrn);
Task upgradeHardwareVersion(URI vmHref);
/** /**
* Powers off a {@link Vm}. * Powers off a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#powerOff(URI) * @see VAppApi#powerOff(String)
*/ */
Task powerOff(URI vmURI); Task powerOff(String vmUrn);
Task powerOff(URI vmHref);
/** /**
* Powers on a {@link Vm}. * Powers on a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#powerOn(URI) * @see VAppApi#powerOn(String)
*/ */
Task powerOn(URI vmURI); Task powerOn(String vmUrn);
Task powerOn(URI vmHref);
/** /**
* Reboots a {@link Vm}. * Reboots a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#reboot(URI) * @see VAppApi#reboot(String)
*/ */
Task reboot(URI vmURI); Task reboot(String vmUrn);
Task reboot(URI vmHref);
/** /**
* Resets a {@link Vm}. * Resets a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#reset(URI) * @see VAppApi#reset(String)
*/ */
Task reset(URI vmURI); Task reset(String vmUrn);
Task reset(URI vmHref);
/** /**
* Shuts down a {@link Vm}. * Shuts down a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#shutdown(URI) * @see VAppApi#shutdown(String)
*/ */
Task shutdown(URI vmURI); Task shutdown(String vmUrn);
Task shutdown(URI vmHref);
/** /**
* Suspends a {@link Vm}. * Suspends a {@link Vm}.
* *
* @since 0.9 * @since 0.9
* @see VAppApi#suspend(URI) * @see VAppApi#suspend(String)
*/ */
Task suspend(URI vmURI); Task suspend(String vmUrn);
Task suspend(URI vmHref);
/** /**
* Retrieves the guest customization section of a {@link Vm}. * Retrieves the guest customization section of a {@link Vm}.
@ -203,9 +238,10 @@ public interface VmApi {
* </pre> * </pre>
* *
* @since 1.0 * @since 1.0
* @see VAppApi#
*/ */
GuestCustomizationSection getGuestCustomizationSection(URI vmURI); GuestCustomizationSection getGuestCustomizationSection(String vmUrn);
GuestCustomizationSection getGuestCustomizationSection(URI vmHref);
/** /**
* Modifies the guest customization section of a {@link Vm}. * Modifies the guest customization section of a {@link Vm}.
@ -216,7 +252,9 @@ public interface VmApi {
* *
* @since 1.0 * @since 1.0
*/ */
Task editGuestCustomizationSection(URI vmURI, GuestCustomizationSection section); Task editGuestCustomizationSection(String vmUrn, GuestCustomizationSection section);
Task editGuestCustomizationSection(URI vmHref, GuestCustomizationSection section);
/** /**
* Ejects media from a {@link Vm}. * Ejects media from a {@link Vm}.
@ -227,7 +265,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); Task ejectMedia(String vmUrn, MediaInsertOrEjectParams mediaParams);
Task ejectMedia(URI vmHref, MediaInsertOrEjectParams mediaParams);
/** /**
* Insert media into a {@link Vm}. * Insert media into a {@link Vm}.
@ -238,7 +278,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); Task insertMedia(String vmUrn, MediaInsertOrEjectParams mediaParams);
Task insertMedia(URI vmHref, MediaInsertOrEjectParams mediaParams);
/** /**
* Retrieves the network connection section of a {@link Vm}. * Retrieves the network connection section of a {@link Vm}.
@ -249,7 +291,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
NetworkConnectionSection getNetworkConnectionSection(URI vmURI); NetworkConnectionSection getNetworkConnectionSection(String vmUrn);
NetworkConnectionSection getNetworkConnectionSection(URI vmHref);
/** /**
* Modifies the network connection section of a {@link Vm}. * Modifies the network connection section of a {@link Vm}.
@ -260,7 +304,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editNetworkConnectionSection(URI vmURI, NetworkConnectionSection section); Task editNetworkConnectionSection(String vmUrn, NetworkConnectionSection section);
Task editNetworkConnectionSection(URI vmHref, NetworkConnectionSection section);
/** /**
* Retrieves the operating system section of a {@link Vm}. * Retrieves the operating system section of a {@link Vm}.
@ -271,7 +317,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
OperatingSystemSection getOperatingSystemSection(URI vmURI); OperatingSystemSection getOperatingSystemSection(String vmUrn);
OperatingSystemSection getOperatingSystemSection(URI vmHref);
/** /**
* Modifies the operating system section of a {@link Vm}. * Modifies the operating system section of a {@link Vm}.
@ -282,29 +330,36 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editOperatingSystemSection(URI vmURI, OperatingSystemSection section); Task editOperatingSystemSection(String vmUrn, OperatingSystemSection section);
Task editOperatingSystemSection(URI vmHref, OperatingSystemSection section);
/** /**
* Retrieves {@link Vm} product sections. * Retrieves {@link Vm} product sections.
* *
* @since 1.5 * @since 1.5
* @see VAppApi#getProductSections(URI) * @see VAppApi#getProductSections(String)
*/ */
ProductSectionList getProductSections(URI vmURI); ProductSectionList getProductSections(String vmUrn);
ProductSectionList getProductSections(URI vmHref);
/** /**
* Modifies the product section information of a {@link Vm}. * Modifies the product section information of a {@link Vm}.
* *
* @since 1.5 * @since 1.5
* @see VAppApi#editProductSections(URI, ProductSectionList) * @see VAppApi#editProductSections(String, ProductSectionList)
*/ */
Task editProductSections(URI vmURI, ProductSectionList sectionList); Task editProductSections(String vmUrn, ProductSectionList sectionList);
Task editProductSections(URI vmHref, ProductSectionList sectionList);
/** /**
* Retrieves a pending question for a {@link Vm}. * Retrieves a pending question for a {@link Vm}.
* *
* The user should answer to the question by operation {@link #answerQuestion(URI, VmQuestionAnswer)}. * The user should answer to the question by operation
* Usually questions will be asked when the VM is powering on. * {@link #answerQuestion(String, VmQuestionAnswer)}. Usually questions will be asked when the VM
* is powering on.
* *
* <pre> * <pre>
* GET /vApp/{id}/question * GET /vApp/{id}/question
@ -312,12 +367,15 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
VmPendingQuestion getPendingQuestion(URI vmURI); VmPendingQuestion getPendingQuestion(String vmUrn);
VmPendingQuestion getPendingQuestion(URI vmHref);
/** /**
* Answer a pending question on a {@link Vm}. * Answer a pending question on a {@link Vm}.
* *
* The answer IDs of choice and question should match the ones returned from operation {@link #getPendingQuestion(URI)}. * The answer IDs of choice and question should match the ones returned from operation
* {@link #getPendingQuestion(String)}.
* *
* <pre> * <pre>
* POST /vApp/{id}/question/action/answer * POST /vApp/{id}/question/action/answer
@ -325,7 +383,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
void answerQuestion(URI vmURI, VmQuestionAnswer answer); void answerQuestion(String vmUrn, VmQuestionAnswer answer);
void answerQuestion(URI vmHref, VmQuestionAnswer answer);
/** /**
* Retrieves the runtime info section of a {@link Vm}. * Retrieves the runtime info section of a {@link Vm}.
@ -336,7 +396,9 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
RuntimeInfoSection getRuntimeInfoSection(URI vmURI); RuntimeInfoSection getRuntimeInfoSection(String vmUrn);
RuntimeInfoSection getRuntimeInfoSection(URI vmHref);
/** /**
* Retrieves the thumbnail of the screen of a {@link Vm}. * Retrieves the thumbnail of the screen of a {@link Vm}.
@ -349,15 +411,19 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
byte[] getScreenImage(URI vmURI); byte[] getScreenImage(String vmUrn);
byte[] getScreenImage(URI vmHref);
/** /**
* Retrieve a screen ticket for remote console connection to a {@link Vm}. * Retrieve a screen ticket for remote console connection to a {@link Vm}.
* *
* A screen ticket is a string that includes the virtual machine's IP address, its managed object reference, and a string * A screen ticket is a string that includes the virtual machine's IP address, its managed object
* that has been encoded as described in RFC 2396. Each VM element in a vApp includes a link where rel="screen:acquireTicket". * reference, and a string that has been encoded as described in RFC 2396. Each VM element in a
* You can use that link to request a screen ticket that you can use with the vmware-vmrc utility to open a VMware Remote * vApp includes a link where rel="screen:acquireTicket". You can use that link to request a
* Console for the virtual machine represented by that VM element. The vApp should be running to get a valid screen ticket. * screen ticket that you can use with the vmware-vmrc utility to open a VMware Remote Console
* for the virtual machine represented by that VM element. The vApp should be running to get a
* valid screen ticket.
* *
* <pre> * <pre>
* GET /vApp/{id}/screen/action/acquireTicket * GET /vApp/{id}/screen/action/acquireTicket
@ -365,7 +431,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
ScreenTicket getScreenTicket(URI vmURI); ScreenTicket getScreenTicket(String vmUrn);
ScreenTicket getScreenTicket(URI vmHref);
/** /**
* Retrieves the virtual hardware section of a {@link Vm}. * Retrieves the virtual hardware section of a {@link Vm}.
@ -376,7 +444,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
VirtualHardwareSection getVirtualHardwareSection(URI vmURI); VirtualHardwareSection getVirtualHardwareSection(String vmUrn);
VirtualHardwareSection getVirtualHardwareSection(URI vmHref);
/** /**
* Modifies the virtual hardware section of a {@link Vm}. * Modifies the virtual hardware section of a {@link Vm}.
@ -387,7 +457,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editVirtualHardwareSection(URI vmURI, VirtualHardwareSection section); Task editVirtualHardwareSection(String vmUrn, VirtualHardwareSection section);
Task editVirtualHardwareSection(URI vmHref, VirtualHardwareSection section);
/** /**
* Retrieves the CPU properties in virtual hardware section of a {@link Vm}. * Retrieves the CPU properties in virtual hardware section of a {@link Vm}.
@ -398,7 +470,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
RasdItem getVirtualHardwareSectionCpu(URI vmURI); RasdItem getVirtualHardwareSectionCpu(String vmUrn);
RasdItem getVirtualHardwareSectionCpu(URI vmHref);
/** /**
* Modifies the CPU properties in virtual hardware section of a {@link Vm}. * Modifies the CPU properties in virtual hardware section of a {@link Vm}.
@ -409,7 +483,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd); Task editVirtualHardwareSectionCpu(String vmUrn, RasdItem rasd);
Task editVirtualHardwareSectionCpu(URI vmHref, RasdItem rasd);
/** /**
* Retrieves a list of items for disks from virtual hardware section of a {@link Vm}. * Retrieves a list of items for disks from virtual hardware section of a {@link Vm}.
@ -420,7 +496,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
RasdItemsList getVirtualHardwareSectionDisks(URI vmURI); RasdItemsList getVirtualHardwareSectionDisks(String vmUrn);
RasdItemsList getVirtualHardwareSectionDisks(URI vmHref);
/** /**
* Modifies the disks list in virtual hardware section of a {@link Vm}. * Modifies the disks list in virtual hardware section of a {@link Vm}.
@ -431,7 +509,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editVirtualHardwareSectionDisks(URI vmURI, RasdItemsList rasdItemsList); Task editVirtualHardwareSectionDisks(String vmUrn, RasdItemsList rasdItemsList);
Task editVirtualHardwareSectionDisks(URI vmHref, RasdItemsList rasdItemsList);
/** /**
* Retrieves the list of items that represents the floppies and CD/DVD drives in a {@link Vm}. * Retrieves the list of items that represents the floppies and CD/DVD drives in a {@link Vm}.
@ -442,10 +522,13 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
RasdItemsList getVirtualHardwareSectionMedia(URI vmURI); RasdItemsList getVirtualHardwareSectionMedia(String vmUrn);
RasdItemsList getVirtualHardwareSectionMedia(URI vmHref);
/** /**
* Retrieves the item that contains memory information from virtual hardware section of a {@link Vm}. * Retrieves the item that contains memory information from virtual hardware section of a
* {@link Vm}.
* *
* <pre> * <pre>
* GET /vApp/{id}/virtualHardwareSection/memory * GET /vApp/{id}/virtualHardwareSection/memory
@ -453,7 +536,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
RasdItem getVirtualHardwareSectionMemory(URI vmURI); RasdItem getVirtualHardwareSectionMemory(String vmUrn);
RasdItem getVirtualHardwareSectionMemory(URI vmHref);
/** /**
* Modifies the memory properties in virtual hardware section of a {@link Vm}. * Modifies the memory properties in virtual hardware section of a {@link Vm}.
@ -464,7 +549,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editVirtualHardwareSectionMemory(URI vmURI, RasdItem rasd); Task editVirtualHardwareSectionMemory(String vmUrn, RasdItem rasd);
Task editVirtualHardwareSectionMemory(URI vmHref, RasdItem rasd);
/** /**
* Retrieves a list of items for network cards from virtual hardware section of a {@link Vm}. * Retrieves a list of items for network cards from virtual hardware section of a {@link Vm}.
@ -475,7 +562,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI); RasdItemsList getVirtualHardwareSectionNetworkCards(String vmUrn);
RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmHref);
/** /**
* Modifies the network cards list in virtual hardware section of a {@link Vm}. * Modifies the network cards list in virtual hardware section of a {@link Vm}.
@ -486,7 +575,9 @@ public interface VmApi {
* *
* @since 0.9 * @since 0.9
*/ */
Task editVirtualHardwareSectionNetworkCards(URI vmURI, RasdItemsList rasdItemsList); Task editVirtualHardwareSectionNetworkCards(String vmUrn, RasdItemsList rasdItemsList);
Task editVirtualHardwareSectionNetworkCards(URI vmHref, RasdItemsList rasdItemsList);
/** /**
* Retrieves a list of items for serial ports from virtual hardware section of a {@link Vm}. * Retrieves a list of items for serial ports from virtual hardware section of a {@link Vm}.
@ -497,7 +588,9 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI); RasdItemsList getVirtualHardwareSectionSerialPorts(String vmUrn);
RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmHref);
/** /**
* Modifies the serial ports list in virtual hardware section of a {@link Vm}. * Modifies the serial ports list in virtual hardware section of a {@link Vm}.
@ -508,11 +601,17 @@ public interface VmApi {
* *
* @since 1.5 * @since 1.5
*/ */
Task editVirtualHardwareSectionSerialPorts(URI vmURI, RasdItemsList rasdItemsList); Task editVirtualHardwareSectionSerialPorts(String vmUrn, RasdItemsList rasdItemsList);
Task editVirtualHardwareSectionSerialPorts(URI vmHref, RasdItemsList rasdItemsList);
/** /**
* Synchronous access to {@link Vm} {@link Metadata} features. * Synchronous access to {@link Vm} {@link Metadata} features.
*/ */
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI vmHref);
} }

View File

@ -44,6 +44,7 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.dmtf.cim.ResourceAllocationSettingData;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
@ -53,6 +54,7 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket;
@ -72,16 +74,470 @@ import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes; import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes;
import org.jclouds.vcloud.director.v1_5.functions.href.VmURNToHref;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
* @author grkvlt@apache.org * @author grkvlt@apache.org, Adrian Cole
* @see VmApi * @see VmApi
*/ */
@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
public interface VmAsyncApi { public interface VmAsyncApi {
/**
* @see VmApi#get(String)
*/
@GET
@Consumes(VM)
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Vm> get(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#edit(String, Vm)
*/
@PUT
@Produces(VM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> edit(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) Vm vApp);
/**
* @see VmApi#remove(String)
*/
@DELETE
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> remove(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#consolidate(String)
*/
@POST
@Path("/action/consolidate")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> consolidate(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#deploy(String, DeployVAppParams)
*/
@POST
@Path("/action/deploy")
@Produces(DEPLOY_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> deploy(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) DeployVAppParams params);
/**
* @see VmApi#discardSuspendedState(String)
*/
@POST
@Path("/action/discardSuspendedState")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> discardSuspendedState(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#installVMwareTools(String)
*/
@POST
@Path("/action/installVMwareTools")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> installVMwareTools(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#relocate(String, RelocateParams)
*/
@POST
@Path("/action/relocate")
@Produces(RELOCATE_VM_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> relocate(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) RelocateParams params);
/**
* @see VmApi#undeploy(String, UndeployVAppParams)
*/
@POST
@Path("/action/undeploy")
@Produces(UNDEPLOY_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> undeploy(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) UndeployVAppParams params);
/**
* @see VmApi#upgradeHardwareVersion(String)
*/
@POST
@Path("/action/upgradeHardwareVersion")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> upgradeHardwareVersion(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#powerOff(String)
*/
@POST
@Path("/power/action/powerOff")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> powerOff(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#powerOn(String)
*/
@POST
@Path("/power/action/powerOn")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> powerOn(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#reboot(String)
*/
@POST
@Path("/power/action/powerOff")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> reboot(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#reset(String)
*/
@POST
@Path("/power/action/reset")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> reset(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#shutdown(String)
*/
@POST
@Path("/power/action/shutdown")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> shutdown(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#suspend(String)
*/
@POST
@Path("/power/action/suspend")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> suspend(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#getGuestCustomizationSection(String)
*/
@GET
@Path("/guestCustomizationSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<GuestCustomizationSection> getGuestCustomizationSection(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editGuestCustomizationSection(String, GuestCustomizationSection)
*/
@PUT
@Path("/guestCustomizationSection")
@Produces(GUEST_CUSTOMIZATION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editGuestCustomizationSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) GuestCustomizationSection section);
/**
* @see VmApi#ejectMedia(String, MediaInsertOrEjectParams)
*/
@POST
@Path("/media/action/ejectMedia")
@Produces(MEDIA_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> ejectMedia(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @see VmApi#insertMedia(String, MediaInsertOrEjectParams)
*/
@POST
@Path("/media/action/insertMedia")
@Produces(MEDIA_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> insertMedia(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @see VmApi#getNetworkConnectionSection(String)
*/
@GET
@Path("/networkConnectionSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editNetworkConnectionSection(String, NetworkConnectionSection)
*/
@PUT
@Path("/networkConnectionSection")
@Produces(NETWORK_CONNECTION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editNetworkConnectionSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) NetworkConnectionSection section);
/**
* @see VmApi#getOperatingSystemSection(String)
*/
@GET
@Path("/operatingSystemSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<OperatingSystemSection> getOperatingSystemSection(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editOperatingSystemSection(String, OperatingSystemSection)
*/
@PUT
@Path("/operatingSystemSection")
@Produces(OPERATING_SYSTEM_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editOperatingSystemSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) OperatingSystemSection section);
/**
* @see VmApi#getProductSections(String)
*/
@GET
@Path("/productSections")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editProductSections(String, ProductSectionList)
*/
@PUT
@Path("/productSections")
@Produces(PRODUCT_SECTION_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editProductSections(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) ProductSectionList sectionList);
/**
* @see VmApi#getPendingQuestion(String)
*/
@GET
@Path("/question")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VmPendingQuestion> getPendingQuestion(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#answerQuestion(String, VmQuestionAnswer)
*/
@POST
@Path("/question/action/answer")
@Produces(VM_PENDING_ANSWER)
@Consumes
@JAXBResponseParser
ListenableFuture<Void> answerQuestion(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer);
/**
* @see VmApi#getRuntimeInfoSection(String)
*/
@GET
@Path("/runtimeInfoSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RuntimeInfoSection> getRuntimeInfoSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#getScreenImage(String)
*/
@GET
@Path("/screen")
@Consumes(ANY_IMAGE)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(ReturnPayloadBytes.class)
ListenableFuture<byte[]> getScreenImage(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#getScreenTicket(String)
*/
@POST
@Path("/screen/action/acquireTicket")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ScreenTicket> getScreenTicket(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#getVirtualHardwareSection(String)
*/
@GET
@Path("/virtualHardwareSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VirtualHardwareSection> getVirtualHardwareSection(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editVirtualHardwareSection(String, VirtualHardwareSection)
*/
@PUT
@Path("/virtualHardwareSection")
@Produces(VIRTUAL_HARDWARE_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) VirtualHardwareSection section);
/**
* @see VmApi#getVirtualHardwareSectionCpu(String)
*/
@GET
@Path("/virtualHardwareSection/cpu")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionCpu(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editVirtualHardwareSectionCpu(String, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/cpu")
@Produces(OVF_RASD_ITEM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionCpu(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) RasdItem rasd);
/**
* @see VmApi#getVirtualHardwareSectionDisks(String)
*/
@GET
@Path("/virtualHardwareSection/disks")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editVirtualHardwareSectionDisks(String, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/disks")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionDisks(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @see VmApi#getVirtualHardwareSectionMedia(String)
*/
@GET
@Path("/virtualHardwareSection/media")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#getVirtualHardwareSectionMemory(String)
*/
@GET
@Path("/virtualHardwareSection/memory")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionMemory(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editVirtualHardwareSectionMemory(String, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/memory")
@Produces(OVF_RASD_ITEM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionMemory(@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) RasdItem rasd);
/**
* @see VmApi#getVirtualHardwareSectionNetworkCards(String)
*/
@GET
@Path("/virtualHardwareSection/networkCards")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editVirtualHardwareSectionNetworkCards(String, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/networkCards")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionNetworkCards(
@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @see VmApi#getVirtualHardwareSectionSerialPorts(String)
*/
@GET
@Path("/virtualHardwareSection/serialPorts")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(
@EndpointParam(parser = VmURNToHref.class) String vmUrn);
/**
* @see VmApi#editVirtualHardwareSectionSerialPorts(String, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/serialPorts")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionSerialPorts(
@EndpointParam(parser = VmURNToHref.class) String vmUrn,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/** /**
* @see VmApi#get(URI) * @see VmApi#get(URI)
*/ */
@ -89,7 +545,7 @@ public interface VmAsyncApi {
@Consumes(VM) @Consumes(VM)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Vm> getVm(@EndpointParam URI vmURI); ListenableFuture<Vm> get(@EndpointParam URI vmHref);
/** /**
* @see VmApi#edit(URI, Vm) * @see VmApi#edit(URI, Vm)
@ -98,8 +554,7 @@ public interface VmAsyncApi {
@Produces(VM) @Produces(VM)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVm(@EndpointParam URI vmURI, ListenableFuture<Task> edit(@EndpointParam URI vmHref, @BinderParam(BindToXMLPayload.class) Vm vApp);
@BinderParam(BindToXMLPayload.class) Vm vApp);
/** /**
* @see VmApi#remove(URI) * @see VmApi#remove(URI)
@ -107,7 +562,7 @@ public interface VmAsyncApi {
@DELETE @DELETE
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> removeVm(@EndpointParam URI vmURI); ListenableFuture<Task> remove(@EndpointParam URI vmHref);
/** /**
* @see VmApi#consolidate(URI) * @see VmApi#consolidate(URI)
@ -116,7 +571,7 @@ public interface VmAsyncApi {
@Path("/action/consolidate") @Path("/action/consolidate")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> consolidateVm(@EndpointParam URI vmURI); ListenableFuture<Task> consolidate(@EndpointParam URI vmHref);
/** /**
* @see VmApi#deploy(URI, DeployVAppParams) * @see VmApi#deploy(URI, DeployVAppParams)
@ -126,8 +581,7 @@ public interface VmAsyncApi {
@Produces(DEPLOY_VAPP_PARAMS) @Produces(DEPLOY_VAPP_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> deploy(@EndpointParam URI vmURI, ListenableFuture<Task> deploy(@EndpointParam URI vmHref, @BinderParam(BindToXMLPayload.class) DeployVAppParams params);
@BinderParam(BindToXMLPayload.class) DeployVAppParams params);
/** /**
* @see VmApi#discardSuspendedState(URI) * @see VmApi#discardSuspendedState(URI)
@ -136,7 +590,7 @@ public interface VmAsyncApi {
@Path("/action/discardSuspendedState") @Path("/action/discardSuspendedState")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> discardSuspendedState(@EndpointParam URI vmURI); ListenableFuture<Task> discardSuspendedState(@EndpointParam URI vmHref);
/** /**
* @see VmApi#installVMwareTools(URI) * @see VmApi#installVMwareTools(URI)
@ -145,7 +599,7 @@ public interface VmAsyncApi {
@Path("/action/installVMwareTools") @Path("/action/installVMwareTools")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> installVMwareTools(@EndpointParam URI vmURI); ListenableFuture<Task> installVMwareTools(@EndpointParam URI vmHref);
/** /**
* @see VmApi#relocate(URI, RelocateParams) * @see VmApi#relocate(URI, RelocateParams)
@ -155,8 +609,7 @@ public interface VmAsyncApi {
@Produces(RELOCATE_VM_PARAMS) @Produces(RELOCATE_VM_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> relocateVm(@EndpointParam URI vmURI, ListenableFuture<Task> relocate(@EndpointParam URI vmHref, @BinderParam(BindToXMLPayload.class) RelocateParams params);
@BinderParam(BindToXMLPayload.class) RelocateParams params);
/** /**
* @see VmApi#undeploy(URI, UndeployVAppParams) * @see VmApi#undeploy(URI, UndeployVAppParams)
@ -166,7 +619,7 @@ public interface VmAsyncApi {
@Produces(UNDEPLOY_VAPP_PARAMS) @Produces(UNDEPLOY_VAPP_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> undeploy(@EndpointParam URI vmURI, ListenableFuture<Task> undeploy(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) UndeployVAppParams params); @BinderParam(BindToXMLPayload.class) UndeployVAppParams params);
/** /**
@ -176,7 +629,7 @@ public interface VmAsyncApi {
@Path("/action/upgradeHardwareVersion") @Path("/action/upgradeHardwareVersion")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> upgradeHardwareVersion(@EndpointParam URI vmURI); ListenableFuture<Task> upgradeHardwareVersion(@EndpointParam URI vmHref);
/** /**
* @see VmApi#powerOff(URI) * @see VmApi#powerOff(URI)
@ -185,7 +638,7 @@ public interface VmAsyncApi {
@Path("/power/action/powerOff") @Path("/power/action/powerOff")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> powerOff(@EndpointParam URI vmURI); ListenableFuture<Task> powerOff(@EndpointParam URI vmHref);
/** /**
* @see VmApi#powerOn(URI) * @see VmApi#powerOn(URI)
@ -194,7 +647,7 @@ public interface VmAsyncApi {
@Path("/power/action/powerOn") @Path("/power/action/powerOn")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> powerOn(@EndpointParam URI vmURI); ListenableFuture<Task> powerOn(@EndpointParam URI vmHref);
/** /**
* @see VmApi#reboot(URI) * @see VmApi#reboot(URI)
@ -203,7 +656,7 @@ public interface VmAsyncApi {
@Path("/power/action/powerOff") @Path("/power/action/powerOff")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> reboot(@EndpointParam URI vmURI); ListenableFuture<Task> reboot(@EndpointParam URI vmHref);
/** /**
* @see VmApi#reset(URI) * @see VmApi#reset(URI)
@ -212,7 +665,7 @@ public interface VmAsyncApi {
@Path("/power/action/reset") @Path("/power/action/reset")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> reset(@EndpointParam URI vmURI); ListenableFuture<Task> reset(@EndpointParam URI vmHref);
/** /**
* @see VmApi#shutdown(URI) * @see VmApi#shutdown(URI)
@ -221,7 +674,7 @@ public interface VmAsyncApi {
@Path("/power/action/shutdown") @Path("/power/action/shutdown")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> shutdown(@EndpointParam URI vmURI); ListenableFuture<Task> shutdown(@EndpointParam URI vmHref);
/** /**
* @see VmApi#suspend(URI) * @see VmApi#suspend(URI)
@ -230,7 +683,7 @@ public interface VmAsyncApi {
@Path("/power/action/suspend") @Path("/power/action/suspend")
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> suspend(@EndpointParam URI vmURI); ListenableFuture<Task> suspend(@EndpointParam URI vmHref);
/** /**
* @see VmApi#getGuestCustomizationSection(URI) * @see VmApi#getGuestCustomizationSection(URI)
@ -240,7 +693,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<GuestCustomizationSection> getGuestCustomizationSection(@EndpointParam URI vmURI); ListenableFuture<GuestCustomizationSection> getGuestCustomizationSection(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editGuestCustomizationSection(URI, GuestCustomizationSection) * @see VmApi#editGuestCustomizationSection(URI, GuestCustomizationSection)
@ -250,7 +703,7 @@ public interface VmAsyncApi {
@Produces(GUEST_CUSTOMIZATION_SECTION) @Produces(GUEST_CUSTOMIZATION_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editGuestCustomizationSection(@EndpointParam URI vmURI, ListenableFuture<Task> editGuestCustomizationSection(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section);
/** /**
@ -261,7 +714,7 @@ public interface VmAsyncApi {
@Produces(MEDIA_PARAMS) @Produces(MEDIA_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> ejectMedia(@EndpointParam URI vmURI, ListenableFuture<Task> ejectMedia(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/** /**
@ -272,7 +725,7 @@ public interface VmAsyncApi {
@Produces(MEDIA_PARAMS) @Produces(MEDIA_PARAMS)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> insertMedia(@EndpointParam URI vmURI, ListenableFuture<Task> insertMedia(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/** /**
@ -283,7 +736,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI vmURI); ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editNetworkConnectionSection(URI, NetworkConnectionSection) * @see VmApi#editNetworkConnectionSection(URI, NetworkConnectionSection)
@ -293,7 +746,7 @@ public interface VmAsyncApi {
@Produces(NETWORK_CONNECTION_SECTION) @Produces(NETWORK_CONNECTION_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editNetworkConnectionSection(@EndpointParam URI vmURI, ListenableFuture<Task> editNetworkConnectionSection(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section);
/** /**
@ -304,7 +757,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<OperatingSystemSection> getOperatingSystemSection(@EndpointParam URI vmURI); ListenableFuture<OperatingSystemSection> getOperatingSystemSection(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editOperatingSystemSection(URI, OperatingSystemSection) * @see VmApi#editOperatingSystemSection(URI, OperatingSystemSection)
@ -314,7 +767,7 @@ public interface VmAsyncApi {
@Produces(OPERATING_SYSTEM_SECTION) @Produces(OPERATING_SYSTEM_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editOperatingSystemSection(@EndpointParam URI vmURI, ListenableFuture<Task> editOperatingSystemSection(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) OperatingSystemSection section); @BinderParam(BindToXMLPayload.class) OperatingSystemSection section);
/** /**
@ -325,7 +778,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI vmURI); ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editProductSections(URI, ProductSectionList) * @see VmApi#editProductSections(URI, ProductSectionList)
@ -335,7 +788,7 @@ public interface VmAsyncApi {
@Produces(PRODUCT_SECTION_LIST) @Produces(PRODUCT_SECTION_LIST)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editProductSections(@EndpointParam URI vmURI, ListenableFuture<Task> editProductSections(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList);
/** /**
@ -346,7 +799,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VmPendingQuestion> getPendingQuestion(@EndpointParam URI vmURI); ListenableFuture<VmPendingQuestion> getPendingQuestion(@EndpointParam URI vmHref);
/** /**
* @see VmApi#answerQuestion(URI, VmQuestionAnswer) * @see VmApi#answerQuestion(URI, VmQuestionAnswer)
@ -356,7 +809,7 @@ public interface VmAsyncApi {
@Produces(VM_PENDING_ANSWER) @Produces(VM_PENDING_ANSWER)
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> answerQuestion(@EndpointParam URI vmURI, ListenableFuture<Void> answerQuestion(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer); @BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer);
/** /**
@ -367,7 +820,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RuntimeInfoSection> getRuntimeInfoSection(@EndpointParam URI vmURI); ListenableFuture<RuntimeInfoSection> getRuntimeInfoSection(@EndpointParam URI vmHref);
/** /**
* @see VmApi#getScreenImage(URI) * @see VmApi#getScreenImage(URI)
@ -377,7 +830,7 @@ public interface VmAsyncApi {
@Consumes(ANY_IMAGE) @Consumes(ANY_IMAGE)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(ReturnPayloadBytes.class) @ResponseParser(ReturnPayloadBytes.class)
ListenableFuture<byte[]> getScreenImage(@EndpointParam URI vmURI); ListenableFuture<byte[]> getScreenImage(@EndpointParam URI vmHref);
/** /**
* @see VmApi#getScreenTicket(URI) * @see VmApi#getScreenTicket(URI)
@ -387,7 +840,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ScreenTicket> getScreenTicket(@EndpointParam URI vmURI); ListenableFuture<ScreenTicket> getScreenTicket(@EndpointParam URI vmHref);
/** /**
* @see VmApi#getVirtualHardwareSection(URI) * @see VmApi#getVirtualHardwareSection(URI)
@ -397,7 +850,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VirtualHardwareSection> getVirtualHardwareSection(@EndpointParam URI vmURI); ListenableFuture<VirtualHardwareSection> getVirtualHardwareSection(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editVirtualHardwareSection(URI, VirtualHardwareSection) * @see VmApi#editVirtualHardwareSection(URI, VirtualHardwareSection)
@ -407,7 +860,7 @@ public interface VmAsyncApi {
@Produces(VIRTUAL_HARDWARE_SECTION) @Produces(VIRTUAL_HARDWARE_SECTION)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSection(@EndpointParam URI vmURI, ListenableFuture<Task> editVirtualHardwareSection(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) VirtualHardwareSection section); @BinderParam(BindToXMLPayload.class) VirtualHardwareSection section);
/** /**
@ -418,7 +871,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionCpu(@EndpointParam URI vmURI); ListenableFuture<RasdItem> getVirtualHardwareSectionCpu(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData) * @see VmApi#editVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData)
@ -428,7 +881,7 @@ public interface VmAsyncApi {
@Produces(OVF_RASD_ITEM) @Produces(OVF_RASD_ITEM)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionCpu(@EndpointParam URI vmURI, ListenableFuture<Task> editVirtualHardwareSectionCpu(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) RasdItem rasd); @BinderParam(BindToXMLPayload.class) RasdItem rasd);
/** /**
@ -439,7 +892,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(@EndpointParam URI vmURI); ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editVirtualHardwareSectionDisks(URI, RasdItemsList) * @see VmApi#editVirtualHardwareSectionDisks(URI, RasdItemsList)
@ -449,7 +902,7 @@ public interface VmAsyncApi {
@Produces(OVF_RASD_ITEMS_LIST) @Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionDisks(@EndpointParam URI vmURI, ListenableFuture<Task> editVirtualHardwareSectionDisks(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/** /**
@ -460,7 +913,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(@EndpointParam URI vmURI); ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(@EndpointParam URI vmHref);
/** /**
* @see VmApi#getVirtualHardwareSectionMemory(URI) * @see VmApi#getVirtualHardwareSectionMemory(URI)
@ -470,7 +923,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionMemory(@EndpointParam URI vmURI); ListenableFuture<RasdItem> getVirtualHardwareSectionMemory(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData) * @see VmApi#editVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData)
@ -480,7 +933,7 @@ public interface VmAsyncApi {
@Produces(OVF_RASD_ITEM) @Produces(OVF_RASD_ITEM)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionMemory(@EndpointParam URI vmURI, ListenableFuture<Task> editVirtualHardwareSectionMemory(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) RasdItem rasd); @BinderParam(BindToXMLPayload.class) RasdItem rasd);
/** /**
@ -491,7 +944,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI); ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editVirtualHardwareSectionNetworkCards(URI, RasdItemsList) * @see VmApi#editVirtualHardwareSectionNetworkCards(URI, RasdItemsList)
@ -501,7 +954,7 @@ public interface VmAsyncApi {
@Produces(OVF_RASD_ITEMS_LIST) @Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI, ListenableFuture<Task> editVirtualHardwareSectionNetworkCards(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/** /**
@ -512,7 +965,7 @@ public interface VmAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI); ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmHref);
/** /**
* @see VmApi#editVirtualHardwareSectionSerialPorts(URI, RasdItemsList) * @see VmApi#editVirtualHardwareSectionSerialPorts(URI, RasdItemsList)
@ -522,12 +975,16 @@ public interface VmAsyncApi {
@Produces(OVF_RASD_ITEMS_LIST) @Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> editVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI, ListenableFuture<Task> editVirtualHardwareSectionSerialPorts(@EndpointParam URI vmHref,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/** /**
* Asynchronous access to {@Vm} {@link Metadata} features. * Asynchronous access to {@Vm} {@link Metadata} features.
*/ */
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VmURNToHref.class) String vmUrn);
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI vmHref);
} }

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
@ -30,6 +31,7 @@ import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams;
import org.jclouds.vcloud.director.v1_5.features.CatalogApi; import org.jclouds.vcloud.director.v1_5.features.CatalogApi;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
import org.jclouds.vcloud.director.v1_5.functions.href.CatalogURNToAdminHref;
/** /**
* Provides synchronous access to {@link AdminCatalog} objects. * Provides synchronous access to {@link AdminCatalog} objects.
@ -166,5 +168,10 @@ public interface AdminCatalogApi extends CatalogApi {
*/ */
@Override @Override
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = CatalogURNToAdminHref.class) String catalogUrn);
@Override
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI catalogAdminHref);
} }

View File

@ -248,6 +248,10 @@ public interface AdminCatalogAsyncApi extends CatalogAsyncApi {
*/ */
@Override @Override
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = CatalogURNToAdminHref.class) String catalogUrn);
@Override
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI catalogAdminHref);
} }

View File

@ -23,11 +23,13 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.domain.network.Network;
import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
import org.jclouds.vcloud.director.v1_5.features.NetworkApi; import org.jclouds.vcloud.director.v1_5.features.NetworkApi;
import org.jclouds.vcloud.director.v1_5.functions.href.NetworkURNToAdminHref;
/** /**
* Provides synchronous access to admin {@link Network} objects. * Provides synchronous access to admin {@link Network} objects.
@ -97,6 +99,10 @@ public interface AdminNetworkApi extends NetworkApi {
*/ */
@Override @Override
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = NetworkURNToAdminHref.class) String networkUrn);
@Override
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI networkAdminHref);
} }

View File

@ -116,5 +116,10 @@ public interface AdminNetworkAsyncApi extends NetworkAsyncApi {
*/ */
@Override @Override
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = NetworkURNToAdminHref.class) String networkUrn);
@Override
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI networkAdminHref);
} }

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.org.Org; import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings;
@ -34,6 +35,7 @@ import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings;
import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
import org.jclouds.vcloud.director.v1_5.features.OrgApi; import org.jclouds.vcloud.director.v1_5.features.OrgApi;
import org.jclouds.vcloud.director.v1_5.functions.href.OrgURNToAdminHref;
/** /**
* Provides synchronous access to {@link Org} objects. * Provides synchronous access to {@link Org} objects.
@ -274,6 +276,10 @@ public interface AdminOrgApi extends OrgApi {
*/ */
@Override @Override
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = OrgURNToAdminHref.class) String orgUrn);
@Override
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI orgAdminHref);
} }

View File

@ -363,5 +363,10 @@ public interface AdminOrgAsyncApi extends OrgAsyncApi {
*/ */
@Override @Override
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = OrgURNToAdminHref.class) String orgUrn);
@Override
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI adminOrgHref);
} }

View File

@ -23,11 +23,13 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi.Writeable; import org.jclouds.vcloud.director.v1_5.features.MetadataApi.Writeable;
import org.jclouds.vcloud.director.v1_5.features.VdcApi; import org.jclouds.vcloud.director.v1_5.features.VdcApi;
import org.jclouds.vcloud.director.v1_5.functions.href.VdcURNToAdminHref;
/** /**
* Provides synchronous access to {@link AdminVdc}. * Provides synchronous access to {@link AdminVdc}.
@ -51,7 +53,7 @@ public interface AdminVdcApi extends VdcApi {
AdminVdc get(String vdcUrn); AdminVdc get(String vdcUrn);
@Override @Override
AdminVdc get(URI vdcHref); AdminVdc get(URI vdcAdminHref);
/** /**
* Modifies a Virtual Data Center. Virtual Data Center could be enabled or disabled. * Modifies a Virtual Data Center. Virtual Data Center could be enabled or disabled.
@ -60,7 +62,7 @@ public interface AdminVdcApi extends VdcApi {
*/ */
Task edit(String vdcUrn, AdminVdc vdc); Task edit(String vdcUrn, AdminVdc vdc);
Task edit(URI vdcHref, AdminVdc vdc); Task edit(URI vdcAdminHref, AdminVdc vdc);
/** /**
* Deletes a Virtual Data Center. The Virtual Data Center should be disabled when remove is issued. * Deletes a Virtual Data Center. The Virtual Data Center should be disabled when remove is issued.
@ -69,7 +71,7 @@ public interface AdminVdcApi extends VdcApi {
// TODO Saw what exception, instead of 400 // TODO Saw what exception, instead of 400
Task remove(String vdcUrn); Task remove(String vdcUrn);
Task remove(URI vdcHref); Task remove(URI vdcAdminHref);
/** /**
* Enables a Virtual Data Center. This operation enables disabled Virtual Data Center. * Enables a Virtual Data Center. This operation enables disabled Virtual Data Center.
@ -77,7 +79,7 @@ public interface AdminVdcApi extends VdcApi {
*/ */
void enable(String vdcUrn); void enable(String vdcUrn);
void enable(URI vdcHref); void enable(URI vdcAdminHref);
/** /**
* Disables a Virtual Data Center. If the Virtual Data Center is disabled this operation does not * Disables a Virtual Data Center. If the Virtual Data Center is disabled this operation does not
@ -85,11 +87,15 @@ public interface AdminVdcApi extends VdcApi {
*/ */
void disable(String vdcUrn); void disable(String vdcUrn);
void disable(URI vdcHref); void disable(URI vdcAdminHref);
/** /**
* @return synchronous access to {@link Writeable} features * @return synchronous access to {@link Writeable} features
*/ */
@Delegate @Delegate
MetadataApi.Writeable getMetadataApi(); MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn);
@Delegate
MetadataApi.Writeable getMetadataApi(@EndpointParam URI vdcAdminHref);
} }

View File

@ -104,7 +104,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<AdminVdc> get(@EndpointParam URI vdcHref); ListenableFuture<AdminVdc> get(@EndpointParam URI vdcAdminHref);
/** /**
* @see AdminVdcApi#edit(URI, AdminVdc) * @see AdminVdcApi#edit(URI, AdminVdc)
@ -113,7 +113,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi {
@Consumes @Consumes
@Produces(VCloudDirectorMediaType.ADMIN_VDC) @Produces(VCloudDirectorMediaType.ADMIN_VDC)
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> edit(@EndpointParam URI vdcHref, AdminVdc vdc); ListenableFuture<Task> edit(@EndpointParam URI vdcAdminHref, AdminVdc vdc);
/** /**
* @see AdminVdcApi#remove(URI) * @see AdminVdcApi#remove(URI)
@ -121,7 +121,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi {
@DELETE @DELETE
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> remove(@EndpointParam URI vdcHref); ListenableFuture<Task> remove(@EndpointParam URI vdcAdminHref);
/** /**
* @see AdminVdcApi#enable(URI) * @see AdminVdcApi#enable(URI)
@ -130,7 +130,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi {
@Consumes @Consumes
@Path("/action/enable") @Path("/action/enable")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> enable(@EndpointParam URI vdcHref); ListenableFuture<Void> enable(@EndpointParam URI vdcAdminHref);
/** /**
* @see AdminVdcApi#disable(URI) * @see AdminVdcApi#disable(URI)
@ -139,12 +139,17 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi {
@Consumes @Consumes
@Path("/action/disable") @Path("/action/disable")
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> disable(@EndpointParam URI vdcHref); ListenableFuture<Void> disable(@EndpointParam URI vdcAdminHref);
/** /**
* @return asynchronous access to {@link Writeable} features * @return asynchronous access to {@link Writeable} features
*/ */
@Override @Override
@Delegate @Delegate
MetadataAsyncApi.Writeable getMetadataApi(); MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn);
@Override
@Delegate
MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI vdcAdminHref);
} }

View File

@ -90,7 +90,7 @@ public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogIt
@Override @Override
public Future<? extends VAppTemplate> apply(CatalogItem from) { public Future<? extends VAppTemplate> apply(CatalogItem from) {
return new ExceptionParsingListenableFuture<VAppTemplate>(Futures.makeListenable(VCloudDirectorAsyncApi.class return new ExceptionParsingListenableFuture<VAppTemplate>(Futures.makeListenable(VCloudDirectorAsyncApi.class
.cast(aapi).getVAppTemplateApi().getVAppTemplate(from.getEntity().getHref()), executor), .cast(aapi).getVAppTemplateApi().get(from.getEntity().getHref()), executor),
returnNullOnAuthorizationException); returnNullOnAuthorizationException);
} }

View File

@ -0,0 +1,43 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions.href;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Entity;
import org.jclouds.vcloud.director.v1_5.functions.URNToHref;
import com.google.common.cache.LoadingCache;
@Singleton
public class MediaURNToHref extends URNToHref {
@Inject
public MediaURNToHref(LoadingCache<String, Entity> resolveEntityCache) {
super(resolveEntityCache);
}
@Override
protected String type() {
return VCloudDirectorMediaType.MEDIA;
}
}

View File

@ -0,0 +1,43 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions.href;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Entity;
import org.jclouds.vcloud.director.v1_5.functions.URNToHref;
import com.google.common.cache.LoadingCache;
@Singleton
public class VAppTemplateURNToHref extends URNToHref {
@Inject
public VAppTemplateURNToHref(LoadingCache<String, Entity> resolveEntityCache) {
super(resolveEntityCache);
}
@Override
protected String type() {
return VCloudDirectorMediaType.VAPP_TEMPLATE;
}
}

View File

@ -0,0 +1,43 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions.href;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Entity;
import org.jclouds.vcloud.director.v1_5.functions.URNToHref;
import com.google.common.cache.LoadingCache;
@Singleton
public class VAppURNToHref extends URNToHref {
@Inject
public VAppURNToHref(LoadingCache<String, Entity> resolveEntityCache) {
super(resolveEntityCache);
}
@Override
protected String type() {
return VCloudDirectorMediaType.VAPP;
}
}

View File

@ -0,0 +1,43 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions.href;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Entity;
import org.jclouds.vcloud.director.v1_5.functions.URNToHref;
import com.google.common.cache.LoadingCache;
@Singleton
public class VmURNToHref extends URNToHref {
@Inject
public VmURNToHref(LoadingCache<String, Entity> resolveEntityCache) {
super(resolveEntityCache);
}
@Override
protected String type() {
return VCloudDirectorMediaType.VM;
}
}

View File

@ -107,8 +107,8 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
protected Vm vm; protected Vm vm;
protected VApp vApp; protected VApp vApp;
protected VAppTemplate vAppTemplate; protected VAppTemplate vAppTemplate;
protected URI vmURI; protected String vmUrn;
protected URI vAppURI; protected String vAppUrn;
/** /**
* Retrieves the required apis from the REST API context * Retrieves the required apis from the REST API context
@ -137,35 +137,35 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
vdc = lazyGetVdc(); vdc = lazyGetVdc();
// Get the configured VAppTemplate for the tests // Get the configured VAppTemplate for the tests
vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn);
assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
// Instantiate a new VApp // Instantiate a new VApp
VApp vAppInstantiated = instantiateVApp(); VApp vAppInstantiated = instantiateVApp();
assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP));
vAppURI = vAppInstantiated.getHref(); vAppUrn = vAppInstantiated.getId();
// Wait for the task to complete // Wait for the task to complete
Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks()); Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks());
assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask")); assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask"));
// Get the instantiated VApp // Get the instantiated VApp
vApp = vAppApi.getVApp(vAppURI); vApp = vAppApi.get(vAppUrn);
// Get the Vm // Get the Vm
List<Vm> vms = vApp.getChildren().getVms(); List<Vm> vms = vApp.getChildren().getVms();
vm = Iterables.getOnlyElement(vms); vm = Iterables.getOnlyElement(vms);
vmURI = vm.getHref(); vmUrn = vm.getId();
assertFalse(vms.isEmpty(), "The VApp must have a Vm"); assertFalse(vms.isEmpty(), "The VApp must have a Vm");
} }
protected void getGuestCustomizationSection(final Function<URI, GuestCustomizationSection> getGuestCustomizationSection) { protected void getGuestCustomizationSection(final Function<String, GuestCustomizationSection> getGuestCustomizationSection) {
// Get URI for child VM // Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); String vmUrn = Iterables.getOnlyElement(vApp.getChildren().getVms()).getId();
// The method under test // The method under test
try { try {
GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI); GuestCustomizationSection section = getGuestCustomizationSection.apply(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkGuestCustomizationSection(section); checkGuestCustomizationSection(section);
@ -174,13 +174,13 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
} }
} }
protected void getNetworkConnectionSection(final Function<URI, NetworkConnectionSection> getNetworkConnectionSection) { protected void getNetworkConnectionSection(final Function<String, NetworkConnectionSection> getNetworkConnectionSection) {
// Get URI for child VM // Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); String vmUrn = Iterables.getOnlyElement(vApp.getChildren().getVms()).getId();
// The method under test // The method under test
try { try {
NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI); NetworkConnectionSection section = getNetworkConnectionSection.apply(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConnectionSection(section); checkNetworkConnectionSection(section);
@ -200,7 +200,7 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
// If we found any references, remove the VApp they point to // If we found any references, remove the VApp they point to
if (!Iterables.isEmpty(vApps)) { if (!Iterables.isEmpty(vApps)) {
for (Reference ref : vApps) { for (Reference ref : vApps) {
cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting cleanUpVApp(context.getApi().getVAppApi().get(ref.getHref())); // NOTE may fail, but should continue deleting
} }
} else { } else {
logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), Iterables.toString(vAppNames)); logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), Iterables.toString(vAppNames));
@ -248,14 +248,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Power on a {@link VApp}. * Power on a {@link VApp}.
*/ */
protected VApp powerOnVApp(final URI testVAppURI) { protected VApp powerOnVApp(String vAppUrn) {
VApp test = vAppApi.getVApp(testVAppURI); VApp test = vAppApi.get(vAppUrn);
Status status = test.getStatus(); Status status = test.getStatus();
if (status != Status.POWERED_ON) { if (status != Status.POWERED_ON) {
Task powerOn = vAppApi.powerOn(vm.getHref()); Task powerOn = vAppApi.powerOn(vAppUrn);
assertTaskSucceedsLong(powerOn); assertTaskSucceedsLong(powerOn);
} }
test = vAppApi.getVApp(testVAppURI); test = vAppApi.get(vAppUrn);
assertStatus(VAPP, test, Status.POWERED_ON); assertStatus(VAPP, test, Status.POWERED_ON);
return test; return test;
} }
@ -263,14 +263,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Power on a {@link Vm}. * Power on a {@link Vm}.
*/ */
protected Vm powerOnVm(final URI testVmURI) { protected Vm powerOnVm(String vmUrn) {
Vm test = vmApi.get(testVmURI); Vm test = vmApi.get(vmUrn);
Status status = test.getStatus(); Status status = test.getStatus();
if (status != Status.POWERED_ON) { if (status != Status.POWERED_ON) {
Task powerOn = vmApi.powerOn(vm.getHref()); Task powerOn = vmApi.powerOn(vmUrn);
assertTaskSucceedsLong(powerOn); assertTaskSucceedsLong(powerOn);
} }
test = vmApi.get(testVmURI); test = vmApi.get(vmUrn);
assertStatus(VM, test, Status.POWERED_ON); assertStatus(VM, test, Status.POWERED_ON);
return test; return test;
} }
@ -278,14 +278,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Power off a {@link VApp}. * Power off a {@link VApp}.
*/ */
protected VApp powerOffVApp(final URI testVAppURI) { protected VApp powerOffVApp(String vAppUrn) {
VApp test = vAppApi.getVApp(testVAppURI); VApp test = vAppApi.get(vAppUrn);
Status status = test.getStatus(); Status status = test.getStatus();
if (status != Status.POWERED_OFF) { if (status != Status.POWERED_OFF) {
Task powerOff = vAppApi.powerOff(vm.getHref()); Task powerOff = vAppApi.powerOff(vAppUrn);
assertTaskSucceedsLong(powerOff); assertTaskSucceedsLong(powerOff);
} }
test = vAppApi.getVApp(testVAppURI); test = vAppApi.get(vAppUrn);
assertStatus(VAPP, test, Status.POWERED_OFF); assertStatus(VAPP, test, Status.POWERED_OFF);
return test; return test;
} }
@ -293,15 +293,15 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Power off a {@link Vm}. * Power off a {@link Vm}.
*/ */
protected Vm powerOffVm(final URI testVmURI) { protected Vm powerOffVm(String vmUrn) {
Vm test = vmApi.get(testVmURI); Vm test = vmApi.get(vmUrn);
Status status = test.getStatus(); Status status = test.getStatus();
if (status != Status.POWERED_OFF || test.isDeployed()) { if (status != Status.POWERED_OFF || test.isDeployed()) {
UndeployVAppParams undeployParams = UndeployVAppParams.builder().build(); UndeployVAppParams undeployParams = UndeployVAppParams.builder().build();
Task shutdownVapp = vAppApi.undeploy(test.getHref(), undeployParams); Task shutdownVapp = vAppApi.undeploy(vmUrn, undeployParams);
assertTaskSucceedsLong(shutdownVapp); assertTaskSucceedsLong(shutdownVapp);
} }
test = vmApi.get(testVmURI); test = vmApi.get(vmUrn);
assertStatus(VM, test, Status.POWERED_OFF); assertStatus(VM, test, Status.POWERED_OFF);
return test; return test;
} }
@ -309,14 +309,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Suspend a {@link VApp}. * Suspend a {@link VApp}.
*/ */
protected VApp suspendVApp(final URI testVAppURI) { protected VApp suspendVApp(String vAppUrn) {
VApp test = vAppApi.getVApp(testVAppURI); VApp test = vAppApi.get(vAppUrn);
Status status = test.getStatus(); Status status = test.getStatus();
if (status != Status.SUSPENDED) { if (status != Status.SUSPENDED) {
Task suspend = vAppApi.suspend(vm.getHref()); Task suspend = vAppApi.suspend(vAppUrn);
assertTaskSucceedsLong(suspend); assertTaskSucceedsLong(suspend);
} }
test = vAppApi.getVApp(testVAppURI); test = vAppApi.get(vAppUrn);
assertStatus(VAPP, test, Status.SUSPENDED); assertStatus(VAPP, test, Status.SUSPENDED);
return test; return test;
} }
@ -324,14 +324,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Suspend a {@link Vm}. * Suspend a {@link Vm}.
*/ */
protected Vm suspendVm(final URI testVmURI) { protected Vm suspendVm(String vmUrn) {
Vm test = vmApi.get(testVmURI); Vm test = vmApi.get(vmUrn);
Status status = test.getStatus(); Status status = test.getStatus();
if (status != Status.SUSPENDED) { if (status != Status.SUSPENDED) {
Task suspend = vmApi.suspend(vm.getHref()); Task suspend = vmApi.suspend(vmUrn);
assertTaskSucceedsLong(suspend); assertTaskSucceedsLong(suspend);
} }
test = vmApi.get(testVmURI); test = vmApi.get(vmUrn);
assertStatus(VM, test, Status.SUSPENDED); assertStatus(VM, test, Status.SUSPENDED);
return test; return test;
} }
@ -339,16 +339,16 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
/** /**
* Check the {@link VApp}s current status. * Check the {@link VApp}s current status.
*/ */
protected void assertVAppStatus(final URI testVAppURI, final Status status) { protected void assertVAppStatus(final String vAppUrn, final Status status) {
VApp testVApp = vAppApi.getVApp(testVAppURI); VApp testVApp = vAppApi.get(vAppUrn);
assertStatus(VAPP, testVApp, status); assertStatus(VAPP, testVApp, status);
} }
/** /**
* Check the {@link Vm}s current status. * Check the {@link Vm}s current status.
*/ */
protected void assertVmStatus(final URI testVmURI, final Status status) { protected void assertVmStatus(String vmUrn, final Status status) {
Vm testVm = vmApi.get(testVmURI); Vm testVm = vmApi.get(vmUrn);
assertStatus(VM, testVm, status); assertStatus(VM, testVm, status);
} }
@ -376,7 +376,7 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
} }
protected VAppNetworkConfiguration getVAppNetworkConfig(VApp vApp) { protected VAppNetworkConfiguration getVAppNetworkConfig(VApp vApp) {
Set<VAppNetworkConfiguration> vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getHref()).getNetworkConfigs(); Set<VAppNetworkConfiguration> vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getId()).getNetworkConfigs();
return Iterables.tryFind(vAppNetworkConfigs, Predicates.notNull()).orNull(); return Iterables.tryFind(vAppNetworkConfigs, Predicates.notNull()).orNull();
} }
@ -389,11 +389,11 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
} }
protected Set<NetworkConnection> listNetworkConnections(Vm vm) { protected Set<NetworkConnection> listNetworkConnections(Vm vm) {
return vmApi.getNetworkConnectionSection(vm.getHref()).getNetworkConnections(); return vmApi.getNetworkConnectionSection(vm.getId()).getNetworkConnections();
} }
protected Set<VAppNetworkConfiguration> listVappNetworkConfigurations(VApp vApp) { protected Set<VAppNetworkConfiguration> listVappNetworkConfigurations(VApp vApp) {
Set<VAppNetworkConfiguration> vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getHref()).getNetworkConfigs(); Set<VAppNetworkConfiguration> vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getId()).getNetworkConfigs();
return vAppNetworkConfigs; return vAppNetworkConfigs;
} }
} }

View File

@ -151,7 +151,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
@Test @Test
public void testGetCatalogMetadataHref() { public void testGetCatalogMetadataHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse);
assertEquals(api.getCatalogApi().getMetadataApi().get(catalogHref), metadata()); assertEquals(api.getCatalogApi().getMetadataApi(catalogHref).get(), metadata());
} }
static Metadata metadata() { static Metadata metadata() {
@ -182,7 +182,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
@Test @Test
public void testGetCatalogMetadataEntryHref() { public void testGetCatalogMetadataEntryHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse);
assertEquals(api.getCatalogApi().getMetadataApi().getValue(catalogHref, "KEY"), metadataValue()); assertEquals(api.getCatalogApi().getMetadataApi(catalogHref).getValue("KEY"), metadataValue());
} }
static String item = "a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"; static String item = "a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df";
@ -308,7 +308,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
@Test @Test
public void testGetCatalogItemMetadataHref() { public void testGetCatalogItemMetadataHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadata, getItemMetadataResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadata, getItemMetadataResponse);
assertEquals(api.getCatalogApi().getMetadataApi().get(itemHref), expected); assertEquals(api.getCatalogApi().getMetadataApi(itemHref).get(), expected);
} }
HttpRequest mergeItemMetadata = HttpRequest.builder() HttpRequest mergeItemMetadata = HttpRequest.builder()
@ -330,7 +330,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, mergeItemMetadata, mergeItemMetadataResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, mergeItemMetadata, mergeItemMetadataResponse);
// TODO: horrendous way of representing Map<String,String> // TODO: horrendous way of representing Map<String,String>
Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build(); Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build();
assertEquals(api.getCatalogApi().getItemMetadataApi().merge(itemHref, metadata), mergeMetadataTask()); assertEquals(api.getCatalogApi().getItemMetadataApi(itemHref).merge(metadata), mergeMetadataTask());
} }
HttpRequest getItemMetadataValue = HttpRequest.builder() HttpRequest getItemMetadataValue = HttpRequest.builder()
@ -348,7 +348,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
@Test @Test
public void testGetCatalogItemMetadataEntryHref() { public void testGetCatalogItemMetadataEntryHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadataValue, getItemMetadataValueResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadataValue, getItemMetadataValueResponse);
assertEquals(api.getCatalogApi().getMetadataApi().getValue(itemHref, "KEY"), itemMetadataValue()); assertEquals(api.getCatalogApi().getMetadataApi(itemHref).getValue("KEY"), itemMetadataValue());
} }
HttpRequest putItemMetadata = HttpRequest.builder() HttpRequest putItemMetadata = HttpRequest.builder()
@ -368,7 +368,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
@Test @Test
public void testSetCatalogItemMetadataEntryHref() { public void testSetCatalogItemMetadataEntryHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, putItemMetadata, putItemMetadataResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, putItemMetadata, putItemMetadataResponse);
assertEquals(api.getCatalogApi().getItemMetadataApi().putEntry(itemHref, "KEY", MetadataValue.builder().value("KITTENS").build()), setMetadataValueTask()); assertEquals(api.getCatalogApi().getItemMetadataApi(itemHref).putEntry("KEY", MetadataValue.builder().value("KITTENS").build()), setMetadataValueTask());
} }
HttpRequest removeItemMetadataEntry = HttpRequest.builder() HttpRequest removeItemMetadataEntry = HttpRequest.builder()
@ -386,7 +386,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest {
@Test @Test
public void testRemoveCatalogItemMetadataEntryHref() { public void testRemoveCatalogItemMetadataEntryHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, removeItemMetadataEntry, removeItemMetadataEntryResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, removeItemMetadataEntry, removeItemMetadataEntryResponse);
assertEquals(api.getCatalogApi().getItemMetadataApi().removeEntry(itemHref, "KEY"), removeEntryTask()); assertEquals(api.getCatalogApi().getItemMetadataApi(itemHref).removeEntry("KEY"), removeEntryTask());
} }
public static final Catalog catalog() { public static final Catalog catalog() {

View File

@ -96,7 +96,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build()) Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build())
.build(); .build();
Task mergeCatalogMetadata = adminCatalogApi.getMetadataApi().merge(adminCatalog.getHref(), newMetadata); Task mergeCatalogMetadata = adminCatalogApi.getMetadataApi(adminCatalog.getId()).merge(newMetadata);
checkTask(mergeCatalogMetadata); checkTask(mergeCatalogMetadata);
assertTrue(retryTaskSuccess.apply(mergeCatalogMetadata), assertTrue(retryTaskSuccess.apply(mergeCatalogMetadata),
String.format(TASK_COMPLETE_TIMELY, "setupRequiredApis")); String.format(TASK_COMPLETE_TIMELY, "setupRequiredApis"));
@ -184,13 +184,13 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /catalog/{id}/metadata") @Test(description = "GET /catalog/{id}/metadata")
public void testGetCatalogMetadata() { public void testGetCatalogMetadata() {
Metadata catalogMetadata = catalogApi.getMetadataApi().get(lazyGetCatalog().getHref()); Metadata catalogMetadata = catalogApi.getMetadataApi(catalogUrn).get();
checkMetadata(catalogMetadata); checkMetadata(catalogMetadata);
} }
@Test(description = "GET /catalog/{id}/metadata/{key}") @Test(description = "GET /catalog/{id}/metadata/{key}")
public void testGetCatalogMetadataValue() { public void testGetCatalogMetadataValue() {
Metadata catalogMetadata = catalogApi.getMetadataApi().get(lazyGetCatalog().getHref()); Metadata catalogMetadata = catalogApi.getMetadataApi(catalogUrn).get();
MetadataEntry existingMetadataEntry = Iterables.find(catalogMetadata.getMetadataEntries(), MetadataEntry existingMetadataEntry = Iterables.find(catalogMetadata.getMetadataEntries(),
new Predicate<MetadataEntry>() { new Predicate<MetadataEntry>() {
@Override @Override
@ -198,7 +198,8 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
return input.getKey().equals("KEY"); return input.getKey().equals("KEY");
} }
}); });
MetadataValue metadataValue = catalogApi.getMetadataApi().getValue(existingMetadataEntry.getHref(), "KEY"); MetadataValue metadataValue = catalogApi.getMetadataApi(catalogApi.get(existingMetadataEntry.getHref()).getId())
.getValue("KEY");
assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT,
"Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue())); "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue()));
checkMetadataValue(metadataValue); checkMetadataValue(metadataValue);
@ -206,7 +207,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /catalogItem/{id}/metadata", dependsOnMethods = "testAddCatalogItem") @Test(description = "GET /catalogItem/{id}/metadata", dependsOnMethods = "testAddCatalogItem")
public void testGetCatalogItemMetadata() { public void testGetCatalogItemMetadata() {
Metadata catalogItemMetadata = catalogApi.getItemMetadataApi().get(catalogItem.getHref()); Metadata catalogItemMetadata = catalogApi.getItemMetadataApi(catalogItem.getId()).get();
checkMetadata(catalogItemMetadata); checkMetadata(catalogItemMetadata);
} }
@ -215,23 +216,23 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build()) Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build())
.entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build()).build(); .entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build()).build();
Metadata before = catalogApi.getItemMetadataApi().get(catalogItem.getHref()); Metadata before = catalogApi.getItemMetadataApi(catalogItem.getId()).get();
Task mergeCatalogItemMetadata = catalogApi.getItemMetadataApi().merge(catalogItem.getHref(), newMetadata); Task mergeCatalogItemMetadata = catalogApi.getItemMetadataApi(catalogItem.getId()).merge(newMetadata);
checkTask(mergeCatalogItemMetadata); checkTask(mergeCatalogItemMetadata);
assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata),
String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
Metadata mergedCatalogItemMetadata = catalogApi.getItemMetadataApi().get(catalogItem.getHref()); Metadata mergedCatalogItemMetadata = catalogApi.getItemMetadataApi(catalogItem.getId()).get();
assertTrue(mergedCatalogItemMetadata.getMetadataEntries().size() > before.getMetadataEntries().size(), assertTrue(mergedCatalogItemMetadata.getMetadataEntries().size() > before.getMetadataEntries().size(),
"Should have added at least one other MetadataEntry to the CatalogItem"); "Should have added at least one other MetadataEntry to the CatalogItem");
MetadataValue keyMetadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "KEY"); MetadataValue keyMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY");
assertEquals(keyMetadataValue.getValue(), "MARMALADE", assertEquals(keyMetadataValue.getValue(), "MARMALADE",
"The Value of the MetadataValue for KEY should have changed"); "The Value of the MetadataValue for KEY should have changed");
checkMetadataValue(keyMetadataValue); checkMetadataValue(keyMetadataValue);
MetadataValue newKeyMetadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "VEGIMITE"); MetadataValue newKeyMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("VEGIMITE");
assertEquals(newKeyMetadataValue.getValue(), "VALUE", assertEquals(newKeyMetadataValue.getValue(), "VALUE",
"The Value of the MetadataValue for NEW_KEY should have been set"); "The Value of the MetadataValue for NEW_KEY should have been set");
@ -240,7 +241,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /catalogItem/{id}/metadata/{key}", dependsOnMethods = "testSetCatalogItemMetadataValue") @Test(description = "GET /catalogItem/{id}/metadata/{key}", dependsOnMethods = "testSetCatalogItemMetadataValue")
public void testGetCatalogItemMetadataValue() { public void testGetCatalogItemMetadataValue() {
MetadataValue metadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "KEY"); MetadataValue metadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY");
checkMetadataValue(metadataValue); checkMetadataValue(metadataValue);
} }
@ -248,26 +249,25 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void testSetCatalogItemMetadataValue() { public void testSetCatalogItemMetadataValue() {
MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build(); MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build();
Task setCatalogItemMetadataValue = catalogApi.getItemMetadataApi().putEntry(catalogItem.getHref(), "KEY", Task setCatalogItemMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).putEntry("KEY",
newMetadataValue); newMetadataValue);
checkTask(setCatalogItemMetadataValue); checkTask(setCatalogItemMetadataValue);
assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue), assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue),
String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue")); String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue"));
MetadataValue editedMetadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "KEY"); MetadataValue editedMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY");
assertEquals(editedMetadataValue.getValue(), newMetadataValue.getValue(), String.format( assertEquals(editedMetadataValue.getValue(), newMetadataValue.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT,
CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), "Value", "MetadataValue", newMetadataValue.getValue(), editedMetadataValue.getValue()));
editedMetadataValue.getValue()));
checkMetadataValue(editedMetadataValue); checkMetadataValue(editedMetadataValue);
} }
@Test(description = "DELETE /catalogItem/{id}/metadata/{key}", dependsOnMethods = "testGetCatalogItemMetadataValue") @Test(description = "DELETE /catalogItem/{id}/metadata/{key}", dependsOnMethods = "testGetCatalogItemMetadataValue")
public void testRemoveCatalogItemMetadataValue() { public void testRemoveCatalogItemMetadataValue() {
Task removeCatalogItemMetadataValue = catalogApi.getItemMetadataApi().removeEntry(catalogItem.getHref(), "KEY"); Task removeCatalogItemMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).removeEntry("KEY");
checkTask(removeCatalogItemMetadataValue); checkTask(removeCatalogItemMetadataValue);
assertTrue(retryTaskSuccess.apply(removeCatalogItemMetadataValue), assertTrue(retryTaskSuccess.apply(removeCatalogItemMetadataValue),
String.format(TASK_COMPLETE_TIMELY, "removeCatalogItemMetadataValue")); String.format(TASK_COMPLETE_TIMELY, "removeCatalogItemMetadataValue"));
MetadataValue removed = catalogApi.getMetadataApi().getValue(catalogItem.getHref(), "KEY"); MetadataValue removed = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY");
assertNull(removed); assertNull(removed);
} }
} }

View File

@ -239,7 +239,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Metadata expected = metadata(); Metadata expected = metadata();
assertEquals(api.getMediaApi().getMetadataApi().get(mediaUri), expected); assertEquals(api.getMediaApi().getMetadataApi(mediaUri).get(), expected);
} }
@Test @Test
@ -259,7 +259,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Metadata inputMetadata = metadata(); Metadata inputMetadata = metadata();
Task expectedTask = mergeMetadataTask(); Task expectedTask = mergeMetadataTask();
assertEquals(api.getMediaApi().getMetadataApi().merge(mediaUri, inputMetadata), expectedTask); assertEquals(api.getMediaApi().getMetadataApi(mediaUri).merge(inputMetadata), expectedTask);
} }
public void testGetMetadataValue() { public void testGetMetadataValue() {
@ -277,7 +277,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest {
MetadataValue expected = metadataValue(); MetadataValue expected = metadataValue();
assertEquals(api.getMediaApi().getMetadataApi().getValue(mediaUri, "key"), expected); assertEquals(api.getMediaApi().getMetadataApi(mediaUri).getValue("key"), expected);
} }
@Test @Test
@ -298,7 +298,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Task expectedTask = setMetadataEntryTask(); Task expectedTask = setMetadataEntryTask();
assertEquals(api.getMediaApi().getMetadataApi().putEntry(mediaUri, "key", inputMetadataValue), expectedTask); assertEquals(api.getMediaApi().getMetadataApi(mediaUri).putEntry("key", inputMetadataValue), expectedTask);
} }
@Test @Test
@ -316,7 +316,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Task expectedTask = removeEntryTask(); Task expectedTask = removeEntryTask();
assertEquals(api.getMediaApi().getMetadataApi().removeEntry(mediaUri, "key"), expectedTask); assertEquals(api.getMediaApi().getMetadataApi(mediaUri).removeEntry("key"), expectedTask);
} }
@Test @Test

View File

@ -133,19 +133,16 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
// TODO: generate an iso // TODO: generate an iso
byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
Media sourceMedia = Media.builder() Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name("Test media " + random.nextInt())
.type(VCloudDirectorMediaType.MEDIA) .size(iso.length).imageType(Media.ImageType.ISO).description("Test media generated by testAddMedia()")
.name("Test media "+random.nextInt())
.size(iso.length)
.imageType(Media.ImageType.ISO)
.description("Test media generated by testAddMedia()")
.build(); .build();
media = mediaApi.addMedia(addMedia.getHref(), sourceMedia); media = mediaApi.addMedia(addMedia.getHref(), sourceMedia);
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files")); assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size())); assertTrue(media.getFiles().size() == 1,
String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size()));
File uploadFile = getFirst(media.getFiles(), null); File uploadFile = getFirst(media.getFiles(), null);
assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first")); assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
assertEquals(uploadFile.getSize(), Long.valueOf(iso.length)); assertEquals(uploadFile.getSize(), Long.valueOf(iso.length));
@ -155,7 +152,11 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Set<Link> links = uploadFile.getLinks(); Set<Link> links = uploadFile.getLinks();
assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links")); assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size())); assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size()));
assertTrue(Iterables.all(links, Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT), LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))), assertTrue(
Iterables.all(
links,
Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT),
LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))),
String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));
Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT)); Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT));
@ -186,12 +187,10 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /media/{id}/owner", dependsOnMethods = { "testGetMedia" }) @Test(description = "GET /media/{id}/owner", dependsOnMethods = { "testGetMedia" })
public void testGetMediaOwner() { public void testGetMediaOwner() {
Owner directOwner = mediaApi.getOwner(media.getHref()); Owner directOwner = mediaApi.getOwner(media.getHref());
assertEquals(owner.toBuilder() assertEquals(owner.toBuilder().user(owner.getUser()).build(),
.user(owner.getUser()) directOwner.toBuilder().links(Collections.<Link> emptySet()).build(), String.format(
.build(), GETTER_RETURNS_SAME_OBJ, "getOwner()", "owner", "media.getOwner()", owner.toString(),
directOwner.toBuilder().links(Collections.<Link>emptySet()).build(), directOwner.toString()));
String.format(GETTER_RETURNS_SAME_OBJ,
"getOwner()", "owner", "media.getOwner()", owner.toString(), directOwner.toString()));
// parent type // parent type
Checks.checkResourceType(directOwner); Checks.checkResourceType(directOwner);
@ -204,11 +203,10 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "POST /vdc/{id}/action/cloneMedia", dependsOnMethods = { "testGetMediaOwner" }) @Test(description = "POST /vdc/{id}/action/cloneMedia", dependsOnMethods = { "testGetMediaOwner" })
public void testCloneMedia() { public void testCloneMedia() {
oldMedia = media; oldMedia = media;
media = vdcApi.cloneMedia(vdcUrn, CloneMediaParams.builder() media = vdcApi.cloneMedia(
.source(Reference.builder().fromEntity(media).build()) vdcUrn,
.name("copied "+media.getName()) CloneMediaParams.builder().source(Reference.builder().fromEntity(media).build())
.description("copied by testCloneMedia()") .name("copied " + media.getName()).description("copied by testCloneMedia()").build());
.build());
Checks.checkMediaFor(VDC, media); Checks.checkMediaFor(VDC, media);
@ -222,17 +220,14 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "copied media", assertTrue(media.clone(oldMedia),
media.toString(), oldMedia.toString())); String.format(OBJ_FIELD_CLONE, MEDIA, "copied media", media.toString(), oldMedia.toString()));
mediaApi.getMetadataApi().putEntry(media.getHref(), "key", MetadataValue.builder().value("value").build()); mediaApi.getMetadataApi(media.getId()).putEntry("key", MetadataValue.builder().value("value").build());
media = vdcApi.cloneMedia(vdcUrn, CloneMediaParams.builder() media = vdcApi
.source(Reference.builder().fromEntity(media).build()) .cloneMedia(vdcUrn, CloneMediaParams.builder().source(Reference.builder().fromEntity(media).build())
.name("moved test media") .name("moved test media").description("moved by testCloneMedia()").isSourceDelete(true).build());
.description("moved by testCloneMedia()")
.isSourceDelete(true)
.build());
Checks.checkMediaFor(VDC, media); Checks.checkMediaFor(VDC, media);
@ -246,16 +241,16 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "moved media", assertTrue(media.clone(oldMedia),
media.toString(), oldMedia.toString())); String.format(OBJ_FIELD_CLONE, MEDIA, "moved media", media.toString(), oldMedia.toString()));
} }
@Test(description = "PUT /media/{id}", dependsOnMethods = { "testCloneMedia" }) @Test(description = "PUT /media/{id}", dependsOnMethods = { "testCloneMedia" })
public void testSetMedia() { public void testSetMedia() {
String oldName = media.getName(); String oldName = media.getName();
String newName = "new "+oldName; String newName = "new " + oldName;
String oldDescription = media.getDescription(); String oldDescription = media.getDescription();
String newDescription = "new "+oldDescription; String newDescription = "new " + oldDescription;
media = media.toBuilder().name(newName).description(newDescription).build(); media = media.toBuilder().name(newName).description(newDescription).build();
Task editMedia = mediaApi.editMedia(media.getHref(), media); Task editMedia = mediaApi.editMedia(media.getHref(), media);
@ -267,7 +262,7 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
assertTrue(equal(media.getDescription(), newDescription), assertTrue(equal(media.getDescription(), newDescription),
String.format(OBJ_FIELD_UPDATABLE, MEDIA, "description")); String.format(OBJ_FIELD_UPDATABLE, MEDIA, "description"));
//TODO negative tests? // TODO negative tests?
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
@ -281,10 +276,9 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /media/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }) @Test(description = "GET /media/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" })
public void testGetMetadata() { public void testGetMetadata() {
metadata = mediaApi.getMetadataApi().get(media.getHref()); metadata = mediaApi.getMetadataApi(media.getId()).get();
// required for testing // required for testing
assertFalse(isEmpty(metadata.getMetadataEntries()), assertFalse(isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries"));
String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries"));
Checks.checkMetadataFor(MEDIA, metadata); Checks.checkMetadataFor(MEDIA, metadata);
} }
@ -293,14 +287,12 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void testMergeMetadata() { public void testMergeMetadata() {
// test new // test new
Set<MetadataEntry> inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build()); Set<MetadataEntry> inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build());
Metadata inputMetadata = Metadata.builder() Metadata inputMetadata = Metadata.builder().entries(inputEntries).build();
.entries(inputEntries)
.build();
Task mergeMetadata = mediaApi.getMetadataApi().merge(media.getHref(), inputMetadata); Task mergeMetadata = mediaApi.getMetadataApi(media.getId()).merge(inputMetadata);
Checks.checkTask(mergeMetadata); Checks.checkTask(mergeMetadata);
assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)"));
metadata = mediaApi.getMetadataApi().get(media.getHref()); metadata = mediaApi.getMetadataApi(media.getId()).get();
Checks.checkMetadataFor(MEDIA, metadata); Checks.checkMetadataFor(MEDIA, metadata);
checkMetadataContainsEntries(metadata, inputEntries); checkMetadataContainsEntries(metadata, inputEntries);
@ -309,14 +301,12 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
// test edit // test edit
inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "new testValue").build()); inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "new testValue").build());
inputMetadata = Metadata.builder() inputMetadata = Metadata.builder().entries(inputEntries).build();
.entries(inputEntries)
.build();
mergeMetadata = mediaApi.getMetadataApi().merge(media.getHref(), inputMetadata); mergeMetadata = mediaApi.getMetadataApi(media.getId()).merge(inputMetadata);
Checks.checkTask(mergeMetadata); Checks.checkTask(mergeMetadata);
assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(edit)")); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(edit)"));
metadata = mediaApi.getMetadataApi().get(media.getHref()); metadata = mediaApi.getMetadataApi(media.getId()).get();
Checks.checkMetadataFor(MEDIA, metadata); Checks.checkMetadataFor(MEDIA, metadata);
checkMetadataContainsEntries(metadata, inputEntries); checkMetadataContainsEntries(metadata, inputEntries);
@ -329,13 +319,13 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
boolean found = false; boolean found = false;
for (MetadataEntry entry : metadata.getMetadataEntries()) { for (MetadataEntry entry : metadata.getMetadataEntries()) {
if (equal(inputEntry.getKey(), entry.getKey())) { if (equal(inputEntry.getKey(), entry.getKey())) {
found = true; break; found = true;
break;
} }
} }
if (!found) { if (!found) {
String.format(OBJ_FIELD_CONTAINS, MEDIA, "metadata", String.format(OBJ_FIELD_CONTAINS, MEDIA, "metadata", Iterables.toString(metadata.getMetadataEntries()),
Iterables.toString(metadata.getMetadataEntries()),
Iterables.toString(entries)); Iterables.toString(entries));
} }
} }
@ -343,7 +333,7 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) @Test(description = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" })
public void testGetMetadataValue() { public void testGetMetadataValue() {
metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "key"); metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("key");
Checks.checkMetadataValueFor(MEDIA, metadataValue); Checks.checkMetadataValueFor(MEDIA, metadataValue);
} }
@ -352,39 +342,37 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
metadataEntryValue = "value"; metadataEntryValue = "value";
MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build();
Task setMetadataEntry = mediaApi.getMetadataApi().putEntry(media.getHref(), "key", newValue); Task setMetadataEntry = mediaApi.getMetadataApi(media.getId()).putEntry("key", newValue);
Checks.checkTask(setMetadataEntry); Checks.checkTask(setMetadataEntry);
assertTrue(retryTaskSuccess.apply(setMetadataEntry), assertTrue(retryTaskSuccess.apply(setMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry"));
String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("key");
metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "key");
Checks.checkMetadataValueFor(MEDIA, metadataValue); Checks.checkMetadataValueFor(MEDIA, metadataValue);
} }
@Test(description = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata", "testGetMetadataValue" } ) @Test(description = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata",
"testGetMetadataValue" })
public void testRemoveMetadata() { public void testRemoveMetadata() {
Task removeEntry = mediaApi.getMetadataApi().removeEntry(media.getHref(), "testKey"); Task removeEntry = mediaApi.getMetadataApi(media.getId()).removeEntry("testKey");
Checks.checkTask(removeEntry); Checks.checkTask(removeEntry);
assertTrue(retryTaskSuccess.apply(removeEntry), assertTrue(retryTaskSuccess.apply(removeEntry), String.format(TASK_COMPLETE_TIMELY, "removeEntry"));
String.format(TASK_COMPLETE_TIMELY, "removeEntry"));
metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "testKey"); metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("testKey");
assertNull(metadataValue, String.format(OBJ_FIELD_ATTRB_DEL, MEDIA, assertNull(metadataValue, String.format(OBJ_FIELD_ATTRB_DEL, MEDIA, "Metadata",
"Metadata", metadataValue != null ? metadataValue.toString() : "", metadataValue != null ? metadataValue.toString() : "", "MetadataEntry",
"MetadataEntry", metadataValue != null ? metadataValue.toString() : "")); metadataValue != null ? metadataValue.toString() : ""));
metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "key"); metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("key");
Checks.checkMetadataValueFor(MEDIA, metadataValue); Checks.checkMetadataValueFor(MEDIA, metadataValue);
media = mediaApi.getMedia(media.getHref()); media = mediaApi.getMedia(media.getHref());
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
} }
@Test(description = "DELETE /media/{id}", dependsOnMethods = { "testRemoveMetadata" } ) @Test(description = "DELETE /media/{id}", dependsOnMethods = { "testRemoveMetadata" })
public void testRemoveMedia() { public void testRemoveMedia() {
Task removeMedia = mediaApi.removeMedia(media.getHref()); Task removeMedia = mediaApi.removeMedia(media.getHref());
Checks.checkTask(removeMedia); Checks.checkTask(removeMedia);
assertTrue(retryTaskSuccess.apply(removeMedia), assertTrue(retryTaskSuccess.apply(removeMedia), String.format(TASK_COMPLETE_TIMELY, "removeMedia"));
String.format(TASK_COMPLETE_TIMELY, "removeMedia"));
media = mediaApi.getMedia(media.getHref()); media = mediaApi.getMedia(media.getHref());
assertNull(media, String.format(OBJ_DEL, MEDIA, media != null ? media.toString() : "")); assertNull(media, String.format(OBJ_DEL, MEDIA, media != null ? media.toString() : ""));

View File

@ -181,7 +181,7 @@ public class NetworkApiExpectTest extends VCloudDirectorAdminApiExpectTest {
@Test @Test
public void testGetNetworkMetadataHref() { public void testGetNetworkMetadataHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse);
assertEquals(api.getNetworkApi().getMetadataApi().get(networkHref), metadata()); assertEquals(api.getNetworkApi().getMetadataApi(networkHref).get(), metadata());
} }
static Metadata metadata() { static Metadata metadata() {
@ -216,7 +216,7 @@ public class NetworkApiExpectTest extends VCloudDirectorAdminApiExpectTest {
@Test @Test
public void testGetNetworkMetadataEntryHref() { public void testGetNetworkMetadataEntryHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse);
assertEquals(api.getNetworkApi().getMetadataApi().getValue(networkHref, "KEY"), metadataValue()); assertEquals(api.getNetworkApi().getMetadataApi(networkHref).getValue("KEY"), metadataValue());
} }
private MetadataValue metadataValue() { private MetadataValue metadataValue() {

View File

@ -22,8 +22,8 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceType; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceType;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
@ -60,20 +60,18 @@ public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
protected NetworkApi networkApi; protected NetworkApi networkApi;
private boolean metadataSet = false; private boolean metadataSet = false;
private Network network;
@Override @Override
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
public void setupRequiredApis() { public void setupRequiredApis() {
networkApi = context.getApi().getNetworkApi(); networkApi = context.getApi().getNetworkApi();
network = lazyGetNetwork();
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)
public void cleanUp() { public void cleanUp() {
if (metadataSet) { if (metadataSet) {
try { try {
Task remove = adminContext.getApi().getNetworkApi().getMetadataApi().removeEntry(network.getHref(), "key"); Task remove = adminContext.getApi().getNetworkApi().getMetadataApi(networkUrn).removeEntry("key");
taskDoneEventually(remove); taskDoneEventually(remove);
} catch (Exception e) { } catch (Exception e) {
logger.warn(e, "Error when deleting metadata"); logger.warn(e, "Error when deleting metadata");
@ -87,8 +85,8 @@ public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
assertNotNull(networkUrn, String.format(URN_REQ_LIVE, NETWORK)); assertNotNull(networkUrn, String.format(URN_REQ_LIVE, NETWORK));
Network abstractNetwork = networkApi.get(networkUrn); Network abstractNetwork = networkApi.get(networkUrn);
assertTrue(abstractNetwork instanceof OrgNetwork, String.format(REQUIRED_VALUE_OBJECT_FMT, assertTrue(abstractNetwork instanceof OrgNetwork,
".class", NETWORK, abstractNetwork.getClass(),"OrgNetwork")); String.format(REQUIRED_VALUE_OBJECT_FMT, ".class", NETWORK, abstractNetwork.getClass(), "OrgNetwork"));
OrgNetwork network = Network.toSubType(abstractNetwork); OrgNetwork network = Network.toSubType(abstractNetwork);
assertNotNull(network, String.format(OBJ_REQ_LIVE, NETWORK)); assertNotNull(network, String.format(OBJ_REQ_LIVE, NETWORK));
assertTrue(!network.getDescription().equals("DO NOT USE"), "Network isn't to be used for testing"); assertTrue(!network.getDescription().equals("DO NOT USE"), "Network isn't to be used for testing");
@ -97,8 +95,8 @@ public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
private void setupMetadata() { private void setupMetadata() {
adminContext.getApi().getNetworkApi().getMetadataApi().putEntry(network.getHref(), adminContext.getApi().getNetworkApi().getMetadataApi(networkUrn)
"key", MetadataValue.builder().value("value").build()); .putEntry("key", MetadataValue.builder().value("value").build());
metadataSet = true; metadataSet = true;
} }
@ -108,7 +106,7 @@ public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
setupMetadata(); setupMetadata();
} }
Metadata metadata = networkApi.getMetadataApi().get(network.getHref()); Metadata metadata = networkApi.getMetadataApi(networkUrn).get();
// required for testing // required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries")); String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries"));
@ -130,7 +128,7 @@ public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /network/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) @Test(description = "GET /network/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
public void testGetMetadataValue() { public void testGetMetadataValue() {
MetadataValue metadataValue = networkApi.getMetadataApi().getValue(network.getHref(), "key"); MetadataValue metadataValue = networkApi.getMetadataApi(networkUrn).getValue("key");
// Check parent type // Check parent type
checkResourceType(metadataValue); checkResourceType(metadataValue);
@ -138,9 +136,7 @@ public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest {
// Check required elements and attributes // Check required elements and attributes
String value = metadataValue.getValue(); String value = metadataValue.getValue();
assertNotNull(value, assertNotNull(value,
String.format(OBJ_FIELD_ATTRB_REQ, NETWORK, "MetadataEntry", String.format(OBJ_FIELD_ATTRB_REQ, NETWORK, "MetadataEntry", metadataValue.toString(), "value"));
metadataValue.toString(), "value")); assertEquals(value, "value", String.format(OBJ_FIELD_EQ, NETWORK, "metadataEntry.value", "value", value));
assertEquals(value, "value",
String.format(OBJ_FIELD_EQ, NETWORK, "metadataEntry.value", "value", value));
} }
} }

View File

@ -148,7 +148,7 @@ public class OrgApiExpectTest extends VCloudDirectorAdminApiExpectTest {
@Test @Test
public void testGetOrgMetadataHref() { public void testGetOrgMetadataHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse);
assertEquals(api.getOrgApi().getMetadataApi().get(orgHref), metadata()); assertEquals(api.getOrgApi().getMetadataApi(orgHref).get(), metadata());
} }
static Metadata metadata() { static Metadata metadata() {
@ -179,7 +179,7 @@ public class OrgApiExpectTest extends VCloudDirectorAdminApiExpectTest {
@Test @Test
public void testGetOrgMetadataEntryHref() { public void testGetOrgMetadataEntryHref() {
VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse); VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse);
assertEquals(api.getOrgApi().getMetadataApi().getValue(orgHref, "KEY"), metadataValue()); assertEquals(api.getOrgApi().getMetadataApi(orgHref).getValue("KEY"), metadataValue());
} }
public static Org org() { public static Org org() {

View File

@ -29,15 +29,12 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; import org.jclouds.vcloud.director.v1_5.domain.org.OrgList;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
@ -70,7 +67,7 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void cleanUp() throws Exception { public void cleanUp() throws Exception {
if (adminMembersSet) { if (adminMembersSet) {
try { try {
Task remove = adminContext.getApi().getOrgApi().getMetadataApi().removeEntry(toAdminUri(orgURI), "KEY"); Task remove = adminContext.getApi().getOrgApi().getMetadataApi(orgUrn).removeEntry("KEY");
taskDoneEventually(remove); taskDoneEventually(remove);
} catch (Exception e) { } catch (Exception e) {
logger.warn(e, "Error when deleting metadata entry"); logger.warn(e, "Error when deleting metadata entry");
@ -88,8 +85,6 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
*/ */
private OrgList orgList; private OrgList orgList;
private URI orgURI;
private Org org;
private boolean adminMembersSet = false; // track if test entities have been addd private boolean adminMembersSet = false; // track if test entities have been addd
@Test(description = "GET /org") @Test(description = "GET /org")
@ -114,12 +109,10 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Reference orgRef = Iterables.getFirst(orgList, null); Reference orgRef = Iterables.getFirst(orgList, null);
assertNotNull(orgRef); assertNotNull(orgRef);
orgURI = orgRef.getHref();
// Call the method being tested // Call the method being tested
org = orgApi.get(orgURI); org = orgApi.get(orgUrn);
assertEquals(orgApi.get(org.getId()), org); assertEquals(orgApi.get(orgUrn), org);
checkOrg(org); checkOrg(org);
@ -133,12 +126,12 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
* the need for configuration * the need for configuration
*/ */
private void setupAdminMembers() { private void setupAdminMembers() {
adminContext.getApi().getOrgApi().getMetadataApi() adminContext.getApi().getOrgApi().getMetadataApi(orgUrn)
.putEntry(toAdminUri(orgURI), "KEY", MetadataValue.builder().value("VALUE").build()); .putEntry("KEY", MetadataValue.builder().value("VALUE").build());
AdminCatalog newCatalog = AdminCatalog.builder().name("Test Catalog " + getTestDateTimeStamp()) AdminCatalog newCatalog = AdminCatalog.builder().name("Test Catalog " + getTestDateTimeStamp())
.description("created by testOrg()").build(); .description("created by testOrg()").build();
newCatalog = adminContext.getApi().getCatalogApi().addCatalogToOrg(newCatalog, org.getId()); newCatalog = adminContext.getApi().getCatalogApi().addCatalogToOrg(newCatalog, orgUrn);
catalogUrn = newCatalog.getId(); catalogUrn = newCatalog.getId();
@ -149,7 +142,7 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void testGetOrgMetadata() { public void testGetOrgMetadata() {
// Call the method being tested // Call the method being tested
Metadata metadata = orgApi.getMetadataApi().get(orgURI); Metadata metadata = orgApi.getMetadataApi(orgUrn).get();
// NOTE The environment MUST have at one metadata entry for the first organisation configured // NOTE The environment MUST have at one metadata entry for the first organisation configured
@ -163,7 +156,7 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" }) @Test(description = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" })
public void testGetOrgMetadataValue() { public void testGetOrgMetadataValue() {
// Call the method being tested // Call the method being tested
MetadataValue value = orgApi.getMetadataApi().getValue(orgURI, "KEY"); MetadataValue value = orgApi.getMetadataApi(orgUrn).getValue("KEY");
// NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" // NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE"
// )' // )'

View File

@ -52,10 +52,10 @@ import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** /**
* Tests live behavior of {@link QueryApi}. * Tests live behavior of {@link QueryApi}.
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "QueryApiLiveTest") @Test(groups = { "live", "user" }, singleThreaded = true, testName = "QueryApiLiveTest")
public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest { public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@ -64,44 +64,48 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
*/ */
private QueryApi queryApi; private QueryApi queryApi;
private VAppTemplateApi vAppTemplateApi;
private VAppApi vAppApi; private VAppApi vAppApi;
private VApp vApp; private VApp vApp;
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)
public void cleanUp() throws Exception { public void cleanUp() throws Exception {
if (vApp != null) cleanUpVApp(vApp); if (vApp != null)
cleanUpVApp(vApp);
} }
@Override @Override
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
public void setupRequiredApis() { public void setupRequiredApis() {
queryApi = context.getApi().getQueryApi(); queryApi = context.getApi().getQueryApi();
vAppTemplateApi = context.getApi().getVAppTemplateApi();
vAppApi = context.getApi().getVAppApi(); vAppApi = context.getApi().getVAppApi();
} }
@Test(description = "GET /query") @Test(description = "GET /query")
public void testQuery() { public void testQuery() {
VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); VAppTemplate vAppTemplate = lazyGetVAppTemplate();
QueryResultRecords queryResult = queryApi.query("vAppTemplate", String.format("name==%s", vAppTemplate.getName())); QueryResultRecords queryResult = queryApi
.query("vAppTemplate", String.format("name==%s", vAppTemplate.getName()));
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null),
assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should include vAppTemplate "+vAppTemplateURI+"; but only has "+hrefs); QueryResultVAppTemplateRecord.class);
assertTrue(hrefs.contains(vAppTemplate.getHref()), "VAppTemplates query result should include vAppTemplate "
+ vAppTemplate.getHref() + "; but only has " + hrefs);
} }
@Test(description = "GET /catalogs/query") @Test(description = "GET /catalogs/query")
public void testQueryAllCatalogs() { public void testQueryAllCatalogs() {
QueryResultRecords catalogRecords = queryApi.catalogsQueryAll(); QueryResultRecords catalogRecords = queryApi.catalogsQueryAll();
assertFalse(catalogRecords.getRecords().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords")); assertFalse(catalogRecords.getRecords().isEmpty(),
String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords"));
} }
@Test(description = "GET /catalogs/query?format=references", dependsOnMethods = { "testQueryAllCatalogs" }) @Test(description = "GET /catalogs/query?format=references", dependsOnMethods = { "testQueryAllCatalogs" })
public void testQueryAllCatalogReferences() { public void testQueryAllCatalogReferences() {
CatalogReferences catalogReferences = queryApi.catalogReferencesQueryAll(); CatalogReferences catalogReferences = queryApi.catalogReferencesQueryAll();
assertFalse(catalogReferences.getReferences().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogReference", "CatalogReferences")); assertFalse(catalogReferences.getReferences().isEmpty(),
String.format(NOT_EMPTY_OBJECT_FMT, "CatalogReference", "CatalogReferences"));
} }
@Test(description = "GET /vAppTemplates/query") @Test(description = "GET /vAppTemplates/query")
@ -109,18 +113,22 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
QueryResultRecords queryResult = queryApi.vAppTemplatesQueryAll(); QueryResultRecords queryResult = queryApi.vAppTemplatesQueryAll();
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null),
assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should include vAppTemplate "+vAppTemplateURI+"; but only has "+hrefs); QueryResultVAppTemplateRecord.class);
assertTrue(hrefs.contains(lazyGetVAppTemplate().getHref()), "VAppTemplates query result should include vAppTemplate "
+ lazyGetVAppTemplate().getHref() + "; but only has " + hrefs);
} }
@Test(description = "GET /vAppTemplates/query?filter") @Test(description = "GET /vAppTemplates/query?filter")
public void testQueryVAppTemplatesWithFilter() { public void testQueryVAppTemplatesWithFilter() {
VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); VAppTemplate vAppTemplate = lazyGetVAppTemplate();
QueryResultRecords queryResult = queryApi.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName())); QueryResultRecords queryResult = queryApi.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null),
assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should have found vAppTemplate "+vAppTemplateURI); QueryResultVAppTemplateRecord.class);
assertTrue(hrefs.contains(vAppTemplate.getHref()), "VAppTemplates query result should have found vAppTemplate "
+ vAppTemplate.getHref());
} }
@Test(description = "GET /vApps/query") @Test(description = "GET /vApps/query")
@ -131,19 +139,21 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
assertTrue(hrefs.contains(vApp.getHref()), "VApp query result should include vapp "+vApp.getHref()+"; but only has "+hrefs); assertTrue(hrefs.contains(vApp.getHref()), "VApp query result should include vapp " + vApp.getHref()
+ "; but only has " + hrefs);
} }
@Test(description = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" } ) @Test(description = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" })
public void testQueryVAppsWithFilter() { public void testQueryVAppsWithFilter() {
QueryResultRecords queryResult = queryApi.vAppsQuery(String.format("name==%s", vApp.getName())); QueryResultRecords queryResult = queryApi.vAppsQuery(String.format("name==%s", vApp.getName()));
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
assertEquals(hrefs, Collections.singleton(vApp.getHref()), "VApps query result should have found vApp "+vApp.getHref()); assertEquals(hrefs, Collections.singleton(vApp.getHref()),
"VApps query result should have found vApp " + vApp.getHref());
} }
@Test(description = "GET /vms/query", dependsOnMethods = { "testQueryAllVApps" } ) @Test(description = "GET /vms/query", dependsOnMethods = { "testQueryAllVApps" })
public void testQueryAllVms() { public void testQueryAllVms() {
// Wait for vApp to have been entirely instantiated // Wait for vApp to have been entirely instantiated
Task instantiateTask = Iterables.getFirst(vApp.getTasks(), null); Task instantiateTask = Iterables.getFirst(vApp.getTasks(), null);
@ -152,10 +162,10 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
// Start the vApp so that it has VMs // Start the vApp so that it has VMs
Task task = vAppApi.powerOn(vApp.getHref()); Task task = vAppApi.powerOn(vApp.getId());
assertTaskSucceedsLong(task); assertTaskSucceedsLong(task);
vApp = vAppApi.getVApp(vApp.getHref()); // reload, so it has the VMs vApp = vAppApi.get(vApp.getId()); // reload, so it has the VMs
List<Vm> vms = vApp.getChildren().getVms(); List<Vm> vms = vApp.getChildren().getVms();
Set<URI> vmHrefs = toHrefs(vms); Set<URI> vmHrefs = toHrefs(vms);
@ -164,10 +174,11 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
assertTrue(hrefs.containsAll(vmHrefs), "VMs query result should include vms "+vmHrefs+"; but only has "+hrefs); assertTrue(hrefs.containsAll(vmHrefs), "VMs query result should include vms " + vmHrefs + "; but only has "
+ hrefs);
} }
@Test(description = "GET /vms/query?filter", dependsOnMethods = { "testQueryAllVms" } ) @Test(description = "GET /vms/query?filter", dependsOnMethods = { "testQueryAllVms" })
public void testQueryAllVmsWithFilter() { public void testQueryAllVmsWithFilter() {
List<Vm> vms = vApp.getChildren().getVms(); List<Vm> vms = vApp.getChildren().getVms();
Set<URI> vmHrefs = toHrefs(vms); Set<URI> vmHrefs = toHrefs(vms);
@ -176,7 +187,8 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Set<URI> hrefs = toHrefs(queryResult); Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs); assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp " + vApp.getName() + " (" + vmHrefs
+ "); but only has " + hrefs);
} }
@Test(description = "GET /mediaList/query") @Test(description = "GET /mediaList/query")
@ -194,10 +206,13 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest {
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class); assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class);
} }
private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes, Class<?> validClazz) { private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes,
Class<?> validClazz) {
for (QueryResultRecordType record : queryResult.getRecords()) { for (QueryResultRecordType record : queryResult.getRecords()) {
assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes); assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, " + record.getType()
assertEquals(record.getClass(), validClazz, "invalid type for query result record, "+record.getClass()+"; expected "+validClazz); + "; valid types are " + validTypes);
assertEquals(record.getClass(), validClazz, "invalid type for query result record, " + record.getClass()
+ "; expected " + validClazz);
} }
} }

View File

@ -82,7 +82,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest {
VApp expected = getVApp(); VApp expected = getVApp();
assertEquals(api.getVAppApi().getVApp(vAppURI), expected); assertEquals(api.getVAppApi().get(vAppURI), expected);
} }
@Test(enabled = false) @Test(enabled = false)
@ -103,7 +103,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Task expected = editVAppTask(); Task expected = editVAppTask();
assertEquals(api.getVAppApi().editVApp(vAppURI, modified), expected); assertEquals(api.getVAppApi().edit(vAppURI, modified), expected);
} }
@Test(enabled = false) @Test(enabled = false)
@ -119,7 +119,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Task expected = removeVAppTask(); Task expected = removeVAppTask();
assertEquals(api.getVAppApi().removeVApp(vAppURI), expected); assertEquals(api.getVAppApi().remove(vAppURI), expected);
} }
@Test(enabled = false) @Test(enabled = false)
@ -349,12 +349,12 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest {
.acceptAnyMedia() .acceptAnyMedia()
.httpRequestBuilder().build(), .httpRequestBuilder().build(),
new VcloudHttpResponsePrimer() new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getControlAccess.xml", VCloudDirectorMediaType.VAPP) .xmlFilePayload("/vApp/getAccessControl.xml", VCloudDirectorMediaType.VAPP)
.httpResponseBuilder().build()); .httpResponseBuilder().build());
ControlAccessParams expected = getControlAccessParams(); ControlAccessParams expected = getAccessControlParams();
assertEquals(api.getVAppApi().getControlAccess(vAppURI), expected); assertEquals(api.getVAppApi().getAccessControl(vAppURI), expected);
} }
@Test(enabled = false) @Test(enabled = false)
@ -690,7 +690,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest {
return task; return task;
} }
public static ControlAccessParams getControlAccessParams() { public static ControlAccessParams getAccessControlParams() {
ControlAccessParams params = ControlAccessParams.builder() ControlAccessParams params = ControlAccessParams.builder()
.build(); .build();

View File

@ -183,12 +183,12 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
} }
/** /**
* @see VAppApi#getVApp(URI) * @see VAppApi#get(URI)
*/ */
@Test(description = "GET /vApp/{id}") @Test(description = "GET /vApp/{id}")
public void testGetVApp() { public void testGetVApp() {
// The method under test // The method under test
vApp = vAppApi.getVApp(vAppURI); vApp = vAppApi.get(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkVApp(vApp); checkVApp(vApp);
@ -205,7 +205,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
// TODO source.href vAppTemplateURI // TODO source.href vAppTemplateURI
// Check status // Check status
assertVAppStatus(vAppURI, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/action/recomposeVApp") @Test(description = "POST /vApp/{id}/action/recomposeVApp")
@ -220,22 +220,22 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
RecomposeVAppParams params = addRecomposeParams(composedVApp, toAddVm); RecomposeVAppParams params = addRecomposeParams(composedVApp, toAddVm);
// The method under test // The method under test
Task recomposeVApp = vAppApi.recompose(composedVApp.getHref(), params); Task recomposeVApp = vAppApi.recompose(composedVApp.getId(), params);
assertTaskSucceedsLong(recomposeVApp); assertTaskSucceedsLong(recomposeVApp);
// add another vm instance to vApp // add another vm instance to vApp
params = addRecomposeParams(composedVApp, toAddVm); params = addRecomposeParams(composedVApp, toAddVm);
recomposeVApp = vAppApi.recompose(composedVApp.getHref(), params); recomposeVApp = vAppApi.recompose(composedVApp.getId(), params);
assertTaskSucceedsLong(recomposeVApp); assertTaskSucceedsLong(recomposeVApp);
// remove a vm // remove a vm
VApp configured = vAppApi.getVApp(composedVApp.getHref()); VApp configured = vAppApi.get(composedVApp.getId());
List<Vm> vmsToBeDeleted = configured.getChildren().getVms(); List<Vm> vmsToBeDeleted = configured.getChildren().getVms();
Vm toBeDeleted = Iterables.get(vmsToBeDeleted, 0); Vm toBeDeleted = Iterables.get(vmsToBeDeleted, 0);
Task removeVm = vmApi.remove(toBeDeleted.getHref()); Task removeVm = vmApi.remove(toBeDeleted.getId());
assertTaskSucceedsLong(removeVm); assertTaskSucceedsLong(removeVm);
Task removeVApp = vAppApi.removeVApp(composedVApp.getHref()); Task removeVApp = vAppApi.remove(composedVApp.getId());
assertTaskSucceedsLong(removeVApp); assertTaskSucceedsLong(removeVApp);
} }
@ -243,7 +243,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
Set<Vm> vms = Sets.newLinkedHashSet(); Set<Vm> vms = Sets.newLinkedHashSet();
QueryResultRecords templatesRecords = queryApi.vAppTemplatesQueryAll(); QueryResultRecords templatesRecords = queryApi.vAppTemplatesQueryAll();
for (QueryResultRecordType templateRecord : templatesRecords.getRecords()) { for (QueryResultRecordType templateRecord : templatesRecords.getRecords()) {
VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(templateRecord.getHref()); VAppTemplate vAppTemplate = vAppTemplateApi.get(templateRecord.getId());
vms.addAll(vAppTemplate.getChildren()); vms.addAll(vAppTemplate.getChildren());
} }
return ImmutableSet.copyOf(Iterables.filter(vms, new Predicate<Vm>() { return ImmutableSet.copyOf(Iterables.filter(vms, new Predicate<Vm>() {
@ -251,7 +251,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
// or both. // or both.
@Override @Override
public boolean apply(Vm input) { public boolean apply(Vm input) {
GuestCustomizationSection guestCustomizationSection = vmApi.getGuestCustomizationSection(input.getHref()); GuestCustomizationSection guestCustomizationSection = vmApi.getGuestCustomizationSection(input.getId());
String computerName = guestCustomizationSection.getComputerName(); String computerName = guestCustomizationSection.getComputerName();
String retainComputerName = CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'z')) String retainComputerName = CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'z'))
.or(CharMatcher.inRange('A', 'Z')).or(CharMatcher.is('-')).retainFrom(computerName); .or(CharMatcher.inRange('A', 'Z')).or(CharMatcher.is('-')).retainFrom(computerName);
@ -261,7 +261,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
} }
/** /**
* @see VAppApi#editVApp(URI, VApp) * @see VAppApi#edit(URI, VApp)
*/ */
@Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" }) @Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" })
public void testEditVApp() { public void testEditVApp() {
@ -269,11 +269,11 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
vAppNames.add(newVApp.getName()); vAppNames.add(newVApp.getName());
// The method under test // The method under test
Task editVApp = vAppApi.editVApp(vApp.getHref(), newVApp); Task editVApp = vAppApi.edit(vAppUrn, newVApp);
assertTrue(retryTaskSuccess.apply(editVApp), String.format(TASK_COMPLETE_TIMELY, "editVApp")); assertTrue(retryTaskSuccess.apply(editVApp), String.format(TASK_COMPLETE_TIMELY, "editVApp"));
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vApp.getHref()); vApp = vAppApi.get(vAppUrn);
// Check the required fields are set // Check the required fields are set
assertEquals(vApp.getName(), newVApp.getName(), assertEquals(vApp.getName(), newVApp.getName(),
@ -289,139 +289,139 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
.notPowerOn().build(); .notPowerOn().build();
// The method under test // The method under test
Task deployVApp = vAppApi.deploy(vApp.getHref(), params); Task deployVApp = vAppApi.deploy(vAppUrn, params);
assertTrue(retryTaskSuccessLong.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp")); assertTrue(retryTaskSuccessLong.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp"));
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vApp.getHref()); vApp = vAppApi.get(vAppUrn);
// Check the required fields are set // Check the required fields are set
assertTrue(vApp.isDeployed(), String.format(OBJ_FIELD_EQ, VAPP, "deployed", "TRUE", vApp.isDeployed().toString())); assertTrue(vApp.isDeployed(), String.format(OBJ_FIELD_EQ, VAPP, "deployed", "TRUE", vApp.isDeployed().toString()));
// Check status // Check status
assertVAppStatus(vAppURI, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" })
public void testPowerOnVApp() { public void testPowerOnVApp() {
// Power off VApp // Power off VApp
vApp = powerOffVApp(vApp.getHref()); vApp = powerOffVApp(vAppUrn);
// The method under test // The method under test
Task powerOnVApp = vAppApi.powerOn(vApp.getHref()); Task powerOnVApp = vAppApi.powerOn(vAppUrn);
assertTaskSucceedsLong(powerOnVApp); assertTaskSucceedsLong(powerOnVApp);
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vApp.getHref()); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertVAppStatus(vAppURI, Status.POWERED_ON); assertVAppStatus(vAppUrn, Status.POWERED_ON);
} }
@Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVApp" })
public void testReboot() { public void testReboot() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
// The method under test // The method under test
Task reboot = vAppApi.reboot(vApp.getHref()); Task reboot = vAppApi.reboot(vAppUrn);
assertTaskSucceedsLong(reboot); assertTaskSucceedsLong(reboot);
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vApp.getHref()); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertVAppStatus(vAppURI, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testDeployVApp" })
public void testShutdown() { public void testShutdown() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
// The method under test // The method under test
Task shutdown = vAppApi.shutdown(vApp.getHref()); Task shutdown = vAppApi.shutdown(vAppUrn);
assertTaskSucceedsLong(shutdown); assertTaskSucceedsLong(shutdown);
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vApp.getHref()); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertVAppStatus(vApp.getHref(), Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
// Power on the VApp again // Power on the VApp again
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
} }
@Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVApp" })
public void testSuspend() { public void testSuspend() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
// The method under test // The method under test
Task suspend = vAppApi.suspend(vAppURI); Task suspend = vAppApi.suspend(vAppUrn);
assertTaskSucceedsLong(suspend); assertTaskSucceedsLong(suspend);
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vApp.getHref()); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertVAppStatus(vAppURI, Status.SUSPENDED); assertVAppStatus(vAppUrn, Status.SUSPENDED);
// Power on the VApp again // Power on the VApp again
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
} }
@Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVApp" })
public void testReset() { public void testReset() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
// The method under test // The method under test
Task reset = vAppApi.reset(vAppURI); Task reset = vAppApi.reset(vAppUrn);
assertTaskSucceedsLong(reset); assertTaskSucceedsLong(reset);
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vAppURI); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertVAppStatus(vAppURI, Status.POWERED_ON); assertVAppStatus(vAppUrn, Status.POWERED_ON);
} }
@Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" })
public void testUndeployVApp() { public void testUndeployVApp() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
UndeployVAppParams params = UndeployVAppParams.builder().build(); UndeployVAppParams params = UndeployVAppParams.builder().build();
// The method under test // The method under test
Task undeploy = vAppApi.undeploy(vApp.getHref(), params); Task undeploy = vAppApi.undeploy(vAppUrn, params);
assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy")); assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy"));
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vAppURI); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertFalse(vApp.isDeployed(), assertFalse(vApp.isDeployed(),
String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString())); String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString()));
assertVAppStatus(vAppURI, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" }) @Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" })
public void testPowerOffVApp() { public void testPowerOffVApp() {
// Power on VApp // Power on VApp
vApp = powerOnVApp(vApp.getHref()); vApp = powerOnVApp(vAppUrn);
// The method under test // The method under test
Task powerOffVApp = vAppApi.powerOff(vApp.getHref()); Task powerOffVApp = vAppApi.powerOff(vAppUrn);
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp")); assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
// Get the edited VApp // Get the edited VApp
vApp = vAppApi.getVApp(vAppURI); vApp = vAppApi.get(vAppUrn);
// Check status // Check status
assertVAppStatus(vAppURI, Status.POWERED_OFF); assertVAppStatus(vAppUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" }) @Test(description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" })
@ -435,7 +435,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
.accessLevel("ReadOnly").build()).build(); .accessLevel("ReadOnly").build()).build();
// The method under test // The method under test
ControlAccessParams modified = vAppApi.editControlAccess(vApp.getHref(), params); ControlAccessParams modified = vAppApi.editControlAccess(vAppUrn, params);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkControlAccessParams(modified); checkControlAccessParams(modified);
@ -450,7 +450,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
.build(); .build();
// The method under test // The method under test
ControlAccessParams modified = vAppApi.editControlAccess(vApp.getHref(), params); ControlAccessParams modified = vAppApi.editControlAccess(vAppUrn, params);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkControlAccessParams(modified); checkControlAccessParams(modified);
@ -462,11 +462,11 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVApp" }) @Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVApp" })
public void testDiscardSuspendedState() { public void testDiscardSuspendedState() {
// Power on, then suspend the VApp // Power on, then suspend the VApp
vApp = powerOnVApp(vAppURI); vApp = powerOnVApp(vAppUrn);
vApp = suspendVApp(vAppURI); vApp = suspendVApp(vAppUrn);
// The method under test // The method under test
Task discardSuspendedState = vAppApi.discardSuspendedState(vApp.getHref()); Task discardSuspendedState = vAppApi.discardSuspendedState(vAppUrn);
assertTrue(retryTaskSuccess.apply(discardSuspendedState), assertTrue(retryTaskSuccess.apply(discardSuspendedState),
String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState")); String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState"));
} }
@ -479,19 +479,19 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
DeployVAppParams params = DeployVAppParams.builder() DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization()
.notPowerOn().build(); .notPowerOn().build();
Task deployVApp = vAppApi.deploy(temp.getHref(), params); Task deployVApp = vAppApi.deploy(temp.getId(), params);
assertTaskSucceedsLong(deployVApp); assertTaskSucceedsLong(deployVApp);
try { try {
// Method under test // Method under test
vAppApi.enterMaintenanceMode(temp.getHref()); vAppApi.enterMaintenanceMode(temp.getId());
temp = vAppApi.getVApp(temp.getHref()); temp = vAppApi.get(temp.getId());
assertTrue(temp.isInMaintenanceMode(), assertTrue(temp.isInMaintenanceMode(),
String.format(CONDITION_FMT, "InMaintenanceMode", "TRUE", temp.isInMaintenanceMode())); String.format(CONDITION_FMT, "InMaintenanceMode", "TRUE", temp.isInMaintenanceMode()));
// Exit maintenance mode // Exit maintenance mode
vAppApi.exitMaintenanceMode(temp.getHref()); vAppApi.exitMaintenanceMode(temp.getId());
} finally { } finally {
cleanUpVApp(temp); cleanUpVApp(temp);
} }
@ -504,17 +504,17 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
DeployVAppParams params = DeployVAppParams.builder() DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization()
.notPowerOn().build(); .notPowerOn().build();
Task deployVApp = vAppApi.deploy(temp.getHref(), params); Task deployVApp = vAppApi.deploy(temp.getId(), params);
assertTaskSucceedsLong(deployVApp); assertTaskSucceedsLong(deployVApp);
try { try {
// Enter maintenance mode // Enter maintenance mode
vAppApi.enterMaintenanceMode(temp.getHref()); vAppApi.enterMaintenanceMode(temp.getId());
// Method under test // Method under test
vAppApi.exitMaintenanceMode(temp.getHref()); vAppApi.exitMaintenanceMode(temp.getId());
temp = vAppApi.getVApp(temp.getHref()); temp = vAppApi.get(temp.getId());
assertFalse(temp.isInMaintenanceMode(), assertFalse(temp.isInMaintenanceMode(),
String.format(CONDITION_FMT, "InMaintenanceMode", "FALSE", temp.isInMaintenanceMode())); String.format(CONDITION_FMT, "InMaintenanceMode", "FALSE", temp.isInMaintenanceMode()));
} finally { } finally {
@ -525,7 +525,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testGetControlAccess() { public void testGetControlAccess() {
// The method under test // The method under test
ControlAccessParams controlAccess = vAppApi.getControlAccess(vApp.getHref()); ControlAccessParams controlAccess = vAppApi.getAccessControl(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkControlAccessParams(controlAccess); checkControlAccessParams(controlAccess);
@ -534,7 +534,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetVApp" })
public void testGetLeaseSettingsSection() { public void testGetLeaseSettingsSection() {
// The method under test // The method under test
LeaseSettingsSection section = vAppApi.getLeaseSettingsSection(vApp.getHref()); LeaseSettingsSection section = vAppApi.getLeaseSettingsSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkLeaseSettingsSection(section); checkLeaseSettingsSection(section);
@ -543,17 +543,17 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" }) @Test(description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" })
public void testEditLeaseSettingsSection() { public void testEditLeaseSettingsSection() {
// Copy existing section // Copy existing section
LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vApp.getHref()); LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vAppUrn);
Integer twoHours = (int) TimeUnit.SECONDS.convert(2L, TimeUnit.HOURS); Integer twoHours = (int) TimeUnit.SECONDS.convert(2L, TimeUnit.HOURS);
LeaseSettingsSection newSection = oldSection.toBuilder().deploymentLeaseInSeconds(twoHours).build(); LeaseSettingsSection newSection = oldSection.toBuilder().deploymentLeaseInSeconds(twoHours).build();
// The method under test // The method under test
Task editLeaseSettingsSection = vAppApi.editLeaseSettingsSection(vApp.getHref(), newSection); Task editLeaseSettingsSection = vAppApi.editLeaseSettingsSection(vAppUrn, newSection);
assertTrue(retryTaskSuccess.apply(editLeaseSettingsSection), assertTrue(retryTaskSuccess.apply(editLeaseSettingsSection),
String.format(TASK_COMPLETE_TIMELY, "editLeaseSettingsSection")); String.format(TASK_COMPLETE_TIMELY, "editLeaseSettingsSection"));
// Retrieve the modified section // Retrieve the modified section
LeaseSettingsSection modified = vAppApi.getLeaseSettingsSection(vApp.getHref()); LeaseSettingsSection modified = vAppApi.getLeaseSettingsSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkLeaseSettingsSection(modified); checkLeaseSettingsSection(modified);
@ -588,7 +588,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConfigSection() { public void testGetNetworkConfigSection() {
// The method under test // The method under test
NetworkConfigSection section = vAppApi.getNetworkConfigSection(vApp.getHref()); NetworkConfigSection section = vAppApi.getNetworkConfigSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConfigSection(section); checkNetworkConfigSection(section);
@ -597,17 +597,17 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetNetworkConfigSection" }) @Test(description = "PUT /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetNetworkConfigSection" })
public void testEditNetworkConfigSection() { public void testEditNetworkConfigSection() {
// Copy existing section and edit fields // Copy existing section and edit fields
NetworkConfigSection oldSection = vAppApi.getNetworkConfigSection(vApp.getHref()); NetworkConfigSection oldSection = vAppApi.getNetworkConfigSection(vAppUrn);
VAppNetworkConfiguration networkConfig = VAppNetworkConfiguration.builder().build(); VAppNetworkConfiguration networkConfig = VAppNetworkConfiguration.builder().build();
NetworkConfigSection newSection = oldSection.toBuilder().networkConfigs(ImmutableSet.of(networkConfig)).build(); NetworkConfigSection newSection = oldSection.toBuilder().networkConfigs(ImmutableSet.of(networkConfig)).build();
// The method under test // The method under test
Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vApp.getHref(), newSection); Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppUrn, newSection);
assertTrue(retryTaskSuccess.apply(editNetworkConfigSection), assertTrue(retryTaskSuccess.apply(editNetworkConfigSection),
String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection")); String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection"));
// Retrieve the modified section // Retrieve the modified section
NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vApp.getHref()); NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConfigSection(modified); checkNetworkConfigSection(modified);
@ -622,7 +622,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkSection() { public void testGetNetworkSection() {
// The method under test // The method under test
NetworkSection section = vAppApi.getNetworkSection(vApp.getHref()); NetworkSection section = vAppApi.getNetworkSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkSection(section); checkNetworkSection(section);
@ -631,7 +631,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" })
public void testGetOwner() { public void testGetOwner() {
// The method under test // The method under test
Owner owner = vAppApi.getOwner(vApp.getHref()); Owner owner = vAppApi.getOwner(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkOwner(owner); checkOwner(owner);
@ -642,10 +642,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
Owner newOwner = Owner.builder().user(Reference.builder().href(user.getHref()).type(ADMIN_USER).build()).build(); Owner newOwner = Owner.builder().user(Reference.builder().href(user.getHref()).type(ADMIN_USER).build()).build();
// The method under test // The method under test
vAppApi.editOwner(vApp.getHref(), newOwner); vAppApi.editOwner(vAppUrn, newOwner);
// Get the new VApp owner // Get the new VApp owner
Owner modified = vAppApi.getOwner(vApp.getHref()); Owner modified = vAppApi.getOwner(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkOwner(modified); checkOwner(modified);
@ -657,7 +657,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVApp" })
public void testGetProductSections() { public void testGetProductSections() {
// The method under test // The method under test
ProductSectionList sectionList = vAppApi.getProductSections(vApp.getHref()); ProductSectionList sectionList = vAppApi.getProductSections(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkProductSectionList(sectionList); checkProductSectionList(sectionList);
@ -666,7 +666,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" }) @Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" })
public void testEditProductSections() { public void testEditProductSections() {
// Copy existing section and edit fields // Copy existing section and edit fields
ProductSectionList oldSections = vAppApi.getProductSections(vApp.getHref()); ProductSectionList oldSections = vAppApi.getProductSections(vAppUrn);
ProductSectionList newSections = oldSections ProductSectionList newSections = oldSections
.toBuilder() .toBuilder()
.productSection( .productSection(
@ -678,12 +678,12 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
.build()).build(); .build()).build();
// The method under test // The method under test
Task editProductSections = vAppApi.editProductSections(vApp.getHref(), newSections); Task editProductSections = vAppApi.editProductSections(vAppUrn, newSections);
assertTrue(retryTaskSuccess.apply(editProductSections), assertTrue(retryTaskSuccess.apply(editProductSections),
String.format(TASK_COMPLETE_TIMELY, "editProductSections")); String.format(TASK_COMPLETE_TIMELY, "editProductSections"));
// Retrieve the modified section // Retrieve the modified section
ProductSectionList modified = vAppApi.getProductSections(vApp.getHref()); ProductSectionList modified = vAppApi.getProductSections(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkProductSectionList(modified); checkProductSectionList(modified);
@ -698,7 +698,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" }) @Test(description = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" })
public void testGetStartupSection() { public void testGetStartupSection() {
// The method under test // The method under test
StartupSection section = vAppApi.getStartupSection(vApp.getHref()); StartupSection section = vAppApi.getStartupSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkStartupSection(section); checkStartupSection(section);
@ -707,15 +707,15 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/startupSection", dependsOnMethods = { "testGetStartupSection" }) @Test(description = "PUT /vApp/{id}/startupSection", dependsOnMethods = { "testGetStartupSection" })
public void testEditStartupSection() { public void testEditStartupSection() {
// Copy existing section and edit fields // Copy existing section and edit fields
StartupSection oldSection = vAppApi.getStartupSection(vApp.getHref()); StartupSection oldSection = vAppApi.getStartupSection(vAppUrn);
StartupSection newSection = oldSection.toBuilder().build(); StartupSection newSection = oldSection.toBuilder().build();
// The method under test // The method under test
Task editStartupSection = vAppApi.editStartupSection(vApp.getHref(), newSection); Task editStartupSection = vAppApi.editStartupSection(vAppUrn, newSection);
assertTrue(retryTaskSuccess.apply(editStartupSection), String.format(TASK_COMPLETE_TIMELY, "editStartupSection")); assertTrue(retryTaskSuccess.apply(editStartupSection), String.format(TASK_COMPLETE_TIMELY, "editStartupSection"));
// Retrieve the modified section // Retrieve the modified section
StartupSection modified = vAppApi.getStartupSection(vApp.getHref()); StartupSection modified = vAppApi.getStartupSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkStartupSection(modified); checkStartupSection(modified);
@ -730,10 +730,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
key = name("key-"); key = name("key-");
String value = name("value-"); String value = name("value-");
metadataValue = MetadataValue.builder().value(value).build(); metadataValue = MetadataValue.builder().value(value).build();
vAppApi.getMetadataApi().putEntry(vApp.getHref(), key, metadataValue); vAppApi.getMetadataApi(vAppUrn).putEntry(key, metadataValue);
// Retrieve the value, and assert it was set correctly // Retrieve the value, and assert it was set correctly
MetadataValue newMetadataValue = vAppApi.getMetadataApi().getValue(vApp.getHref(), key); MetadataValue newMetadataValue = vAppApi.getMetadataApi(vAppUrn).getValue(key);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkMetadataValueFor(VAPP, newMetadataValue, value); checkMetadataValueFor(VAPP, newMetadataValue, value);
@ -744,10 +744,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
key = name("key-"); key = name("key-");
String value = name("value-"); String value = name("value-");
metadataValue = MetadataValue.builder().value(value).build(); metadataValue = MetadataValue.builder().value(value).build();
vAppApi.getMetadataApi().putEntry(vApp.getHref(), key, metadataValue); vAppApi.getMetadataApi(vAppUrn).putEntry(key, metadataValue);
// Call the method being tested // Call the method being tested
Metadata metadata = vAppApi.getMetadataApi().get(vApp.getHref()); Metadata metadata = vAppApi.getMetadataApi(vAppUrn).get();
checkMetadata(metadata); checkMetadata(metadata);
@ -759,7 +759,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) @Test(description = "GET /vApp/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
public void testGetOrgMetadataValue() { public void testGetOrgMetadataValue() {
// Call the method being tested // Call the method being tested
MetadataValue value = vAppApi.getMetadataApi().getValue(vApp.getHref(), key); MetadataValue value = vAppApi.getMetadataApi(vAppUrn).getValue(key);
String expected = metadataValue.getValue(); String expected = metadataValue.getValue();
@ -771,11 +771,11 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) @Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" })
public void testRemoveMetadataEntry() { public void testRemoveMetadataEntry() {
// Delete the entry // Delete the entry
Task task = vAppApi.getMetadataApi().removeEntry(vApp.getHref(), key); Task task = vAppApi.getMetadataApi(vAppUrn).removeEntry(key);
retryTaskSuccess.apply(task); retryTaskSuccess.apply(task);
// Confirm the entry has been removed // Confirm the entry has been removed
Metadata newMetadata = vAppApi.getMetadataApi().get(vApp.getHref()); Metadata newMetadata = vAppApi.getMetadataApi(vAppUrn).get();
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkMetadataKeyAbsentFor(VAPP, newMetadata, key); checkMetadataKeyAbsentFor(VAPP, newMetadata, key);
@ -783,18 +783,18 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" }) @Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testMergeMetadata() { public void testMergeMetadata() {
Metadata oldMetadata = vAppApi.getMetadataApi().get(vApp.getHref()); Metadata oldMetadata = vAppApi.getMetadataApi(vAppUrn).get();
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata); Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
// Store a value, to be removed // Store a value, to be removed
String key = name("key-"); String key = name("key-");
String value = name("value-"); String value = name("value-");
Metadata addedMetadata = Metadata.builder().entry(MetadataEntry.builder().key(key).value(value).build()).build(); Metadata addedMetadata = Metadata.builder().entry(MetadataEntry.builder().key(key).value(value).build()).build();
Task task = vAppApi.getMetadataApi().merge(vApp.getHref(), addedMetadata); Task task = vAppApi.getMetadataApi(vAppUrn).merge(addedMetadata);
retryTaskSuccess.apply(task); retryTaskSuccess.apply(task);
// Confirm the entry contains everything that was there, and everything that was being added // Confirm the entry contains everything that was there, and everything that was being added
Metadata newMetadata = vAppApi.getMetadataApi().get(vApp.getHref()); Metadata newMetadata = vAppApi.getMetadataApi(vAppUrn).get();
Map<String, String> expectedMetadataMap = ImmutableMap.<String, String> builder().putAll(oldMetadataMap) Map<String, String> expectedMetadataMap = ImmutableMap.<String, String> builder().putAll(oldMetadataMap)
.put(key, value).build(); .put(key, value).build();
@ -803,7 +803,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
} }
/** /**
* @see VAppApi#removeVApp(URI) * @see VAppApi#remove(URI)
*/ */
@Test(description = "DELETE /vApp/{id}") @Test(description = "DELETE /vApp/{id}")
public void testRemoveVApp() { public void testRemoveVApp() {
@ -811,10 +811,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
VApp temp = instantiateVApp(); VApp temp = instantiateVApp();
// The method under test // The method under test
Task removeVApp = vAppApi.removeVApp(temp.getHref()); Task removeVApp = vAppApi.remove(temp.getId());
assertTrue(retryTaskSuccess.apply(removeVApp), String.format(TASK_COMPLETE_TIMELY, "removeVApp")); assertTrue(retryTaskSuccess.apply(removeVApp), String.format(TASK_COMPLETE_TIMELY, "removeVApp"));
VApp removed = vAppApi.getVApp(temp.getHref()); VApp removed = vAppApi.get(temp.getId());
assertNull(removed, "The VApp " + temp.getName() + " should have been removed"); assertNull(removed, "The VApp " + temp.getName() + " should have been removed");
} }

View File

@ -22,7 +22,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.T
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConfigSection; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConfigSection;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -79,7 +78,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
protected void tidyUp() { protected void tidyUp() {
if (key != null) { if (key != null) {
try { try {
Task remove = vAppTemplateApi.getMetadataApi().removeEntry(vAppTemplateURI, key); Task remove = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).removeEntry(key);
taskDoneEventually(remove); taskDoneEventually(remove);
} catch (Exception e) { } catch (Exception e) {
logger.warn(e, "Error when deleting metadata entry '%s'", key); logger.warn(e, "Error when deleting metadata entry '%s'", key);
@ -101,10 +100,10 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "Create a vApp Network based on an org network with `default` firewall rules applied") @Test(description = "Create a vApp Network based on an org network with `default` firewall rules applied")
public void testAddVAppNetworkWithDefaultSecurityGroup() { public void testAddVAppNetworkWithDefaultSecurityGroup() {
ImmutableList<String> securityGroups = ImmutableList.of(DEFAULT_SECURITY_GROUP); ImmutableList<String> securityGroups = ImmutableList.of(DEFAULT_SECURITY_GROUP);
addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppURI); addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppUrn);
// Retrieve the modified section // Retrieve the modified section
NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppURI); NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConfigSection(modified); checkNetworkConfigSection(modified);
@ -120,10 +119,10 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "Create a vApp Network based on an org network with `http` firewall rules applied") @Test(description = "Create a vApp Network based on an org network with `http` firewall rules applied")
public void testAddVAppNetworkWithHttpSecurityGroup() { public void testAddVAppNetworkWithHttpSecurityGroup() {
ImmutableList<String> securityGroups = ImmutableList.of(HTTP_SECURITY_GROUP); ImmutableList<String> securityGroups = ImmutableList.of(HTTP_SECURITY_GROUP);
addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppURI); addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppUrn);
// Retrieve the modified section // Retrieve the modified section
NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppURI); NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConfigSection(modified); checkNetworkConfigSection(modified);
@ -139,10 +138,10 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "Create a vApp Network based on an org network with both `defautl` and `http` firewall rules applied") @Test(description = "Create a vApp Network based on an org network with both `defautl` and `http` firewall rules applied")
public void testAddVAppNetworkWithDefaultAndHttpSecurityGroup() { public void testAddVAppNetworkWithDefaultAndHttpSecurityGroup() {
ImmutableList<String> securityGroups = ImmutableList.of(DEFAULT_SECURITY_GROUP, HTTP_SECURITY_GROUP); ImmutableList<String> securityGroups = ImmutableList.of(DEFAULT_SECURITY_GROUP, HTTP_SECURITY_GROUP);
addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppURI); addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppUrn);
// Retrieve the modified section // Retrieve the modified section
NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppURI); NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConfigSection(modified); checkNetworkConfigSection(modified);
@ -155,11 +154,11 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
*/ */
} }
private void addVAppNetworkWithSecurityGroupOnVApp(ImmutableList<String> securityGroups, URI vAppURI) { private void addVAppNetworkWithSecurityGroupOnVApp(ImmutableList<String> securityGroups, String vAppUrn) {
String newVAppNetworkName = generateVAppNetworkName(network.getName(), securityGroups); String newVAppNetworkName = generateVAppNetworkName(network.getName(), securityGroups);
// Create a vAppNetwork with firewall rules // Create a vAppNetwork with firewall rules
NetworkConfigSection newSection = generateNetworkConfigSection(securityGroups, newVAppNetworkName); NetworkConfigSection newSection = generateNetworkConfigSection(securityGroups, newVAppNetworkName);
Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppURI, newSection); Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppUrn, newSection);
assertTrue(retryTaskSuccess.apply(editNetworkConfigSection), String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection")); assertTrue(retryTaskSuccess.apply(editNetworkConfigSection), String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection"));
attachVmToVAppNetwork(vm, newVAppNetworkName); attachVmToVAppNetwork(vm, newVAppNetworkName);
} }
@ -191,7 +190,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
} }
private void attachVmToVAppNetwork(Vm vm, String vAppNetworkName) { private void attachVmToVAppNetwork(Vm vm, String vAppNetworkName) {
Set<NetworkConnection> networkConnections = vmApi.getNetworkConnectionSection(vm.getHref()) Set<NetworkConnection> networkConnections = vmApi.getNetworkConnectionSection(vm.getId())
.getNetworkConnections(); .getNetworkConnections();
NetworkConnectionSection section = NetworkConnectionSection.builder() NetworkConnectionSection section = NetworkConnectionSection.builder()
@ -209,7 +208,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
section = section.toBuilder().networkConnection(newNetworkConnection).build(); section = section.toBuilder().networkConnection(newNetworkConnection).build();
} }
Task configureNetwork = vmApi.editNetworkConnectionSection(vm.getHref(), section); Task configureNetwork = vmApi.editNetworkConnectionSection(vm.getId(), section);
assertTaskSucceedsLong(configureNetwork); assertTaskSucceedsLong(configureNetwork);
} }
@ -333,7 +332,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
private void disconnectVmFromVAppNetwork(Vm vm) { private void disconnectVmFromVAppNetwork(Vm vm) {
Set<NetworkConnection> networkConnections = vmApi.getNetworkConnectionSection(vm.getHref()) Set<NetworkConnection> networkConnections = vmApi.getNetworkConnectionSection(vm.getId())
.getNetworkConnections(); .getNetworkConnections();
NetworkConnectionSection section = NetworkConnectionSection.builder() NetworkConnectionSection section = NetworkConnectionSection.builder()
@ -350,7 +349,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest {
.build()) .build())
.build(); .build();
} }
Task cleanUpNetworks = vmApi.editNetworkConnectionSection(vm.getHref(), section); Task cleanUpNetworks = vmApi.editNetworkConnectionSection(vm.getId(), section);
assertTaskSucceedsLong(cleanUpNetworks); assertTaskSucceedsLong(cleanUpNetworks);
} }

View File

@ -21,12 +21,10 @@ package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ANY; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ANY;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ERROR; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ERROR;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.METADATA; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.METADATA;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.METADATA_ENTRY; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.METADATA_ENTRY;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_TEMPLATE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -50,7 +48,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vm; import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
@ -86,14 +83,14 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
).getVAppTemplateApi(); ).getVAppTemplateApi();
assertNotNull(api); assertNotNull(api);
VAppTemplate template = api.getVAppTemplate(uri); VAppTemplate template = api.get(uri);
assertEquals(template, exampleTemplate()); assertEquals(template, exampleTemplate());
Task task = api.editVAppTemplate(uri, exampleTemplate()); Task task = api.edit(uri, exampleTemplate());
assertNotNull(task); assertNotNull(task);
task = api.removeVappTemplate(uri); task = api.remove(uri);
assertNotNull(task); assertNotNull(task);
} }
@ -106,7 +103,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("GET", templateId).acceptMedia(VAPP_TEMPLATE).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("GET", templateId).acceptMedia(VAPP_TEMPLATE).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.getVAppTemplate(uri); api.get(uri);
} }
@Test(expectedExceptions = ResourceNotFoundException.class) @Test(expectedExceptions = ResourceNotFoundException.class)
@ -118,7 +115,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId).xmlFilePayload("/vapptemplate/vAppTemplate.xml", VAPP_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("PUT", templateId).xmlFilePayload("/vapptemplate/vAppTemplate.xml", VAPP_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi();
api.editVAppTemplate(uri, exampleTemplate()); api.edit(uri, exampleTemplate());
} }
@Test(expectedExceptions = VCloudDirectorException.class) @Test(expectedExceptions = VCloudDirectorException.class)
@ -130,33 +127,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.removeVappTemplate(uri); api.remove(uri);
}
public void testConsolidateVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/consolidate").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
).getVAppTemplateApi();
assertNotNull(api);
Task task = api.consolidateVm(uri);
assertNotNull(task);
}
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testConsolidateMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/consolidate").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi();
api.consolidateVm(uri);
} }
public void testDisableDownloadVAppTemplate() { public void testDisableDownloadVAppTemplate() {
@ -210,39 +181,6 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
api.enableDownload(uri); api.enableDownload(uri);
} }
public void testRelocateVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/relocate").xmlFilePayload("/vapptemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
).getVAppTemplateApi();
assertNotNull(api);
Reference datastore = Reference.builder().href(URI.create("https://vcloud.example.com/api/admin/extension/datastore/607")).build();
RelocateParams params = RelocateParams.builder().datastore(datastore).build();
Task task = api.relocateVm(uri, params);
assertNotNull(task);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testRelocateMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/relocate").xmlFilePayload("/vapptemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
Reference datastore = Reference.builder().href(URI.create("https://vcloud.example.com/api/admin/extension/datastore/607")).build();
RelocateParams params = RelocateParams.builder().datastore(datastore).build();
api.relocateVm(uri, params);
}
public void testErrorGetCustomizationSection() { public void testErrorGetCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
@ -254,50 +192,6 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
assertNull(api.getCustomizationSection(uri)); assertNull(api.getCustomizationSection(uri));
} }
public void testGuestCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/guestCustomizationSection").acceptMedia(GUEST_CUSTOMIZATION_SECTION).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).httpResponseBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/guestCustomizationSection").xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
).getVAppTemplateApi();
assertNotNull(api);
GuestCustomizationSection section = api.getGuestCustomizationSection(uri);
assertEquals(section, exampleGuestCustomizationSection());
Task task = api.editGuestCustomizationSection(uri, exampleGuestCustomizationSection());
assertNotNull(task);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetGuestCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/guestCustomizationSection").acceptMedia(GUEST_CUSTOMIZATION_SECTION).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.getGuestCustomizationSection(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditGuestCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/guestCustomizationSection").xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.editGuestCustomizationSection(uri, exampleGuestCustomizationSection());
}
public void testLeaseSettingsSection() throws ParseException { public void testLeaseSettingsSection() throws ParseException {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
@ -353,11 +247,11 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
).getVAppTemplateApi(); ).getVAppTemplateApi();
assertNotNull(api); assertNotNull(api);
Metadata metadata = api.getMetadataApi().get(uri); Metadata metadata = api.getMetadataApi(uri).get();
assertEquals(metadata, exampleMetadata()); assertEquals(metadata, exampleMetadata());
Task task = api.getMetadataApi().merge(uri, exampleMetadata()); Task task = api.getMetadataApi(uri).merge(exampleMetadata());
assertNotNull(task); assertNotNull(task);
} }
@ -370,7 +264,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(ANY).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(ANY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.getMetadataApi().get(uri); api.getMetadataApi(uri).get();
} }
@Test(expectedExceptions = VCloudDirectorException.class) @Test(expectedExceptions = VCloudDirectorException.class)
@ -382,7 +276,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.getMetadataApi().merge(uri, exampleMetadata()); api.getMetadataApi(uri).merge(exampleMetadata());
} }
public void testVappTemplateMetadataValue() { public void testVappTemplateMetadataValue() {
@ -399,14 +293,14 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
).getVAppTemplateApi(); ).getVAppTemplateApi();
assertNotNull(api); assertNotNull(api);
MetadataValue metadata = api.getMetadataApi().getValue(uri, "12345"); MetadataValue metadata = api.getMetadataApi(uri).getValue("12345");
assertEquals(metadata, exampleMetadataValue()); assertEquals(metadata, exampleMetadataValue());
Task task = api.getMetadataApi().putEntry(uri, "12345", exampleMetadataValue()); Task task = api.getMetadataApi(uri).putEntry("12345", exampleMetadataValue());
assertNotNull(task); assertNotNull(task);
task = api.getMetadataApi().removeEntry(uri, "12345"); task = api.getMetadataApi(uri).removeEntry("12345");
assertNotNull(task); assertNotNull(task);
} }
@ -418,7 +312,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata/12345").acceptMedia(METADATA_ENTRY).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata/12345").acceptMedia(METADATA_ENTRY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi();
assertNull(api.getMetadataApi().getValue(uri, "12345")); assertNull(api.getMetadataApi(uri).getValue("12345"));
} }
@Test(expectedExceptions = VCloudDirectorException.class) @Test(expectedExceptions = VCloudDirectorException.class)
@ -430,7 +324,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata/12345").xmlFilePayload("/vapptemplate/metadataValue.xml", METADATA_ENTRY).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata/12345").xmlFilePayload("/vapptemplate/metadataValue.xml", METADATA_ENTRY).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi();
api.getMetadataApi().putEntry(uri, "12345", exampleMetadataValue()); api.getMetadataApi(uri).putEntry("12345", exampleMetadataValue());
} }
@Test(expectedExceptions = ResourceNotFoundException.class) @Test(expectedExceptions = ResourceNotFoundException.class)
@ -442,7 +336,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest
new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId + "/metadata/12345").acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId + "/metadata/12345").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi();
api.getMetadataApi().removeEntry(uri, "12345"); api.getMetadataApi(uri).removeEntry("12345");
} }
@Test(expectedExceptions = VCloudDirectorException.class) @Test(expectedExceptions = VCloudDirectorException.class)

View File

@ -19,7 +19,6 @@
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCustomizationSection; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCustomizationSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkGuestCustomizationSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkLeaseSettingsSection; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkLeaseSettingsSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataFor; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataFor;
@ -38,7 +37,6 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
import java.net.URI;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -46,7 +44,6 @@ import java.util.Set;
import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.AbstractVAppApiLiveTest; import org.jclouds.vcloud.director.v1_5.AbstractVAppApiLiveTest;
import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Link.Rel; import org.jclouds.vcloud.director.v1_5.domain.Link.Rel;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
@ -55,17 +52,13 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.References;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope;
import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -91,7 +84,7 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
protected void tidyUp() { protected void tidyUp() {
if (key != null) { if (key != null) {
try { try {
Task remove = vAppTemplateApi.getMetadataApi().removeEntry(vAppTemplateURI, key); Task remove = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).removeEntry(key);
taskDoneEventually(remove); taskDoneEventually(remove);
} catch (Exception e) { } catch (Exception e) {
logger.warn(e, "Error when deleting metadata entry '%s'", key); logger.warn(e, "Error when deleting metadata entry '%s'", key);
@ -101,10 +94,8 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
private VAppTemplate cloneVAppTemplate(boolean waitForTask) throws Exception { private VAppTemplate cloneVAppTemplate(boolean waitForTask) throws Exception {
CloneVAppTemplateParams cloneVAppTemplateParams = CloneVAppTemplateParams.builder() CloneVAppTemplateParams cloneVAppTemplateParams = CloneVAppTemplateParams.builder()
.source(Reference.builder().href(vAppTemplateURI).build()) .source(Reference.builder().href(lazyGetVAppTemplate().getHref()).build()).isSourceDelete(false)
.isSourceDelete(false) .name("clone").build();
.name("clone")
.build();
VAppTemplate clonedVappTemplate = vdcApi.cloneVAppTemplate(vdcUrn, cloneVAppTemplateParams); VAppTemplate clonedVappTemplate = vdcApi.cloneVAppTemplate(vdcUrn, cloneVAppTemplateParams);
if (waitForTask) { if (waitForTask) {
@ -117,30 +108,30 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vAppTemplate/{id}") @Test(description = "GET /vAppTemplate/{id}")
public void testGetVAppTemplate() { public void testGetVAppTemplate() {
vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn);
checkVAppTemplate(vAppTemplate); checkVAppTemplate(vAppTemplate);
assertEquals(vAppTemplate.getHref(), vAppTemplateURI); assertEquals(vAppTemplate.getId(), vAppTemplateUrn);
} }
@Test(description = "GET /vAppTemplate/{id}/owner") @Test(description = "GET /vAppTemplate/{id}/owner")
public void testGetVAppTemplateOwner() { public void testGetVAppTemplateOwner() {
Owner owner = vAppTemplateApi.getOwner(vAppTemplateURI); Owner owner = vAppTemplateApi.getOwner(vAppTemplateUrn);
checkOwner(owner); checkOwner(owner);
assertEquals(owner.getUser(), vAppTemplateApi.getVAppTemplate(vAppTemplateURI).getOwner().getUser()); assertEquals(owner.getUser(), vAppTemplateApi.get(vAppTemplateUrn).getOwner().getUser());
} }
@Test(description = "GET /vAppTemplate/{id}/customizationSection") @Test(description = "GET /vAppTemplate/{id}/customizationSection")
public void testGetCustomizationSection() { public void testGetCustomizationSection() {
CustomizationSection customizationSection = vAppTemplateApi.getCustomizationSection(vAppTemplateURI); CustomizationSection customizationSection = vAppTemplateApi.getCustomizationSection(vAppTemplateUrn);
checkCustomizationSection(customizationSection); checkCustomizationSection(customizationSection);
} }
@Test(description = "GET /vAppTemplate/{id}/productSections") @Test(description = "GET /vAppTemplate/{id}/productSections")
public void testGetProductSections() { public void testGetProductSections() {
ProductSectionList productSectionList = vAppTemplateApi.getProductSections(vAppTemplateURI); ProductSectionList productSectionList = vAppTemplateApi.getProductSections(vAppTemplateUrn);
checkProductSectionList(productSectionList); checkProductSectionList(productSectionList);
} }
@ -149,47 +140,38 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
public void testEditProductSections() { public void testEditProductSections() {
// TODO make a real modification // TODO make a real modification
ProductSectionList origSections = vAppTemplateApi.getProductSections(vApp.getHref()); ProductSectionList origSections = vAppTemplateApi.getProductSections(vApp.getId());
ProductSectionList newSections = origSections.toBuilder().build(); ProductSectionList newSections = origSections.toBuilder().build();
Task task = vAppTemplateApi.editProductSections(vApp.getHref(), newSections); Task task = vAppTemplateApi.editProductSections(vApp.getId(), newSections);
assertTaskSucceeds(task); assertTaskSucceeds(task);
ProductSectionList modified = vAppTemplateApi.getProductSections(vApp.getHref()); ProductSectionList modified = vAppTemplateApi.getProductSections(vApp.getId());
checkProductSectionList(modified); checkProductSectionList(modified);
} }
@Test(description = "GET /vAppTemplate/{id}/guestCustomizationSection")
public void testGetGuestCustomizationSection() {
getGuestCustomizationSection(new Function<URI, GuestCustomizationSection>() {
@Override
public GuestCustomizationSection apply(URI uri) {
return vAppTemplateApi.getGuestCustomizationSection(uri);
}
});
}
@Test(description = "GET /vAppTemplate/{id}/leaseSettingsSection") @Test(description = "GET /vAppTemplate/{id}/leaseSettingsSection")
public void testGetLeaseSettingsSection() { public void testGetLeaseSettingsSection() {
LeaseSettingsSection leaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateURI); LeaseSettingsSection leaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateUrn);
checkLeaseSettingsSection(leaseSettingsSection); checkLeaseSettingsSection(leaseSettingsSection);
} }
@Test(description = "GET /vAppTemplate/{id}/metadata", dependsOnMethods = { "testEditMetadataValue" }) @Test(description = "GET /vAppTemplate/{id}/metadata", dependsOnMethods = { "testEditMetadataValue" })
public void testGetVAppTemplateMetadata() { public void testGetVAppTemplateMetadata() {
Metadata metadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); Metadata metadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get();
checkMetadata(metadata); checkMetadata(metadata);
} }
// implicitly tested by testEditVAppTemplateMetadataValue, which first adds the metadata entry; otherwise no entry may exist // implicitly tested by testEditVAppTemplateMetadataValue, which first adds the metadata entry;
// otherwise no entry may exist
@Test(description = "GET /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetVAppTemplateMetadata" }) @Test(description = "GET /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetVAppTemplateMetadata" })
public void testGetMetadataValue() { public void testGetMetadataValue() {
Metadata metadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); Metadata metadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get();
MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0); MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0);
MetadataValue val = vAppTemplateApi.getMetadataApi().getValue(vAppTemplateURI, entry.getKey()); MetadataValue val = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).getValue(entry.getKey());
checkMetadataValue(val); checkMetadataValue(val);
assertEquals(val.getValue(), entry.getValue()); assertEquals(val.getValue(), entry.getValue());
@ -197,31 +179,21 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vAppTemplate/{id}/networkConfigSection") @Test(description = "GET /vAppTemplate/{id}/networkConfigSection")
public void testGetVAppTemplateNetworkConfigSection() { public void testGetVAppTemplateNetworkConfigSection() {
NetworkConfigSection networkConfigSection = vAppTemplateApi.getNetworkConfigSection(vAppTemplateURI); NetworkConfigSection networkConfigSection = vAppTemplateApi.getNetworkConfigSection(vAppTemplateUrn);
checkNetworkConfigSection(networkConfigSection); checkNetworkConfigSection(networkConfigSection);
} }
@Test(description = "GET /vAppTemplate/{id}/networkConnectionSection")
public void testGetNetworkConnectionSection() {
getNetworkConnectionSection(new Function<URI, NetworkConnectionSection>() {
@Override
public NetworkConnectionSection apply(URI uri) {
return vAppTemplateApi.getNetworkConnectionSection(uri);
}
});
}
@Test(description = "GET /vAppTemplate/{id}/networkSection") @Test(description = "GET /vAppTemplate/{id}/networkSection")
public void testGetVAppTemplateNetworkSection() { public void testGetVAppTemplateNetworkSection() {
NetworkSection networkSection = vAppTemplateApi.getNetworkSection(vAppTemplateURI); NetworkSection networkSection = vAppTemplateApi.getNetworkSection(vAppTemplateUrn);
checkOvfNetworkSection(networkSection); checkOvfNetworkSection(networkSection);
} }
@Test(description = "GET /vAppTemplate/{id}/ovf") @Test(description = "GET /vAppTemplate/{id}/ovf")
public void testGetVAppTemplateOvf() { public void testGetVAppTemplateOvf() {
Envelope envelope = vAppTemplateApi.getOvf(vAppTemplateURI); Envelope envelope = vAppTemplateApi.getOvf(vAppTemplateUrn);
checkOvfEnvelope(envelope); checkOvfEnvelope(envelope);
} }
@ -230,94 +202,70 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
public void testEditVAppTemplate() { public void testEditVAppTemplate() {
String name = name("myname-"); String name = name("myname-");
String description = name("Description "); String description = name("Description ");
VAppTemplate template = VAppTemplate.builder() VAppTemplate template = VAppTemplate.builder().name(name).description(description).build();
.name(name)
.description(description)
.build();
final Task task = vAppTemplateApi.editVAppTemplate(vAppTemplateURI, template); final Task task = vAppTemplateApi.edit(vAppTemplateUrn, template);
assertTaskSucceeds(task); assertTaskSucceeds(task);
VAppTemplate newTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); VAppTemplate newTemplate = vAppTemplateApi.get(vAppTemplateUrn);
assertEquals(newTemplate.getName(), name); assertEquals(newTemplate.getName(), name);
assertEquals(newTemplate.getDescription(), description); assertEquals(newTemplate.getDescription(), description);
} }
@Test(description = "POST /vAppTemplate/{id}/metadata", dependsOnMethods = { "testGetVAppTemplate" }) @Test(description = "POST /vAppTemplate/{id}/metadata", dependsOnMethods = { "testGetVAppTemplate" })
public void testEditMetadata() { public void testEditMetadata() {
Metadata oldMetadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); Metadata oldMetadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get();
Map<String,String> oldMetadataMap = metadataToMap(oldMetadata); Map<String, String> oldMetadataMap = metadataToMap(oldMetadata);
key = name("key-"); key = name("key-");
val = name("value-"); val = name("value-");
MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build(); MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build();
Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build(); Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build();
final Task task = vAppTemplateApi.getMetadataApi().merge(vAppTemplateURI, metadata); final Task task = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).merge(metadata);
assertTaskSucceeds(task); assertTaskSucceeds(task);
Metadata newMetadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); Metadata newMetadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get();
Map<String,String> expectedMetadataMap = ImmutableMap.<String,String>builder() Map<String, String> expectedMetadataMap = ImmutableMap.<String, String> builder().putAll(oldMetadataMap)
.putAll(oldMetadataMap) .put(key, val).build();
.put(key, val)
.build();
checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap); checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap);
} }
@Test(description = "PUT /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testEditMetadata" }) @Test(description = "PUT /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testEditMetadata" })
public void testEditMetadataValue() { public void testEditMetadataValue() {
val = "new"+val; val = "new" + val;
MetadataValue metadataValue = MetadataValue.builder().value(val).build(); MetadataValue metadataValue = MetadataValue.builder().value(val).build();
final Task task = vAppTemplateApi.getMetadataApi().putEntry(vAppTemplateURI, key, metadataValue); final Task task = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).putEntry(key, metadataValue);
retryTaskSuccess.apply(task); retryTaskSuccess.apply(task);
MetadataValue newMetadataValue = vAppTemplateApi.getMetadataApi().getValue(vAppTemplateURI, key); MetadataValue newMetadataValue = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).getValue(key);
assertEquals(newMetadataValue.getValue(), metadataValue.getValue()); assertEquals(newMetadataValue.getValue(), metadataValue.getValue());
} }
@Test(description = "DELETE /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" }) @Test(description = "DELETE /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" })
public void testRemoveVAppTemplateMetadataValue() { public void testRemoveVAppTemplateMetadataValue() {
final Task deletionTask = vAppTemplateApi.getMetadataApi().removeEntry(vAppTemplateURI, key); final Task deletionTask = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).removeEntry(key);
assertTaskSucceeds(deletionTask); assertTaskSucceeds(deletionTask);
Metadata newMetadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); Metadata newMetadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get();
checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key); checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key);
key = null; key = null;
} }
@Test(description = "PUT /vAppTemplate/{id}/guestCustomizationSection")
public void testEditGuestCustomizationSection() {
String computerName = name("n");
GuestCustomizationSection newSection = GuestCustomizationSection.builder()
.info("")
.computerName(computerName)
.build();
final Task task = vAppTemplateApi.editGuestCustomizationSection(vm.getHref(), newSection);
assertTaskSucceeds(task);
GuestCustomizationSection modified = vAppTemplateApi.getGuestCustomizationSection(vm.getHref());
checkGuestCustomizationSection(modified);
assertEquals(modified.getComputerName(), computerName);
}
// NOTE vAppTemplate supports only storageLease (deployment lease applies to vApp too) // NOTE vAppTemplate supports only storageLease (deployment lease applies to vApp too)
@Test(description = "PUT /vAppTemplate/{id}/leaseSettingsSection") @Test(description = "PUT /vAppTemplate/{id}/leaseSettingsSection")
public void testEditLeaseSettingsSection() throws Exception { public void testEditLeaseSettingsSection() throws Exception {
// NOTE use smallish number for storageLeaseInSeconds; it seems to be capped at 5184000? // NOTE use smallish number for storageLeaseInSeconds; it seems to be capped at 5184000?
int storageLeaseInSeconds = random.nextInt(10000)+1; int storageLeaseInSeconds = random.nextInt(10000) + 1;
LeaseSettingsSection leaseSettingSection = LeaseSettingsSection.builder() LeaseSettingsSection leaseSettingSection = LeaseSettingsSection.builder().info("my info")
.info("my info") .storageLeaseInSeconds(storageLeaseInSeconds).build();
.storageLeaseInSeconds(storageLeaseInSeconds)
.build();
final Task task = vAppTemplateApi.editLeaseSettingsSection(vAppTemplateURI, leaseSettingSection); final Task task = vAppTemplateApi.editLeaseSettingsSection(vAppTemplateUrn, leaseSettingSection);
assertTaskSucceeds(task); assertTaskSucceeds(task);
LeaseSettingsSection newLeaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateURI); LeaseSettingsSection newLeaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateUrn);
assertEquals(newLeaseSettingsSection.getStorageLeaseInSeconds(), (Integer) storageLeaseInSeconds); assertEquals(newLeaseSettingsSection.getStorageLeaseInSeconds(), (Integer) storageLeaseInSeconds);
} }
@ -326,45 +274,48 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
VAppTemplate clonedVappTemplate = cloneVAppTemplate(true); VAppTemplate clonedVappTemplate = cloneVAppTemplate(true);
// Confirm that "get" works pre-remove // Confirm that "get" works pre-remove
VAppTemplate vAppTemplatePreDelete = vAppTemplateApi.getVAppTemplate(clonedVappTemplate.getHref()); VAppTemplate vAppTemplatePreDelete = vAppTemplateApi.get(clonedVappTemplate.getId());
checkVAppTemplate(vAppTemplatePreDelete); checkVAppTemplate(vAppTemplatePreDelete);
// Delete the template // Delete the template
final Task task = vAppTemplateApi.removeVappTemplate(clonedVappTemplate.getHref()); final Task task = vAppTemplateApi.remove(clonedVappTemplate.getId());
assertTaskSucceeds(task); assertTaskSucceeds(task);
// Confirm that can't access post-remove, i.e. template has been removed // Confirm that can't access post-remove, i.e. template has been removed
VAppTemplate removed = vAppTemplateApi.getVAppTemplate(clonedVappTemplate.getHref()); VAppTemplate removed = vAppTemplateApi.get(clonedVappTemplate.getId());
assertNull(removed); assertNull(removed);
} }
@Test(description = "POST /vAppTemplate/{id}/action/disableDownload") @Test(description = "POST /vAppTemplate/{id}/action/disableDownload")
public void testDisableVAppTemplateDownload() throws Exception { public void testDisableVAppTemplateDownload() throws Exception {
vAppTemplateApi.disableDownload(vAppTemplateURI); vAppTemplateApi.disableDownload(vAppTemplateUrn);
// TODO Check that it really is disabled. The only thing I can see for determining this // TODO Check that it really is disabled. The only thing I can see for determining this
// is the undocumented "download" link in the VAppTemplate. But that is brittle and we // is the undocumented "download" link in the VAppTemplate. But that is brittle and we
// don't know what timing guarantees there are for adding/removing the link. // don't know what timing guarantees there are for adding/removing the link.
VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn);
Set<Link> links = vAppTemplate.getLinks(); Set<Link> links = vAppTemplate.getLinks();
assertTrue(Iterables.all(Iterables.transform(links, rel), Predicates.not(Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE)))), assertTrue(Iterables.all(Iterables.transform(links, rel),
"Should not offer download link after disabling download: "+vAppTemplate); Predicates.not(Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE)))),
"Should not offer download link after disabling download: " + vAppTemplate);
} }
@Test(description = "POST /vAppTemplate/{id}/action/enableDownload") @Test(description = "POST /vAppTemplate/{id}/action/enableDownload")
public void testEnableVAppTemplateDownload() throws Exception { public void testEnableVAppTemplateDownload() throws Exception {
// First disable so that enable really has some work to do... // First disable so that enable really has some work to do...
vAppTemplateApi.disableDownload(vAppTemplateURI); vAppTemplateApi.disableDownload(vAppTemplateUrn);
final Task task = vAppTemplateApi.enableDownload(vAppTemplateURI); final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn);
assertTaskSucceeds(task); assertTaskSucceeds(task);
// TODO Check that it really is enabled. The only thing I can see for determining this // TODO Check that it really is enabled. The only thing I can see for determining this
// is the undocumented "download" link in the VAppTemplate. But that is brittle and we // is the undocumented "download" link in the VAppTemplate. But that is brittle and we
// don't know what timing guarantees there are for adding/removing the link. // don't know what timing guarantees there are for adding/removing the link.
VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn);
Set<Link> links = vAppTemplate.getLinks(); Set<Link> links = vAppTemplate.getLinks();
assertTrue(Iterables.any(Iterables.transform(links, rel), Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE))), assertTrue(
"Should offer download link after enabling download: "+vAppTemplate); Iterables.any(Iterables.transform(links, rel),
Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE))),
"Should offer download link after enabling download: " + vAppTemplate);
} }
private Function<Link, Link.Rel> rel = new Function<Link, Link.Rel>() { private Function<Link, Link.Rel> rel = new Function<Link, Link.Rel>() {
@ -374,53 +325,23 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
} }
}; };
@Test(description = "POST /vAppTemplate/{id}/action/consolidate")
public void testConsolidateVAppTemplate() throws Exception {
final Task task = vAppTemplateApi.consolidateVm(vm.getHref());
assertTaskSucceedsLong(task);
// TODO Need assertion that command had effect
}
// TODO How to obtain a datastore reference?
@Test(description = "POST /vAppTemplate/{id}/action/relocate")
public void testRelocateVAppTemplate() throws Exception {
Reference dataStore = null; // FIXME
RelocateParams relocateParams = RelocateParams.builder()
.datastore(dataStore)
.build();
final Task task = vAppTemplateApi.relocateVm(vAppTemplateURI, relocateParams);
assertTaskSucceedsLong(task);
// TODO Need assertion that command had effect
}
// NOTE This will fail unless we can relocate a template to another datastore
@Test(description = "GET /vAppTemplate/{id}/shadowVms", dependsOnMethods = { "testRelocateVAppTemplate" })
public void testGetShadowVms() {
References references = vAppTemplateApi.getShadowVms(vAppTemplateURI);
Checks.checkReferences(references);
}
// This failed previously, but is passing now. // This failed previously, but is passing now.
// However, it's not part of the official API so not necessary to assert it. // However, it's not part of the official API so not necessary to assert it.
@Test(description = "test completed task not included in vAppTemplate") @Test(description = "test completed task not included in vAppTemplate")
public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception { public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception {
// Kick off a task, and wait for it to complete // Kick off a task, and wait for it to complete
vAppTemplateApi.disableDownload(vAppTemplateURI); vAppTemplateApi.disableDownload(vAppTemplateUrn);
final Task task = vAppTemplateApi.enableDownload(vAppTemplateURI); final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn);
assertTaskDoneEventually(task); assertTaskDoneEventually(task);
// Ask the VAppTemplate for its tasks, and the status of the matching task if it exists // Ask the VAppTemplate for its tasks, and the status of the matching task if it exists
VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn);
List<Task> tasks = vAppTemplate.getTasks(); List<Task> tasks = vAppTemplate.getTasks();
for (Task contender : tasks) { for (Task contender : tasks) {
if (task.getId().equals(contender.getId())) { if (task.getId().equals(contender.getId())) {
Task.Status status = contender.getStatus(); Task.Status status = contender.getStatus();
if (EnumSet.of(Task.Status.QUEUED, Task.Status.PRE_RUNNING, Task.Status.RUNNING).contains(status)) { if (EnumSet.of(Task.Status.QUEUED, Task.Status.PRE_RUNNING, Task.Status.RUNNING).contains(status)) {
fail("Task "+contender+" reported complete, but is included in VAppTemplate in status "+status); fail("Task " + contender + " reported complete, but is included in VAppTemplate in status " + status);
} }
} }
} }

View File

@ -355,7 +355,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Metadata expected = metadata(); Metadata expected = metadata();
assertEquals(api.getVdcApi().getMetadataApi().get(vdcUri), expected); assertEquals(api.getVdcApi().getMetadataApi(vdcUri).get(), expected);
} }
@Test(enabled = false) @Test(enabled = false)
@ -373,7 +373,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
MetadataValue expected = metadataValue(); MetadataValue expected = metadataValue();
assertEquals(api.getVdcApi().getMetadataApi().getValue(vdcUri, "key"), expected); assertEquals(api.getVdcApi().getMetadataApi(vdcUri).getValue("key"), expected);
} }
public static Vdc getVdc() { public static Vdc getVdc() {

View File

@ -64,7 +64,7 @@ import com.google.common.collect.Iterables;
/** /**
* Tests behavior of {@link VdcApi} * Tests behavior of {@link VdcApi}
* *
* @author danikov * @author danikov, Adrian Cole
*/ */
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcApiLiveTest") @Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcApiLiveTest")
public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@ -121,7 +121,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
if (metadataSet) { if (metadataSet) {
try { try {
Task remove = adminContext.getApi().getVdcApi().getMetadataApi().removeEntry(lazyGetVdc().getHref(), "key"); Task remove = adminContext.getApi().getVdcApi().getMetadataApi(vdcUrn).removeEntry("key");
taskDoneEventually(remove); taskDoneEventually(remove);
} catch (Exception e) { } catch (Exception e) {
logger.warn(e, "Error deleting metadata entry"); logger.warn(e, "Error deleting metadata entry");
@ -187,8 +187,8 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "POST /vdc/{id}/action/cloneVAppTemplate") @Test(description = "POST /vdc/{id}/action/cloneVAppTemplate")
public void testCloneVAppTemplate() { public void testCloneVAppTemplate() {
clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn, CloneVAppTemplateParams.builder().source(vAppTemplateURI) clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn,
.build()); CloneVAppTemplateParams.builder().source(lazyGetVAppTemplate().getHref()).build());
Task task = Iterables.getFirst(clonedVAppTemplate.getTasks(), null); Task task = Iterables.getFirst(clonedVAppTemplate.getTasks(), null);
assertNotNull(task, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks"); assertNotNull(task, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks");
@ -259,7 +259,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name(name("test-vapp-")) InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name(name("test-vapp-"))
.notDeploy().notPowerOn().description("Test VApp").instantiationParams(instantiationParams) .notDeploy().notPowerOn().description("Test VApp").instantiationParams(instantiationParams)
.source(vAppTemplateURI).build(); .source(lazyGetVAppTemplate().getHref()).build();
instantiatedVApp = vdcApi.instantiateVApp(vdcUrn, instantiate); instantiatedVApp = vdcApi.instantiateVApp(vdcUrn, instantiate);
Task instantiationTask = Iterables.getFirst(instantiatedVApp.getTasks(), null); Task instantiationTask = Iterables.getFirst(instantiatedVApp.getTasks(), null);
@ -300,8 +300,8 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
private void setupMetadata() { private void setupMetadata() {
adminContext.getApi().getVdcApi().getMetadataApi() adminContext.getApi().getVdcApi().getMetadataApi(vdcUrn)
.putEntry(lazyGetVdc().getHref(), "key", MetadataValue.builder().value("value").build()); .putEntry("key", MetadataValue.builder().value("value").build());
metadataSet = true; metadataSet = true;
} }
@ -311,7 +311,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
setupMetadata(); setupMetadata();
} }
Metadata metadata = vdcApi.getMetadataApi().get(lazyGetVdc().getHref()); Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get();
// required for testing // required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
@ -323,12 +323,12 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) @Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
public void testGetMetadataValue() { public void testGetMetadataValue() {
// First find a key // First find a key
Metadata metadata = vdcApi.getMetadataApi().get(lazyGetVdc().getHref()); Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get();
Map<String, String> metadataMap = Checks.metadataToMap(metadata); Map<String, String> metadataMap = Checks.metadataToMap(metadata);
String key = Iterables.getFirst(metadataMap.keySet(), "MadeUpKey!"); String key = Iterables.getFirst(metadataMap.keySet(), "MadeUpKey!");
String value = metadataMap.get(key); String value = metadataMap.get(key);
MetadataValue metadataValue = vdcApi.getMetadataApi().getValue(lazyGetVdc().getHref(), key); MetadataValue metadataValue = vdcApi.getMetadataApi(vdcUrn).getValue(key);
Checks.checkMetadataValueFor(VDC, metadataValue, value); Checks.checkMetadataValueFor(VDC, metadataValue, value);
} }

View File

@ -985,7 +985,7 @@ public class VmApiExpectTest extends VCloudDirectorAdminApiExpectTest {
return task; return task;
} }
public static ControlAccessParams getControlAccessParams() { public static ControlAccessParams getAccessControlParams() {
ControlAccessParams params = ControlAccessParams.builder() ControlAccessParams params = ControlAccessParams.builder()
.build(); .build();

View File

@ -53,7 +53,6 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -180,12 +179,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
} }
/** /**
* @see VmApi#get(URI) * @see VmApi#get(String)
*/ */
@Test(description = "GET /vApp/{id}") @Test(description = "GET /vApp/{id}")
public void testGetVm() { public void testGetVm() {
// The method under test // The method under test
vm = vmApi.get(vmURI); vm = vmApi.get(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkVm(vm); checkVm(vm);
@ -195,22 +194,22 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
String.format(OBJ_FIELD_EQ, VM, "deployed", "FALSE", vm.isDeployed().toString())); String.format(OBJ_FIELD_EQ, VM, "deployed", "FALSE", vm.isDeployed().toString()));
// Check status // Check status
assertVmStatus(vm.getHref(), Status.POWERED_OFF); assertVmStatus(vmUrn, Status.POWERED_OFF);
} }
/** /**
* @see VmApi#edit(URI, Vm) * @see VmApi#edit(String, Vm)
*/ */
@Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVm" }) @Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVm" })
public void testEditVm() { public void testEditVm() {
Vm newVm = Vm.builder().name(name("new-name-")).description("New Description").build(); Vm newVm = Vm.builder().name(name("new-name-")).description("New Description").build();
// The method under test // The method under test
Task editVm = vmApi.edit(vm.getHref(), newVm); Task editVm = vmApi.edit(vmUrn, newVm);
assertTrue(retryTaskSuccess.apply(editVm), String.format(TASK_COMPLETE_TIMELY, "editVm")); assertTrue(retryTaskSuccess.apply(editVm), String.format(TASK_COMPLETE_TIMELY, "editVm"));
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check the required fields are set // Check the required fields are set
assertEquals(vm.getName(), newVm.getName(), assertEquals(vm.getName(), newVm.getName(),
@ -226,155 +225,155 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.notPowerOn().build(); .notPowerOn().build();
// The method under test // The method under test
Task deployVm = vmApi.deploy(vm.getHref(), params); Task deployVm = vmApi.deploy(vmUrn, params);
assertTrue(retryTaskSuccessLong.apply(deployVm), String.format(TASK_COMPLETE_TIMELY, "deployVm")); assertTrue(retryTaskSuccessLong.apply(deployVm), String.format(TASK_COMPLETE_TIMELY, "deployVm"));
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check the required fields are set // Check the required fields are set
assertTrue(vm.isDeployed(), String.format(OBJ_FIELD_EQ, VM, "deployed", "TRUE", vm.isDeployed().toString())); assertTrue(vm.isDeployed(), String.format(OBJ_FIELD_EQ, VM, "deployed", "TRUE", vm.isDeployed().toString()));
// Check status // Check status
assertVmStatus(vmURI, Status.POWERED_OFF); assertVmStatus(vmUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVm" })
public void testPowerOnVm() { public void testPowerOnVm() {
// Power off Vm // Power off Vm
vm = powerOffVm(vm.getHref()); vm = powerOffVm(vmUrn);
// The method under test // The method under test
Task powerOnVm = vmApi.powerOn(vm.getHref()); Task powerOnVm = vmApi.powerOn(vmUrn);
assertTaskSucceedsLong(powerOnVm); assertTaskSucceedsLong(powerOnVm);
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check status // Check status
assertVmStatus(vm.getHref(), Status.POWERED_ON); assertVmStatus(vmUrn, Status.POWERED_ON);
} }
@Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVm" })
public void testReboot() { public void testReboot() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
Task reboot = vmApi.reboot(vm.getHref()); Task reboot = vmApi.reboot(vmUrn);
assertTaskSucceedsLong(reboot); assertTaskSucceedsLong(reboot);
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check status // Check status
assertVmStatus(vmURI, Status.POWERED_OFF); assertVmStatus(vmUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testInstallVMwareTools" }) @Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testInstallVMwareTools" })
public void testShutdown() { public void testShutdown() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
Task shutdown = vmApi.shutdown(vm.getHref()); Task shutdown = vmApi.shutdown(vmUrn);
assertTaskSucceedsLong(shutdown); assertTaskSucceedsLong(shutdown);
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check status // Check status
assertVmStatus(vm.getHref(), Status.POWERED_OFF); assertVmStatus(vmUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVm" })
public void testSuspend() { public void testSuspend() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
Task suspend = vmApi.suspend(vmURI); Task suspend = vmApi.suspend(vmUrn);
assertTaskSucceedsLong(suspend); assertTaskSucceedsLong(suspend);
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check status // Check status
assertVmStatus(vmURI, Status.SUSPENDED); assertVmStatus(vmUrn, Status.SUSPENDED);
// Power on the Vm again // Power on the Vm again
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
} }
@Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVm" })
public void testReset() { public void testReset() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
Task reset = vmApi.reset(vmURI); Task reset = vmApi.reset(vmUrn);
assertTaskSucceedsLong(reset); assertTaskSucceedsLong(reset);
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check status // Check status
assertVmStatus(vmURI, Status.POWERED_ON); assertVmStatus(vmUrn, Status.POWERED_ON);
} }
@Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVm" })
public void testUndeployVm() { public void testUndeployVm() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
UndeployVAppParams params = UndeployVAppParams.builder().build(); UndeployVAppParams params = UndeployVAppParams.builder().build();
// The method under test // The method under test
Task undeploy = vmApi.undeploy(vm.getHref(), params); Task undeploy = vmApi.undeploy(vmUrn, params);
assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy")); assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy"));
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vm.getHref()); vm = vmApi.get(vmUrn);
// Check status // Check status
assertFalse(vm.isDeployed(), String.format(OBJ_FIELD_EQ, VM, "deployed", "FALSE", vm.isDeployed().toString())); assertFalse(vm.isDeployed(), String.format(OBJ_FIELD_EQ, VM, "deployed", "FALSE", vm.isDeployed().toString()));
assertVmStatus(vmURI, Status.POWERED_OFF); assertVmStatus(vmUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVm" }) @Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVm" })
public void testPowerOffVm() { public void testPowerOffVm() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
// NB this will put the vm in partially powered off state // NB this will put the vm in partially powered off state
Task powerOffVm = vmApi.powerOff(vm.getHref()); Task powerOffVm = vmApi.powerOff(vmUrn);
assertTrue(retryTaskSuccess.apply(powerOffVm), String.format(TASK_COMPLETE_TIMELY, "powerOffVm")); assertTrue(retryTaskSuccess.apply(powerOffVm), String.format(TASK_COMPLETE_TIMELY, "powerOffVm"));
// Get the edited Vm // Get the edited Vm
vm = vmApi.get(vmURI); vm = vmApi.get(vmUrn);
// Check status // Check status
assertVmStatus(vmURI, Status.POWERED_OFF); assertVmStatus(vmUrn, Status.POWERED_OFF);
} }
@Test(description = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testDeployVm" })
public void testConsolidateVm() { public void testConsolidateVm() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
Task consolidateVm = vmApi.consolidate(vm.getHref()); Task consolidateVm = vmApi.consolidate(vmUrn);
assertTrue(retryTaskSuccess.apply(consolidateVm), String.format(TASK_COMPLETE_TIMELY, "consolidateVm")); assertTrue(retryTaskSuccess.apply(consolidateVm), String.format(TASK_COMPLETE_TIMELY, "consolidateVm"));
} }
@Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVm" })
public void testDiscardSuspendedState() { public void testDiscardSuspendedState() {
// Suspend the Vm // Suspend the Vm
vm = suspendVm(vm.getHref()); vm = suspendVm(vmUrn);
// The method under test // The method under test
Task discardSuspendedState = vmApi.discardSuspendedState(vm.getHref()); Task discardSuspendedState = vmApi.discardSuspendedState(vmUrn);
assertTrue(retryTaskSuccess.apply(discardSuspendedState), assertTrue(retryTaskSuccess.apply(discardSuspendedState),
String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState")); String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState"));
} }
@ -382,10 +381,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testDeployVm" })
public void testInstallVMwareTools() { public void testInstallVMwareTools() {
// First ensure the vApp is powered on // First ensure the vApp is powered on
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
Task installVMwareTools = vmApi.installVMwareTools(vm.getHref()); Task installVMwareTools = vmApi.installVMwareTools(vmUrn);
assertTrue(retryTaskSuccess.apply(installVMwareTools), String.format(TASK_COMPLETE_TIMELY, "installVMwareTools")); assertTrue(retryTaskSuccess.apply(installVMwareTools), String.format(TASK_COMPLETE_TIMELY, "installVMwareTools"));
} }
@ -399,29 +398,29 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.build(); .build();
// The method under test // The method under test
Task relocate = vmApi.relocate(vm.getHref(), params); Task relocate = vmApi.relocate(vmUrn, params);
assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate")); assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate"));
} }
@Test(description = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVm" }) @Test(description = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVm" })
public void testUpgradeHardwareVersion() { public void testUpgradeHardwareVersion() {
// Power off Vm // Power off Vm
vm = powerOffVm(vm.getHref()); vm = powerOffVm(vmUrn);
// The method under test // The method under test
Task upgradeHardwareVersion = vmApi.upgradeHardwareVersion(vm.getHref()); Task upgradeHardwareVersion = vmApi.upgradeHardwareVersion(vmUrn);
assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion), assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion),
String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion")); String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion"));
// Power on the Vm again // Power on the Vm again
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
} }
@Test(description = "GET /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetVm" }) @Test(description = "GET /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetVm" })
public void testGetGuestCustomizationSection() { public void testGetGuestCustomizationSection() {
getGuestCustomizationSection(new Function<URI, GuestCustomizationSection>() { getGuestCustomizationSection(new Function<String, GuestCustomizationSection>() {
@Override @Override
public GuestCustomizationSection apply(URI uri) { public GuestCustomizationSection apply(String uri) {
return vmApi.getGuestCustomizationSection(uri); return vmApi.getGuestCustomizationSection(uri);
} }
}); });
@ -430,18 +429,18 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetGuestCustomizationSection" }) @Test(description = "PUT /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetGuestCustomizationSection" })
public void testEditGuestCustomizationSection() { public void testEditGuestCustomizationSection() {
// Copy existing section and edit fields // Copy existing section and edit fields
GuestCustomizationSection oldSection = vmApi.getGuestCustomizationSection(vm.getHref()); GuestCustomizationSection oldSection = vmApi.getGuestCustomizationSection(vmUrn);
GuestCustomizationSection newSection = oldSection.toBuilder().computerName(name("n")).enabled(Boolean.TRUE) GuestCustomizationSection newSection = oldSection.toBuilder().computerName(name("n")).enabled(Boolean.TRUE)
.adminPassword(null) // Not allowed .adminPassword(null) // Not allowed
.build(); .build();
// The method under test // The method under test
Task editGuestCustomizationSection = vmApi.editGuestCustomizationSection(vm.getHref(), newSection); Task editGuestCustomizationSection = vmApi.editGuestCustomizationSection(vmUrn, newSection);
assertTrue(retryTaskSuccess.apply(editGuestCustomizationSection), assertTrue(retryTaskSuccess.apply(editGuestCustomizationSection),
String.format(TASK_COMPLETE_TIMELY, "editGuestCustomizationSection")); String.format(TASK_COMPLETE_TIMELY, "editGuestCustomizationSection"));
// Retrieve the modified section // Retrieve the modified section
GuestCustomizationSection modified = vmApi.getGuestCustomizationSection(vm.getHref()); GuestCustomizationSection modified = vmApi.getGuestCustomizationSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkGuestCustomizationSection(modified); checkGuestCustomizationSection(modified);
@ -466,7 +465,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.media(Reference.builder().href(mediaURI).type(MEDIA).build()).build(); .media(Reference.builder().href(mediaURI).type(MEDIA).build()).build();
// The method under test // The method under test
Task insertMedia = vmApi.insertMedia(vm.getHref(), params); Task insertMedia = vmApi.insertMedia(vmUrn, params);
assertTrue(retryTaskSuccess.apply(insertMedia), String.format(TASK_COMPLETE_TIMELY, "insertMedia")); assertTrue(retryTaskSuccess.apply(insertMedia), String.format(TASK_COMPLETE_TIMELY, "insertMedia"));
} }
@ -477,15 +476,15 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.media(Reference.builder().href(mediaURI).type(MEDIA).build()).build(); .media(Reference.builder().href(mediaURI).type(MEDIA).build()).build();
// The method under test // The method under test
Task ejectMedia = vmApi.ejectMedia(vm.getHref(), params); Task ejectMedia = vmApi.ejectMedia(vmUrn, params);
assertTrue(retryTaskSuccess.apply(ejectMedia), String.format(TASK_COMPLETE_TIMELY, "ejectMedia")); assertTrue(retryTaskSuccess.apply(ejectMedia), String.format(TASK_COMPLETE_TIMELY, "ejectMedia"));
} }
@Test(description = "GET /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetVm" }) @Test(description = "GET /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetVm" })
public void testGetNetworkConnectionSection() { public void testGetNetworkConnectionSection() {
getNetworkConnectionSection(new Function<URI, NetworkConnectionSection>() { getNetworkConnectionSection(new Function<String, NetworkConnectionSection>() {
@Override @Override
public NetworkConnectionSection apply(URI uri) { public NetworkConnectionSection apply(String uri) {
return vmApi.getNetworkConnectionSection(uri); return vmApi.getNetworkConnectionSection(uri);
} }
}); });
@ -494,13 +493,13 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
// FIXME "Task error: Unable to perform this action. Contact your cloud administrator." // FIXME "Task error: Unable to perform this action. Contact your cloud administrator."
@Test(description = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testEditGuestCustomizationSection" }) @Test(description = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testEditGuestCustomizationSection" })
public void testEditNetworkConnectionSection() { public void testEditNetworkConnectionSection() {
powerOffVm(vm.getHref()); powerOffVm(vmUrn);
// Look up a network in the Vdc // Look up a network in the Vdc
Set<Reference> networks = vdc.getAvailableNetworks(); Set<Reference> networks = vdc.getAvailableNetworks();
Reference network = Iterables.getLast(networks); Reference network = Iterables.getLast(networks);
// Copy existing section and edit fields // Copy existing section and edit fields
NetworkConnectionSection oldSection = vmApi.getNetworkConnectionSection(vm.getHref()); NetworkConnectionSection oldSection = vmApi.getNetworkConnectionSection(vmUrn);
NetworkConnectionSection newSection = oldSection NetworkConnectionSection newSection = oldSection
.toBuilder() .toBuilder()
.networkConnection( .networkConnection(
@ -508,12 +507,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.network(network.getName()).build()).build(); .network(network.getName()).build()).build();
// The method under test // The method under test
Task editNetworkConnectionSection = vmApi.editNetworkConnectionSection(vm.getHref(), newSection); Task editNetworkConnectionSection = vmApi.editNetworkConnectionSection(vmUrn, newSection);
assertTrue(retryTaskSuccess.apply(editNetworkConnectionSection), assertTrue(retryTaskSuccess.apply(editNetworkConnectionSection),
String.format(TASK_COMPLETE_TIMELY, "editNetworkConnectionSection")); String.format(TASK_COMPLETE_TIMELY, "editNetworkConnectionSection"));
// Retrieve the modified section // Retrieve the modified section
NetworkConnectionSection modified = vmApi.getNetworkConnectionSection(vm.getHref()); NetworkConnectionSection modified = vmApi.getNetworkConnectionSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkNetworkConnectionSection(modified); checkNetworkConnectionSection(modified);
@ -528,7 +527,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetVm" }) @Test(description = "GET /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetVm" })
public void testGetOperatingSystemSection() { public void testGetOperatingSystemSection() {
// The method under test // The method under test
OperatingSystemSection section = vmApi.getOperatingSystemSection(vm.getHref()); OperatingSystemSection section = vmApi.getOperatingSystemSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkOperatingSystemSection(section); checkOperatingSystemSection(section);
@ -544,12 +543,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.id(OSType.RHEL_64.getCode()).osType("rhel5_64Guest").build(); .id(OSType.RHEL_64.getCode()).osType("rhel5_64Guest").build();
// The method under test // The method under test
Task editOperatingSystemSection = vmApi.editOperatingSystemSection(vm.getHref(), newSection); Task editOperatingSystemSection = vmApi.editOperatingSystemSection(vmUrn, newSection);
assertTrue(retryTaskSuccess.apply(editOperatingSystemSection), assertTrue(retryTaskSuccess.apply(editOperatingSystemSection),
String.format(TASK_COMPLETE_TIMELY, "editOperatingSystemSection")); String.format(TASK_COMPLETE_TIMELY, "editOperatingSystemSection"));
// Retrieve the modified section // Retrieve the modified section
OperatingSystemSection modified = vmApi.getOperatingSystemSection(vm.getHref()); OperatingSystemSection modified = vmApi.getOperatingSystemSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkOperatingSystemSection(modified); checkOperatingSystemSection(modified);
@ -561,7 +560,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVm" }) @Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVm" })
public void testGetProductSections() { public void testGetProductSections() {
// The method under test // The method under test
ProductSectionList sectionList = vmApi.getProductSections(vm.getHref()); ProductSectionList sectionList = vmApi.getProductSections(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkProductSectionList(sectionList); checkProductSectionList(sectionList);
@ -569,9 +568,9 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" }) @Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" })
public void testEditProductSections() { public void testEditProductSections() {
powerOffVm(vm.getHref()); powerOffVm(vmUrn);
// Copy existing section and edit fields // Copy existing section and edit fields
ProductSectionList oldSections = vmApi.getProductSections(vm.getHref()); ProductSectionList oldSections = vmApi.getProductSections(vmUrn);
ProductSectionList newSections = oldSections ProductSectionList newSections = oldSections
.toBuilder() .toBuilder()
.productSection( .productSection(
@ -583,12 +582,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
.build()).build(); .build()).build();
// The method under test // The method under test
Task editProductSections = vmApi.editProductSections(vm.getHref(), newSections); Task editProductSections = vmApi.editProductSections(vmUrn, newSections);
assertTrue(retryTaskSuccess.apply(editProductSections), assertTrue(retryTaskSuccess.apply(editProductSections),
String.format(TASK_COMPLETE_TIMELY, "editProductSections")); String.format(TASK_COMPLETE_TIMELY, "editProductSections"));
// Retrieve the modified section // Retrieve the modified section
ProductSectionList modified = vmApi.getProductSections(vm.getHref()); ProductSectionList modified = vmApi.getProductSections(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkProductSectionList(modified); checkProductSectionList(modified);
@ -604,12 +603,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/question", dependsOnMethods = { "testDeployVm" }) @Test(description = "GET /vApp/{id}/question", dependsOnMethods = { "testDeployVm" })
public void testGetPendingQuestion() { public void testGetPendingQuestion() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// TODO how to test? // TODO how to test?
// The method under test // The method under test
VmPendingQuestion question = vmApi.getPendingQuestion(vm.getHref()); VmPendingQuestion question = vmApi.getPendingQuestion(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkVmPendingQuestion(question); checkVmPendingQuestion(question);
@ -620,7 +619,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
// TODO check that the question has been answered (e.g. asking for getPendingQuestion does not // TODO check that the question has been answered (e.g. asking for getPendingQuestion does not
// include our answered question). // include our answered question).
VmPendingQuestion question = vmApi.getPendingQuestion(vm.getHref()); VmPendingQuestion question = vmApi.getPendingQuestion(vmUrn);
List<VmQuestionAnswerChoice> answerChoices = question.getChoices(); List<VmQuestionAnswerChoice> answerChoices = question.getChoices();
VmQuestionAnswerChoice answerChoice = Iterables.getFirst(answerChoices, null); VmQuestionAnswerChoice answerChoice = Iterables.getFirst(answerChoices, null);
assertNotNull(answerChoice, "Question " + question + " must have at least once answer-choice"); assertNotNull(answerChoice, "Question " + question + " must have at least once answer-choice");
@ -628,13 +627,13 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
VmQuestionAnswer answer = VmQuestionAnswer.builder().choiceId(answerChoice.getId()) VmQuestionAnswer answer = VmQuestionAnswer.builder().choiceId(answerChoice.getId())
.questionId(question.getQuestionId()).build(); .questionId(question.getQuestionId()).build();
vmApi.answerQuestion(vm.getHref(), answer); vmApi.answerQuestion(vmUrn, answer);
} }
@Test(description = "GET /vApp/{id}/runtimeInfoSection", dependsOnMethods = { "testGetVm" }) @Test(description = "GET /vApp/{id}/runtimeInfoSection", dependsOnMethods = { "testGetVm" })
public void testGetRuntimeInfoSection() { public void testGetRuntimeInfoSection() {
// The method under test // The method under test
RuntimeInfoSection section = vmApi.getRuntimeInfoSection(vm.getHref()); RuntimeInfoSection section = vmApi.getRuntimeInfoSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRuntimeInfoSection(section); checkRuntimeInfoSection(section);
@ -644,10 +643,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/screen", dependsOnMethods = { "testInstallVMwareTools" }) @Test(description = "GET /vApp/{id}/screen", dependsOnMethods = { "testInstallVMwareTools" })
public void testGetScreenImage() { public void testGetScreenImage() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
byte[] image = vmApi.getScreenImage(vm.getHref()); byte[] image = vmApi.getScreenImage(vmUrn);
// Check returned bytes against PNG header magic number // Check returned bytes against PNG header magic number
byte[] pngHeaderBytes = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; byte[] pngHeaderBytes = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
@ -662,10 +661,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "POST /vApp/{id}/screen/action/acquireTicket", dependsOnMethods = { "testDeployVm" }) @Test(description = "POST /vApp/{id}/screen/action/acquireTicket", dependsOnMethods = { "testDeployVm" })
public void testGetScreenTicket() { public void testGetScreenTicket() {
// Power on Vm // Power on Vm
vm = powerOnVm(vm.getHref()); vm = powerOnVm(vmUrn);
// The method under test // The method under test
ScreenTicket ticket = vmApi.getScreenTicket(vm.getHref()); ScreenTicket ticket = vmApi.getScreenTicket(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkScreenTicket(ticket); checkScreenTicket(ticket);
@ -674,7 +673,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVm" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVm" })
public void testGetVirtualHardwareSection() { public void testGetVirtualHardwareSection() {
// Method under test // Method under test
VirtualHardwareSection hardware = vmApi.getVirtualHardwareSection(vm.getHref()); VirtualHardwareSection hardware = vmApi.getVirtualHardwareSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkVirtualHardwareSection(hardware); checkVirtualHardwareSection(hardware);
@ -683,10 +682,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "PUT /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testEditVirtualHardwareSection() { public void testEditVirtualHardwareSection() {
// Power off Vm // Power off Vm
vm = powerOffVm(vm.getHref()); vm = powerOffVm(vmUrn);
// Copy existing section and edit fields // Copy existing section and edit fields
VirtualHardwareSection oldSection = vmApi.getVirtualHardwareSection(vm.getHref()); VirtualHardwareSection oldSection = vmApi.getVirtualHardwareSection(vmUrn);
Set<? extends ResourceAllocationSettingData> oldItems = oldSection.getItems(); Set<? extends ResourceAllocationSettingData> oldItems = oldSection.getItems();
Set<ResourceAllocationSettingData> newItems = Sets.newLinkedHashSet(oldItems); Set<ResourceAllocationSettingData> newItems = Sets.newLinkedHashSet(oldItems);
ResourceAllocationSettingData oldMemory = Iterables.find(oldItems, ResourceAllocationSettingData oldMemory = Iterables.find(oldItems,
@ -703,12 +702,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
VirtualHardwareSection newSection = oldSection.toBuilder().items(newItems).build(); VirtualHardwareSection newSection = oldSection.toBuilder().items(newItems).build();
// The method under test // The method under test
Task editVirtualHardwareSection = vmApi.editVirtualHardwareSection(vm.getHref(), newSection); Task editVirtualHardwareSection = vmApi.editVirtualHardwareSection(vmUrn, newSection);
assertTrue(retryTaskSuccess.apply(editVirtualHardwareSection), assertTrue(retryTaskSuccess.apply(editVirtualHardwareSection),
String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSection")); String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSection"));
// Retrieve the modified section // Retrieve the modified section
VirtualHardwareSection modifiedSection = vmApi.getVirtualHardwareSection(vm.getHref()); VirtualHardwareSection modifiedSection = vmApi.getVirtualHardwareSection(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkVirtualHardwareSection(modifiedSection); checkVirtualHardwareSection(modifiedSection);
@ -729,7 +728,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionCpu() { public void testGetVirtualHardwareSectionCpu() {
// Method under test // Method under test
RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkResourceAllocationSettingData(rasd); checkResourceAllocationSettingData(rasd);
@ -738,17 +737,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" }) @Test(description = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" })
public void testEditVirtualHardwareSectionCpu() { public void testEditVirtualHardwareSectionCpu() {
// Copy existing section and edit fields // Copy existing section and edit fields
RasdItem oldItem = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); RasdItem oldItem = vmApi.getVirtualHardwareSectionCpu(vmUrn);
RasdItem newItem = oldItem.toBuilder().elementName("2 virtual CPU(s)").virtualQuantity(new BigInteger("2")) RasdItem newItem = oldItem.toBuilder().elementName("2 virtual CPU(s)").virtualQuantity(new BigInteger("2"))
.build(); .build();
// Method under test // Method under test
Task editVirtualHardwareSectionCpu = vmApi.editVirtualHardwareSectionCpu(vm.getHref(), newItem); Task editVirtualHardwareSectionCpu = vmApi.editVirtualHardwareSectionCpu(vmUrn, newItem);
assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionCpu), assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionCpu),
String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionCpu")); String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionCpu"));
// Retrieve the modified section // Retrieve the modified section
RasdItem modified = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); RasdItem modified = vmApi.getVirtualHardwareSectionCpu(vmUrn);
// Check the retrieved object // Check the retrieved object
checkResourceAllocationSettingData(modified); checkResourceAllocationSettingData(modified);
@ -762,7 +761,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionDisks() { public void testGetVirtualHardwareSectionDisks() {
// Method under test // Method under test
RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionDisks(vm.getHref()); RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionDisks(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(rasdItems); checkRasdItemsList(rasdItems);
@ -771,16 +770,16 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSectionDisks" }) @Test(description = "PUT /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSectionDisks" })
public void testEditVirtualHardwareSectionDisks() { public void testEditVirtualHardwareSectionDisks() {
// Copy the existing items list and edit the name of an item // Copy the existing items list and edit the name of an item
RasdItemsList oldSection = vmApi.getVirtualHardwareSectionDisks(vm.getHref()); RasdItemsList oldSection = vmApi.getVirtualHardwareSectionDisks(vmUrn);
RasdItemsList newSection = oldSection.toBuilder().build(); RasdItemsList newSection = oldSection.toBuilder().build();
// Method under test // Method under test
Task editVirtualHardwareSectionDisks = vmApi.editVirtualHardwareSectionDisks(vm.getHref(), newSection); Task editVirtualHardwareSectionDisks = vmApi.editVirtualHardwareSectionDisks(vmUrn, newSection);
assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionDisks), assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionDisks),
String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionDisks")); String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionDisks"));
// Retrieve the modified section // Retrieve the modified section
RasdItemsList modified = vmApi.getVirtualHardwareSectionDisks(vm.getHref()); RasdItemsList modified = vmApi.getVirtualHardwareSectionDisks(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(modified); checkRasdItemsList(modified);
@ -812,7 +811,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection/media", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection/media", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionMedia() { public void testGetVirtualHardwareSectionMedia() {
// Method under test // Method under test
RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionMedia(vm.getHref()); RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionMedia(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(rasdItems); checkRasdItemsList(rasdItems);
@ -821,7 +820,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionMemory() { public void testGetVirtualHardwareSectionMemory() {
// Method under test // Method under test
RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkResourceAllocationSettingData(rasd); checkResourceAllocationSettingData(rasd);
@ -829,17 +828,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" }) @Test(description = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" })
public void testEditVirtualHardwareSectionMemory() { public void testEditVirtualHardwareSectionMemory() {
RasdItem origItem = vmApi.getVirtualHardwareSectionMemory(vm.getHref()); RasdItem origItem = vmApi.getVirtualHardwareSectionMemory(vmUrn);
RasdItem newItem = origItem.toBuilder().elementName("1024 MB of memory").virtualQuantity(new BigInteger("1024")) RasdItem newItem = origItem.toBuilder().elementName("1024 MB of memory").virtualQuantity(new BigInteger("1024"))
.build(); .build();
// Method under test // Method under test
Task editVirtualHardwareSectionMemory = vmApi.editVirtualHardwareSectionMemory(vm.getHref(), newItem); Task editVirtualHardwareSectionMemory = vmApi.editVirtualHardwareSectionMemory(vmUrn, newItem);
assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionMemory), assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionMemory),
String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionMemory")); String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionMemory"));
// Retrieve the modified section // Retrieve the modified section
RasdItem modified = vmApi.getVirtualHardwareSectionMemory(vm.getHref()); RasdItem modified = vmApi.getVirtualHardwareSectionMemory(vmUrn);
// Check the retrieved object // Check the retrieved object
checkResourceAllocationSettingData(modified); checkResourceAllocationSettingData(modified);
@ -853,7 +852,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionNetworkCards() { public void testGetVirtualHardwareSectionNetworkCards() {
// Method under test // Method under test
RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionNetworkCards(vm.getHref()); RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionNetworkCards(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(rasdItems); checkRasdItemsList(rasdItems);
@ -861,17 +860,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSectionNetworkCards" }) @Test(description = "PUT /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSectionNetworkCards" })
public void testEditVirtualHardwareSectionNetworkCards() { public void testEditVirtualHardwareSectionNetworkCards() {
RasdItemsList oldSection = vmApi.getVirtualHardwareSectionNetworkCards(vm.getHref()); RasdItemsList oldSection = vmApi.getVirtualHardwareSectionNetworkCards(vmUrn);
RasdItemsList newSection = oldSection.toBuilder().build(); RasdItemsList newSection = oldSection.toBuilder().build();
// Method under test // Method under test
Task editVirtualHardwareSectionNetworkCards = vmApi.editVirtualHardwareSectionNetworkCards(vm.getHref(), Task editVirtualHardwareSectionNetworkCards = vmApi.editVirtualHardwareSectionNetworkCards(vmUrn,
newSection); newSection);
assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionNetworkCards), assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionNetworkCards),
String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionNetworkCards")); String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionNetworkCards"));
// Retrieve the modified section // Retrieve the modified section
RasdItemsList modified = vmApi.getVirtualHardwareSectionNetworkCards(vm.getHref()); RasdItemsList modified = vmApi.getVirtualHardwareSectionNetworkCards(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(modified); checkRasdItemsList(modified);
@ -885,7 +884,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSection" }) @Test(description = "GET /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionSerialPorts() { public void testGetVirtualHardwareSectionSerialPorts() {
// Method under test // Method under test
RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionSerialPorts(vm.getHref()); RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionSerialPorts(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(rasdItems); checkRasdItemsList(rasdItems);
@ -893,17 +892,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSectionSerialPorts" }) @Test(description = "PUT /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSectionSerialPorts" })
public void testEditVirtualHardwareSectionSerialPorts() { public void testEditVirtualHardwareSectionSerialPorts() {
RasdItemsList oldSection = vmApi.getVirtualHardwareSectionSerialPorts(vm.getHref()); RasdItemsList oldSection = vmApi.getVirtualHardwareSectionSerialPorts(vmUrn);
RasdItemsList newSection = oldSection.toBuilder().build(); RasdItemsList newSection = oldSection.toBuilder().build();
// Method under test // Method under test
Task editVirtualHardwareSectionSerialPorts = vmApi Task editVirtualHardwareSectionSerialPorts = vmApi
.editVirtualHardwareSectionSerialPorts(vm.getHref(), newSection); .editVirtualHardwareSectionSerialPorts(vmUrn, newSection);
assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionSerialPorts), assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionSerialPorts),
String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionSerialPorts")); String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionSerialPorts"));
// Retrieve the modified section // Retrieve the modified section
RasdItemsList modified = vmApi.getVirtualHardwareSectionSerialPorts(vm.getHref()); RasdItemsList modified = vmApi.getVirtualHardwareSectionSerialPorts(vmUrn);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkRasdItemsList(modified); checkRasdItemsList(modified);
@ -919,10 +918,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
key = name("key-"); key = name("key-");
String value = name("value-"); String value = name("value-");
metadataValue = MetadataValue.builder().value(value).build(); metadataValue = MetadataValue.builder().value(value).build();
vmApi.getMetadataApi().putEntry(vm.getHref(), key, metadataValue); vmApi.getMetadataApi(vmUrn).putEntry(key, metadataValue);
// Retrieve the value, and assert it was set correctly // Retrieve the value, and assert it was set correctly
MetadataValue newMetadataValue = vmApi.getMetadataApi().getValue(vm.getHref(), key); MetadataValue newMetadataValue = vmApi.getMetadataApi(vmUrn).getValue(key);
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkMetadataValueFor(VM, newMetadataValue, value); checkMetadataValueFor(VM, newMetadataValue, value);
@ -931,7 +930,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "GET /vApp/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }) @Test(description = "GET /vApp/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" })
public void testGetMetadata() { public void testGetMetadata() {
// Call the method being tested // Call the method being tested
Metadata metadata = vmApi.getMetadataApi().get(vm.getHref()); Metadata metadata = vmApi.getMetadataApi(vmUrn).get();
checkMetadata(metadata); checkMetadata(metadata);
@ -945,10 +944,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
key = name("key-"); key = name("key-");
String value = name("value-"); String value = name("value-");
metadataValue = MetadataValue.builder().value(value).build(); metadataValue = MetadataValue.builder().value(value).build();
vmApi.getMetadataApi().putEntry(vm.getHref(), key, metadataValue); vmApi.getMetadataApi(vmUrn).putEntry(key, metadataValue);
// Call the method being tested // Call the method being tested
MetadataValue metadataValue = vmApi.getMetadataApi().getValue(vm.getHref(), key); MetadataValue metadataValue = vmApi.getMetadataApi(vmUrn).getValue(key);
String expected = metadataValue.getValue(); String expected = metadataValue.getValue();
@ -960,11 +959,11 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) @Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" })
public void testRemoveMetadataEntry() { public void testRemoveMetadataEntry() {
// Delete the entry // Delete the entry
Task task = vmApi.getMetadataApi().removeEntry(vm.getHref(), key); Task task = vmApi.getMetadataApi(vmUrn).removeEntry(key);
retryTaskSuccess.apply(task); retryTaskSuccess.apply(task);
// Confirm the entry has been removed // Confirm the entry has been removed
Metadata newMetadata = vmApi.getMetadataApi().get(vm.getHref()); Metadata newMetadata = vmApi.getMetadataApi(vmUrn).get();
// Check the retrieved object is well formed // Check the retrieved object is well formed
checkMetadataKeyAbsentFor(VM, newMetadata, key); checkMetadataKeyAbsentFor(VM, newMetadata, key);
@ -972,18 +971,18 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" }) @Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testMergeMetadata() { public void testMergeMetadata() {
Metadata oldMetadata = vmApi.getMetadataApi().get(vm.getHref()); Metadata oldMetadata = vmApi.getMetadataApi(vmUrn).get();
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata); Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
// Store a value, to be removed // Store a value, to be removed
String key = name("key-"); String key = name("key-");
String value = name("value-"); String value = name("value-");
Metadata addedMetadata = Metadata.builder().entry(MetadataEntry.builder().key(key).value(value).build()).build(); Metadata addedMetadata = Metadata.builder().entry(MetadataEntry.builder().key(key).value(value).build()).build();
Task task = vmApi.getMetadataApi().merge(vm.getHref(), addedMetadata); Task task = vmApi.getMetadataApi(vmUrn).merge(addedMetadata);
retryTaskSuccess.apply(task); retryTaskSuccess.apply(task);
// Confirm the entry contains everything that was there, and everything that was being added // Confirm the entry contains everything that was there, and everything that was being added
Metadata newMetadata = vmApi.getMetadataApi().get(vm.getHref()); Metadata newMetadata = vmApi.getMetadataApi(vmUrn).get();
Map<String, String> expectedMetadataMap = ImmutableMap.<String, String> builder().putAll(oldMetadataMap) Map<String, String> expectedMetadataMap = ImmutableMap.<String, String> builder().putAll(oldMetadataMap)
.put(key, value).build(); .put(key, value).build();
@ -992,7 +991,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
} }
/** /**
* @see VmApi#remove(URI) * @see VmApi#remove(String)
*/ */
@Test(description = "DELETE /vApp/{id}") @Test(description = "DELETE /vApp/{id}")
public void testRemoveVm() { public void testRemoveVm() {
@ -1001,27 +1000,27 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
DeployVAppParams params = DeployVAppParams.builder() DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization()
.powerOn().build(); .powerOn().build();
Task deployVApp = vAppApi.deploy(remove.getHref(), params); Task deployVApp = vAppApi.deploy(remove.getId(), params);
assertTaskSucceedsLong(deployVApp); assertTaskSucceedsLong(deployVApp);
// Get the edited VApp and the Vm // Get the edited VApp and the Vm
remove = vAppApi.getVApp(remove.getHref()); remove = vAppApi.get(remove.getId());
List<Vm> vms = remove.getChildren().getVms(); List<Vm> vms = remove.getChildren().getVms();
Vm temp = Iterables.get(vms, 0); Vm temp = Iterables.get(vms, 0);
// otherwise it's impossible to stop a running vApp with no vms // otherwise it's impossible to stop a running vApp with no vms
if (vms.size() == 1) { if (vms.size() == 1) {
UndeployVAppParams undeployParams = UndeployVAppParams.builder().build(); UndeployVAppParams undeployParams = UndeployVAppParams.builder().build();
Task shutdownVapp = vAppApi.undeploy(remove.getHref(), undeployParams); Task shutdownVapp = vAppApi.undeploy(remove.getId(), undeployParams);
assertTaskSucceedsLong(shutdownVapp); assertTaskSucceedsLong(shutdownVapp);
} else { } else {
powerOffVm(temp.getHref()); powerOffVm(temp.getId());
} }
// The method under test // The method under test
Task removeVm = vmApi.remove(temp.getHref()); Task removeVm = vmApi.remove(temp.getId());
assertTrue(retryTaskSuccess.apply(removeVm), String.format(TASK_COMPLETE_TIMELY, "removeVm")); assertTrue(retryTaskSuccess.apply(removeVm), String.format(TASK_COMPLETE_TIMELY, "removeVm"));
Vm removed = vmApi.get(temp.getHref()); Vm removed = vmApi.get(temp.getId());
assertNull(removed, "The Vm " + temp.getName() + " should have been removed"); assertNull(removed, "The Vm " + temp.getName() + " should have been removed");
} }
} }

View File

@ -60,14 +60,14 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
public void setupRequiredApis() { public void setupRequiredApis() {
vdcApi = adminContext.getApi().getVdcApi(); vdcApi = adminContext.getApi().getVdcApi();
metadataApi = vdcApi.getMetadataApi(); metadataApi = vdcApi.getMetadataApi(vdcUrn);
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)
public void cleanUp() throws Exception { public void cleanUp() throws Exception {
if (metadataKey != null) { if (metadataKey != null) {
try { try {
Task task = metadataApi.removeEntry(lazyGetVdc().getHref(), metadataKey); Task task = metadataApi.removeEntry(metadataKey);
taskDoneEventually(task); taskDoneEventually(task);
} catch (VCloudDirectorException e) { } catch (VCloudDirectorException e) {
logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing..."); logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing...");
@ -161,7 +161,7 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /admin/vdc/{id}/metadata") @Test(description = "GET /admin/vdc/{id}/metadata")
public void testGetMetadata() throws Exception { public void testGetMetadata() throws Exception {
Metadata metadata = metadataApi.get(lazyGetVdc().getHref()); Metadata metadata = metadataApi.get();
Checks.checkMetadata(metadata); Checks.checkMetadata(metadata);
} }
@ -174,10 +174,10 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry(metadataKey, metadataValue).build()) Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry(metadataKey, metadataValue).build())
.build(); .build();
Task task = metadataApi.merge(lazyGetVdc().getHref(), metadata); Task task = metadataApi.merge(metadata);
assertTaskSucceeds(task); assertTaskSucceeds(task);
MetadataValue modified = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); MetadataValue modified = metadataApi.getValue(metadataKey);
Checks.checkMetadataValueFor("AdminVdc", modified, metadataValue); Checks.checkMetadataValueFor("AdminVdc", modified, metadataValue);
Checks.checkMetadata(metadata); Checks.checkMetadata(metadata);
} }
@ -185,7 +185,7 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
// TODO insufficient permissions to test // TODO insufficient permissions to test
@Test(description = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled = false) @Test(description = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled = false)
public void testGetMetadataValue() throws Exception { public void testGetMetadataValue() throws Exception {
MetadataValue retrievedMetadataValue = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); MetadataValue retrievedMetadataValue = metadataApi.getValue(metadataKey);
Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue); Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue);
} }
@ -196,10 +196,10 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
metadataValue = name("value-"); metadataValue = name("value-");
MetadataValue newV = MetadataValue.builder().value(metadataValue).build(); MetadataValue newV = MetadataValue.builder().value(metadataValue).build();
Task task = metadataApi.putEntry(lazyGetVdc().getHref(), metadataKey, newV); Task task = metadataApi.putEntry(metadataKey, newV);
assertTaskSucceeds(task); assertTaskSucceeds(task);
MetadataValue retrievedMetadataValue = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); MetadataValue retrievedMetadataValue = metadataApi.getValue(metadataKey);
Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue); Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue);
} }
@ -208,11 +208,11 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void testRemoveMetadataValue() throws Exception { public void testRemoveMetadataValue() throws Exception {
// TODO Remove dependency on other tests; make cleanUp remove a list of metadata entries? // TODO Remove dependency on other tests; make cleanUp remove a list of metadata entries?
Task task = metadataApi.removeEntry(lazyGetVdc().getHref(), metadataKey); Task task = metadataApi.removeEntry(metadataKey);
assertTaskSucceeds(task); assertTaskSucceeds(task);
try { try {
metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); metadataApi.getValue(metadataKey);
fail("Retrieval of metadata value " + metadataKey + " should have fail after deletion"); fail("Retrieval of metadata value " + metadataKey + " should have fail after deletion");
} catch (VCloudDirectorException e) { } catch (VCloudDirectorException e) {
// success; should not be accessible // success; should not be accessible

View File

@ -19,7 +19,6 @@
package org.jclouds.vcloud.director.v1_5.internal; package org.jclouds.vcloud.director.v1_5.internal;
import static com.google.common.base.Strings.emptyToNull; import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.Iterables.any; import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.getFirst; import static com.google.common.collect.Iterables.getFirst;
@ -33,6 +32,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ORG_NETWORK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ORG_NETWORK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.USER; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.USER;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VDC; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VDC;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@ -61,6 +61,7 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminApi;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncApi; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncApi;
import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Link.Rel;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
@ -83,7 +84,6 @@ import org.jclouds.vcloud.director.v1_5.features.TaskApi;
import org.jclouds.vcloud.director.v1_5.features.VAppApi; import org.jclouds.vcloud.director.v1_5.features.VAppApi;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi;
import org.jclouds.vcloud.director.v1_5.features.VdcApi; import org.jclouds.vcloud.director.v1_5.features.VdcApi;
import org.jclouds.vcloud.director.v1_5.predicates.EntityPredicates;
import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates; import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates;
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates; import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
import org.jclouds.vcloud.director.v1_5.predicates.TaskStatusEquals; import org.jclouds.vcloud.director.v1_5.predicates.TaskStatusEquals;
@ -96,10 +96,13 @@ import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
@ -128,13 +131,17 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
public Predicate<Task> retryTaskSuccessLong; public Predicate<Task> retryTaskSuccessLong;
protected RestContext<VCloudDirectorAdminApi, VCloudDirectorAdminAsyncApi> adminContext; protected RestContext<VCloudDirectorAdminApi, VCloudDirectorAdminAsyncApi> adminContext;
protected RestContext<VCloudDirectorApi, VCloudDirectorAsyncApi> context; // FIXME: rename to userContext? protected RestContext<VCloudDirectorApi, VCloudDirectorAsyncApi> context; // FIXME: rename to
// userContext?
protected Session adminSession; protected Session adminSession;
protected Session session; protected Session session;
protected String orgUrn;
protected Org org;
protected String catalogUrn; protected String catalogUrn;
private Catalog catalog; private Catalog catalog;
protected URI vAppTemplateURI; protected String vAppTemplateUrn;
private VAppTemplate vAppTemplate;
protected URI mediaURI; protected URI mediaURI;
protected String networkUrn; protected String networkUrn;
private Network network; private Network network;
@ -154,8 +161,6 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected VCloudDirectorTestSession testSession; protected VCloudDirectorTestSession testSession;
protected Org org;
protected static String testStamp; protected static String testStamp;
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
@ -185,13 +190,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
@Override @Override
protected void initializeContext() { protected void initializeContext() {
Properties overrides = setupProperties(); Properties overrides = setupProperties();
testSession = VCloudDirectorTestSession.builder() testSession = VCloudDirectorTestSession.builder().provider(provider).identity(identity).credential(credential)
.provider(provider) .endpoint(endpoint).overrides(overrides).build();
.identity(identity)
.credential(credential)
.endpoint(endpoint)
.overrides(overrides)
.build();
context = testSession.getUserContext(); context = testSession.getUserContext();
adminContext = testSession.getAdminContext(); adminContext = testSession.getAdminContext();
@ -220,10 +220,12 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
return getRoleReferenceFor(name, adminContext); return getRoleReferenceFor(name, adminContext);
} }
public static Reference getRoleReferenceFor(String name, RestContext<VCloudDirectorAdminApi, VCloudDirectorAdminAsyncApi> adminContext) { public static Reference getRoleReferenceFor(String name,
RestContext<VCloudDirectorAdminApi, VCloudDirectorAdminAsyncApi> adminContext) {
RoleReferences roles = adminContext.getApi().getQueryApi().roleReferencesQueryAll(); RoleReferences roles = adminContext.getApi().getQueryApi().roleReferencesQueryAll();
// backend in a builder to strip out unwanted xml cruft that the api chokes on // backend in a builder to strip out unwanted xml cruft that the api chokes on
return Reference.builder().fromReference(find(roles.getReferences(), ReferencePredicates.nameEquals(name))).build(); return Reference.builder().fromReference(find(roles.getReferences(), ReferencePredicates.nameEquals(name)))
.build();
} }
public User randomTestUser(String prefix) { public User randomTestUser(String prefix) {
@ -231,29 +233,16 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
} }
public User randomTestUser(String prefix, Reference role) { public User randomTestUser(String prefix, Reference role) {
return User.builder() return User.builder().name(name(prefix) + getTestDateTimeStamp()).fullName("testFullName")
.name(name(prefix)+getTestDateTimeStamp()) .emailAddress("test@test.com").telephone("555-1234").isEnabled(false).im("testIM").isAlertEnabled(false)
.fullName("testFullName") .alertEmailPrefix("testPrefix").alertEmail("testAlert@test.com").isExternal(false).isGroupRole(false)
.emailAddress("test@test.com") .role(role).password("password").build();
.telephone("555-1234")
.isEnabled(false)
.im("testIM")
.isAlertEnabled(false)
.alertEmailPrefix("testPrefix")
.alertEmail("testAlert@test.com")
.isExternal(false)
.isGroupRole(false)
.role(role)
.password("password")
.build();
} }
protected void initTestParametersFromPropertiesOrLazyDiscover() { protected void initTestParametersFromPropertiesOrLazyDiscover() {
catalogUrn = emptyToNull(System.getProperty("test." + provider + ".catalog-id")); catalogUrn = emptyToNull(System.getProperty("test." + provider + ".catalog-id"));
String vAppTemplateId = emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id")); vAppTemplateUrn = emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id"));
if (vAppTemplateId != null)
vAppTemplateURI = URI.create(endpoint + "/vAppTemplate/" + vAppTemplateId);
vdcUrn = emptyToNull(System.getProperty("test." + provider + ".vdc-id")); vdcUrn = emptyToNull(System.getProperty("test." + provider + ".vdc-id"));
@ -265,43 +254,132 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
userUrn = emptyToNull(System.getProperty("test." + provider + ".user-id")); userUrn = emptyToNull(System.getProperty("test." + provider + ".user-id"));
org = context.getApi().getOrgApi().get( org = context
find(context.getApi().getOrgApi().list(), .getApi()
ReferencePredicates.<Reference> nameEquals(session.get())).getHref()); .getOrgApi()
.get(find(context.getApi().getOrgApi().list(), ReferencePredicates.<Reference> nameEquals(session.get()))
.getHref());
orgUrn = org.getId();
if (any(Lists.newArrayList(vAppTemplateURI, networkUrn, vdcUrn), Predicates.isNull())) { if (any(Lists.newArrayList(vAppTemplateUrn, networkUrn, vdcUrn), Predicates.isNull())) {
if (vdcUrn == null) { if (vdcUrn == null) {
vdc = context.getApi().getVdcApi().get(find(org.getLinks(), vdc = context.getApi().getVdcApi()
ReferencePredicates.<Link> typeEquals(VDC)).getHref()); .get(find(org.getLinks(), ReferencePredicates.<Link> typeEquals(VDC)).getHref());
vdcUrn = vdc.getId(); vdcUrn = vdc.getId();
if (vAppTemplateUrn == null) {
Reference vAppTemplateRef = Iterables.find(vdc.getResourceEntities(),
ReferencePredicates.<Reference> typeEquals(VAPP_TEMPLATE));
vAppTemplate = context.getApi().getVAppTemplateApi().get(vAppTemplateRef.getHref());
vAppTemplateUrn = vAppTemplate.getId();
}
} }
if (networkUrn == null) { if (networkUrn == null) {
network = context.getApi().getNetworkApi().get(find(org.getLinks(), Optional<Network> optionalNetwork = tryFindBridgedNetworkInOrg();
ReferencePredicates.<Link> typeEquals(ORG_NETWORK)).getHref()); if (optionalNetwork.isPresent()) {
network = optionalNetwork.get();
networkUrn = network.getId(); networkUrn = network.getId();
} }
}
if (catalogUrn == null) { if (catalogUrn == null) {
catalog = context.getApi().getCatalogApi().get(find(org.getLinks(), Optional<Catalog> optionalCatalog = tryFindWritableCatalogInOrg();
ReferencePredicates.<Link> typeEquals(CATALOG)).getHref()); if (optionalCatalog.isPresent()) {
catalog = optionalCatalog.get();
catalogUrn = catalog.getId(); catalogUrn = catalog.getId();
} }
} }
} }
}
Function<Catalog, String> prettyCatalog = new Function<Catalog, String>() {
@Override
public String apply(Catalog input) {
return Objects.toStringHelper("").omitNullValues().add("name", input.getName()).add("id", input.getId())
.add("owner", input.getOwner()).add("isPublished", input.isPublished()).toString();
}
};
/**
* If I can add to a catalog, I can write to it
*/
public Optional<Catalog> tryFindWritableCatalogInOrg() {
FluentIterable<Catalog> catalogs = FluentIterable.from(org.getLinks())
.filter(ReferencePredicates.<Link> typeEquals(CATALOG)).transform(new Function<Link, Catalog>() {
@Override
public Catalog apply(Link in) {
return context.getApi().getCatalogApi().get(in.getHref());
}
});
Optional<Catalog> optionalCatalog = tryFind(catalogs, new Predicate<Catalog>() {
@Override
public boolean apply(Catalog input) {
return Iterables.any(input.getLinks(), LinkPredicates.relEquals(Rel.ADD));
}
});
if (optionalCatalog.isPresent()) {
Logger.CONSOLE.info("found catalog: %s", prettyCatalog.apply(optionalCatalog.get()));
} else {
Logger.CONSOLE.warn("%s doesn't own any catalogs in org %s; catalogs: %s", context.getApi()
.getCurrentSession().getUser(), org.getName(), Iterables.transform(catalogs, prettyCatalog));
}
return optionalCatalog;
}
Function<Network, String> prettyNetwork = new Function<Network, String>() {
@Override
public String apply(Network input) {
return Objects.toStringHelper("").omitNullValues().add("name", input.getName()).add("id", input.getId())
.add("fenceMode", input.getConfiguration().getFenceMode())
.add("taskCount", input.getTasks().size() > 0 ? input.getTasks().size() : null).toString();
}
};
public Optional<Network> tryFindBridgedNetworkInOrg() {
FluentIterable<Network> networks = FluentIterable.from(org.getLinks())
.filter(ReferencePredicates.<Link> typeEquals(ORG_NETWORK)).transform(new Function<Link, Network>() {
@Override
public Network apply(Link in) {
return context.getApi().getNetworkApi().get(in.getHref());
}
});
Optional<Network> optionalNetwork = tryFind(networks, new Predicate<Network>() {
@Override
public boolean apply(Network input) {
if (input.getConfiguration().getFenceMode().equals(Network.FenceMode.BRIDGED)) {
if (input.getTasks().size() == 0) {
return true;
}
}
return false;
}
});
if (optionalNetwork.isPresent()) {
Logger.CONSOLE.info("found network: %s", prettyNetwork.apply(optionalNetwork.get()));
} else {
Logger.CONSOLE.warn("no ready bridged networks present in org %s; networks: %s", org.getName(),
Iterables.transform(networks, prettyNetwork));
}
return optionalNetwork;
}
protected Vdc lazyGetVdc() { protected Vdc lazyGetVdc() {
if (vdc == null) { if (vdc == null) {
assertNotNull(vdcUrn, String.format(URN_REQ_LIVE, VDC)); assertNotNull(vdcUrn, String.format(URN_REQ_LIVE, VDC));
vdc = from(org.getLinks()).filter(LinkPredicates.typeEquals(VDC)) vdc = context.getApi().getVdcApi().get(vdcUrn);
.transform(new Function<Link, Vdc>() {
@Override
public Vdc apply(Link in) {
return context.getApi().getVdcApi().get(in.getHref());
}
}).firstMatch(EntityPredicates.idEquals(vdcUrn)).get();
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
} }
return vdc; return vdc;
@ -310,14 +388,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected Network lazyGetNetwork() { protected Network lazyGetNetwork() {
if (network == null) { if (network == null) {
assertNotNull(networkUrn, String.format(URN_REQ_LIVE, NETWORK)); assertNotNull(networkUrn, String.format(URN_REQ_LIVE, NETWORK));
network = from(org.getLinks()).filter(LinkPredicates.typeEquals(ORG_NETWORK)) network = context.getApi().getNetworkApi().get(networkUrn);
.transform(new Function<Link, Network>() {
@Override
public Network apply(Link in) {
return context.getApi().getNetworkApi().get(in.getHref());
}
}).firstMatch(EntityPredicates.idEquals(networkUrn)).get();
assertNotNull(network, String.format(ENTITY_NON_NULL, NETWORK)); assertNotNull(network, String.format(ENTITY_NON_NULL, NETWORK));
} }
return network; return network;
@ -326,14 +397,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected Catalog lazyGetCatalog() { protected Catalog lazyGetCatalog() {
if (catalog == null) { if (catalog == null) {
assertNotNull(catalogUrn, String.format(URN_REQ_LIVE, CATALOG)); assertNotNull(catalogUrn, String.format(URN_REQ_LIVE, CATALOG));
catalog = from(org.getLinks()).filter(LinkPredicates.typeEquals(CATALOG)) catalog = context.getApi().getCatalogApi().get(catalogUrn);
.transform(new Function<Link, Catalog>() {
@Override
public Catalog apply(Link in) {
return context.getApi().getCatalogApi().get(in.getHref());
}
}).firstMatch(EntityPredicates.idEquals(catalogUrn)).get();
assertNotNull(catalog, String.format(ENTITY_NON_NULL, CATALOG)); assertNotNull(catalog, String.format(ENTITY_NON_NULL, CATALOG));
} }
return catalog; return catalog;
@ -348,6 +412,15 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
return user; return user;
} }
protected VAppTemplate lazyGetVAppTemplate() {
if (vAppTemplate == null) {
assertNotNull(vAppTemplateUrn, String.format(URN_REQ_LIVE, VAPP_TEMPLATE));
vAppTemplate = adminContext.getApi().getVAppTemplateApi().get(vAppTemplateUrn);
assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
}
return vAppTemplate;
}
@Deprecated @Deprecated
public URI toAdminUri(Reference ref) { public URI toAdminUri(Reference ref) {
return toAdminUri(ref.getHref()); return toAdminUri(ref.getHref());
@ -369,7 +442,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected boolean taskStatusEventually(Task task, Task.Status running, ImmutableSet<Task.Status> immutableSet) { protected boolean taskStatusEventually(Task task, Task.Status running, ImmutableSet<Task.Status> immutableSet) {
TaskApi taskApi = context.getApi().getTaskApi(); TaskApi taskApi = context.getApi().getTaskApi();
TaskStatusEquals predicate = new TaskStatusEquals(taskApi, running, immutableSet); TaskStatusEquals predicate = new TaskStatusEquals(taskApi, running, immutableSet);
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, TASK_TIMEOUT_SECONDS * 1000L); RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate,
TASK_TIMEOUT_SECONDS * 1000L);
return retryablePredicate.apply(task); return retryablePredicate.apply(task);
} }
@ -380,21 +454,20 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected boolean taskDoneEventually(Task task) { protected boolean taskDoneEventually(Task task) {
TaskApi taskApi = context.getApi().getTaskApi(); TaskApi taskApi = context.getApi().getTaskApi();
TaskStatusEquals predicate = new TaskStatusEquals( TaskStatusEquals predicate = new TaskStatusEquals(taskApi, ImmutableSet.of(Task.Status.ABORTED,
taskApi, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), Collections.<Task.Status> emptySet());
ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate,
Collections.<Task.Status>emptySet()); LONG_TASK_TIMEOUT_SECONDS * 1000L);
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L);
return retryablePredicate.apply(task); return retryablePredicate.apply(task);
} }
protected void assertTaskDoneEventually(Task task) { protected void assertTaskDoneEventually(Task task) {
assertTrue(taskDoneEventually(task), assertTrue(taskDoneEventually(task), String.format("Task '%s' must complete", task.getOperationName()));
String.format("Task '%s' must complete", task.getOperationName()));
} }
/** /**
* Instantiate a {@link VApp} in a {@link Vdc} using the {@link VAppTemplate} we have configured for the tests. * Instantiate a {@link VApp} in a {@link Vdc} using the {@link VAppTemplate} we have configured
* for the tests.
* *
* @return the VApp that is being instantiated * @return the VApp that is being instantiated
*/ */
@ -403,21 +476,17 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
} }
protected VApp instantiateVApp(String name) { protected VApp instantiateVApp(String name) {
InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder() InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name(name).notDeploy()
.name(name) .notPowerOn().description("Test VApp").instantiationParams(instantiationParams())
.notDeploy() .source(Reference.builder().href(lazyGetVAppTemplate().getHref()).build()).build();
.notPowerOn()
.description("Test VApp")
.instantiationParams(instantiationParams())
.source(Reference.builder().href(vAppTemplateURI).build())
.build();
VdcApi vdcApi = context.getApi().getVdcApi(); VdcApi vdcApi = context.getApi().getVdcApi();
VApp vAppInstantiated = vdcApi.instantiateVApp(vdcUrn, instantiate); VApp vAppInstantiated = vdcApi.instantiateVApp(vdcUrn, instantiate);
assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP));
Task instantiationTask = getFirst(vAppInstantiated.getTasks(), null); Task instantiationTask = getFirst(vAppInstantiated.getTasks(), null);
if (instantiationTask != null) assertTaskSucceedsLong(instantiationTask); if (instantiationTask != null)
assertTaskSucceedsLong(instantiationTask);
// Save VApp name for cleanUp // Save VApp name for cleanUp
vAppNames.add(name); vAppNames.add(name);
@ -428,23 +497,19 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
/** Build an {@link InstantiationParams} object. */ /** Build an {@link InstantiationParams} object. */
protected InstantiationParams instantiationParams() { protected InstantiationParams instantiationParams() {
InstantiationParams instantiationParams = InstantiationParams.builder() InstantiationParams instantiationParams = InstantiationParams.builder()
.sections(ImmutableSet.of(networkConfigSection())) .sections(ImmutableSet.of(networkConfigSection())).build();
.build();
return instantiationParams; return instantiationParams;
} }
/** Build a {@link NetworkConfigSection} object. */ /** Build a {@link NetworkConfigSection} object. */
private NetworkConfigSection networkConfigSection() { private NetworkConfigSection networkConfigSection() {
NetworkConfigSection networkConfigSection = NetworkConfigSection.builder() NetworkConfigSection networkConfigSection = NetworkConfigSection
.builder()
.info("Configuration parameters for logical networks") .info("Configuration parameters for logical networks")
.networkConfigs( .networkConfigs(
ImmutableSet.of( ImmutableSet.of(VAppNetworkConfiguration.builder().networkName("vAppNetwork")
VAppNetworkConfiguration.builder() .configuration(networkConfiguration()).build())).build();
.networkName("vAppNetwork")
.configuration(networkConfiguration())
.build()))
.build();
return networkConfigSection; return networkConfigSection;
} }
@ -470,10 +535,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
} }
// Build the configuration object // Build the configuration object
NetworkConfiguration networkConfiguration = NetworkConfiguration.builder() NetworkConfiguration networkConfiguration = NetworkConfiguration.builder().parentNetwork(parentNetwork.get())
.parentNetwork(parentNetwork.get()) .fenceMode(Network.FenceMode.BRIDGED).build();
.fenceMode(Network.FenceMode.BRIDGED)
.build();
return networkConfiguration; return networkConfiguration;
} }
@ -481,7 +544,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) { protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) {
VAppTemplateApi vappTemplateApi = context.getApi().getVAppTemplateApi(); VAppTemplateApi vappTemplateApi = context.getApi().getVAppTemplateApi();
try { try {
Task task = vappTemplateApi.removeVappTemplate(vAppTemplate.getHref()); Task task = vappTemplateApi.remove(vAppTemplate.getId());
taskDoneEventually(task); taskDoneEventually(task);
} catch (Exception e) { } catch (Exception e) {
logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName()); logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName());
@ -489,19 +552,15 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
} }
protected void cleanUpVApp(VApp vApp) { protected void cleanUpVApp(VApp vApp) {
cleanUpVApp(vApp.getHref());
}
// TODO code tidy for cleanUpVApp? Seems extremely verbose!
protected void cleanUpVApp(URI vAppURI) {
VAppApi vAppApi = context.getApi().getVAppApi(); VAppApi vAppApi = context.getApi().getVAppApi();
VApp vApp = vAppApi.getVApp(vAppURI); // Refresh String vAppUrn = vApp.getId();
vApp = vAppApi.get(vAppUrn); // Refresh
if (vApp == null) { if (vApp == null) {
logger.info("Cannot find VApp at %s", vAppURI.getPath()); logger.info("Cannot find VApp at %s", vAppUrn);
return; // Presumably vApp has already been removed. Ignore. return; // Presumably vApp has already been removed. Ignore.
} }
logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppURI.getPath()); logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppUrn);
// Wait for busy tasks to complete (don't care if it's failed or successful) // Wait for busy tasks to complete (don't care if it's failed or successful)
// Otherwise, get error on remove "entity is busy completing an operation. // Otherwise, get error on remove "entity is busy completing an operation.
@ -516,7 +575,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
// Shutdown and power off the VApp if necessary // Shutdown and power off the VApp if necessary
if (vApp.getStatus() == Status.POWERED_ON) { if (vApp.getStatus() == Status.POWERED_ON) {
try { try {
Task shutdownTask = vAppApi.shutdown(vAppURI); Task shutdownTask = vAppApi.shutdown(vAppUrn);
taskDoneEventually(shutdownTask); taskDoneEventually(shutdownTask);
} catch (Exception e) { } catch (Exception e) {
// keep going; cleanup as much as possible // keep going; cleanup as much as possible
@ -528,9 +587,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
if (vApp.isDeployed()) { if (vApp.isDeployed()) {
try { try {
UndeployVAppParams params = UndeployVAppParams.builder() UndeployVAppParams params = UndeployVAppParams.builder()
.undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN) .undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN).build();
.build(); Task undeployTask = vAppApi.undeploy(vAppUrn, params);
Task undeployTask = vAppApi.undeploy(vAppURI, params);
taskDoneEventually(undeployTask); taskDoneEventually(undeployTask);
} catch (Exception e) { } catch (Exception e) {
// keep going; cleanup as much as possible // keep going; cleanup as much as possible
@ -539,13 +597,13 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
} }
try { try {
Task task = vAppApi.removeVApp(vAppURI); Task task = vAppApi.remove(vAppUrn);
taskDoneEventually(task); taskDoneEventually(task);
vAppNames.remove(vApp.getName()); vAppNames.remove(vApp.getName());
logger.info("Deleted VApp %s", vApp.getName()); logger.info("Deleted VApp %s", vApp.getName());
} catch (Exception e) { } catch (Exception e) {
vApp = vAppApi.getVApp(vAppURI); // Refresh vApp = vAppApi.get(vApp.getId()); // Refresh
logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppURI.getPath()); logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppUrn);
} }
} }