Merge pull request #586 from grkvlt/vm-client

Issue 830: Added a VmClient
This commit is contained in:
Adrian Cole 2012-04-26 10:51:37 -07:00
commit 7d6f791550
16 changed files with 3521 additions and 1859 deletions

View File

@ -67,6 +67,8 @@ import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient;
import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VdcClient;
import org.jclouds.vcloud.director.v1_5.features.VmAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VmClient;
import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient;
import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkAsyncClient;
@ -122,6 +124,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
.put(VAppClient.class, VAppAsyncClient.class)
.put(VAppTemplateClient.class, VAppTemplateAsyncClient.class)
.put(VdcClient.class, VdcAsyncClient.class)
.put(VmClient.class, VmAsyncClient.class)
.build();
public static final Map<Class<?>, Class<?>> ADMIN_DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>>builder()
@ -166,6 +169,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
bindClientAndAsyncClient(binder(), SessionClient.class, SessionAsyncClient.class);
bindClientAndAsyncClient(binder(), TaskClient.class, TaskAsyncClient.class);
bindClientAndAsyncClient(binder(), VAppClient.class, VAppAsyncClient.class);
bindClientAndAsyncClient(binder(), VmClient.class, VmAsyncClient.class);
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(InvalidateSessionAndRetryOn401AndLogoutOnClose.class);

View File

