From 8becbd03947ef7d08a5761419212730cc4e47b2c Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 26 Apr 2012 01:34:43 +0100 Subject: [PATCH] Create new VmClient and references using existing methods from VAppClient --- .../VCloudDirectorRestClientModule.java | 4 + .../v1_5/features/VAppAsyncClient.java | 312 +------ .../director/v1_5/features/VAppClient.java | 421 +--------- .../director/v1_5/features/VmAsyncClient.java | 691 +++++++++++++++ .../director/v1_5/features/VmClient.java | 794 ++++++++++++++++++ .../v1_5/user/VCloudDirectorAsyncClient.java | 7 + .../v1_5/user/VCloudDirectorClient.java | 7 + 7 files changed, 1536 insertions(+), 700 deletions(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncClient.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmClient.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index c6c4df7485..d8af02ac6e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -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, Class> ADMIN_DELEGATE_MAP = ImmutableMap., Class>builder() @@ -166,6 +169,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule deleteVApp(@EndpointParam URI vAppURI); - /** - * @see VAppClient#consolidateVm(URI) - */ - @POST - @Path("/action/consolidate") - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture consolidateVm(@EndpointParam URI vAppURI); - /** * @see VAppClient#modifyControlAccess(URI, ControlAccessParams) */ @@ -180,15 +171,6 @@ public interface VAppAsyncClient { @JAXBResponseParser ListenableFuture exitMaintenanceMode(@EndpointParam URI vAppURI); - /** - * @see VAppClient#installVMwareTools(URI) - */ - @POST - @Path("/action/installVMwareTools") - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture installVMwareTools(@EndpointParam URI vAppURI); - /** * @see VAppClient#recompose(URI, RecomposeVAppParams) */ @@ -200,17 +182,6 @@ public interface VAppAsyncClient { ListenableFuture 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 relocateVm(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) RelocateParams params); - /** * @see VAppClient#undeploy(URI, UndeployVAppParams) */ @@ -222,15 +193,6 @@ public interface VAppAsyncClient { ListenableFuture undeploy(@EndpointParam URI vAppURI, @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); - /** - * @see VAppClient#upgradeHardwareVersion(URI) - */ - @POST - @Path("/action/upgradeHardwareVersion") - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture upgradeHardwareVersion(@EndpointParam URI vAppURI); - /** * @see VAppClient#getControlAccess(URI) */ @@ -295,27 +257,6 @@ public interface VAppAsyncClient { @JAXBResponseParser ListenableFuture suspend(@EndpointParam URI vAppURI); - /** - * @see VAppClient#getGuestCustomizationSection(URI) - */ - @GET - @Path("/guestCustomizationSection") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getGuestCustomizationSection(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyGuestCustomizationSection(URI, GuestCustomizationSection) - */ - @PUT - @Path("/guestCustomizationSection") - @Produces(GUEST_CUSTOMIZATION_SECTION) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyGuestCustomizationSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); - /** * @see VAppClient#getLeaseSettingsSection(URI) */ @@ -337,28 +278,6 @@ public interface VAppAsyncClient { ListenableFuture 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 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 insertMedia(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); - /** * @see VAppClient#getNetworkConfigSection(URI) */ @@ -380,27 +299,6 @@ public interface VAppAsyncClient { ListenableFuture modifyNetworkConfigSection(@EndpointParam URI vAppURI, @BinderParam(BindToXMLPayload.class) NetworkConfigSection section); - /** - * @see VAppClient#getNetworkConnectionSection(URI) - */ - @GET - @Path("/networkConnectionSection") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkConnectionSection(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyNetworkConnectionSection(URI, NetworkConnectionSection) - */ - @PUT - @Path("/networkConnectionSection") - @Produces(NETWORK_CONNECTION_SECTION) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyNetworkConnectionSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); - /** * @see VAppClient#getNetworkSection(URI) */ @@ -411,27 +309,6 @@ public interface VAppAsyncClient { @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getNetworkSection(@EndpointParam URI vAppURI); - /** - * @see VAppClient#getOperatingSystemSection(URI) - */ - @GET - @Path("/operatingSystemSection") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getOperatingSystemSection(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyOperatingSystemSection(URI, OperatingSystemSection) - */ - @PUT - @Path("/operatingSystemSection") - @Produces(OPERATING_SYSTEM_SECTION) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyOperatingSystemSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) OperatingSystemSection section); - /** * @see VAppClient#getOwner(URI) */ @@ -474,56 +351,6 @@ public interface VAppAsyncClient { ListenableFuture modifyProductSections(@EndpointParam URI vAppURI, @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); - /** - * @see VAppClient#getPendingQuestion(URI) - */ - @GET - @Path("/question") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPendingQuestion(@EndpointParam URI vAppURI); - - /** - * @see VAppClient#answerQuestion(URI, VmQuestionAnswer) - */ - @POST - @Path("/question/action/answer") - @Produces(VM_PENDING_ANSWER) - @Consumes - @JAXBResponseParser - ListenableFuture answerQuestion(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer); - - /** - * @see VAppClient#getRuntimeInfoSection(URI) - */ - @GET - @Path("/runtimeInfoSection") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getRuntimeInfoSection(@EndpointParam URI vmURI); - - /** - * @see VAppClient#getScreenImage(URI) - */ - @GET - @Path("/screen") - @Consumes(ANY_IMAGE) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @ResponseParser(ReturnPayloadBytes.class) - ListenableFuture getScreenImage(@EndpointParam URI vAppURI); - - /** - * @see VAppClient#getScreenTicket(URI) - */ - @POST - @Path("/screen/action/acquireTicket") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture 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 getVirtualHardwareSection(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyVirtualHardwareSection(URI, VirtualHardwareSection) - */ - @PUT - @Path("/virtualHardwareSection") - @Produces(VIRTUAL_HARDWARE_SECTION) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyVirtualHardwareSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) VirtualHardwareSection section); - - /** - * @see VAppClient#getVirtualHardwareSectionCpu(URI) - */ - @GET - @Path("/virtualHardwareSection/cpu") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData) - */ - @PUT - @Path("/virtualHardwareSection/cpu") - @Produces(OVF_RASD_ITEM) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyVirtualHardwareSectionCpu(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItem rasd); - - /** - * @see VAppClient#getVirtualHardwareSectionDisks(URI) - */ - @GET - @Path("/virtualHardwareSection/disks") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionDisks(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyVirtualHardwareSectionDisks(URI, RasdItemsList) - */ - @PUT - @Path("/virtualHardwareSection/disks") - @Produces(OVF_RASD_ITEMS_LIST) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyVirtualHardwareSectionDisks(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); - - /** - * @see VAppClient#getVirtualHardwareSectionMedia(URI) - */ - @GET - @Path("/virtualHardwareSection/media") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionMedia(@EndpointParam URI vmURI); - - /** - * @see VAppClient#getVirtualHardwareSectionMemory(URI) - */ - @GET - @Path("/virtualHardwareSection/memory") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData) - */ - @PUT - @Path("/virtualHardwareSection/memory") - @Produces(OVF_RASD_ITEM) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyVirtualHardwareSectionMemory(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItem rasd); - - /** - * @see VAppClient#getVirtualHardwareSectionNetworkCards(URI) - */ - @GET - @Path("/virtualHardwareSection/networkCards") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyVirtualHardwareSectionNetworkCards(URI, RasdItemsList) - */ - @PUT - @Path("/virtualHardwareSection/networkCards") - @Produces(OVF_RASD_ITEMS_LIST) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture modifyVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); - - /** - * @see VAppClient#getVirtualHardwareSectionSerialPorts(URI) - */ - @GET - @Path("/virtualHardwareSection/serialPorts") - @Consumes - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI); - - /** - * @see VAppClient#modifyVirtualHardwareSectionSerialPorts(URI, RasdItemsList) - */ - @PUT - @Path("/virtualHardwareSection/serialPorts") - @Produces(OVF_RASD_ITEMS_LIST) - @Consumes(TASK) - @JAXBResponseParser - ListenableFuture 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(); - } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java index f8dc431db4..431eb5583c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java @@ -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: *
    *
  • {@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}. * *
         * PUT /vApp/{id}
    @@ -112,7 +100,7 @@ public interface VAppClient {
        Task modifyVApp(URI vAppURI, VApp vApp);
     
        /**
    -    * Deletes a vApp/VM.
    +    * Deletes a {@link VApp}.
         *
         * 
         * DELETE /vApp/{id}
    @@ -123,18 +111,7 @@ public interface VAppClient {
        Task deleteVApp(URI vAppURI);
     
        /**
    -    * Consolidates a vm.
    -    *
    -    * 
    -    * POST /vApp/{id}/action/consolidate
    -    * 
    - * - * @since 1.5 - */ - Task consolidateVm(URI vAppURI); - - /** - * Modifies the control access of a vApp. + * Modifies the control access of a {@link VApp}. * *
         * 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.
         *
         * 
         * 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.
    -    *
    -    * 
    -    * POST /vApp/{id}/action/installVMwareTools
    -    * 
    - * - * @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. - * - *
    -    * POST /vApp/{id}/action/relocate
    -    * 
    - * - * @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. - * - *
    -    * POST /vApp/{id}/action/upgradeHardwareVersion
    -    * 
    - * - * @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. - * - *
    -    * GET /vApp/{id}/guestCustomizationSection
    -    * 
    - * - * @since 1.0 - */ - GuestCustomizationSection getGuestCustomizationSection(URI vmURI); - - /** - * Modifies the guest customization section of a VM. - * - *
    -    * PUT /vApp/{id}/guestCustomizationSection
    -    * 
    - * - * @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}. * *
         * 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}.
         *
         * 
         * PUT /vApp/{id}/leaseSettingsSection
    @@ -412,29 +331,7 @@ public interface VAppClient {
        Task modifyLeaseSettingsSection(URI vAppURI, LeaseSettingsSection section);
     
        /**
    -    * Ejects a media from a VM.
    -    *
    -    * 
    -    * PUT /vApp/{id}/media/action/ejectMedia
    -    * 
    - * - * @since 0.9 - */ - Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); - - /** - * Inserts a media into a VM. - * - *
    -    * PUT /vApp/{id}/media/action/insertMedia
    -    * 
    - * - * @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}. * *
         * 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}.
         *
         * 
         * 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.
    -    *
    -    * 
    -    * GET /vApp/{id}/networkConnectionSection
    -    * 
    - * - * @since 0.9 - */ - NetworkConnectionSection getNetworkConnectionSection(URI vmURI); - - /** - * Modifies the network connection section of a VM. - * - *
    -    * PUT /vApp/{id}/networkConnectionSection
    -    * 
    - * - * @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}. * *
         * GET /vApp/{id}/networkSection
    @@ -489,29 +364,7 @@ public interface VAppClient {
        NetworkSection getNetworkSection(URI vAppURI);
     
        /**
    -    * Retrieves the operating system section of a VM.
    -    *
    -    * 
    -    * GET /vApp/{id}/operatingSystemSection
    -    * 
    - * - * @since 0.9 - */ - OperatingSystemSection getOperatingSystemSection(URI vmURI); - - /** - * Modifies the operating system section of a VM. - * - *
    -    * PUT /vApp/{id}/operatingSystemSection
    -    * 
    - * - * @since 0.9 - */ - Task modifyOperatingSystemSection(URI vmURI, OperatingSystemSection section); - - /** - * Retrieves the owner of a vApp. + * Retrieves the owner of a {@link VApp}. * *
         * GET /vApp/{id}/owner
    @@ -522,7 +375,7 @@ public interface VAppClient {
        Owner getOwner(URI vAppURI);
     
        /**
    -    * Changes VApp owner.
    +    * Changes {@link VApp} owner.
         *
         * 
         * 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.
         *
         * 
         * 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}.
         *
         * 
         * 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.
    -    *
    -    * 
    -    * GET /vApp/{id}/question
    -    * 
    - * - * @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)}. - * - *
    -    * POST /vApp/{id}/question/action/answer
    -    * 
    - * - * @since 0.9 - */ - void answerQuestion(URI vAppURI, VmQuestionAnswer answer); - - /** - * Retrieves the runtime info section of a VM. - * - *
    -    * GET /vApp/{id}/runtimeInfoSection
    -    * 
    - * - * @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}). - * - *
    -    * GET /vApp/{id}/screen
    -    * 
    - * - * @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. - * - *
    -    * GET /vApp/{id}/screen/action/acquireTicket
    -    * 
    - * - * @since 0.9 - */ - ScreenTicket getScreenTicket(URI vAppURI); - - /** - * Retrieves the startup section of a VApp. + * Retrieves the startup section of a {@link VApp}. * *
         * 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}.
         *
         * 
         * 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.
    -    *
    -    * 
    -    * GET /vApp/{id}/virtualHardwareSection
    -    * 
    - * - * @since 0.9 - */ - VirtualHardwareSection getVirtualHardwareSection(URI vmURI); - - /** - * Modifies the virtual hardware section of a VM. - * - *
    -    * PUT /vApp/{id}/virtualHardwareSection
    -    * 
    - * - * @since 0.9 - */ - Task modifyVirtualHardwareSection(URI vmURI, VirtualHardwareSection section); - - /** - * Retrieves the CPU properties in virtual hardware section of a VM. - * - *
    -    * GET /vApp/{id}/virtualHardwareSection/cpu
    -    * 
    - * - * @since 0.9 - */ - RasdItem getVirtualHardwareSectionCpu(URI vmURI); - - /** - * Modifies the CPU properties in virtual hardware section of a VM. - * - *
    -    * PUT /vApp/{id}/virtualHardwareSection/cpu
    -    * 
    - * - * @since 0.9 - */ - Task modifyVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd); - - /** - * Retrieves a list of ResourceAllocationSettingData items for disks from virtual hardware section of a VM. - * - *
    -    * GET /vApp/{id}/virtualHardwareSection/disks
    -    * 
    - * - * @since 0.9 - */ - RasdItemsList getVirtualHardwareSectionDisks(URI vmURI); - - /** - * Modifies the disks list in virtual hardware section of a VM. - * - *
    -    * PUT /vApp/{id}/virtualHardwareSection/disks
    -    * 
    - * - * @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. - * - *
    -    * GET /vApp/{id}/virtualHardwareSection/media
    -    * 
    - * - * @since 0.9 - */ - RasdItemsList getVirtualHardwareSectionMedia(URI vmURI); - - /** - * Retrieves the ResourceAllocationSettingData item that contains memory information from virtual hardware section of a VM. - * - *
    -    * GET /vApp/{id}/virtualHardwareSection/memory
    -    * 
    - * - * @since 0.9 - */ - RasdItem getVirtualHardwareSectionMemory(URI vmURI); - - /** - * Modifies the memory properties in virtual hardware section of a VM. - * - *
    -    * PUT /vApp/{id}/virtualHardwareSection/memory
    -    * 
    - * - * @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. - * - *
    -    * GET /vApp/{id}/virtualHardwareSection/networkCards
    -    * 
    - * - * @since 0.9 - */ - RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI); - - /** - * Modifies the network cards list in virtual hardware section of a VM. - * - *
    -    * PUT /vApp/{id}/virtualHardwareSection/networkCards
    -    * 
    - * - * @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. - * - *
    -    * GET /vApp/{id}/virtualHardwareSection/serialPorts
    -    * 
    - * - * @since 1.5 - */ - RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI); - - /** - * Modifies the serial ports list in virtual hardware section of a VM. - * - *
    -    * PUT /vApp/{id}/virtualHardwareSection/serialPorts
    -    * 
    - * - * @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(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncClient.java new file mode 100644 index 0000000000..aea8247d04 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncClient.java @@ -0,0 +1,691 @@ +/* + * 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.CONTROL_ACCESS; +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.LEASE_SETTINGS_SECTION; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.MEDIA_PARAMS; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.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.OWNER; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.PRODUCT_SECTION_LIST; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RECOMPOSE_VAPP_PARAMS; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_VM_PARAMS; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.STARTUP_SECTION; +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.VAPP; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VIRTUAL_HARDWARE_SECTION; +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.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.StartupSection; +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.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; +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 VAppClient + */ +@RequestFilters(AddVCloudAuthorizationToRequest.class) +public interface VmAsyncClient { + + /** + * @see VAppClient#getVApp(URI) + */ + @GET + @Consumes(VAPP) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVApp(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyVApp(URI, VApp) + */ + @PUT + @Produces(VAPP) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVApp(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) VApp vApp); + + /** + * @see VAppClient#deleteVApp(URI) + */ + @DELETE + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture deleteVApp(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#consolidateVm(URI) + */ + @POST + @Path("/action/consolidate") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture consolidateVm(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyControlAccess(URI, ControlAccessParams) + */ + @POST + @Path("/action/controlAccess") + @Produces(CONTROL_ACCESS) + @Consumes(CONTROL_ACCESS) + @JAXBResponseParser + ListenableFuture modifyControlAccess(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) ControlAccessParams params); + + /** + * @see VAppClient#deploy(URI, DeployVAppParams) + */ + @POST + @Path("/action/deploy") + @Produces(DEPLOY_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture deploy(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) DeployVAppParams params); + + /** + * @see VAppClient#discardSuspendedState(URI) + */ + @POST + @Path("/action/discardSuspendedState") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture discardSuspendedState(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#enterMaintenanceMode(URI) + */ + @POST + @Path("/action/enterMaintenanceMode") + @Consumes + @JAXBResponseParser + ListenableFuture enterMaintenanceMode(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#exitMaintenanceMode(URI) + */ + @POST + @Path("/action/exitMaintenanceMode") + @Consumes + @JAXBResponseParser + ListenableFuture exitMaintenanceMode(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#installVMwareTools(URI) + */ + @POST + @Path("/action/installVMwareTools") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture installVMwareTools(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#recompose(URI, RecomposeVAppParams) + */ + @POST + @Path("/action/recomposeVApp") + @Produces(RECOMPOSE_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture 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 relocateVm(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) RelocateParams params); + + /** + * @see VAppClient#undeploy(URI, UndeployVAppParams) + */ + @POST + @Path("/action/undeploy") + @Produces(UNDEPLOY_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture undeploy(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); + + /** + * @see VAppClient#upgradeHardwareVersion(URI) + */ + @POST + @Path("/action/upgradeHardwareVersion") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture upgradeHardwareVersion(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#getControlAccess(URI) + */ + @GET + @Path("/controlAccess") + @Consumes(CONTROL_ACCESS) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getControlAccess(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#powerOff(URI) + */ + @POST + @Path("/power/action/powerOff") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture powerOff(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#powerOn(URI) + */ + @POST + @Path("/power/action/powerOn") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture powerOn(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#reboot(URI) + */ + @POST + @Path("/power/action/powerOff") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture reboot(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#reset(URI) + */ + @POST + @Path("/power/action/reset") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture reset(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#shutdown(URI) + */ + @POST + @Path("/power/action/shutdown") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture shutdown(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#suspend(URI) + */ + @POST + @Path("/power/action/suspend") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture suspend(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#getGuestCustomizationSection(URI) + */ + @GET + @Path("/guestCustomizationSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getGuestCustomizationSection(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyGuestCustomizationSection(URI, GuestCustomizationSection) + */ + @PUT + @Path("/guestCustomizationSection") + @Produces(GUEST_CUSTOMIZATION_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyGuestCustomizationSection(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); + + /** + * @see VAppClient#getLeaseSettingsSection(URI) + */ + @GET + @Path("/leaseSettingsSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getLeaseSettingsSection(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyLeaseSettingsSection(URI, LeaseSettingsSection) + */ + @PUT + @Path("/leaseSettingsSection") + @Produces(LEASE_SETTINGS_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture 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 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 insertMedia(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); + + /** + * @see VAppClient#getNetworkConfigSection(URI) + */ + @GET + @Path("/networkConfigSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkConfigSection(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyNetworkConfigSection(URI, NetworkConfigSection) + */ + @PUT + @Path("/networkConfigSection") + @Produces(NETWORK_CONFIG_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyNetworkConfigSection(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) NetworkConfigSection section); + + /** + * @see VAppClient#getNetworkConnectionSection(URI) + */ + @GET + @Path("/networkConnectionSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkConnectionSection(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyNetworkConnectionSection(URI, NetworkConnectionSection) + */ + @PUT + @Path("/networkConnectionSection") + @Produces(NETWORK_CONNECTION_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyNetworkConnectionSection(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); + + /** + * @see VAppClient#getNetworkSection(URI) + */ + @GET + @Path("/networkSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkSection(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#getOperatingSystemSection(URI) + */ + @GET + @Path("/operatingSystemSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOperatingSystemSection(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyOperatingSystemSection(URI, OperatingSystemSection) + */ + @PUT + @Path("/operatingSystemSection") + @Produces(OPERATING_SYSTEM_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyOperatingSystemSection(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) OperatingSystemSection section); + + /** + * @see VAppClient#getOwner(URI) + */ + @GET + @Path("/owner") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOwner(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyOwner(URI, Owner) + */ + @PUT + @Path("/owner") + @Produces(OWNER) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyOwner(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) Owner owner); + + /** + * @see VAppClient#getProductSections(URI) + */ + @GET + @Path("/productSections") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getProductSections(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyProductSections(URI, ProductSectionList) + */ + @PUT + @Path("/productSections") + @Produces(PRODUCT_SECTION_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyProductSections(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); + + /** + * @see VAppClient#getPendingQuestion(URI) + */ + @GET + @Path("/question") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPendingQuestion(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#answerQuestion(URI, VmQuestionAnswer) + */ + @POST + @Path("/question/action/answer") + @Produces(VM_PENDING_ANSWER) + @Consumes + @JAXBResponseParser + ListenableFuture answerQuestion(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer); + + /** + * @see VAppClient#getRuntimeInfoSection(URI) + */ + @GET + @Path("/runtimeInfoSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getRuntimeInfoSection(@EndpointParam URI vmURI); + + /** + * @see VAppClient#getScreenImage(URI) + */ + @GET + @Path("/screen") + @Consumes(ANY_IMAGE) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @ResponseParser(ReturnPayloadBytes.class) + ListenableFuture getScreenImage(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#getScreenTicket(URI) + */ + @POST + @Path("/screen/action/acquireTicket") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getScreenTicket(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#getStartupSection(URI) + */ + @GET + @Path("/startupSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getStartupSection(@EndpointParam URI vAppURI); + + /** + * @see VAppClient#modifyStartupSection(URI, StartupSection) + */ + @PUT + @Path("/startupSection") + @Produces(STARTUP_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyStartupSection(@EndpointParam URI vAppURI, + @BinderParam(BindToXMLPayload.class) StartupSection section); + + /** + * @see VAppClient#getVirtualHardwareSection(URI) + */ + @GET + @Path("/virtualHardwareSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSection(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyVirtualHardwareSection(URI, VirtualHardwareSection) + */ + @PUT + @Path("/virtualHardwareSection") + @Produces(VIRTUAL_HARDWARE_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVirtualHardwareSection(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) VirtualHardwareSection section); + + /** + * @see VAppClient#getVirtualHardwareSectionCpu(URI) + */ + @GET + @Path("/virtualHardwareSection/cpu") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData) + */ + @PUT + @Path("/virtualHardwareSection/cpu") + @Produces(OVF_RASD_ITEM) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVirtualHardwareSectionCpu(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) RasdItem rasd); + + /** + * @see VAppClient#getVirtualHardwareSectionDisks(URI) + */ + @GET + @Path("/virtualHardwareSection/disks") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionDisks(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyVirtualHardwareSectionDisks(URI, RasdItemsList) + */ + @PUT + @Path("/virtualHardwareSection/disks") + @Produces(OVF_RASD_ITEMS_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVirtualHardwareSectionDisks(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + + /** + * @see VAppClient#getVirtualHardwareSectionMedia(URI) + */ + @GET + @Path("/virtualHardwareSection/media") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionMedia(@EndpointParam URI vmURI); + + /** + * @see VAppClient#getVirtualHardwareSectionMemory(URI) + */ + @GET + @Path("/virtualHardwareSection/memory") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData) + */ + @PUT + @Path("/virtualHardwareSection/memory") + @Produces(OVF_RASD_ITEM) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVirtualHardwareSectionMemory(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) RasdItem rasd); + + /** + * @see VAppClient#getVirtualHardwareSectionNetworkCards(URI) + */ + @GET + @Path("/virtualHardwareSection/networkCards") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyVirtualHardwareSectionNetworkCards(URI, RasdItemsList) + */ + @PUT + @Path("/virtualHardwareSection/networkCards") + @Produces(OVF_RASD_ITEMS_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + + /** + * @see VAppClient#getVirtualHardwareSectionSerialPorts(URI) + */ + @GET + @Path("/virtualHardwareSection/serialPorts") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI); + + /** + * @see VAppClient#modifyVirtualHardwareSectionSerialPorts(URI, RasdItemsList) + */ + @PUT + @Path("/virtualHardwareSection/serialPorts") + @Produces(OVF_RASD_ITEMS_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture modifyVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + + /** + * @return asynchronous access to {@link Metadata} features + */ + @Delegate + MetadataAsyncClient.Writeable getMetadataClient(); + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmClient.java new file mode 100644 index 0000000000..e927ec9e37 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmClient.java @@ -0,0 +1,794 @@ +/* + * 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.dmtf.ovf.NetworkSection; +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. + * + * @author grkvlt@apache.org + * @see VAppAsyncClient + * @version 1.5 + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface VmClient { + + /** + * Retrieves a vApp/VM. + * + * The vApp/VM could be in one of these statuses: + *
      + *
    • {@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 + * exist yet. This is further sub-categorized in the respective entities. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED UNRESOLVED(0)} - + * Entity is whole, e.g., VM creation is complete and all the required model objects and VC backings are + * created. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED RESOLVED(1)} - + * Entity is resolved. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#DEPLOYED DEPLOYED(2)} - + * Entity is deployed. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#SUSPENDED SUSPENDED(3)} - + * All VMs of the vApp are suspended. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_ON POWERED_ON(4)} - + * All VMs of the vApp are powered on. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#WAITING_FOR_INPUT WAITING_FOR_INPUT(5)} - + * VM is pending response on a question. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN UNKNOWN(6)} - + * Entity state could not be retrieved from the inventory, e.g., VM power state is null. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRECOGNIZED UNRECOGNIZED(7)} - + * Entity state was retrieved from the inventory but could not be mapped to an internal state. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF POWERED_OFF(8)} - + * All VMs of the vApp are powered off. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#INCONSISTENT_STATE INCONSISTENT_STATE(9)} - + * Apply to VM status, if a vm is {@code POWERED_ON}, or {@code WAITING_FOR_INPUT}, but is + * undeployed, it is in an inconsistent state. + *
    • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} - + * vApp status is set to {@code MIXED} when the VMs in the vApp are in different power states + *
    + * + *
    +    * GET /vApp/{id}
    +    * 
    + * + * @since 0.9 + */ + VApp getVApp(URI vAppURI); + + /** + * Modifies the name/description of a vApp/VM. + * + *
    +    * PUT /vApp/{id}
    +    * 
    + * + * @since 0.9 + */ + Task modifyVApp(URI vAppURI, VApp vApp); + + /** + * Deletes a vApp/VM. + * + *
    +    * DELETE /vApp/{id}
    +    * 
    + * + * @since 0.9 + */ + Task deleteVApp(URI vAppURI); + + /** + * Consolidates a vm. + * + *
    +    * POST /vApp/{id}/action/consolidate
    +    * 
    + * + * @since 1.5 + */ + Task consolidateVm(URI vAppURI); + + /** + * Modifies the control access of a vApp. + * + *
    +    * POST /vApp/{id}/action/controlAccess
    +    * 
    + * + * @since 0.9 + */ + ControlAccessParams modifyControlAccess(URI vAppURI, ControlAccessParams params); + + /** + * Deploys a vApp/VM. + * + * 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 + * virtual machines it contains. As of version 1.5 the operation supports force + * customization passed with {@link DeployVAppParamsType#setForceCustomization(Boolean)} + * parameter. + * + *
    +    * POST /vApp/{id}/action/deploy
    +    * 
    + * + * @since 0.9 + */ + Task deploy(URI vAppURI, DeployVAppParams params); + + /** + * Discard suspended state of a vApp/VM. + * + * Discarding suspended state of a vApp automatically discarded suspended + * states of all of the virtual machines it contains. + * + *
    +    * POST /vApp/{id}/action/discardSuspendedState
    +    * 
    + * + * @since 0.9 + */ + Task discardSuspendedState(URI vAppURI); + + /** + * Place the 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 + * user-initiated tasks running when the vApp enters maintenance mode will + * continue. + * + *
    +    * POST /vApp/{id}/action/enterMaintenanceMode
    +    * 
    + * + * @since 1.5 + */ + void enterMaintenanceMode(URI vAppURI); + + /** + * Take the vApp out of maintenance mode. + * + *
    +    * POST /vApp/{id}/action/exitMaintenanceMode
    +    * 
    + * + * @since 1.5 + */ + void exitMaintenanceMode(URI vAppURI); + + /** + * Installs VMware tools to the virtual machine. + * + * It should be running in order for them to be installed. + * + *
    +    * POST /vApp/{id}/action/installVMwareTools
    +    * 
    + * + * @since 1.5 + */ + Task installVMwareTools(URI vAppURI); + + /** + * Recompose a 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 + * VMs is the same as described in compose vApp operation + * {@link VdcClient#composeVApp(URI, org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams)}. + * The status of vApp will be in {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED} + * until the recompose task is finished. + * + *
    +    * POST /vApp/{id}/action/recomposeVApp
    +    * 
    + * + * @since 1.0 + */ + Task recompose(URI vAppURI, RecomposeVAppParams params); + + /** + * Relocates a vm. + * + *
    +    * POST /vApp/{id}/action/relocate
    +    * 
    + * + * @since 1.5 + */ + Task relocateVm(URI vAppURI, RelocateParams params); + + /** + * Undeploy a vApp/VM. + * + * Undeployment means deallocation of all resources for a vApp/VM like CPU + * and memory from a vDC resource pool. Undeploying a vApp automatically + * undeploys all of the virtual machines it contains. + * + *
    +    * POST /vApp/{id}/action/undeploy
    +    * 
    + * + * @since 0.9 + */ + 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. + * + *
    +    * POST /vApp/{id}/action/upgradeHardwareVersion
    +    * 
    + * + * @since 1.5 + */ + Task upgradeHardwareVersion(URI vAppURI); + + /** + * Retrieves the control access information for a vApp. + * + * The vApp could be shared to everyone or could be shared to specific user, + * by modifying the control access values. + * + *
    +    * GET /vApp/{id}/controlAccess
    +    * 
    + * + * @since 0.9 + */ + ControlAccessParams getControlAccess(URI vAppURI); + + /** + * Powers off a vApp/VM. + * + * 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. + * + *
    +    * POST /vApp/{id}/power/action/powerOff
    +    * 
    + * + * @since 0.9 + */ + Task powerOff(URI vAppURI); + + /** + * Powers on a vApp/VM. + * + * 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. + * + *
    +    * POST /vApp/{id}/power/action/powerOn
    +    * 
    + * + * @since 0.9 + */ + Task powerOn(URI vAppURI); + + /** + * Reboots a vApp/VM. + * + * The vApp/VM should be started in order to reboot it. + * + *
    +    * POST /vApp/{id}/power/action/reboot
    +    * 
    + * + * @since 0.9 + */ + Task reboot(URI vAppURI); + + /** + * Resets a vApp/VM. + * + * 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. + * + *
    +    * POST /vApp/{id}/power/action/reset
    +    * 
    + * + * @since 0.9 + */ + Task reset(URI vAppURI); + + /** + * Shutdowns a vApp/VM. + * + * 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. + * + *
    +    * POST /vApp/{id}/power/action/shutdown
    +    * 
    + * + * @since 0.9 + */ + Task shutdown(URI vAppURI); + + /** + * Suspends a vApp/VM. + * + * 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. + * + *
    +    * POST /vApp/{id}/power/action/suspend
    +    * 
    + * + * @since 0.9 + */ + Task suspend(URI vAppURI); + + /** + * Retrieves the guest customization section of a VM. + * + *
    +    * GET /vApp/{id}/guestCustomizationSection
    +    * 
    + * + * @since 1.0 + */ + GuestCustomizationSection getGuestCustomizationSection(URI vmURI); + + /** + * Modifies the guest customization section of a VM. + * + *
    +    * PUT /vApp/{id}/guestCustomizationSection
    +    * 
    + * + * @since 1.0 + */ + Task modifyGuestCustomizationSection(URI vmURI, GuestCustomizationSection section); + + /** + * Retrieves the lease settings section of a vApp or vApp template. + * + *
    +    * GET /vApp/{id}/leaseSettingsSection
    +    * 
    + * + * @since 0.9 + */ + LeaseSettingsSection getLeaseSettingsSection(URI vAppURI); + + /** + * Modifies the lease settings section of a vApp or vApp template. + * + *
    +    * PUT /vApp/{id}/leaseSettingsSection
    +    * 
    + * + * @since 0.9 + */ + Task modifyLeaseSettingsSection(URI vAppURI, LeaseSettingsSection section); + + /** + * Ejects a media from a VM. + * + *
    +    * PUT /vApp/{id}/media/action/ejectMedia
    +    * 
    + * + * @since 0.9 + */ + Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); + + /** + * Inserts a media into a VM. + * + *
    +    * PUT /vApp/{id}/media/action/insertMedia
    +    * 
    + * + * @since 0.9 + */ + Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); + + /** + * Retrieves the network config section of a vApp or vApp template. + * + *
    +    * GET /vApp/{id}/networkConfigSection
    +    * 
    + * + * @since 0.9 + */ + NetworkConfigSection getNetworkConfigSection(URI vmURI); + + /** + * Modifies the network config section of a vApp. + * + *
    +    * PUT /vApp/{id}/networkConfigSection
    +    * 
    + * + * @since 0.9 + */ + Task modifyNetworkConfigSection(URI vmURI, NetworkConfigSection section); + + /** + * Retrieves the network connection section of a VM. + * + *
    +    * GET /vApp/{id}/networkConnectionSection
    +    * 
    + * + * @since 0.9 + */ + NetworkConnectionSection getNetworkConnectionSection(URI vmURI); + + /** + * Modifies the network connection section of a VM. + * + *
    +    * PUT /vApp/{id}/networkConnectionSection
    +    * 
    + * + * @since 0.9 + */ + Task modifyNetworkConnectionSection(URI vmURI, NetworkConnectionSection section); + + /** + * Retrieves the network section of a vApp or vApp template. + * + *
    +    * GET /vApp/{id}/networkSection
    +    * 
    + * + * @since 0.9 + */ + NetworkSection getNetworkSection(URI vAppURI); + + /** + * Retrieves the operating system section of a VM. + * + *
    +    * GET /vApp/{id}/operatingSystemSection
    +    * 
    + * + * @since 0.9 + */ + OperatingSystemSection getOperatingSystemSection(URI vmURI); + + /** + * Modifies the operating system section of a VM. + * + *
    +    * PUT /vApp/{id}/operatingSystemSection
    +    * 
    + * + * @since 0.9 + */ + Task modifyOperatingSystemSection(URI vmURI, OperatingSystemSection section); + + /** + * Retrieves the owner of a vApp. + * + *
    +    * GET /vApp/{id}/owner
    +    * 
    + * + * @since 1.5 + */ + Owner getOwner(URI vAppURI); + + /** + * Changes VApp owner. + * + *
    +    * PUT /vApp/{id}/owner
    +    * 
    + * + * @since 1.5 + */ + void modifyOwner(URI vAppURI, Owner owner); + + /** + * Retrieves VAppTemplate/VM product sections. + * + *
    +    * GET /vApp/{id}/productSections
    +    * 
    + * + * @since 1.5 + */ + ProductSectionList getProductSections(URI vAppURI); + + /** + * Modifies the product section information of a vApp/VM. + * + *
    +    * PUT /vApp/{id}/productSections
    +    * 
    + * + * @since 1.5 + */ + 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. + * + *
    +    * GET /vApp/{id}/question
    +    * 
    + * + * @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)}. + * + *
    +    * POST /vApp/{id}/question/action/answer
    +    * 
    + * + * @since 0.9 + */ + void answerQuestion(URI vAppURI, VmQuestionAnswer answer); + + /** + * Retrieves the runtime info section of a VM. + * + *
    +    * GET /vApp/{id}/runtimeInfoSection
    +    * 
    + * + * @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}). + * + *
    +    * GET /vApp/{id}/screen
    +    * 
    + * + * @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. + * + *
    +    * GET /vApp/{id}/screen/action/acquireTicket
    +    * 
    + * + * @since 0.9 + */ + ScreenTicket getScreenTicket(URI vAppURI); + + /** + * Retrieves the startup section of a VApp. + * + *
    +    * GET /vApp/{id}/startupSection
    +    * 
    + * + * @since 0.9 + */ + StartupSection getStartupSection(URI vAppURI); + + /** + * Modifies the startup section of a VApp. + * + *
    +    * PUT /vApp/{id}/startupSection
    +    * 
    + * + * @since 0.9 + */ + Task modifyStartupSection(URI vAppURI, StartupSection section); + + /** + * Retrieves the virtual hardware section of a VM. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection
    +    * 
    + * + * @since 0.9 + */ + VirtualHardwareSection getVirtualHardwareSection(URI vmURI); + + /** + * Modifies the virtual hardware section of a VM. + * + *
    +    * PUT /vApp/{id}/virtualHardwareSection
    +    * 
    + * + * @since 0.9 + */ + Task modifyVirtualHardwareSection(URI vmURI, VirtualHardwareSection section); + + /** + * Retrieves the CPU properties in virtual hardware section of a VM. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection/cpu
    +    * 
    + * + * @since 0.9 + */ + RasdItem getVirtualHardwareSectionCpu(URI vmURI); + + /** + * Modifies the CPU properties in virtual hardware section of a VM. + * + *
    +    * PUT /vApp/{id}/virtualHardwareSection/cpu
    +    * 
    + * + * @since 0.9 + */ + Task modifyVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd); + + /** + * Retrieves a list of ResourceAllocationSettingData items for disks from virtual hardware section of a VM. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection/disks
    +    * 
    + * + * @since 0.9 + */ + RasdItemsList getVirtualHardwareSectionDisks(URI vmURI); + + /** + * Modifies the disks list in virtual hardware section of a VM. + * + *
    +    * PUT /vApp/{id}/virtualHardwareSection/disks
    +    * 
    + * + * @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. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection/media
    +    * 
    + * + * @since 0.9 + */ + RasdItemsList getVirtualHardwareSectionMedia(URI vmURI); + + /** + * Retrieves the ResourceAllocationSettingData item that contains memory information from virtual hardware section of a VM. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection/memory
    +    * 
    + * + * @since 0.9 + */ + RasdItem getVirtualHardwareSectionMemory(URI vmURI); + + /** + * Modifies the memory properties in virtual hardware section of a VM. + * + *
    +    * PUT /vApp/{id}/virtualHardwareSection/memory
    +    * 
    + * + * @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. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection/networkCards
    +    * 
    + * + * @since 0.9 + */ + RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI); + + /** + * Modifies the network cards list in virtual hardware section of a VM. + * + *
    +    * PUT /vApp/{id}/virtualHardwareSection/networkCards
    +    * 
    + * + * @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. + * + *
    +    * GET /vApp/{id}/virtualHardwareSection/serialPorts
    +    * 
    + * + * @since 1.5 + */ + RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI); + + /** + * Modifies the serial ports list in virtual hardware section of a VM. + * + *
    +    * PUT /vApp/{id}/virtualHardwareSection/serialPorts
    +    * 
    + * + * @since 1.5 + */ + Task modifyVirtualHardwareSectionSerialPorts(URI vmURI, RasdItemsList rasdItemsList); + + /** + * @return synchronous access to {@link Metadata} features + */ + @Delegate + MetadataClient.Writeable getMetadataClient(); +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java index 90b848b5e9..60cd65bfde 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java @@ -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(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java index fda7a3686e..cf0c5803bc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java @@ -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(); }