@ -39,8 +39,8 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/**
* Represents a media.
* <p/>
* Represents removable media, such as a CD-ROM, DVD or Floppy disk.
*
* <pre>
* &lt;complexType name="Media" /&gt;
* </pre>
@ -53,7 +53,7 @@ public class Media extends ResourceEntity {
public static enum ImageType {
@XmlEnumValue("iso") ISO("iso"),
@XmlEnumValue("floppy") FLOPPY("floppy"),
UNRECOGNIZED("unrecognized");
@XmlEnumValue("") UNRECOGNIZED("unrecognized");
public static final List<ImageType> ALL = ImmutableList.of(ISO, FLOPPY);

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.dmtf.ovf.environment.EnvironmentType;
@ -30,15 +31,16 @@ import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
* Represents a VM.
* Represents a virtual machine.
*
* <pre>
* &lt;complexType name="Vm" /&gt;
* &lt;complexType name="VmType" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlType(name = "Vm")
@XmlRootElement(name = "Vm")
@XmlType(name = "VmType")
public class Vm extends AbstractVAppType {
public static Builder<?> builder() {

View File

@ -122,15 +122,6 @@ public interface VAppAsyncClient {
@JAXBResponseParser
ListenableFuture<Task> deleteVApp(@EndpointParam URI vAppURI);
/**
* @see VAppClient#consolidateVm(URI)
*/
@POST
@Path("/action/consolidate")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> consolidateVm(@EndpointParam URI vAppURI);
/**
* @see VAppClient#modifyControlAccess(URI, ControlAccessParams)
*/
@ -180,15 +171,6 @@ public interface VAppAsyncClient {
@JAXBResponseParser
ListenableFuture<Void> exitMaintenanceMode(@EndpointParam URI vAppURI);
/**
* @see VAppClient#installVMwareTools(URI)
*/
@POST
@Path("/action/installVMwareTools")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> installVMwareTools(@EndpointParam URI vAppURI);
/**
* @see VAppClient#recompose(URI, RecomposeVAppParams)
*/
@ -200,17 +182,6 @@ public interface VAppAsyncClient {
ListenableFuture<Task> recompose(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) RecomposeVAppParams params);
/**
* @see VAppClient#relocateVm(URI, RelocateParams)
*/
@POST
@Path("/action/relocate")
@Produces(RELOCATE_VM_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> relocateVm(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) RelocateParams params);
/**
* @see VAppClient#undeploy(URI, UndeployVAppParams)
*/
@ -222,15 +193,6 @@ public interface VAppAsyncClient {
ListenableFuture<Task> undeploy(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) UndeployVAppParams params);
/**
* @see VAppClient#upgradeHardwareVersion(URI)
*/
@POST
@Path("/action/upgradeHardwareVersion")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> upgradeHardwareVersion(@EndpointParam URI vAppURI);
/**
* @see VAppClient#getControlAccess(URI)
*/
@ -295,27 +257,6 @@ public interface VAppAsyncClient {
@JAXBResponseParser
ListenableFuture<Task> suspend(@EndpointParam URI vAppURI);
/**
* @see VAppClient#getGuestCustomizationSection(URI)
*/
@GET
@Path("/guestCustomizationSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<GuestCustomizationSection> getGuestCustomizationSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyGuestCustomizationSection(URI, GuestCustomizationSection)
*/
@PUT
@Path("/guestCustomizationSection")
@Produces(GUEST_CUSTOMIZATION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyGuestCustomizationSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) GuestCustomizationSection section);
/**
* @see VAppClient#getLeaseSettingsSection(URI)
*/
@ -337,28 +278,6 @@ public interface VAppAsyncClient {
ListenableFuture<Task> modifyLeaseSettingsSection(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection section);
/**
* @see VAppClient#ejectMedia(URI, MediaInsertOrEjectParams)
*/
@POST
@Path("/media/action/ejectMedia")
@Produces(MEDIA_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> ejectMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @see VAppClient#insertMedia(URI, MediaInsertOrEjectParams)
*/
@POST
@Path("/media/action/insertMedia")
@Produces(MEDIA_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> insertMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @see VAppClient#getNetworkConfigSection(URI)
*/
@ -380,27 +299,6 @@ public interface VAppAsyncClient {
ListenableFuture<Task> modifyNetworkConfigSection(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) NetworkConfigSection section);
/**
* @see VAppClient#getNetworkConnectionSection(URI)
*/
@GET
@Path("/networkConnectionSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyNetworkConnectionSection(URI, NetworkConnectionSection)
*/
@PUT
@Path("/networkConnectionSection")
@Produces(NETWORK_CONNECTION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyNetworkConnectionSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) NetworkConnectionSection section);
/**
* @see VAppClient#getNetworkSection(URI)
*/
@ -411,27 +309,6 @@ public interface VAppAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkSection> getNetworkSection(@EndpointParam URI vAppURI);
/**
* @see VAppClient#getOperatingSystemSection(URI)
*/
@GET
@Path("/operatingSystemSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<OperatingSystemSection> getOperatingSystemSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyOperatingSystemSection(URI, OperatingSystemSection)
*/
@PUT
@Path("/operatingSystemSection")
@Produces(OPERATING_SYSTEM_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyOperatingSystemSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) OperatingSystemSection section);
/**
* @see VAppClient#getOwner(URI)
*/
@ -474,56 +351,6 @@ public interface VAppAsyncClient {
ListenableFuture<Task> modifyProductSections(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) ProductSectionList sectionList);
/**
* @see VAppClient#getPendingQuestion(URI)
*/
@GET
@Path("/question")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VmPendingQuestion> getPendingQuestion(@EndpointParam URI vAppURI);
/**
* @see VAppClient#answerQuestion(URI, VmQuestionAnswer)
*/
@POST
@Path("/question/action/answer")
@Produces(VM_PENDING_ANSWER)
@Consumes
@JAXBResponseParser
ListenableFuture<Void> answerQuestion(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer);
/**
* @see VAppClient#getRuntimeInfoSection(URI)
*/
@GET
@Path("/runtimeInfoSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RuntimeInfoSection> getRuntimeInfoSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#getScreenImage(URI)
*/
@GET
@Path("/screen")
@Consumes(ANY_IMAGE)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(ReturnPayloadBytes.class)
ListenableFuture<byte[]> getScreenImage(@EndpointParam URI vAppURI);
/**
* @see VAppClient#getScreenTicket(URI)
*/
@POST
@Path("/screen/action/acquireTicket")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ScreenTicket> getScreenTicket(@EndpointParam URI vAppURI);
/**
* @see VAppClient#getStartupSection(URI)
@ -547,145 +374,8 @@ public interface VAppAsyncClient {
@BinderParam(BindToXMLPayload.class) StartupSection section);
/**
* @see VAppClient#getVirtualHardwareSection(URI)
*/
@GET
@Path("/virtualHardwareSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VirtualHardwareSection> getVirtualHardwareSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyVirtualHardwareSection(URI, VirtualHardwareSection)
*/
@PUT
@Path("/virtualHardwareSection")
@Produces(VIRTUAL_HARDWARE_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) VirtualHardwareSection section);
/**
* @see VAppClient#getVirtualHardwareSectionCpu(URI)
*/
@GET
@Path("/virtualHardwareSection/cpu")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionCpu(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/cpu")
@Produces(OVF_RASD_ITEM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionCpu(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItem rasd);
/**
* @see VAppClient#getVirtualHardwareSectionDisks(URI)
*/
@GET
@Path("/virtualHardwareSection/disks")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionDisks(URI, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/disks")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionDisks(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @see VAppClient#getVirtualHardwareSectionMedia(URI)
*/
@GET
@Path("/virtualHardwareSection/media")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(@EndpointParam URI vmURI);
/**
* @see VAppClient#getVirtualHardwareSectionMemory(URI)
*/
@GET
@Path("/virtualHardwareSection/memory")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionMemory(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/memory")
@Produces(OVF_RASD_ITEM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionMemory(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItem rasd);
/**
* @see VAppClient#getVirtualHardwareSectionNetworkCards(URI)
*/
@GET
@Path("/virtualHardwareSection/networkCards")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionNetworkCards(URI, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/networkCards")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @see VAppClient#getVirtualHardwareSectionSerialPorts(URI)
*/
@GET
@Path("/virtualHardwareSection/serialPorts")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionSerialPorts(URI, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/serialPorts")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @return asynchronous access to {@link Metadata} features
* Asynchronous access to {@link VApp} {@link Metadata} features
*/
@Delegate
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -27,26 +27,14 @@ import org.jclouds.dmtf.ovf.StartupSection;
import org.jclouds.rest.annotations.Delegate;
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.RasdItemsList;
import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
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.NetworkConfigSection;
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.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
/**
* Provides synchronous access to {@link VApp} objects.
@ -59,9 +47,9 @@ import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
public interface VAppClient {
/**
* Retrieves a vApp/VM.
* Retrieves a {@link VApp}.
*
* The vApp/VM could be in one of these statuses:
* The {@link VApp} could be in one of these statuses:
* <ul>
* <li>{@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION FAILED_CREATION(-1)} -
* Transient entity state, e.g., model object is created but the corresponding VC backing does not
@ -101,7 +89,7 @@ public interface VAppClient {
VApp getVApp(URI vAppURI);
/**
* Modifies the name/description of a vApp/VM.
* Modifies the name/description of a {@link VApp}.
*
* <pre>
* PUT /vApp/{id}
@ -112,7 +100,7 @@ public interface VAppClient {
Task modifyVApp(URI vAppURI, VApp vApp);
/**
* Deletes a vApp/VM.
* Deletes a {@link VApp}.
*
* <pre>
* DELETE /vApp/{id}
@ -123,18 +111,7 @@ public interface VAppClient {
Task deleteVApp(URI vAppURI);
/**
* Consolidates a vm.
*
* <pre>
* POST /vApp/{id}/action/consolidate
* </pre>
*
* @since 1.5
*/
Task consolidateVm(URI vAppURI);
/**
* Modifies the control access of a vApp.
* Modifies the control access of a {@link VApp}.
*
* <pre>
* POST /vApp/{id}/action/controlAccess
@ -145,7 +122,7 @@ public interface VAppClient {
ControlAccessParams modifyControlAccess(URI vAppURI, ControlAccessParams params);
/**
* Deploys a vApp/VM.
* Deploys a {@link VApp}.
*
* Deployment means allocation of all resource for a vApp/VM like CPU and memory
* from a vDC resource pool. Deploying a vApp automatically deploys all of the
@ -162,7 +139,7 @@ public interface VAppClient {
Task deploy(URI vAppURI, DeployVAppParams params);
/**
* Discard suspended state of a vApp/VM.
* Discard suspended state of a {@link VApp}.
*
* Discarding suspended state of a vApp automatically discarded suspended
* states of all of the virtual machines it contains.
@ -176,7 +153,7 @@ public interface VAppClient {
Task discardSuspendedState(URI vAppURI);
/**
* Place the vApp into maintenance mode.
* Place the {@link VApp} into maintenance mode.
*
* While in maintenance mode, a system admin can operate on the vApp as
* usual, but end users are restricted to read-only operations. Any
@ -192,7 +169,7 @@ public interface VAppClient {
void enterMaintenanceMode(URI vAppURI);
/**
* Take the vApp out of maintenance mode.
* Take the {@link VApp} out of maintenance mode.
*
* <pre>
* POST /vApp/{id}/action/exitMaintenanceMode
@ -203,20 +180,7 @@ public interface VAppClient {
void exitMaintenanceMode(URI vAppURI);
/**
* Installs VMware tools to the virtual machine.
*
* It should be running in order for them to be installed.
*
* <pre>
* POST /vApp/{id}/action/installVMwareTools
* </pre>
*
* @since 1.5
*/
Task installVMwareTools(URI vAppURI);
/**
* Recompose a 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 vApp templates.
*
* To remove VMs you should put their references in elements. The way you add
@ -234,18 +198,7 @@ public interface VAppClient {
Task recompose(URI vAppURI, RecomposeVAppParams params);
/**
* Relocates a vm.
*
* <pre>
* POST /vApp/{id}/action/relocate
* </pre>
*
* @since 1.5
*/
Task relocateVm(URI vAppURI, RelocateParams params);
/**
* Undeploy a vApp/VM.
* Undeploy a {@link VApp}.
*
* Undeployment means deallocation of all resources for a vApp/VM like CPU
* and memory from a vDC resource pool. Undeploying a vApp automatically
@ -260,19 +213,7 @@ public interface VAppClient {
Task undeploy(URI vAppURI, UndeployVAppParams params);
/**
* Upgrade virtual hardware version of a VM to the highest supported virtual
* hardware version of provider vDC where the VM locates.
*
* <pre>
* POST /vApp/{id}/action/upgradeHardwareVersion
* </pre>
*
* @since 1.5
*/
Task upgradeHardwareVersion(URI vAppURI);
/**
* Retrieves the control access information for a vApp.
* Retrieves the control access information for a {@link VApp}.
*
* The vApp could be shared to everyone or could be shared to specific user,
* by modifying the control access values.
@ -286,7 +227,7 @@ public interface VAppClient {
ControlAccessParams getControlAccess(URI vAppURI);
/**
* Powers off a vApp/VM.
* 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.
*
@ -299,7 +240,7 @@ public interface VAppClient {
Task powerOff(URI vAppURI);
/**
* Powers on a vApp/VM.
* Powers on a {@link VApp}.
*
* If the operation is used over a vApp then all VMs are powered on. This
* operation is allowed only when the vApp/VM is powered off.
@ -313,7 +254,7 @@ public interface VAppClient {
Task powerOn(URI vAppURI);
/**
* Reboots a vApp/VM.
* Reboots a {@link VApp}.
*
* The vApp/VM should be started in order to reboot it.
*
@ -326,7 +267,7 @@ public interface VAppClient {
Task reboot(URI vAppURI);
/**
* Resets a vApp/VM.
* Resets a {@link VApp}.
*
* If the operation is used over a vApp then all VMs are reset. This
* operation is allowed only when the vApp/VM is powered on.
@ -340,7 +281,7 @@ public interface VAppClient {
Task reset(URI vAppURI);
/**
* Shutdowns a vApp/VM.
* Shuts down a {@link VApp}.
*
* If the operation is used over a vApp then all VMs are shutdown. This
* operation is allowed only when the vApp/VM is powered on.
@ -354,7 +295,7 @@ public interface VAppClient {
Task shutdown(URI vAppURI);
/**
* Suspends a vApp/VM.
* Suspends a {@link VApp}.
*
* If the operation is used over a vApp then all VMs are suspended. This
* operation is allowed only when the vApp/VM is powered on.
@ -368,29 +309,7 @@ public interface VAppClient {
Task suspend(URI vAppURI);
/**
* Retrieves the guest customization section of a VM.
*
* <pre>
* GET /vApp/{id}/guestCustomizationSection
* </pre>
*
* @since 1.0
*/
GuestCustomizationSection getGuestCustomizationSection(URI vmURI);
/**
* Modifies the guest customization section of a VM.
*
* <pre>
* PUT /vApp/{id}/guestCustomizationSection
* </pre>
*
* @since 1.0
*/
Task modifyGuestCustomizationSection(URI vmURI, GuestCustomizationSection section);
/**
* Retrieves the lease settings section of a vApp or vApp template.
* Retrieves the lease settings section of a {@link VApp}.
*
* <pre>
* GET /vApp/{id}/leaseSettingsSection
@ -401,7 +320,7 @@ public interface VAppClient {
LeaseSettingsSection getLeaseSettingsSection(URI vAppURI);
/**
* Modifies the lease settings section of a vApp or vApp template.
* Modifies the lease settings section of a {@link VApp}.
*
* <pre>
* PUT /vApp/{id}/leaseSettingsSection
@ -412,29 +331,7 @@ public interface VAppClient {
Task modifyLeaseSettingsSection(URI vAppURI, LeaseSettingsSection section);
/**
* Ejects a media from a VM.
*
* <pre>
* PUT /vApp/{id}/media/action/ejectMedia
* </pre>
*
* @since 0.9
*/
Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* Inserts a media into a VM.
*
* <pre>
* PUT /vApp/{id}/media/action/insertMedia
* </pre>
*
* @since 0.9
*/
Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* Retrieves the network config section of a vApp or vApp template.
* Retrieves the network config section of a {@link VApp}.
*
* <pre>
* GET /vApp/{id}/networkConfigSection
@ -442,10 +339,10 @@ public interface VAppClient {
*
* @since 0.9
*/
NetworkConfigSection getNetworkConfigSection(URI vmURI);
NetworkConfigSection getNetworkConfigSection(URI vAppURI);
/**
* Modifies the network config section of a vApp.
* Modifies the network config section of a {@link VApp}.
*
* <pre>
* PUT /vApp/{id}/networkConfigSection
@ -453,32 +350,10 @@ public interface VAppClient {
*
* @since 0.9
*/
Task modifyNetworkConfigSection(URI vmURI, NetworkConfigSection section);
Task modifyNetworkConfigSection(URI vAppURI, NetworkConfigSection section);
/**
* Retrieves the network connection section of a VM.
*
* <pre>
* GET /vApp/{id}/networkConnectionSection
* </pre>
*
* @since 0.9
*/
NetworkConnectionSection getNetworkConnectionSection(URI vmURI);
/**
* Modifies the network connection section of a VM.
*
* <pre>
* PUT /vApp/{id}/networkConnectionSection
* </pre>
*
* @since 0.9
*/
Task modifyNetworkConnectionSection(URI vmURI, NetworkConnectionSection section);
/**
* Retrieves the network section of a vApp or vApp template.
* Retrieves the network section of a {@link VApp}.
*
* <pre>
* GET /vApp/{id}/networkSection
@ -489,29 +364,7 @@ public interface VAppClient {
NetworkSection getNetworkSection(URI vAppURI);
/**
* Retrieves the operating system section of a VM.
*
* <pre>
* GET /vApp/{id}/operatingSystemSection
* </pre>
*
* @since 0.9
*/
OperatingSystemSection getOperatingSystemSection(URI vmURI);
/**
* Modifies the operating system section of a VM.
*
* <pre>
* PUT /vApp/{id}/operatingSystemSection
* </pre>
*
* @since 0.9
*/
Task modifyOperatingSystemSection(URI vmURI, OperatingSystemSection section);
/**
* Retrieves the owner of a vApp.
* Retrieves the owner of a {@link VApp}.
*
* <pre>
* GET /vApp/{id}/owner
@ -522,7 +375,7 @@ public interface VAppClient {
Owner getOwner(URI vAppURI);
/**
* Changes VApp owner.
* Changes {@link VApp} owner.
*
* <pre>
* PUT /vApp/{id}/owner
@ -533,7 +386,7 @@ public interface VAppClient {
void modifyOwner(URI vAppURI, Owner owner);
/**
* Retrieves VAppTemplate/VM product sections.
* Retrieves {@link VApp} product sections.
*
* <pre>
* GET /vApp/{id}/productSections
@ -544,7 +397,7 @@ public interface VAppClient {
ProductSectionList getProductSections(URI vAppURI);
/**
* Modifies the product section information of a vApp/VM.
* Modifies the product section information of a {@link VApp}.
*
* <pre>
* PUT /vApp/{id}/productSections
@ -555,74 +408,7 @@ public interface VAppClient {
Task modifyProductSections(URI vAppURI, ProductSectionList sectionList);
/**
* Retrieves a pending question for a VM.
*
* The user should answer to the question by operation {@link #answerQuestion(URI, VmQuestionAnswer)}.
* Usually questions will be asked when the VM is powering on.
*
* <pre>
* GET /vApp/{id}/question
* </pre>
*
* @since 0.9
*/
VmPendingQuestion getPendingQuestion(URI vAppURI);
/**
* Answer on a pending question.
*
* The answer IDs of choice and question should match the ones returned from operation {@link #getPendingQuestion(URI)}.
*
* <pre>
* POST /vApp/{id}/question/action/answer
* </pre>
*
* @since 0.9
*/
void answerQuestion(URI vAppURI, VmQuestionAnswer answer);
/**
* Retrieves the runtime info section of a VM.
*
* <pre>
* GET /vApp/{id}/runtimeInfoSection
* </pre>
*
* @since 1.5
*/
RuntimeInfoSection getRuntimeInfoSection(URI vmURI);
/**
* Retrieves the thumbnail of the screen of a VM.
*
* The content type of the response may vary (e.g. {@code image/png}, {@code image/gif}).
*
* <pre>
* GET /vApp/{id}/screen
* </pre>
*
* @since 0.9
*/
byte[] getScreenImage(URI vAppURI);
/**
* Retrieve a screen ticket for remote console connection to a VM.
*
* A screen ticket is a string that includes the virtual machine's IP address, its managed object reference, and a string
* that has been encoded as described in RFC 2396. Each VM element in a vApp includes a link where rel="screen:acquireTicket".
* You can use that link to request a 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>
* GET /vApp/{id}/screen/action/acquireTicket
* </pre>
*
* @since 0.9
*/
ScreenTicket getScreenTicket(URI vAppURI);
/**
* Retrieves the startup section of a VApp.
* Retrieves the startup section of a {@link VApp}.
*
* <pre>
* GET /vApp/{id}/startupSection
@ -633,7 +419,7 @@ public interface VAppClient {
StartupSection getStartupSection(URI vAppURI);
/**
* Modifies the startup section of a VApp.
* Modifies the startup section of a {@link VApp}.
*
* <pre>
* PUT /vApp/{id}/startupSection
@ -644,150 +430,7 @@ public interface VAppClient {
Task modifyStartupSection(URI vAppURI, StartupSection section);
/**
* Retrieves the virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection
* </pre>
*
* @since 0.9
*/
VirtualHardwareSection getVirtualHardwareSection(URI vmURI);
/**
* Modifies the virtual hardware section of a VM.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSection(URI vmURI, VirtualHardwareSection section);
/**
* Retrieves the CPU properties in virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/cpu
* </pre>
*
* @since 0.9
*/
RasdItem getVirtualHardwareSectionCpu(URI vmURI);
/**
* Modifies the CPU properties in virtual hardware section of a VM.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/cpu
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd);
/**
* Retrieves a list of ResourceAllocationSettingData items for disks from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/disks
* </pre>
*
* @since 0.9
*/
RasdItemsList getVirtualHardwareSectionDisks(URI vmURI);
/**
* Modifies the disks list in virtual hardware section of a VM.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/disks
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionDisks(URI vmURI, RasdItemsList rasdItemsList);
/**
* Retrieves the list of ResourceAllocationSettingData items that represents the floppies and CD/DVD drives in a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/media
* </pre>
*
* @since 0.9
*/
RasdItemsList getVirtualHardwareSectionMedia(URI vmURI);
/**
* Retrieves the ResourceAllocationSettingData item that contains memory information from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/memory
* </pre>
*
* @since 0.9
*/
RasdItem getVirtualHardwareSectionMemory(URI vmURI);
/**
* Modifies the memory properties in virtual hardware section of a VM.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/memory
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionMemory(URI vmURI, RasdItem rasd);
/**
* Retrieves a list of ResourceAllocationSettingData items for network cards from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/networkCards
* </pre>
*
* @since 0.9
*/
RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI);
/**
* Modifies the network cards list in virtual hardware section of a VM.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/networkCards
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionNetworkCards(URI vmURI, RasdItemsList rasdItemsList);
/**
* Retrieves a list of ResourceAllocationSettingData items for serial ports from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/serialPorts
* </pre>
*
* @since 1.5
*/
RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI);
/**
* Modifies the serial ports list in virtual hardware section of a VM.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/serialPorts
* </pre>
*
* @since 1.5
*/
Task modifyVirtualHardwareSectionSerialPorts(URI vmURI, RasdItemsList rasdItemsList);
/**
* @return synchronous access to {@link Metadata} features
* Synchronous access to {@link VApp} {@link Metadata} features.
*/
@Delegate
MetadataClient.Writeable getMetadataClient();

View File

@ -0,0 +1,533 @@
/*
* 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.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ANY_IMAGE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.DEPLOY_VAPP_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.MEDIA_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OPERATING_SYSTEM_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OVF_RASD_ITEM;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.PRODUCT_SECTION_LIST;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_VM_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VIRTUAL_HARDWARE_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VM;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VM_PENDING_ANSWER;
import java.net.URI;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
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.ScreenTicket;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
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.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @author grkvlt@apache.org
* @see VmClient
*/
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface VmAsyncClient {
/**
* @see VmClient#getVm(URI)
*/
@GET
@Consumes(VM)
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Vm> getVm(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVm(URI, Vm)
*/
@PUT
@Produces(VM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVm(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) Vm vApp);
/**
* @see VmClient#deleteVm(URI)
*/
@DELETE
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> deleteVm(@EndpointParam URI vmURI);
/**
* @see VmClient#consolidateVm(URI)
*/
@POST
@Path("/action/consolidate")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> consolidateVm(@EndpointParam URI vmURI);
/**
* @see VmClient#deploy(URI, DeployVAppParams)
*/
@POST
@Path("/action/deploy")
@Produces(DEPLOY_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> deploy(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) DeployVAppParams params);
/**
* @see VmClient#discardSuspendedState(URI)
*/
@POST
@Path("/action/discardSuspendedState")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> discardSuspendedState(@EndpointParam URI vmURI);
/**
* @see VmClient#installVMwareTools(URI)
*/
@POST
@Path("/action/installVMwareTools")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> installVMwareTools(@EndpointParam URI vmURI);
/**
* @see VmClient#relocateVm(URI, RelocateParams)
*/
@POST
@Path("/action/relocate")
@Produces(RELOCATE_VM_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> relocateVm(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RelocateParams params);
/**
* @see VmClient#undeploy(URI, UndeployVAppParams)
*/
@POST
@Path("/action/undeploy")
@Produces(UNDEPLOY_VAPP_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> undeploy(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) UndeployVAppParams params);
/**
* @see VmClient#upgradeHardwareVersion(URI)
*/
@POST
@Path("/action/upgradeHardwareVersion")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> upgradeHardwareVersion(@EndpointParam URI vmURI);
/**
* @see VmClient#powerOff(URI)
*/
@POST
@Path("/power/action/powerOff")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> powerOff(@EndpointParam URI vmURI);
/**
* @see VmClient#powerOn(URI)
*/
@POST
@Path("/power/action/powerOn")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> powerOn(@EndpointParam URI vmURI);
/**
* @see VmClient#reboot(URI)
*/
@POST
@Path("/power/action/powerOff")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> reboot(@EndpointParam URI vmURI);
/**
* @see VmClient#reset(URI)
*/
@POST
@Path("/power/action/reset")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> reset(@EndpointParam URI vmURI);
/**
* @see VmClient#shutdown(URI)
*/
@POST
@Path("/power/action/shutdown")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> shutdown(@EndpointParam URI vmURI);
/**
* @see VmClient#suspend(URI)
*/
@POST
@Path("/power/action/suspend")
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> suspend(@EndpointParam URI vmURI);
/**
* @see VmClient#getGuestCustomizationSection(URI)
*/
@GET
@Path("/guestCustomizationSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<GuestCustomizationSection> getGuestCustomizationSection(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyGuestCustomizationSection(URI, GuestCustomizationSection)
*/
@PUT
@Path("/guestCustomizationSection")
@Produces(GUEST_CUSTOMIZATION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyGuestCustomizationSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) GuestCustomizationSection section);
/**
* @see VmClient#ejectMedia(URI, MediaInsertOrEjectParams)
*/
@POST
@Path("/media/action/ejectMedia")
@Produces(MEDIA_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> ejectMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @see VmClient#insertMedia(URI, MediaInsertOrEjectParams)
*/
@POST
@Path("/media/action/insertMedia")
@Produces(MEDIA_PARAMS)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> insertMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @see VmClient#getNetworkConnectionSection(URI)
*/
@GET
@Path("/networkConnectionSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyNetworkConnectionSection(URI, NetworkConnectionSection)
*/
@PUT
@Path("/networkConnectionSection")
@Produces(NETWORK_CONNECTION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyNetworkConnectionSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) NetworkConnectionSection section);
/**
* @see VmClient#getOperatingSystemSection(URI)
*/
@GET
@Path("/operatingSystemSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<OperatingSystemSection> getOperatingSystemSection(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyOperatingSystemSection(URI, OperatingSystemSection)
*/
@PUT
@Path("/operatingSystemSection")
@Produces(OPERATING_SYSTEM_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyOperatingSystemSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) OperatingSystemSection section);
/**
* @see VmClient#getProductSections(URI)
*/
@GET
@Path("/productSections")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ProductSectionList> getProductSections(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyProductSections(URI, ProductSectionList)
*/
@PUT
@Path("/productSections")
@Produces(PRODUCT_SECTION_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyProductSections(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) ProductSectionList sectionList);
/**
* @see VmClient#getPendingQuestion(URI)
*/
@GET
@Path("/question")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VmPendingQuestion> getPendingQuestion(@EndpointParam URI vmURI);
/**
* @see VmClient#answerQuestion(URI, VmQuestionAnswer)
*/
@POST
@Path("/question/action/answer")
@Produces(VM_PENDING_ANSWER)
@Consumes
@JAXBResponseParser
ListenableFuture<Void> answerQuestion(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer);
/**
* @see VmClient#getRuntimeInfoSection(URI)
*/
@GET
@Path("/runtimeInfoSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RuntimeInfoSection> getRuntimeInfoSection(@EndpointParam URI vmURI);
/**
* @see VmClient#getScreenImage(URI)
*/
@GET
@Path("/screen")
@Consumes(ANY_IMAGE)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(ReturnPayloadBytes.class)
ListenableFuture<byte[]> getScreenImage(@EndpointParam URI vmURI);
/**
* @see VmClient#getScreenTicket(URI)
*/
@POST
@Path("/screen/action/acquireTicket")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ScreenTicket> getScreenTicket(@EndpointParam URI vmURI);
/**
* @see VmClient#getVirtualHardwareSection(URI)
*/
@GET
@Path("/virtualHardwareSection")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VirtualHardwareSection> getVirtualHardwareSection(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVirtualHardwareSection(URI, VirtualHardwareSection)
*/
@PUT
@Path("/virtualHardwareSection")
@Produces(VIRTUAL_HARDWARE_SECTION)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) VirtualHardwareSection section);
/**
* @see VmClient#getVirtualHardwareSectionCpu(URI)
*/
@GET
@Path("/virtualHardwareSection/cpu")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionCpu(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/cpu")
@Produces(OVF_RASD_ITEM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionCpu(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItem rasd);
/**
* @see VmClient#getVirtualHardwareSectionDisks(URI)
*/
@GET
@Path("/virtualHardwareSection/disks")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVirtualHardwareSectionDisks(URI, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/disks")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionDisks(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @see VmClient#getVirtualHardwareSectionMedia(URI)
*/
@GET
@Path("/virtualHardwareSection/media")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(@EndpointParam URI vmURI);
/**
* @see VmClient#getVirtualHardwareSectionMemory(URI)
*/
@GET
@Path("/virtualHardwareSection/memory")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItem> getVirtualHardwareSectionMemory(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/memory")
@Produces(OVF_RASD_ITEM)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionMemory(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItem rasd);
/**
* @see VmClient#getVirtualHardwareSectionNetworkCards(URI)
*/
@GET
@Path("/virtualHardwareSection/networkCards")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVirtualHardwareSectionNetworkCards(URI, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/networkCards")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @see VmClient#getVirtualHardwareSectionSerialPorts(URI)
*/
@GET
@Path("/virtualHardwareSection/serialPorts")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI);
/**
* @see VmClient#modifyVirtualHardwareSectionSerialPorts(URI, RasdItemsList)
*/
@PUT
@Path("/virtualHardwareSection/serialPorts")
@Produces(OVF_RASD_ITEMS_LIST)
@Consumes(TASK)
@JAXBResponseParser
ListenableFuture<Task> modifyVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* Asynchronous access to {@Vm} {@link Metadata} features.
*/
@Delegate
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -0,0 +1,517 @@
/*
* 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.features;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
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.ScreenTicket;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
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.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
/**
* Provides synchronous access to {@link Vm} objects.
*
* @author grkvlt@apache.org
* @see VmAsyncClient
* @version 1.5
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface VmClient {
/**
* Retrieves a {@link Vm}.
*
* @since 0.9
* @see VAppClient#getVApp(URI)
*/
Vm getVm(URI vmURI);
/**
* Modifies the name/description of a {@link Vm}.
*
* @since 0.9
* @see VAppClient#modifyVApp(URI, VApp)
*/
Task modifyVm(URI vmURI, Vm vm);
/**
* Deletes a {@link Vm}.
*
* @since 0.9
* @see VAppClient#deleteVApp(URI)
*/
Task deleteVm(URI vmURI);
/**
* Consolidates a {@link Vm}.
*
* <pre>
* POST /vApp/{id}/action/consolidate
* </pre>
*
* @since 1.5
*/
Task consolidateVm(URI vmURI);
/**
* Deploys a {@link Vm}.
*
* @since 0.9
* @see VAppClient#deploy(URI, DeployVAppParams)
*/
Task deploy(URI vmURI, DeployVAppParams params);
/**
* Discard suspended state of a {@link Vm}.
*
* @since 0.9
* @see VAppClient#discardSuspendedState(URI)
*/
Task discardSuspendedState(URI vmURI);
/**
* Installs VMware tools to the virtual machine.
*
* It should be running in order for them to be installed.
*
* <pre>
* POST /vApp/{id}/action/installVMwareTools
* </pre>
*
* @since 1.5
*/
Task installVMwareTools(URI vmURI);
/**
* Relocates a {@link Vm}.
*
* <pre>
* POST /vApp/{id}/action/relocate
* </pre>
*
* @since 1.5
*/
Task relocateVm(URI vmURI, RelocateParams params);
/**
* Undeploy a {@link Vm}.
*
* @since 0.9
* @see VAppClient#undeploy(URI, UndeployVAppParams)
*/
Task undeploy(URI vmURI, UndeployVAppParams params);
/**
* Upgrade virtual hardware version of a VM to the highest supported virtual
* hardware version of provider vDC where the VM locates.
*
* <pre>
* POST /vApp/{id}/action/upgradeHardwareVersion
* </pre>
*
* @since 1.5
*/
Task upgradeHardwareVersion(URI vmURI);
/**
* Powers off a {@link Vm}.
*
* @since 0.9
* @see VAppClient#powerOff(URI)
*/
Task powerOff(URI vmURI);
/**
* Powers on a {@link Vm}.
*
* @since 0.9
* @see VAppClient#powerOn(URI)
*/
Task powerOn(URI vmURI);
/**
* Reboots a {@link Vm}.
*
* @since 0.9
* @see VAppClient#reboot(URI)
*/
Task reboot(URI vmURI);
/**
* Resets a {@link Vm}.
*
* @since 0.9
* @see VAppClient#reset(URI)
*/
Task reset(URI vmURI);
/**
* Shuts down a {@link Vm}.
*
* @since 0.9
* @see VAppClient#shutdown(URI)
*/
Task shutdown(URI vmURI);
/**
* Suspends a {@link Vm}.
*
* @since 0.9
* @see VAppClient#suspend(URI)
*/
Task suspend(URI vmURI);
/**
* Retrieves the guest customization section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/guestCustomizationSection
* </pre>
*
* @since 1.0
* @see VAppClient#
*/
GuestCustomizationSection getGuestCustomizationSection(URI vmURI);
/**
* Modifies the guest customization section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/guestCustomizationSection
* </pre>
*
* @since 1.0
*/
Task modifyGuestCustomizationSection(URI vmURI, GuestCustomizationSection section);
/**
* Ejects media from a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/media/action/ejectMedia
* </pre>
*
* @since 0.9
*/
Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* Insert media into a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/media/action/insertMedia
* </pre>
*
* @since 0.9
*/
Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* Retrieves the network connection section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/networkConnectionSection
* </pre>
*
* @since 0.9
*/
NetworkConnectionSection getNetworkConnectionSection(URI vmURI);
/**
* Modifies the network connection section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/networkConnectionSection
* </pre>
*
* @since 0.9
*/
Task modifyNetworkConnectionSection(URI vmURI, NetworkConnectionSection section);
/**
* Retrieves the operating system section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/operatingSystemSection
* </pre>
*
* @since 0.9
*/
OperatingSystemSection getOperatingSystemSection(URI vmURI);
/**
* Modifies the operating system section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/operatingSystemSection
* </pre>
*
* @since 0.9
*/
Task modifyOperatingSystemSection(URI vmURI, OperatingSystemSection section);
/**
* Retrieves {@link Vm} product sections.
*
* @since 1.5
* @see VAppClient#getProductSections(URI)
*/
ProductSectionList getProductSections(URI vmURI);
/**
* Modifies the product section information of a {@link Vm}.
*
* @since 1.5
* @see VAppClient#modifyProductSections(URI, ProductSectionList)
*/
Task modifyProductSections(URI vmURI, ProductSectionList sectionList);
/**
* Retrieves a pending question for a {@link Vm}.
*
* The user should answer to the question by operation {@link #answerQuestion(URI, VmQuestionAnswer)}.
* Usually questions will be asked when the VM is powering on.
*
* <pre>
* GET /vApp/{id}/question
* </pre>
*
* @since 0.9
*/
VmPendingQuestion getPendingQuestion(URI vmURI);
/**
* 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)}.
*
* <pre>
* POST /vApp/{id}/question/action/answer
* </pre>
*
* @since 0.9
*/
void answerQuestion(URI vmURI, VmQuestionAnswer answer);
/**
* Retrieves the runtime info section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/runtimeInfoSection
* </pre>
*
* @since 1.5
*/
RuntimeInfoSection getRuntimeInfoSection(URI vmURI);
/**
* Retrieves the thumbnail of the screen of a {@link Vm}.
*
* The content type of the response may vary (e.g. {@code image/png}, {@code image/gif}).
*
* <pre>
* GET /vApp/{id}/screen
* </pre>
*
* @since 0.9
*/
byte[] getScreenImage(URI vmURI);
/**
* 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
* that has been encoded as described in RFC 2396. Each VM element in a vApp includes a link where rel="screen:acquireTicket".
* You can use that link to request a 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>
* GET /vApp/{id}/screen/action/acquireTicket
* </pre>
*
* @since 0.9
*/
ScreenTicket getScreenTicket(URI vmURI);
/**
* Retrieves the virtual hardware section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection
* </pre>
*
* @since 0.9
*/
VirtualHardwareSection getVirtualHardwareSection(URI vmURI);
/**
* Modifies the virtual hardware section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSection(URI vmURI, VirtualHardwareSection section);
/**
* Retrieves the CPU properties in virtual hardware section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/cpu
* </pre>
*
* @since 0.9
*/
RasdItem getVirtualHardwareSectionCpu(URI vmURI);
/**
* Modifies the CPU properties in virtual hardware section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/cpu
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd);
/**
* Retrieves a list of items for disks from virtual hardware section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/disks
* </pre>
*
* @since 0.9
*/
RasdItemsList getVirtualHardwareSectionDisks(URI vmURI);
/**
* Modifies the disks list in virtual hardware section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/disks
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionDisks(URI vmURI, RasdItemsList rasdItemsList);
/**
* Retrieves the list of items that represents the floppies and CD/DVD drives in a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/media
* </pre>
*
* @since 0.9
*/
RasdItemsList getVirtualHardwareSectionMedia(URI vmURI);
/**
* Retrieves the item that contains memory information from virtual hardware section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/memory
* </pre>
*
* @since 0.9
*/
RasdItem getVirtualHardwareSectionMemory(URI vmURI);
/**
* Modifies the memory properties in virtual hardware section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/memory
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionMemory(URI vmURI, RasdItem rasd);
/**
* Retrieves a list of items for network cards from virtual hardware section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/networkCards
* </pre>
*
* @since 0.9
*/
RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI);
/**
* Modifies the network cards list in virtual hardware section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/networkCards
* </pre>
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionNetworkCards(URI vmURI, RasdItemsList rasdItemsList);
/**
* Retrieves a list of items for serial ports from virtual hardware section of a {@link Vm}.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/serialPorts
* </pre>
*
* @since 1.5
*/
RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI);
/**
* Modifies the serial ports list in virtual hardware section of a {@link Vm}.
*
* <pre>
* PUT /vApp/{id}/virtualHardwareSection/serialPorts
* </pre>
*
* @since 1.5
*/
Task modifyVirtualHardwareSectionSerialPorts(URI vmURI, RasdItemsList rasdItemsList);
/**
* Synchronous access to {@link Vm} {@link Metadata} features.
*/
@Delegate
MetadataClient.Writeable getMetadataClient();
}

View File

@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VAppAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VmAsyncClient;
import com.google.inject.Provides;
@ -105,4 +106,10 @@ public interface VCloudDirectorAsyncClient {
*/
@Delegate
VAppTemplateAsyncClient getVAppTemplateClient();
/**
* @return asynchronous access to {@link Vm} features
*/
@Delegate
VmAsyncClient getVmClient();
}

View File

@ -33,6 +33,7 @@ import org.jclouds.vcloud.director.v1_5.features.UploadClient;
import org.jclouds.vcloud.director.v1_5.features.VAppClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient;
import org.jclouds.vcloud.director.v1_5.features.VdcClient;
import org.jclouds.vcloud.director.v1_5.features.VmClient;
import com.google.inject.Provides;
@ -109,4 +110,10 @@ public interface VCloudDirectorClient {
*/
@Delegate
VAppTemplateClient getVAppTemplateClient();
/**
* @return synchronous access to {@link Vm} features
*/
@Delegate
VmClient getVmClient();
}

View File

@ -37,23 +37,25 @@ import org.jclouds.dmtf.cim.CimBoolean;
import org.jclouds.dmtf.cim.CimString;
import org.jclouds.dmtf.cim.CimUnsignedInt;
import org.jclouds.dmtf.cim.CimUnsignedLong;
import org.jclouds.vcloud.director.v1_5.domain.AbstractVAppType;
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
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.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
import org.jclouds.vcloud.director.v1_5.features.MetadataClient;
import org.jclouds.vcloud.director.v1_5.features.QueryClient;
import org.jclouds.vcloud.director.v1_5.features.VAppClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient;
import org.jclouds.vcloud.director.v1_5.features.VdcClient;
import org.jclouds.vcloud.director.v1_5.features.VmClient;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
import org.jclouds.xml.internal.JAXBParser;
@ -76,9 +78,10 @@ import com.google.common.collect.Iterables;
*/
public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String VAPP = "vApp";
public static final String VAPP_TEMPLATE = "vAppTemplate";
public static final String VDC = "vdc";
public static final String VAPP = "VApp";
public static final String VAPP_TEMPLATE = "VAppTemplate";
public static final String VDC = "Vdc";
public static final String VM = "Vm";
/*
* Convenience reference to API clients.
@ -89,6 +92,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
protected VAppClient vAppClient;
protected VAppTemplateClient vAppTemplateClient;
protected VdcClient vdcClient;
protected VmClient vmClient;
protected MetadataClient.Writeable metadataClient;
/*
@ -97,9 +101,10 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
protected Vdc vdc;
protected Vm vm;
protected URI vAppURI;
protected VApp vApp;
protected VAppTemplate vAppTemplate;
protected URI vmURI;
protected URI vAppURI;
/**
* Retrieves the required clients from the REST API context
@ -116,6 +121,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
vAppClient = context.getApi().getVAppClient();
vAppTemplateClient = context.getApi().getVAppTemplateClient();
vdcClient = context.getApi().getVdcClient();
vmClient = context.getApi().getVmClient();
setupEnvironment();
}
@ -148,6 +154,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
// Get the Vm
List<Vm> vms = vApp.getChildren().getVms();
vm = Iterables.getOnlyElement(vms);
vmURI = vm.getHref();
assertFalse(vms.isEmpty(), "The VApp must have a Vm");
}
@ -182,8 +189,9 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
}
@AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps")
protected void cleanUp() {
protected void cleanUpEnvironment() {
vdc = vdcClient.getVdc(vdcURI); // Refresh
// Find references in the Vdc with the VApp type and in the list of instantiated VApp names
Iterable<Reference> vApps = Iterables.filter(vdc.getResourceEntities(),
Predicates.and(ReferencePredicates.<Reference> typeEquals(VCloudDirectorMediaType.VAPP), ReferencePredicates.<Reference> nameIn(vAppNames)));
@ -237,84 +245,116 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
}
/**
* Power on a {@link VApp}s {@link Vm}s.
*
* @see #powerOn(URI)
* Power on a {@link VApp}.
*/
protected VApp powerOn(final VApp testVApp) {
return powerOn(testVApp.getHref());
}
/**
* Power on a {@link VApp}s {@link Vm}s.
*/
protected VApp powerOn(final URI testVAppURI) {
VApp testVApp = vAppClient.getVApp(testVAppURI);
Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms());
Status status = vm.getStatus();
protected VApp powerOnVApp(final URI testVAppURI) {
VApp test = vAppClient.getVApp(testVAppURI);
Status status = test.getStatus();
if (status != Status.POWERED_ON) {
Task powerOn = vAppClient.powerOn(vm.getHref());
assertTaskSucceedsLong(powerOn);
}
assertVAppStatus(testVAppURI, Status.POWERED_ON);
return testVApp;
test = vAppClient.getVApp(testVAppURI);
assertStatus(VAPP, test, Status.POWERED_ON);
return test;
}
/**
* Power off a {@link VApp}s {@link Vm}s.
*
* @see #powerOff(URI)
* Power on a {@link Vm}.
*/
protected VApp powerOff(final VApp testVApp) {
return powerOff(testVApp.getHref());
protected Vm powerOnVm(final URI testVmURI) {
Vm test = vmClient.getVm(testVmURI);
Status status = test.getStatus();
if (status != Status.POWERED_ON) {
Task powerOn = vmClient.powerOn(vm.getHref());
assertTaskSucceedsLong(powerOn);
}
test = vmClient.getVm(testVmURI);
assertStatus(VM, test, Status.POWERED_ON);
return test;
}
/**
* Power off a {@link VApp}s {@link Vm}s.
* Power off a {@link VApp}.
*/
protected VApp powerOff(final URI testVAppURI) {
VApp testVApp = vAppClient.getVApp(testVAppURI);
Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms());
Status status = vm.getStatus();
protected VApp powerOffVApp(final URI testVAppURI) {
VApp test = vAppClient.getVApp(testVAppURI);
Status status = test.getStatus();
if (status != Status.POWERED_OFF) {
Task powerOff = vAppClient.powerOff(vm.getHref());
assertTaskSucceedsLong(powerOff);
}
assertVAppStatus(testVAppURI, Status.POWERED_OFF);
return testVApp;
test = vAppClient.getVApp(testVAppURI);
assertStatus(VAPP, test, Status.POWERED_OFF);
return test;
}
/**
* Suspend a {@link VApp}s {@link Vm}s.
*
* @see #suspend(URI)
* Power off a {@link Vm}.
*/
protected VApp suspend(final VApp testVApp) {
return powerOff(testVApp.getHref());
protected Vm powerOffVm(final URI testVmURI) {
Vm test = vmClient.getVm(testVmURI);
Status status = test.getStatus();
if (status != Status.POWERED_OFF) {
Task powerOff = vmClient.powerOff(vm.getHref());
assertTaskSucceedsLong(powerOff);
}
test = vmClient.getVm(testVmURI);
assertStatus(VM, test, Status.POWERED_OFF);
return test;
}
/**
* Suspend a {@link VApp}s {@link Vm}s.
* Suspend a {@link VApp}.
*/
protected VApp suspend(final URI testVAppURI) {
VApp testVApp = vAppClient.getVApp(testVAppURI);
Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms());
Status status = vm.getStatus();
protected VApp suspendVApp(final URI testVAppURI) {
VApp test = vAppClient.getVApp(testVAppURI);
Status status = test.getStatus();
if (status != Status.SUSPENDED) {
Task suspend = vAppClient.suspend(vm.getHref());
assertTaskSucceedsLong(suspend);
}
assertVAppStatus(testVAppURI, Status.SUSPENDED);
return testVApp;
test = vAppClient.getVApp(testVAppURI);
assertStatus(VAPP, test, Status.SUSPENDED);
return test;
}
/**
* Check the {@link VApp}s {@link Vm}s current status.
* Suspend a {@link Vm}.
*/
protected Vm suspendVm(final URI testVmURI) {
Vm test = vmClient.getVm(testVmURI);
Status status = test.getStatus();
if (status != Status.SUSPENDED) {
Task suspend = vmClient.suspend(vm.getHref());
assertTaskSucceedsLong(suspend);
}
test = vmClient.getVm(testVmURI);
assertStatus(VM, test, Status.SUSPENDED);
return test;
}
/**
* Check the {@link VApp}s current status.
*/
protected void assertVAppStatus(final URI testVAppURI, final Status status) {
VApp testVApp = vAppClient.getVApp(testVAppURI);
Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms());
assertEquals(vm.getStatus(), status, String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), vm.getStatus().toString()));
assertStatus(VAPP, testVApp, status);
}
/**
* Check the {@link Vm}s current status.
*/
protected void assertVmStatus(final URI testVmURI, final Status status) {
Vm testVm = vmClient.getVm(testVmURI);
assertStatus(VM, testVm, status);
}
/**
* Check a {@link VApp} or {@link Vm}s status.
*/
protected static void assertStatus(final String type, final AbstractVAppType testVApp, final Status status) {
assertEquals(testVApp.getStatus(), status, String.format(OBJ_FIELD_EQ, type, "status", status.toString(), testVApp.getStatus().toString()));
}
/**

View File

@ -39,9 +39,7 @@ import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection;
@ -56,9 +54,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.internal.annotations.Sets;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimaps;
/**
* Allows us to test the {@link VAppClient} via its side effects.
*
@ -127,22 +122,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().deleteVApp(vAppURI), expected);
}
@Test(enabled = false)
public void testConsolidateVApp() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", vAppId + "/action/consolidate")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/consolidateVAppTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Task expected = consolidateVAppTask();
assertEquals(client.getVAppClient().consolidateVm(vAppURI), expected);
}
@Test(enabled = false)
public void testControlAccess() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -226,22 +205,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
client.getVAppClient().exitMaintenanceMode(vAppURI);
}
@Test(enabled = false)
public void testInstallVMwareTools() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", vAppId + "/action/installVMwareTools")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/installVMwareToolsTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Task expected = installVMwareToolsTask();
assertEquals(client.getVAppClient().installVMwareTools(vAppURI), expected);
}
@Test(enabled = false)
public void testRecomposeVApp() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -262,26 +225,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().recompose(vAppURI, params), expected);
}
@Test(enabled = false)
public void testRelocate() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", vAppId + "/action/relocate")
.xmlFilePayload("/vApp/relocateParams.xml", VCloudDirectorMediaType.RELOCATE_VM_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/relocateTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RelocateParams params = RelocateParams.builder()
.build();
Task expected = relocateTask();
assertEquals(client.getVAppClient().relocateVm(vAppURI, params), expected);
}
@Test(enabled = false)
public void testUndeploy() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -302,22 +245,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().undeploy(vAppURI, params), expected);
}
@Test(enabled = false)
public void testUpgradeHardwareVersion() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", vAppId + "/action/upgradeHardwareVersion")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/upgradeHardwareVersionTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Task expected = upgradeHardwareVersionTask();
assertEquals(client.getVAppClient().upgradeHardwareVersion(vAppURI), expected);
}
@Test(enabled = false)
public void testPowerOff() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -430,42 +357,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().getControlAccess(vAppURI), expected);
}
@Test(enabled = false)
public void testGetGuestCustomizationSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/guestCustomizationSection")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getGuestCustomizationSection.xml", VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION)
.httpResponseBuilder().build());
GuestCustomizationSection expected = getGuestCustomizationSection();
assertEquals(client.getVAppClient().getGuestCustomizationSection(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyGuestCustomizationSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/guestCustomizationSection")
.xmlFilePayload("/vApp/modifyGuestCustomizationSection.xml", VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyGuestCustomizationSectionTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
GuestCustomizationSection section = getGuestCustomizationSection().toBuilder()
.build();
Task expected = modifyGuestCustomizationSectionTask();
assertEquals(client.getVAppClient().modifyGuestCustomizationSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testGetLeaseSettingsSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -502,46 +393,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().modifyLeaseSettingsSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testEjectMedia() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/media/action/ejectMedia")
.xmlFilePayload("/vApp/ejectMediaParams.xml", VCloudDirectorMediaType.MEDIA_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/ejectMediaTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
MediaInsertOrEjectParams params = MediaInsertOrEjectParams.builder()
.build();
Task expected = ejectMediaTask();
assertEquals(client.getVAppClient().ejectMedia(vAppURI, params), expected);
}
@Test(enabled = false)
public void testInsertMedia() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/media/action/insertMedia")
.xmlFilePayload("/vApp/insertMediaParams.xml", VCloudDirectorMediaType.MEDIA_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/insertMediaTask.xml", VCloudDirectorMediaType.VAPP)
.httpResponseBuilder().build());
MediaInsertOrEjectParams params = MediaInsertOrEjectParams.builder()
.build();
Task expected = insertMediaTask();
assertEquals(client.getVAppClient().insertMedia(vAppURI, params), expected);
}
@Test(enabled = false)
public void testGetNetworkConfigSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -578,42 +429,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().modifyNetworkConfigSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testGetNetworkConnectionSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/networkConnectionSection")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getNetworkConnectionSection.xml", VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION)
.httpResponseBuilder().build());
NetworkConnectionSection expected = getNetworkConnectionSection();
assertEquals(client.getVAppClient().getNetworkConnectionSection(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyNetworkConnectionSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/networkConnectionSection")
.xmlFilePayload("/vApp/modifyNetworkConnectionSection.xml", VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyNetworkConnectionSectionTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
NetworkConnectionSection section = getNetworkConnectionSection().toBuilder()
.build();
Task expected = modifyNetworkConnectionSectionTask();
assertEquals(client.getVAppClient().modifyNetworkConnectionSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testGetNetworkSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -630,42 +445,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().getNetworkSection(vAppURI), expected);
}
@Test(enabled = false)
public void testGetOperatingSystemSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/operatingSystemSection")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getOperatingSystemSection.xml", VCloudDirectorMediaType.OPERATING_SYSTEM_SECTION)
.httpResponseBuilder().build());
OperatingSystemSection expected = getOperatingSystemSection();
assertEquals(client.getVAppClient().getOperatingSystemSection(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyOperatingSystemSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/operatingSystemSection")
.xmlFilePayload("/vApp/modifyOperatingSystemSection.xml", VCloudDirectorMediaType.OPERATING_SYSTEM_SECTION)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyOperatingSystemSectionTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
OperatingSystemSection section = getOperatingSystemSection().toBuilder()
.build();
Task expected = modifyOperatingSystemSectionTask();
assertEquals(client.getVAppClient().modifyOperatingSystemSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testGetOwner() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -732,89 +511,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().modifyProductSections(vAppURI, null), expected);
}
@Test(enabled = false)
public void testGetPendingQuestion() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/question")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getPendingQuestion.xml", VCloudDirectorMediaType.VM_PENDING_QUESTION)
.httpResponseBuilder().build());
VmPendingQuestion expected = getPendingQuestion();
assertEquals(client.getVAppClient().getPendingQuestion(vAppURI), expected);
}
@Test(enabled = false)
public void testAnswerQuestion() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/question/action/answer")
.xmlFilePayload("/vApp/answerQuestion.xml", VCloudDirectorMediaType.VM_PENDING_ANSWER)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.httpResponseBuilder().statusCode(204).build());
VmQuestionAnswer answer = null; // = VmQuestionAnswer.builder();
// .build;
client.getVAppClient().answerQuestion(vAppURI, answer);
}
@Test(enabled = false)
public void testGetRuntimeInfoSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/runtimeInfoSection")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getRuntimeInfoSection.xml", VCloudDirectorMediaType.RUNTIME_INFO_SECTION)
.httpResponseBuilder().build());
RuntimeInfoSection expected = getRuntimeInfoSection();
assertEquals(client.getVAppClient().getRuntimeInfoSection(vAppURI), expected);
}
@Test(enabled = false)
public void testGetScreenImage() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/screen")
.acceptMedia(VCloudDirectorMediaType.ANY_IMAGE)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.httpResponseBuilder()
.headers(Multimaps.forMap(ImmutableMap.of("Content-Type", "image/png")))
.message(new String(getScreenImage()))
.build());
byte[] expected = getScreenImage();
assertEquals(client.getVAppClient().getScreenImage(vAppURI), expected);
}
@Test(enabled = false)
public void testGetScreenTicket() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", vAppId + "/screen/action/acquireTicket")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getScreenTicket.xml", VCloudDirectorMediaType.SCREEN_TICKET)
.httpResponseBuilder().build());
ScreenTicket expected = getScreenTicket();
assertEquals(client.getVAppClient().getScreenTicket(vAppURI), expected);
}
@Test(enabled = false)
public void testGetStartupSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -851,238 +547,6 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
assertEquals(client.getVAppClient().modifyStartupSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSection.xml", VCloudDirectorMediaType.VIRTUAL_HARDWARE_SECTION)
.httpResponseBuilder().build());
VirtualHardwareSection expected = getVirtualHardwareSection();
assertEquals(client.getVAppClient().getVirtualHardwareSection(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyVirtualHardwareSection() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/virtualHardwareSection")
.xmlFilePayload("/vApp/modifyVirtualHardwareSection.xml", VCloudDirectorMediaType.VIRTUAL_HARDWARE_SECTION)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
VirtualHardwareSection section = getVirtualHardwareSection().toBuilder()
.build();
Task expected = modifyVirtualHardwareSectionTask();
assertEquals(client.getVAppClient().modifyVirtualHardwareSection(vAppURI, section), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSectionCpu() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection/cpu")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSectionCpu.xml", VCloudDirectorMediaType.OVF_RASD_ITEM)
.httpResponseBuilder().build());
RasdItem expected = getVirtualHardwareSectionCpu();
assertEquals(client.getVAppClient().getVirtualHardwareSectionCpu(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyVirtualHardwareSectionCpu() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("", vAppId + "/virtualHardwareSection/cpu")
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionCpu.xml", VCloudDirectorMediaType.OVF_RASD_ITEM)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionCpuTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RasdItem cpu = getVirtualHardwareSectionCpu(); // .toBuilder();
// .build();
Task expected = modifyVirtualHardwareSectionCpuTask();
assertEquals(client.getVAppClient().modifyVirtualHardwareSectionCpu(vAppURI, cpu), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSectionDisks() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection/disks")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSectionDisks.xml", VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST)
.httpResponseBuilder().build());
RasdItemsList expected = getVirtualHardwareSectionDisks();
assertEquals(client.getVAppClient().getVirtualHardwareSectionDisks(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyVirtualHardwareSectionDisks() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/virtualHardwareSection/disks")
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionDisks.xml", VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionDisksTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RasdItemsList disks = getVirtualHardwareSectionDisks().toBuilder()
.build();
Task expected = modifyVirtualHardwareSectionDisksTask();
assertEquals(client.getVAppClient().modifyVirtualHardwareSectionDisks(vAppURI, disks), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSectionMedia() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection/media")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSectionMedia.xml", VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST)
.httpResponseBuilder().build());
RasdItemsList expected = getVirtualHardwareSectionMedia();
assertEquals(client.getVAppClient().getVirtualHardwareSectionMedia(vAppURI), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSectionMemory() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection/memory")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSectionMemory.xml", VCloudDirectorMediaType.OVF_RASD_ITEM)
.httpResponseBuilder().build());
RasdItem expected = getVirtualHardwareSectionMemory();
assertEquals(client.getVAppClient().getVirtualHardwareSectionMemory(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyVirtualHardwareSectionMemory() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/virtualHardwareSection/memory")
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionMemory.xml", VCloudDirectorMediaType.VAPP)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionMemoryTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RasdItem memory = getVirtualHardwareSectionCpu(); // .toBuilder();
// .build();
Task expected = modifyVirtualHardwareSectionMemoryTask();
assertEquals(client.getVAppClient().modifyVirtualHardwareSectionMemory(vAppURI, memory), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSectionNetworkCards() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection/networkCards")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSectionNetworkCards.xml", VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST)
.httpResponseBuilder().build());
RasdItemsList expected = getVirtualHardwareSectionNetworkCards();
assertEquals(client.getVAppClient().getVirtualHardwareSectionNetworkCards(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyVirtualHardwareSectionNetworkCards() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/virtualHardwareSection/networkCards")
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionNetworkCards.xml", VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionNetworkCardsTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RasdItemsList networkCards = getVirtualHardwareSectionNetworkCards().toBuilder()
.build();
Task expected = modifyVirtualHardwareSectionNetworkCardsTask();
assertEquals(client.getVAppClient().modifyVirtualHardwareSectionNetworkCards(vAppURI, networkCards), expected);
}
@Test(enabled = false)
public void testGetVirtualHardwareSectionSerialPorts() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", vAppId + "/virtualHardwareSection/serialPorts")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/getVirtualHardwareSectionSerialPorts.xml", VCloudDirectorMediaType.VAPP)
.httpResponseBuilder().build());
RasdItemsList expected = getVirtualHardwareSectionSerialPorts();
assertEquals(client.getVAppClient().getVirtualHardwareSectionSerialPorts(vAppURI), expected);
}
@Test(enabled = false)
public void testModifyVirtualHardwareSectionSerialPorts() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", vAppId + "/virtualHardwareSection/serialPorts")
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionSerialPorts.xml", VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionSerialPortsTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RasdItemsList serialPorts = getVirtualHardwareSectionSerialPorts().toBuilder()
.build();
Task expected = modifyVirtualHardwareSectionSerialPortsTask();
assertEquals(client.getVAppClient().modifyVirtualHardwareSectionSerialPorts(vAppURI, serialPorts), expected);
}
public static VApp getVApp() {
// FIXME Does not match XML
VApp vApp = VApp.builder()

View File

@ -30,9 +30,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.N
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ADMIN_USER;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.MEDIA;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkControlAccessParams;
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.checkMetadata;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataFor;
@ -40,36 +38,23 @@ import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataKeyAbs
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValueFor;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConfigSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConnectionSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOperatingSystemSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOwner;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkProductSectionList;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkRasdItemsList;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceAllocationSettingData;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkRuntimeInfoSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkScreenTicket;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkStartupSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVApp;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVirtualHardwareSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVmPendingQuestion;
import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.relEquals;
import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.typeEquals;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.math.BigInteger;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.dmtf.cim.OSType;
import org.jclouds.dmtf.cim.ResourceAllocationSettingData;
import org.jclouds.dmtf.ovf.MsgType;
import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.dmtf.ovf.ProductSection;
@ -86,42 +71,23 @@ 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.Owner;
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.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswerChoice;
import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection;
import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection.IpAddressAllocationMode;
import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
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.NetworkConfigSection;
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.RuntimeInfoSection;
import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
/**
* Tests behavior of the {@link VAppClient}.
@ -150,10 +116,10 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
Media sourceMedia = Media.builder()
.type(VCloudDirectorMediaType.MEDIA)
.name("Test media "+random.nextInt())
.name(name("media"))
.size(iso.length)
.imageType(Media.ImageType.ISO)
.description("Test media generated by vAppClientLiveTest")
.description("Test media generated by VAppClientLiveTest")
.build();
Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia);
@ -183,22 +149,21 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
}
}
@Override
@AfterClass(alwaysRun = true)
@AfterClass(alwaysRun = true, dependsOnMethods = { "cleanUpEnvironment" })
public void cleanUp() {
if (adminContext != null && mediaCreated && mediaURI != null) {
try {
Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI);
taskDoneEventually(delete);
Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI);
taskDoneEventually(delete);
} catch (Exception e) {
logger.warn("Error when deleting media: %s", e.getMessage());
logger.warn(e, "Error when deleting media");
}
}
if (adminContext != null && testUserCreated && testUserURI != null) {
try {
adminContext.getApi().getUserClient().deleteUser(testUserURI);
adminContext.getApi().getUserClient().deleteUser(testUserURI);
} catch (Exception e) {
logger.warn("Error when deleting user: %s", e.getMessage());
logger.warn(e, "Error when deleting user");
}
}
}
@ -252,7 +217,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/action/deploy", dependsOnMethods = { "testGetVApp" })
public void testDeployVApp() {
DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
.deploymentLeaseSeconds((int)TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
.notForceCustomization()
.notPowerOn()
.build();
@ -274,7 +239,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" })
public void testPowerOnVApp() {
// Power off VApp
vApp = powerOff(vApp);
vApp = powerOffVApp(vApp.getHref());
// The method under test
Task powerOnVApp = vAppClient.powerOn(vApp.getHref());
@ -290,7 +255,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVApp" })
public void testReboot() {
// Power on VApp
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
// The method under test
Task reboot = vAppClient.reboot(vApp.getHref());
@ -306,7 +271,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testDeployVApp" })
public void testShutdown() {
// Power on VApp
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
// The method under test
Task shutdown = vAppClient.shutdown(vAppURI);
@ -319,13 +284,13 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertVAppStatus(vAppURI, Status.POWERED_OFF);
// Power on the VApp again
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
}
@Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVApp" })
public void testSuspend() {
// Power on VApp
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
// The method under test
Task suspend = vAppClient.suspend(vAppURI);
@ -338,13 +303,13 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertVAppStatus(vAppURI, Status.SUSPENDED);
// Power on the VApp again
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
}
@Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVApp" })
public void testReset() {
// Power on VApp
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
// The method under test
Task reset = vAppClient.reset(vAppURI);
@ -360,7 +325,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" })
public void testUndeployVApp() {
// Power on VApp
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
UndeployVAppParams params = UndeployVAppParams.builder().build();
@ -379,7 +344,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" })
public void testPowerOffVApp() {
// Power on VApp
vApp = powerOn(vApp);
vApp = powerOnVApp(vApp.getHref());
// The method under test
Task powerOffVApp = vAppClient.powerOff(vApp.getHref());
@ -392,16 +357,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertVAppStatus(vAppURI, Status.POWERED_OFF);
}
@Test(description = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testDeployVApp" })
public void testConsolidateVApp() {
// Power on VApp
vApp = powerOn(vApp);
// The method under test
Task consolidateVApp = vAppClient.consolidateVm(vApp.getHref());
assertTrue(retryTaskSuccess.apply(consolidateVApp), String.format(TASK_COMPLETE_TIMELY, "consolidateVApp"));
}
@Test(description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testControlAccessUser() {
ControlAccessParams params = ControlAccessParams.builder()
@ -441,7 +396,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVApp" })
public void testDiscardSuspendedState() {
// Suspend the VApp
vApp = suspend(vAppURI);
vApp = suspendVApp(vApp.getHref());
// The method under test
Task discardSuspendedState = vAppClient.discardSuspendedState(vApp.getHref());
@ -500,16 +455,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
}
}
@Test(description = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testDeployVApp" })
public void testInstallVMwareTools() {
// First ensure the vApp is powered n
vApp = powerOn(vApp);
// The method under test
Task installVMwareTools = vAppClient.installVMwareTools(vm.getHref());
assertTrue(retryTaskSuccess.apply(installVMwareTools), String.format(TASK_COMPLETE_TIMELY, "installVMwareTools"));
}
// FIXME "Could not bind object to request[method=POST, endpoint=https://mycloud.greenhousedata.com/api/vApp/vapp-e124f3f0-adb9-4268-ad49-e54fb27e40af/action/recomposeVApp,
// headers={Accept=[application/vnd.vmware.vcloud.task+xml]}, payload=[content=true, contentMetadata=[contentDisposition=null, contentEncoding=null, contentLanguage=null,
// contentLength=0, contentMD5=null, contentType=application/vnd.vmware.vcloud.recomposeVAppParams+xml], written=false]]: Could not marshall object"
@ -522,29 +467,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertTrue(retryTaskSuccess.apply(recomposeVApp), String.format(TASK_COMPLETE_TIMELY, "recomposeVApp"));
}
// NOTE This test is disabled, as it is not possible to look up datastores using the User API
@Test(description = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" })
public void testRelocate() {
// Relocate to the last of the available datastores
QueryResultRecords records = context.getApi().getQueryClient().queryAll("datastore");
QueryResultRecordType datastore = Iterables.getLast(records.getRecords());
RelocateParams params = RelocateParams.builder().datastore(Reference.builder().href(datastore.getHref()).build()).build();
// The method under test
Task relocate = vAppClient.relocateVm(vApp.getHref(), params);
assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate"));
}
@Test(description = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVApp" })
public void testUpgradeHardwareVersion() {
// Power off VApp
vApp = powerOff(vApp);
// The method under test
Task upgradeHardwareVersion = vAppClient.upgradeHardwareVersion(vm.getHref());
assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion), String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion"));
}
@Test(description = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" })
public void testGetControlAccess() {
// The method under test
@ -554,47 +476,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
checkControlAccessParams(controlAccess);
}
@Test(description = "GET /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetVApp" })
public void testGetGuestCustomizationSection() {
getGuestCustomizationSection(new Function<URI, GuestCustomizationSection>() {
@Override
public GuestCustomizationSection apply(URI uri) {
return vAppClient.getGuestCustomizationSection(uri);
}
});
}
@Test(description = "PUT /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetGuestCustomizationSection" })
public void testModifyGuestCustomizationSection() {
// Copy existing section and update fields
GuestCustomizationSection oldSection = vAppClient.getGuestCustomizationSection(vm.getHref());
GuestCustomizationSection newSection = oldSection.toBuilder()
.computerName(name("n"))
.enabled(Boolean.FALSE)
.adminPassword(null) // Not allowed
.build();
// The method under test
Task modifyGuestCustomizationSection = vAppClient.modifyGuestCustomizationSection(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyGuestCustomizationSection), String.format(TASK_COMPLETE_TIMELY, "modifyGuestCustomizationSection"));
// Retrieve the modified section
GuestCustomizationSection modified = vAppClient.getGuestCustomizationSection(vm.getHref());
// Check the retrieved object is well formed
checkGuestCustomizationSection(modified);
// Check the modified section fields are set correctly
assertEquals(modified.getComputerName(), newSection.getComputerName());
assertFalse(modified.isEnabled());
// Reset the admin password in the retrieved GuestCustomizationSection for equality check
modified = modified.toBuilder().adminPassword(null).build();
// Check the section was modified correctly
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "GuestCustomizationSection"));
}
@Test(description = "GET /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetVApp" })
public void testGetLeaseSettingsSection() {
// The method under test
@ -653,31 +534,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "LeaseSettingsSection"));
}
// FIXME "Error: The requested operation on media "com.vmware.vcloud.entity.media:abfcb4b7-809f-4b50-a0aa-8c97bf09a5b0" is not supported in the current state."
@Test(description = "PUT /vApp/{id}/media/action/insertMedia", dependsOnMethods = { "testGetVApp" })
public void testInsertMedia() {
// Setup media params from configured media id
MediaInsertOrEjectParams params = MediaInsertOrEjectParams.builder()
.media(Reference.builder().href(mediaURI).type(MEDIA).build())
.build();
// The method under test
Task insertMedia = vAppClient.insertMedia(vm.getHref(), params);
assertTrue(retryTaskSuccess.apply(insertMedia), String.format(TASK_COMPLETE_TIMELY, "insertMedia"));
}
@Test(description = "PUT /vApp/{id}/media/action/ejectMedia", dependsOnMethods = { "testInsertMedia" })
public void testEjectMedia() {
// Setup media params from configured media id
MediaInsertOrEjectParams params = MediaInsertOrEjectParams.builder()
.media(Reference.builder().href(mediaURI).type(MEDIA).build())
.build();
// The method under test
Task ejectMedia = vAppClient.ejectMedia(vm.getHref(), params);
assertTrue(retryTaskSuccess.apply(ejectMedia), String.format(TASK_COMPLETE_TIMELY, "ejectMedia"));
}
@Test(description = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConfigSection() {
// The method under test
@ -711,49 +567,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "NetworkConfigSection"));
}
@Test(description = "GET /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConnectionSection() {
getNetworkConnectionSection(new Function<URI, NetworkConnectionSection>() {
@Override
public NetworkConnectionSection apply(URI uri) {
return vAppClient.getNetworkConnectionSection(uri);
}
});
}
// FIXME "Task error: Unable to perform this action. Contact your cloud administrator."
@Test(description = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetNetworkConnectionSection" })
public void testModifyNetworkConnectionSection() {
// Look up a network in the Vdc
Set<Reference> networks = vdc.getAvailableNetworks();
Reference network = Iterables.getLast(networks);
// Copy existing section and update fields
NetworkConnectionSection oldSection = vAppClient.getNetworkConnectionSection(vm.getHref());
NetworkConnectionSection newSection = oldSection.toBuilder()
.networkConnection(NetworkConnection.builder()
.ipAddressAllocationMode(IpAddressAllocationMode.DHCP.toString())
.network(network.getName())
.build())
.build();
// The method under test
Task modifyNetworkConnectionSection = vAppClient.modifyNetworkConnectionSection(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyNetworkConnectionSection), String.format(TASK_COMPLETE_TIMELY, "modifyNetworkConnectionSection"));
// Retrieve the modified section
NetworkConnectionSection modified = vAppClient.getNetworkConnectionSection(vm.getHref());
// Check the retrieved object is well formed
checkNetworkConnectionSection(modified);
// Check the modified section has an extra network connection
assertEquals(modified.getNetworkConnections().size(), newSection.getNetworkConnections().size() + 1);
// Check the section was modified correctly
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "NetworkConnectionSection"));
}
@Test(description = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkSection() {
// The method under test
@ -763,38 +576,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
checkNetworkSection(section);
}
@Test(description = "GET /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetVApp" })
public void testGetOperatingSystemSection() {
// The method under test
OperatingSystemSection section = vAppClient.getOperatingSystemSection(vm.getHref());
// Check the retrieved object is well formed
checkOperatingSystemSection(section);
}
@Test(description = "PUT /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetOperatingSystemSection", "testModifyVirtualHardwareSection" })
public void testModifyOperatingSystemSection() {
// Create new OperatingSystemSection
OperatingSystemSection newSection = OperatingSystemSection.builder()
.info("") // NOTE Required OVF field, ignored
.id(OSType.RHEL_64.getCode())
.osType("rhel5_64Guest")
.build();
// The method under test
Task modifyOperatingSystemSection = vAppClient.modifyOperatingSystemSection(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyOperatingSystemSection), String.format(TASK_COMPLETE_TIMELY, "modifyOperatingSystemSection"));
// Retrieve the modified section
OperatingSystemSection modified = vAppClient.getOperatingSystemSection(vm.getHref());
// Check the retrieved object is well formed
checkOperatingSystemSection(modified);
// Check the modified section fields are set correctly
assertEquals(modified.getId(), newSection.getId());
}
@Test(description = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" })
public void testGetOwner() {
// The method under test
@ -861,78 +642,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(modified, newSections, String.format(ENTITY_EQUAL, "ProductSectionList"));
}
// FIXME How do we force it to ask a question?
@Test(description = "GET /vApp/{id}/question", dependsOnMethods = { "testDeployVApp" })
public void testGetPendingQuestion() {
// Power on VApp
vApp = powerOn(vAppURI);
// TODO how to test?
// The method under test
VmPendingQuestion question = vAppClient.getPendingQuestion(vm.getHref());
// Check the retrieved object is well formed
checkVmPendingQuestion(question);
}
@Test(description = "POST /vApp/{id}/question/action/answer", dependsOnMethods = { "testGetPendingQuestion" })
public void testAnswerQuestion() {
// TODO check that the question has been answered (e.g. asking for getPendingQuestion does not
// include our answered question).
VmPendingQuestion question = vAppClient.getPendingQuestion(vm.getHref());
List<VmQuestionAnswerChoice> answerChoices = question.getChoices();
VmQuestionAnswerChoice answerChoice = Iterables.getFirst(answerChoices, null);
assertNotNull(answerChoice, "Question "+question+" must have at least once answer-choice");
VmQuestionAnswer answer = VmQuestionAnswer.builder()
.choiceId(answerChoice.getId())
.questionId(question.getQuestionId())
.build();
vAppClient.answerQuestion(vm.getHref(), answer);
}
@Test(description = "GET /vApp/{id}/runtimeInfoSection", dependsOnMethods = { "testGetVApp" })
public void testGetRuntimeInfoSection() {
// The method under test
RuntimeInfoSection section = vAppClient.getRuntimeInfoSection(vm.getHref());
// Check the retrieved object is well formed
checkRuntimeInfoSection(section);
}
// FIXME If still failing, consider escalating?
@Test(description = "GET /vApp/{id}/screen", dependsOnMethods = { "testDeployVApp" })
public void testGetScreenImage() {
// Power on VApp
vApp = powerOn(vApp);
// The method under test
byte[] image = vAppClient.getScreenImage(vm.getHref());
// Check returned bytes against PNG header magic number
byte[] pngHeaderBytes = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
assertNotNull(image);
assertTrue(image.length > pngHeaderBytes.length);
for (int i = 0; i < pngHeaderBytes.length; i++) {
assertEquals(image[i], pngHeaderBytes[i], String.format("Image differs from PNG format at byte %d of header", i));
}
}
@Test(description = "GET /vApp/{id}/screen/action/acquireTicket", dependsOnMethods = { "testDeployVApp" })
public void testGetScreenTicket() {
// Power on VApp
vApp = powerOn(vApp);
// The method under test
ScreenTicket ticket = vAppClient.getScreenTicket(vm.getHref());
// Check the retrieved object is well formed
checkScreenTicket(ticket);
}
@Test(description = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" })
public void testGetStartupSection() {
// The method under test
@ -963,242 +672,6 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(modified, newSection);
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVApp" })
public void testGetVirtualHardwareSection() {
// Method under test
VirtualHardwareSection hardware = vAppClient.getVirtualHardwareSection(vm.getHref());
// Check the retrieved object is well formed
checkVirtualHardwareSection(hardware);
}
@Test(description = "PUT /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testModifyVirtualHardwareSection() {
// Power off VApp
vApp = powerOff(vApp);
// Copy existing section and update fields
VirtualHardwareSection oldSection = vAppClient.getVirtualHardwareSection(vm.getHref());
Set<? extends ResourceAllocationSettingData> oldItems = oldSection.getItems();
Set<ResourceAllocationSettingData> newItems = Sets.newLinkedHashSet(oldItems);
ResourceAllocationSettingData oldMemory = Iterables.find(oldItems, new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData rasd) {
return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
}
});
ResourceAllocationSettingData newMemory = oldMemory.toBuilder()
.elementName("1024 MB of memory")
.virtualQuantity(new BigInteger("1024"))
.build();
newItems.remove(oldMemory);
newItems.add(newMemory);
VirtualHardwareSection newSection = oldSection.toBuilder()
.items(newItems)
.build();
// The method under test
Task modifyVirtualHardwareSection = vAppClient.modifyVirtualHardwareSection(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSection), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSection"));
// Retrieve the modified section
VirtualHardwareSection modifiedSection = vAppClient.getVirtualHardwareSection(vm.getHref());
// Check the retrieved object is well formed
checkVirtualHardwareSection(modifiedSection);
// Check the modified section fields are set correctly
ResourceAllocationSettingData modifiedMemory = Iterables.find(modifiedSection.getItems(),
new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData rasd) {
return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
}
});
assertEquals(modifiedMemory.getVirtualQuantity(), new BigInteger("1024"));
assertEquals(modifiedMemory, newMemory);
assertEquals(modifiedSection, newSection);
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionCpu() {
// Method under test
RasdItem rasd = vAppClient.getVirtualHardwareSectionCpu(vm.getHref());
// Check the retrieved object is well formed
checkResourceAllocationSettingData(rasd);
}
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" })
public void testModifyVirtualHardwareSectionCpu() {
// Copy existing section and update fields
RasdItem oldItem = vAppClient.getVirtualHardwareSectionCpu(vm.getHref());
RasdItem newItem = oldItem.toBuilder()
.elementName("2 virtual CPU(s)")
.virtualQuantity(new BigInteger("2"))
.build();
// Method under test
Task modifyVirtualHardwareSectionCpu = vAppClient.modifyVirtualHardwareSectionCpu(vm.getHref(), newItem);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionCpu), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionCpu"));
// Retrieve the modified section
RasdItem modified = vAppClient.getVirtualHardwareSectionCpu(vm.getHref());
// Check the retrieved object
checkResourceAllocationSettingData(modified);
// Check modified item
assertEquals(modified.getVirtualQuantity(), new BigInteger("2"),
String.format(OBJ_FIELD_EQ, "ResourceAllocationSettingData", "VirtualQuantity", "2", modified.getVirtualQuantity().toString()));
assertEquals(modified, newItem);
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionDisks() {
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionDisks(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(rasdItems);
}
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSectionDisks" })
public void testModifyVirtualHardwareSectionDisks() {
// Copy the existing items list and modify the name of an item
RasdItemsList oldSection = vAppClient.getVirtualHardwareSectionDisks(vm.getHref());
RasdItemsList newSection = oldSection.toBuilder().build();
// Method under test
Task modifyVirtualHardwareSectionDisks = vAppClient.modifyVirtualHardwareSectionDisks(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionDisks), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionDisks"));
// Retrieve the modified section
RasdItemsList modified = vAppClient.getVirtualHardwareSectionDisks(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(modified);
// TODO What is modifiable? What can we change, so we can assert the change took effect?
// I tried changing "elementName" of one of the items, but it continued to have the old value when looked up post-modify.
//
// List<ResourceAllocationSettingData> newItems = new ArrayList<ResourceAllocationSettingData>(oldSection.getItems());
// ResourceAllocationSettingData item0 = newItems.get(0);
// String item0InstanceId = item0.getInstanceID().getValue();
// String item0ElementName = item0.getElementName().getValue()+"-"+random.nextInt(Integer.MAX_VALUE);
// newItems.set(0, item0.toBuilder().elementName(newCimString(item0ElementName)).build());
// RasdItemsList newSection = oldSection.toBuilder()
// .items(newItems)
// .build();
// ...
// long weight = random.nextInt(Integer.MAX_VALUE);
// ResourceAllocationSettingData newSection = origSection.toBuilder()
// .weight(newCimUnsignedInt(weight))
// .build();
// ...
// checkHasMatchingItem("virtualHardwareSection/disk", modified, item0InstanceId, item0ElementName);
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection/media", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionMedia() {
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionMedia(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(rasdItems);
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionMemory() {
// Method under test
RasdItem rasd = vAppClient.getVirtualHardwareSectionCpu(vm.getHref());
// Check the retrieved object is well formed
checkResourceAllocationSettingData(rasd);
}
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" })
public void testModifyVirtualHardwareSectionMemory() {
RasdItem origItem = vAppClient.getVirtualHardwareSectionMemory(vm.getHref());
RasdItem newItem = origItem.toBuilder()
.elementName("1024 MB of memory")
.virtualQuantity(new BigInteger("1024"))
.build();
// Method under test
Task modifyVirtualHardwareSectionMemory = vAppClient.modifyVirtualHardwareSectionMemory(vm.getHref(), newItem);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionMemory), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionMemory"));
// Retrieve the modified section
RasdItem modified = vAppClient.getVirtualHardwareSectionMemory(vm.getHref());
// Check the retrieved object
checkResourceAllocationSettingData(modified);
// Check modified item
assertEquals(modified.getVirtualQuantity(), new BigInteger("1024"),
String.format(OBJ_FIELD_EQ, "ResourceAllocationSettingData", "VirtualQuantity", "1024", modified.getVirtualQuantity().toString()));
assertEquals(modified, newItem);
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionNetworkCards() {
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionNetworkCards(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(rasdItems);
}
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSectionNetworkCards" })
public void testModifyVirtualHardwareSectionNetworkCards() {
RasdItemsList oldSection = vAppClient.getVirtualHardwareSectionNetworkCards(vm.getHref());
RasdItemsList newSection = oldSection.toBuilder().build();
// Method under test
Task modifyVirtualHardwareSectionNetworkCards = vAppClient.modifyVirtualHardwareSectionNetworkCards(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionNetworkCards), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionNetworkCards"));
// Retrieve the modified section
RasdItemsList modified = vAppClient.getVirtualHardwareSectionNetworkCards(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(modified);
// TODO What is modifiable? What can we change, so we can assert the change took effect?
// I tried changing "elementName" of one of the items, but it continued to have the old value when looked up post-modify.
// See the description in testModifyVirtualHardwareSectionDisks
}
@Test(description = "GET /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSection" })
public void testGetVirtualHardwareSectionSerialPorts() {
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionSerialPorts(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(rasdItems);
}
@Test(description = "PUT /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSectionSerialPorts" })
public void testModifyVirtualHardwareSectionSerialPorts() {
RasdItemsList oldSection = vAppClient.getVirtualHardwareSectionSerialPorts(vm.getHref());
RasdItemsList newSection = oldSection.toBuilder().build();
// Method under test
Task modifyVirtualHardwareSectionSerialPorts = vAppClient.modifyVirtualHardwareSectionSerialPorts(vm.getHref(), newSection);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionSerialPorts), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionSerialPorts"));
// Retrieve the modified section
RasdItemsList modified = vAppClient.getVirtualHardwareSectionSerialPorts(vm.getHref());
// Check the retrieved object is well formed
checkRasdItemsList(modified);
// TODO What is modifiable? What can we change, so we can assert the change took effect?
// I tried changing "elementName" of one of the items, but it continued to have the old value when looked up post-modify.
// See the description in testModifyVirtualHardwareSectionDisks
}
@Test(description = "PUT /vApp/{id}/metadata", dependsOnMethods = { "testGetVApp" })
public void testSetMetadataValue() {
key = name("key-");

View File

@ -90,7 +90,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
private String key;
private String val;
@AfterClass(alwaysRun = true)
@AfterClass(alwaysRun = true, dependsOnMethods = { "cleanUpEnvironment" })
protected void tidyUp() {
if (key != null) {
try {
@ -385,7 +385,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
Reference network = Iterables.getLast(networks);
// Copy existing section and update fields
NetworkConnectionSection oldSection = vAppClient.getNetworkConnectionSection(vm.getHref());
NetworkConnectionSection oldSection = vAppTemplateClient.getNetworkConnectionSection(vm.getHref());
NetworkConnectionSection newSection = oldSection.toBuilder()
.networkConnection(NetworkConnection.builder()
.ipAddressAllocationMode(IpAddressAllocationMode.DHCP.toString())

View File

@ -43,12 +43,13 @@ import org.jclouds.rest.RestContext;
import org.jclouds.vcloud.director.testng.FormatApiResultsListener;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
import org.jclouds.vcloud.director.v1_5.domain.Link;
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.Role.DefaultRoles;
import org.jclouds.vcloud.director.v1_5.domain.RoleReferences;
import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.domain.Task;
@ -56,8 +57,6 @@ import org.jclouds.vcloud.director.v1_5.domain.User;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
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.network.Network;
import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration;
@ -104,7 +103,7 @@ import com.google.inject.Guice;
public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTest<VCloudDirectorContext> {
@Resource
protected Logger logger = Logger.CONSOLE;
protected Logger logger = Logger.NULL;
protected static final long TASK_TIMEOUT_SECONDS = 100L;
protected static final long LONG_TASK_TIMEOUT_SECONDS = 300L;
@ -429,15 +428,12 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe
protected void cleanUpVApp(URI vAppURI) {
VAppClient vAppClient = context.getApi().getVAppClient();
VApp vApp;
try {
vApp = vAppClient.getVApp(vAppURI); // Refresh
logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppURI.getPath());
} catch (VCloudDirectorException e) {
// Presumably vApp has already been deleted. Ignore.
VApp vApp = vAppClient.getVApp(vAppURI); // Refresh
if (vApp == null) {
logger.info("Cannot find VApp at %s", vAppURI.getPath());
return;
return; // Presumably vApp has already been deleted. Ignore.
}
logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppURI.getPath());
// Wait for busy tasks to complete (don't care if it's failed or successful)
// Otherwise, get error on delete "entity is busy completing an operation.
@ -463,7 +459,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe
// Undeploy the VApp if necessary
if (vApp.isDeployed()) {
try {
UndeployVAppParams params = UndeployVAppParams.builder().build();
UndeployVAppParams params = UndeployVAppParams.builder()
.undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN)
.build();
Task undeployTask = vAppClient.undeploy(vAppURI, params);
taskDoneEventually(undeployTask);
} catch (Exception e) {
@ -478,12 +476,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe
vAppNames.remove(vApp.getName());
logger.info("Deleted VApp %s", vApp.getName());
} catch (Exception e) {
try {
vApp = vAppClient.getVApp(vAppURI); // Refresh
} catch (Exception e2) {
// Ignore
}
vApp = vAppClient.getVApp(vAppURI); // Refresh
logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppURI.getPath());
}
}