mirror of https://github.com/apache/jclouds.git
Issue 571:added cpu/mem update methods and tested lightly
This commit is contained in:
parent
9f1f61d3b4
commit
352a5e1cc1
|
@ -21,6 +21,7 @@ package org.jclouds.vcloud;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML;
|
||||||
|
import static org.jclouds.vcloud.VCloudMediaType.RASDITEM_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
|
||||||
|
@ -56,11 +57,13 @@ import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
import org.jclouds.vcloud.binders.BindCPUCountToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindGuestCustomizationSectionToXmlPayload;
|
import org.jclouds.vcloud.binders.BindGuestCustomizationSectionToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
||||||
|
import org.jclouds.vcloud.binders.BindMemoryToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindNetworkConnectionSectionToXmlPayload;
|
import org.jclouds.vcloud.binders.BindNetworkConnectionSectionToXmlPayload;
|
||||||
import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
|
||||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||||
|
@ -89,7 +92,9 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* Provides access to VCloud resources via their REST API.
|
* Provides access to VCloud resources via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
* @see <a href=
|
||||||
|
* "https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
||||||
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@RequestFilters(SetVCloudTokenCookie.class)
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
|
@ -216,6 +221,28 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends Vm> getVm(@EndpointParam URI vm);
|
ListenableFuture<? extends Vm> getVm(@EndpointParam URI vm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VCloudClient#updateCPUCountOfVm
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Consumes(TASK_XML)
|
||||||
|
@Produces(RASDITEM_XML)
|
||||||
|
@Path("/virtualHardwareSection/cpu")
|
||||||
|
@XMLResponseParser(TaskHandler.class)
|
||||||
|
ListenableFuture<? extends Task> updateCPUCountOfVm(@EndpointParam URI vm,
|
||||||
|
@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VCloudClient#updateMemoryMBOfVm
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Consumes(TASK_XML)
|
||||||
|
@Produces(RASDITEM_XML)
|
||||||
|
@Path("/virtualHardwareSection/memory")
|
||||||
|
@XMLResponseParser(TaskHandler.class)
|
||||||
|
ListenableFuture<? extends Task> updateMemoryMBOfVm(@EndpointParam URI vm,
|
||||||
|
@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VCloudClient#updateGuestCustomizationOfVm
|
* @see VCloudClient#updateGuestCustomizationOfVm
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,9 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
* Provides access to VCloud resources via their REST API.
|
* Provides access to VCloud resources via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
|
* @see <a
|
||||||
|
* href="http://communities.vmware.com/community/developer/forums/vcloudapi"
|
||||||
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
|
@ -58,8 +60,8 @@ public interface VCloudClient extends CommonVCloudClient {
|
||||||
InputStream getThumbnailOfVm(URI vm);
|
InputStream getThumbnailOfVm(URI vm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The response to a login request includes a list of the organizations to which the
|
* The response to a login request includes a list of the organizations to
|
||||||
* authenticated user has access.
|
* which the authenticated user has access.
|
||||||
*
|
*
|
||||||
* @return organizations indexed by name
|
* @return organizations indexed by name
|
||||||
*/
|
*/
|
||||||
|
@ -70,8 +72,8 @@ public interface VCloudClient extends CommonVCloudClient {
|
||||||
Task cloneVAppInVDC(URI vDC, URI toClone, String newName, CloneVAppOptions... options);
|
Task cloneVAppInVDC(URI vDC, URI toClone, String newName, CloneVAppOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The captureVApp request creates a vApp template from an instantiated vApp. <h4>Note</h4>
|
* The captureVApp request creates a vApp template from an instantiated vApp.
|
||||||
* Before it can be captured, a vApp must be undeployed
|
* <h4>Note</h4> Before it can be captured, a vApp must be undeployed
|
||||||
*
|
*
|
||||||
* @param vDC
|
* @param vDC
|
||||||
* @param toClone
|
* @param toClone
|
||||||
|
@ -108,8 +110,9 @@ public interface VCloudClient extends CommonVCloudClient {
|
||||||
Task updateNetworkConnectionOfVm(URI vm, NetworkConnectionSection guestCustomizationSection);
|
Task updateNetworkConnectionOfVm(URI vm, NetworkConnectionSection guestCustomizationSection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the vapp template corresponding to a catalog item in the catalog associated with the
|
* returns the vapp template corresponding to a catalog item in the catalog
|
||||||
* specified name. Note that the org and catalog parameters can be null to choose default.
|
* associated with the specified name. Note that the org and catalog
|
||||||
|
* parameters can be null to choose default.
|
||||||
*
|
*
|
||||||
* @param orgName
|
* @param orgName
|
||||||
* organization name, or null for the default
|
* organization name, or null for the default
|
||||||
|
@ -119,7 +122,8 @@ public interface VCloudClient extends CommonVCloudClient {
|
||||||
* item you wish to lookup
|
* item you wish to lookup
|
||||||
*
|
*
|
||||||
* @throws NoSuchElementException
|
* @throws NoSuchElementException
|
||||||
* if you specified an org, catalog, or catalog item name that isn't present
|
* if you specified an org, catalog, or catalog item name that
|
||||||
|
* isn't present
|
||||||
*/
|
*/
|
||||||
VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName,
|
VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName,
|
||||||
String itemName);
|
String itemName);
|
||||||
|
@ -131,97 +135,129 @@ public interface VCloudClient extends CommonVCloudClient {
|
||||||
Vm getVm(URI vm);
|
Vm getVm(URI vm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp
|
* update the cpuCount of an existing VM
|
||||||
* automatically deploys all of the virtual machines it contains. To deploy a virtual machine,
|
*
|
||||||
* the client makes a request to its action/deploy URL.
|
* @param vm
|
||||||
|
* to update
|
||||||
|
* @param cpuCount
|
||||||
|
* count to change the primary cpu to
|
||||||
|
*/
|
||||||
|
Task updateCPUCountOfVm(URI vm, int cpuCount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update the memoryInMB of an existing VM
|
||||||
|
*
|
||||||
|
* @param vm
|
||||||
|
* to update
|
||||||
|
* @param memoryInMB
|
||||||
|
* memory in MB to assign to the VM
|
||||||
|
*/
|
||||||
|
Task updateMemoryMBOfVm(URI vm, int memoryInMB);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To deploy a vApp, the client makes a request to its action/deploy URL.
|
||||||
|
* Deploying a vApp automatically deploys all of the virtual machines it
|
||||||
|
* contains. To deploy a virtual machine, the client makes a request to its
|
||||||
|
* action/deploy URL.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed.
|
* Deploying a Vm implicitly deploys the parent vApp if that vApp is not
|
||||||
|
* already deployed.
|
||||||
*/
|
*/
|
||||||
Task deployVAppOrVm(URI vAppOrVmId);
|
Task deployVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on state
|
* like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on
|
||||||
|
* state
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Task deployAndPowerOnVAppOrVm(URI vAppOrVmId);
|
Task deployAndPowerOnVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees
|
* Undeploying a vApp powers off or suspends any running virtual machines it
|
||||||
* the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false
|
* contains, then frees the resources reserved for the vApp and sets the
|
||||||
* to indicate that it is not deployed.
|
* vApp’s deploy attribute to a value of false to indicate that it is not
|
||||||
|
* deployed.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Undeploying a virtual machine powers off or suspends the virtual machine, then frees the
|
* Undeploying a virtual machine powers off or suspends the virtual machine,
|
||||||
* resources reserved for it and sets the its deploy attribute to a value of false to indicate
|
* then frees the resources reserved for it and sets the its deploy attribute
|
||||||
* that it is not deployed. This operation has no effect on the containing vApp.
|
* to a value of false to indicate that it is not deployed. This operation
|
||||||
|
* has no effect on the containing vApp.
|
||||||
* <h4>NOTE</h4>
|
* <h4>NOTE</h4>
|
||||||
* Using this method will simply power off the vms. In order to save their state, use
|
* Using this method will simply power off the vms. In order to save their
|
||||||
* {@link #undeployAndSaveStateOfVAppOrVm}
|
* state, use {@link #undeployAndSaveStateOfVAppOrVm}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Task undeployVAppOrVm(URI vAppOrVmId);
|
Task undeployVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines are suspended and
|
* like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines
|
||||||
* their suspend state saved
|
* are suspended and their suspend state saved
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Task undeployAndSaveStateOfVAppOrVm(URI vAppOrVmId);
|
Task undeployAndSaveStateOfVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as
|
* A powerOn request to a vApp URL powers on all of the virtual machines in
|
||||||
* specified in the vApp’s StartupSection field.
|
* the vApp, as specified in the vApp’s StartupSection field.
|
||||||
* <p/>
|
* <p/>
|
||||||
* A powerOn request to a virtual machine URL powers on the specified virtual machine and forces
|
* A powerOn request to a virtual machine URL powers on the specified virtual
|
||||||
* deployment of the parent vApp.
|
* machine and forces deployment of the parent vApp.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is undeployed forces
|
* <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is
|
||||||
* deployment.
|
* undeployed forces deployment.
|
||||||
*/
|
*/
|
||||||
Task powerOnVAppOrVm(URI vAppOrVmId);
|
Task powerOnVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as
|
* A powerOff request to a vApp URL powers off all of the virtual machines in
|
||||||
* specified in its StartupSection field.
|
* the vApp, as specified in its StartupSection field.
|
||||||
* <p/>
|
* <p/>
|
||||||
* A powerOff request to a virtual machine URL powers off the specified virtual machine.
|
* A powerOff request to a virtual machine URL powers off the specified
|
||||||
|
* virtual machine.
|
||||||
*/
|
*/
|
||||||
Task powerOffVAppOrVm(URI vAppOrVmId);
|
Task powerOffVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as
|
* A shutdown request to a vApp URL shuts down all of the virtual machines in
|
||||||
* specified in its StartupSection field.
|
* the vApp, as specified in its StartupSection field.
|
||||||
* <p/>
|
* <p/>
|
||||||
* A shutdown request to a virtual machine URL shuts down the specified virtual machine.
|
* A shutdown request to a virtual machine URL shuts down the specified
|
||||||
|
* virtual machine.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <h4>NOTE</h4Because this request sends a signal to the guest OS, the vCloud API cannot track
|
* <h4>NOTE</h4Because this request sends a signal to the guest OS, the
|
||||||
* the progress or verify the result of the requested operation. Hence, void is returned
|
* vCloud API cannot track the progress or verify the result of the requested
|
||||||
|
* operation. Hence, void is returned
|
||||||
*/
|
*/
|
||||||
void shutdownVAppOrVm(URI vAppOrVmId);
|
void shutdownVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reset request to a vApp URL resets all of the virtual machines in the vApp, as specified in
|
* A reset request to a vApp URL resets all of the virtual machines in the
|
||||||
* its StartupSection field.
|
* vApp, as specified in its StartupSection field.
|
||||||
* <p/>
|
* <p/>
|
||||||
* A reset request to a virtual machine URL resets the specified virtual machine.
|
* A reset request to a virtual machine URL resets the specified virtual
|
||||||
|
* machine.
|
||||||
*/
|
*/
|
||||||
Task resetVAppOrVm(URI vAppOrVmId);
|
Task resetVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified
|
* A reboot request to a vApp URL reboots all of the virtual machines in the
|
||||||
* in its StartupSection field.
|
* vApp, as specified in its StartupSection field.
|
||||||
* <p/>
|
* <p/>
|
||||||
* A reboot request to a virtual machine URL reboots the specified virtual machine.
|
* A reboot request to a virtual machine URL reboots the specified virtual
|
||||||
|
* machine.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <h4>NOTE</h4> Because this request sends a signal to the guest OS, the vCloud API cannot track
|
* <h4>NOTE</h4> Because this request sends a signal to the guest OS, the
|
||||||
* the progress or verify the result of the requested operation. Hence, void is returned
|
* vCloud API cannot track the progress or verify the result of the requested
|
||||||
|
* operation. Hence, void is returned
|
||||||
*/
|
*/
|
||||||
void rebootVAppOrVm(URI vAppOrVmId);
|
void rebootVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified
|
* A suspend request to a vApp URL suspends all of the virtual machines in
|
||||||
* in its StartupSection field.
|
* the vApp, as specified in its StartupSection field.
|
||||||
* <p/>
|
* <p/>
|
||||||
* A suspend request to a virtual machine URL suspends the specified virtual machine.
|
* A suspend request to a virtual machine URL suspends the specified virtual
|
||||||
|
* machine.
|
||||||
*/
|
*/
|
||||||
Task suspendVAppOrVm(URI vAppOrVmId);
|
Task suspendVAppOrVm(URI vAppOrVmId);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.binders;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class BindCPUCountToXmlPayload extends BindToStringPayload {
|
||||||
|
protected final String ns;
|
||||||
|
protected final String schema;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BindCPUCountToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||||
|
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
|
||||||
|
this.ns = ns;
|
||||||
|
this.schema = schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
|
||||||
|
checkArgument(checkNotNull(payload, "cpuCount") instanceof Integer, "this binder is only valid for Integers!");
|
||||||
|
Integer cpuCount = Integer.class.cast(payload);
|
||||||
|
XMLBuilder cpuItem;
|
||||||
|
try {
|
||||||
|
cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS);
|
||||||
|
cpuItem.e("rasd:AllocationUnits").t("hertz * 10^6");
|
||||||
|
cpuItem.e("rasd:Description").t("Number of Virtual CPUs");
|
||||||
|
cpuItem.e("rasd:ElementName").t(cpuCount.toString() + " virtual CPU(s)");
|
||||||
|
cpuItem.e("rasd:InstanceID").t("4");
|
||||||
|
cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value());
|
||||||
|
cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString());
|
||||||
|
cpuItem.e("rasd:Weight").t("0");
|
||||||
|
Properties outputProperties = new Properties();
|
||||||
|
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
|
request = super.bindToRequest(request, cpuItem.asString(outputProperties));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Throwables.propagate(e);
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.binders;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class BindMemoryToXmlPayload extends BindToStringPayload {
|
||||||
|
protected final String ns;
|
||||||
|
protected final String schema;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BindMemoryToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||||
|
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
|
||||||
|
this.ns = ns;
|
||||||
|
this.schema = schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
|
||||||
|
checkArgument(checkNotNull(payload, "memoryInMB") instanceof Integer, "this binder is only valid for Integers!");
|
||||||
|
Integer memoryInMB = Integer.class.cast(payload);
|
||||||
|
XMLBuilder cpuItem;
|
||||||
|
try {
|
||||||
|
cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS);
|
||||||
|
cpuItem.e("rasd:AllocationUnits").t("byte * 2^20");
|
||||||
|
cpuItem.e("rasd:Description").t("Memory Size");
|
||||||
|
cpuItem.e("rasd:ElementName").t(memoryInMB.toString() + " MB of memory");
|
||||||
|
cpuItem.e("rasd:InstanceID").t("5");
|
||||||
|
cpuItem.e("rasd:Reservation").t("0");
|
||||||
|
cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value());
|
||||||
|
cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString());
|
||||||
|
cpuItem.e("rasd:Weight").t("0");
|
||||||
|
Properties outputProperties = new Properties();
|
||||||
|
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
|
request = super.bindToRequest(request, cpuItem.asString(outputProperties));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Throwables.propagate(e);
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,15 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.strategy;
|
package org.jclouds.vcloud.compute.strategy;
|
||||||
|
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
@ -74,21 +72,19 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
|
public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
|
||||||
InstantiateVAppTemplateOptions options = processorCount((int) getCores(template.getHardware())).memory(
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
template.getHardware().getRam()).disk(
|
|
||||||
(long) ((template.getHardware().getVolumes().get(0).getSize()) * 1024 * 1024l));
|
// TODO make disk size specifiable
|
||||||
|
// disk((long) ((template.getHardware().getVolumes().get(0).getSize()) *
|
||||||
|
// 1024 * 1024l));
|
||||||
|
|
||||||
|
String customizationScript = VCloudTemplateOptions.class.cast(template.getOptions()).getCustomizationScript();
|
||||||
|
IpAddressAllocationMode ipAddressAllocationMode = VCloudTemplateOptions.class.cast(template.getOptions())
|
||||||
|
.getIpAddressAllocationMode();
|
||||||
|
|
||||||
String customizationScript = null;
|
|
||||||
IpAddressAllocationMode ipAddressAllocationMode = null;
|
|
||||||
if (template.getOptions() instanceof VCloudTemplateOptions) {
|
|
||||||
customizationScript = VCloudTemplateOptions.class.cast(template.getOptions()).getCustomizationScript();
|
|
||||||
ipAddressAllocationMode = VCloudTemplateOptions.class.cast(template.getOptions()).getIpAddressAllocationMode();
|
|
||||||
if (customizationScript != null || ipAddressAllocationMode != null) {
|
|
||||||
options.customizeOnInstantiate(false);
|
options.customizeOnInstantiate(false);
|
||||||
options.deploy(false);
|
options.deploy(false);
|
||||||
options.powerOn(false);
|
options.powerOn(false);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!template.getOptions().shouldBlockUntilRunning())
|
if (!template.getOptions().shouldBlockUntilRunning())
|
||||||
options.block(false);
|
options.block(false);
|
||||||
|
@ -99,44 +95,53 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
|
||||||
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
|
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
|
||||||
|
|
||||||
VApp vAppResponse = client.instantiateVAppTemplateInVDC(VDC, templateId, name, options);
|
VApp vAppResponse = client.instantiateVAppTemplateInVDC(VDC, templateId, name, options);
|
||||||
|
waitForTask(vAppResponse.getTasks().get(0), vAppResponse);
|
||||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
|
logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
|
||||||
|
|
||||||
Task task = vAppResponse.getTasks().get(0);
|
// note customization is a serial concern at the moment
|
||||||
|
|
||||||
if (customizationScript == null && ipAddressAllocationMode == null) {
|
|
||||||
return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, task);
|
|
||||||
} else {
|
|
||||||
if (!successTester.apply(task.getHref())) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
String.format("failed to %s %s: %s", "instantiate", vAppResponse.getName(), task));
|
|
||||||
}
|
|
||||||
Vm vm = Iterables.get(client.getVApp(vAppResponse.getHref()).getChildren(), 0);
|
Vm vm = Iterables.get(client.getVApp(vAppResponse.getHref()).getChildren(), 0);
|
||||||
if (customizationScript != null)
|
if (customizationScript != null) {
|
||||||
updateVmWithCustomizationScript(vm, customizationScript);
|
logger.trace(">> updating customization vm(%s) ", vm.getName());
|
||||||
if (ipAddressAllocationMode != null)
|
waitForTask(updateVmWithCustomizationScript(vm, customizationScript), vAppResponse);
|
||||||
updateVmWithIpAddressAllocationMode(vm, ipAddressAllocationMode);
|
logger.trace("<< updated customization vm(%s) ", vm.getName());
|
||||||
task = client.deployAndPowerOnVAppOrVm(vAppResponse.getHref());
|
|
||||||
return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, task);
|
|
||||||
}
|
}
|
||||||
|
if (ipAddressAllocationMode != null) {
|
||||||
|
logger.trace(">> updating ipAddressAllocationMode(%s) vm(%s) ", ipAddressAllocationMode, vm.getName());
|
||||||
|
waitForTask(updateVmWithIpAddressAllocationMode(vm, ipAddressAllocationMode), vAppResponse);
|
||||||
|
logger.trace("<< updated ipAddressAllocationMode vm(%s) ", vm.getName());
|
||||||
|
}
|
||||||
|
int cpuCount = new Double(getCores(template.getHardware())).intValue();
|
||||||
|
logger.trace(">> updating cpuCount(%d) vm(%s) ", cpuCount, vm.getName());
|
||||||
|
waitForTask(updateCPUCountOfVm(vm, cpuCount), vAppResponse);
|
||||||
|
logger.trace("<< updated cpuCount vm(%s) ", vm.getName());
|
||||||
|
int memoryMB = template.getHardware().getRam();
|
||||||
|
logger.trace(">> updating memoryMB(%d) vm(%s) ", memoryMB, vm.getName());
|
||||||
|
waitForTask(updateMemoryMBOfVm(vm, memoryMB), vAppResponse);
|
||||||
|
logger.trace("<< updated memoryMB vm(%s) ", vm.getName());
|
||||||
|
logger.trace(">> deploying and powering on vApp(%s) ", vAppResponse.getName());
|
||||||
|
return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse,
|
||||||
|
client.deployAndPowerOnVAppOrVm(vAppResponse.getHref()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVmWithCustomizationScript(Vm vm, String customizationScript) {
|
public void waitForTask(Task task, VApp vAppResponse) {
|
||||||
Task task;
|
if (!successTester.apply(task.getHref())) {
|
||||||
|
throw new RuntimeException(String.format("failed to %s %s: %s", task.getName(), vAppResponse.getName(), task));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task updateVmWithCustomizationScript(Vm vm, String customizationScript) {
|
||||||
GuestCustomizationSection guestConfiguration = vm.getGuestCustomizationSection();
|
GuestCustomizationSection guestConfiguration = vm.getGuestCustomizationSection();
|
||||||
// TODO: determine if the server version is beyond 1.0.0, and if so append to, but
|
// TODO: determine if the server version is beyond 1.0.0, and if so append
|
||||||
// not overwrite the customization script. In version 1.0.0, the api returns a script that
|
// to, but
|
||||||
|
// not overwrite the customization script. In version 1.0.0, the api
|
||||||
|
// returns a script that
|
||||||
// loses newlines.
|
// loses newlines.
|
||||||
guestConfiguration.setCustomizationScript(customizationScript);
|
guestConfiguration.setCustomizationScript(customizationScript);
|
||||||
task = client.updateGuestCustomizationOfVm(vm.getHref(), guestConfiguration);
|
return client.updateGuestCustomizationOfVm(vm.getHref(), guestConfiguration);
|
||||||
if (!successTester.apply(task.getHref())) {
|
|
||||||
throw new RuntimeException(String.format("failed to %s %s: %s", "updateGuestCustomizationOfVm", vm.getName(),
|
|
||||||
task));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVmWithIpAddressAllocationMode(Vm vm, final IpAddressAllocationMode ipAddressAllocationMode) {
|
public Task updateVmWithIpAddressAllocationMode(Vm vm, final IpAddressAllocationMode ipAddressAllocationMode) {
|
||||||
Task task;
|
|
||||||
NetworkConnectionSection net = vm.getNetworkConnectionSection();
|
NetworkConnectionSection net = vm.getNetworkConnectionSection();
|
||||||
Builder builder = net.toBuilder();
|
Builder builder = net.toBuilder();
|
||||||
builder.connections(Iterables.transform(net.getConnections(),
|
builder.connections(Iterables.transform(net.getConnections(),
|
||||||
|
@ -148,20 +153,21 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
task = client.updateNetworkConnectionOfVm(vm.getHref(), builder.build());
|
return client.updateNetworkConnectionOfVm(vm.getHref(), builder.build());
|
||||||
if (!successTester.apply(task.getHref())) {
|
|
||||||
throw new RuntimeException(String.format("failed to %s %s: %s", "updateNetworkConnectionOfVm", vm.getName(),
|
|
||||||
task));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task updateCPUCountOfVm(Vm vm, int cpuCount) {
|
||||||
|
return client.updateCPUCountOfVm(vm.getHref(), cpuCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task updateMemoryMBOfVm(Vm vm, int memoryInMB) {
|
||||||
|
return client.updateMemoryMBOfVm(vm.getHref(), memoryInMB);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeMetadata blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse,
|
private NodeMetadata blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse,
|
||||||
Task task) {
|
Task task) {
|
||||||
if (options.shouldBlock()) {
|
if (options.shouldBlock()) {
|
||||||
if (!successTester.apply(task.getHref())) {
|
waitForTask(task, vAppResponse);
|
||||||
throw new RuntimeException(String.format("failed to %s %s: %s", "deploy and power on",
|
|
||||||
vAppResponse.getName(), task));
|
|
||||||
}
|
|
||||||
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
|
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
|
||||||
}
|
}
|
||||||
return getNode.getNode(vAppResponse.getHref().toASCIIString());
|
return getNode.getNode(vAppResponse.getHref().toASCIIString());
|
||||||
|
|
|
@ -0,0 +1,207 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class InstantiateVAppTemplateOptions {
|
||||||
|
private Set<NetworkConfig> networkConfig = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
private Boolean customizeOnInstantiate;
|
||||||
|
|
||||||
|
private boolean block = true;
|
||||||
|
private boolean deploy = true;
|
||||||
|
private boolean powerOn = true;
|
||||||
|
|
||||||
|
public boolean shouldBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldDeploy() {
|
||||||
|
return deploy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldPowerOn() {
|
||||||
|
return powerOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deploy the vapp after it is instantiated?
|
||||||
|
*/
|
||||||
|
public InstantiateVAppTemplateOptions deploy(boolean deploy) {
|
||||||
|
this.deploy = deploy;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* powerOn the vapp after it is instantiated?
|
||||||
|
*/
|
||||||
|
public InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
|
||||||
|
this.powerOn = powerOn;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* block until instantiate or deployment operations complete?
|
||||||
|
*/
|
||||||
|
public InstantiateVAppTemplateOptions block(boolean block) {
|
||||||
|
this.block = block;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, then customization is executed for all children that include a
|
||||||
|
* GuestCustomizationSection.
|
||||||
|
*/
|
||||||
|
public InstantiateVAppTemplateOptions customizeOnInstantiate(boolean customizeOnInstantiate) {
|
||||||
|
this.customizeOnInstantiate = customizeOnInstantiate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@networkConfig VAppTemplate}s have internal networks that can be
|
||||||
|
* connected in order to access the internet or other external networks.
|
||||||
|
*
|
||||||
|
* <h4>default behaviour if you don't use this option</h4> By default, we
|
||||||
|
* connect the first internal {@networkConfig
|
||||||
|
* org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the
|
||||||
|
* vapp template}to a default chosen from the org or specified via
|
||||||
|
* {@networkConfig
|
||||||
|
* org.jclouds.vcloud.reference.VCloudConstants#
|
||||||
|
* PROPERTY_VCLOUD_DEFAULT_NETWORK} using the {@networkConfig
|
||||||
|
* org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an
|
||||||
|
* override set by the property {@networkConfig
|
||||||
|
* org.jclouds.vcloud.reference.VCloudConstants#
|
||||||
|
* PROPERTY_VCLOUD_DEFAULT_FENCEMODE}.
|
||||||
|
*/
|
||||||
|
public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
|
||||||
|
this.networkConfig.add(checkNotNull(networkConfig, "networkConfig"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<NetworkConfig> getNetworkConfig() {
|
||||||
|
return networkConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean shouldCustomizeOnInstantiate() {
|
||||||
|
return customizeOnInstantiate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#block
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions block(boolean block) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.block(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#deploy
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions deploy(boolean deploy) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.deploy(deploy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#powerOn
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.powerOn(powerOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#customizeOnInstantiate
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions customizeOnInstantiate(Boolean customizeOnInstantiate) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.customizeOnInstantiate(customizeOnInstantiate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#addNetworkConfig
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.addNetworkConfig(networkConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[networkConfig=" + networkConfig + ", customizeOnInstantiate=" + customizeOnInstantiate + ", deploy="
|
||||||
|
+ (deploy) + ", powerOn=" + (powerOn) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (block ? 1231 : 1237);
|
||||||
|
result = prime * result + ((customizeOnInstantiate == null) ? 0 : customizeOnInstantiate.hashCode());
|
||||||
|
result = prime * result + (deploy ? 1231 : 1237);
|
||||||
|
result = prime * result + ((networkConfig == null) ? 0 : networkConfig.hashCode());
|
||||||
|
result = prime * result + (powerOn ? 1231 : 1237);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
InstantiateVAppTemplateOptions other = (InstantiateVAppTemplateOptions) obj;
|
||||||
|
if (block != other.block)
|
||||||
|
return false;
|
||||||
|
if (customizeOnInstantiate == null) {
|
||||||
|
if (other.customizeOnInstantiate != null)
|
||||||
|
return false;
|
||||||
|
} else if (!customizeOnInstantiate.equals(other.customizeOnInstantiate))
|
||||||
|
return false;
|
||||||
|
if (deploy != other.deploy)
|
||||||
|
return false;
|
||||||
|
if (networkConfig == null) {
|
||||||
|
if (other.networkConfig != null)
|
||||||
|
return false;
|
||||||
|
} else if (!networkConfig.equals(other.networkConfig))
|
||||||
|
return false;
|
||||||
|
if (powerOn != other.powerOn)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,7 +22,6 @@ import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -92,13 +91,13 @@ import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudAsyncClient}
|
* Tests behavior of {@code VCloudAsyncClient}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||||
|
// surefire
|
||||||
@Test(groups = "unit", testName = "VCloudAsyncClientTest")
|
@Test(groups = "unit", testName = "VCloudAsyncClientTest")
|
||||||
public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
|
@ -121,8 +120,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
|
public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("updateGuestCustomizationOfVm", URI.class,
|
Method method = VCloudAsyncClient.class.getMethod("updateGuestCustomizationOfVm", URI.class,
|
||||||
GuestCustomizationSection.class);
|
GuestCustomizationSection.class);
|
||||||
GuestCustomizationSection guest = new GuestCustomizationSection(URI
|
GuestCustomizationSection guest = new GuestCustomizationSection(
|
||||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
|
URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
|
||||||
guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
|
guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
|
||||||
HttpRequest request = processor.createRequest(method,
|
HttpRequest request = processor.createRequest(method,
|
||||||
URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"), guest);
|
URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"), guest);
|
||||||
|
@ -130,8 +129,45 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
|
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
assertPayloadEquals(request,
|
||||||
"/guestCustomizationSection.xml")), "application/vnd.vmware.vcloud.guestCustomizationSection+xml", false);
|
Strings2.toStringAndClose(getClass().getResourceAsStream("/guestCustomizationSection.xml")),
|
||||||
|
"application/vnd.vmware.vcloud.guestCustomizationSection+xml", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("updateCPUCountOfVm", URI.class, int.class);
|
||||||
|
HttpRequest request = processor.createRequest(method,
|
||||||
|
URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"), 2);
|
||||||
|
|
||||||
|
assertRequestLineEquals(request,
|
||||||
|
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/cpu HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cpuItem.xml")),
|
||||||
|
"application/vnd.vmware.vcloud.rasdItem+xml", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("updateMemoryMBOfVm", URI.class, int.class);
|
||||||
|
HttpRequest request = processor.createRequest(method,
|
||||||
|
URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"), 512);
|
||||||
|
|
||||||
|
assertRequestLineEquals(request,
|
||||||
|
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/memory HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/memoryItem.xml")),
|
||||||
|
"application/vnd.vmware.vcloud.rasdItem+xml", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
@ -144,18 +180,20 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||||
String.class, InstantiateVAppTemplateOptions[].class);
|
String.class, InstantiateVAppTemplateOptions[].class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp",
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"),
|
||||||
|
"my-vapp",
|
||||||
addNetworkConfig(new NetworkConfig("aloha", URI
|
addNetworkConfig(new NetworkConfig("aloha", URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED)));
|
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED)));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
assertPayloadEquals(request,
|
||||||
"/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
|
Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams-network.xml")),
|
||||||
false);
|
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||||
|
@ -169,19 +207,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
IOException {
|
IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||||
String.class, InstantiateVAppTemplateOptions[].class);
|
String.class, InstantiateVAppTemplateOptions[].class);
|
||||||
processor.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
processor.createRequest(
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
method,
|
||||||
.disk(1024).addNetworkConfig(
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"),
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
null)));
|
"CentOS 01",
|
||||||
|
addNetworkConfig(new NetworkConfig(null, URI
|
||||||
|
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
||||||
CloneVAppOptions[].class);
|
CloneVAppOptions[].class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp");
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp");
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||||
|
@ -199,9 +239,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
||||||
CloneVAppOptions[].class);
|
CloneVAppOptions[].class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server",
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server",
|
||||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
|
@ -220,14 +260,15 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
public void testCaptureVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCaptureVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("captureVAppInVDC", URI.class, URI.class, String.class,
|
Method method = VCloudAsyncClient.class.getMethod("captureVAppInVDC", URI.class, URI.class, String.class,
|
||||||
CaptureVAppOptions[].class);
|
CaptureVAppOptions[].class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template");
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template");
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")),
|
assertPayloadEquals(request,
|
||||||
|
Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")),
|
||||||
"application/vnd.vmware.vcloud.captureVAppParams+xml", false);
|
"application/vnd.vmware.vcloud.captureVAppParams+xml", false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
@ -240,10 +281,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
public void testCaptureVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCaptureVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("captureVAppInVDC", URI.class, URI.class, String.class,
|
Method method = VCloudAsyncClient.class.getMethod("captureVAppInVDC", URI.class, URI.class, String.class,
|
||||||
CaptureVAppOptions[].class);
|
CaptureVAppOptions[].class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", new CaptureVAppOptions()
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template",
|
||||||
.withDescription("The description of the new vApp Template"));
|
new CaptureVAppOptions().withDescription("The description of the new vApp Template"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
|
||||||
|
@ -275,8 +316,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getOrg", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getOrg", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||||
|
@ -306,8 +347,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getCatalog", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getCatalog", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||||
|
@ -337,8 +378,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getNetwork", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getNetwork", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/2"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/2"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||||
|
@ -369,8 +410,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||||
|
@ -417,8 +458,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
|
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||||
|
@ -433,8 +474,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: text/xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: text/xml\n");
|
||||||
|
@ -506,8 +547,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||||
|
@ -522,8 +563,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getTasksList", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getTasksList", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||||
|
@ -553,8 +594,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testDeployVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeployVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("deployVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("deployVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
@ -570,8 +611,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testDeployAndPowerOnVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeployAndPowerOnVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("deployAndPowerOnVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("deployAndPowerOnVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
@ -587,8 +628,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVApp", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getVApp", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||||
|
@ -603,8 +644,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testGetVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vm/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vm/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n");
|
||||||
|
@ -619,8 +660,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testRebootVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRebootVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("rebootVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("rebootVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
|
||||||
|
@ -636,8 +677,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testUndeployVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testUndeployVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("undeployVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("undeployVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||||
|
@ -655,8 +696,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
public void testUndeployAndSaveStateOfVAppOrVmSaveState() throws SecurityException, NoSuchMethodException,
|
public void testUndeployAndSaveStateOfVAppOrVmSaveState() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("undeployAndSaveStateOfVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("undeployAndSaveStateOfVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||||
|
@ -674,8 +715,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
@ -690,8 +731,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testPowerOnVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testPowerOnVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("powerOnVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("powerOnVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
|
||||||
|
@ -707,8 +748,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testPowerOffVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testPowerOffVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("powerOffVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("powerOffVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
|
||||||
|
@ -724,8 +765,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testResetVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testResetVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("resetVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("resetVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
|
||||||
|
@ -741,8 +782,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testSuspendVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testSuspendVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("suspendVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("suspendVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
|
||||||
|
@ -758,8 +799,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testShutdownVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testShutdownVAppOrVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("shutdownVAppOrVm", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("shutdownVAppOrVm", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
assertRequestLineEquals(request,
|
||||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
|
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
|
||||||
|
@ -775,8 +816,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
@ -791,8 +832,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class);
|
Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
@ -912,43 +953,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||||
|
|
||||||
return Suppliers
|
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||||
.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
|
||||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of(
|
|
||||||
"org",
|
|
||||||
|
|
||||||
ImmutableMap
|
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
|
||||||
.<String, org.jclouds.vcloud.domain.VDC> of(
|
|
||||||
"vdc",
|
"vdc",
|
||||||
new VDCImpl(
|
new VDCImpl("vdc", null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||||
"vdc",
|
VDCStatus.READY, null, "description", ImmutableSet.<Task> of(),
|
||||||
null,
|
AllocationModel.ALLOCATION_POOL, null, null, null, ImmutableMap.<String, ReferenceType> of(
|
||||||
URI
|
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
|
||||||
VDCStatus.READY,
|
|
||||||
null,
|
|
||||||
"description",
|
|
||||||
ImmutableSet.<Task> of(),
|
|
||||||
AllocationModel.ALLOCATION_POOL,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
ImmutableMap
|
|
||||||
.<String, ReferenceType> of(
|
|
||||||
"vapp",
|
"vapp",
|
||||||
new ReferenceTypeImpl(
|
new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
|
||||||
"vapp",
|
|
||||||
"application/vnd.vmware.vcloud.vApp+xml",
|
|
||||||
URI
|
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")),
|
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")),
|
||||||
"network",
|
"network",
|
||||||
new ReferenceTypeImpl(
|
new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||||
"network",
|
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), ImmutableMap
|
||||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
.<String, ReferenceType> of(), 0, 0, 0, false))));
|
||||||
URI
|
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))),
|
|
||||||
ImmutableMap.<String, ReferenceType> of(), 0, 0, 0,
|
|
||||||
false))));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,15 +980,18 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Org> get() {
|
public Map<String, Org> get() {
|
||||||
return ImmutableMap.<String, Org> of("org", new OrgImpl("org", null, URI
|
return ImmutableMap.<String, Org> of(
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org", "description", ImmutableMap
|
"org",
|
||||||
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog",
|
new OrgImpl("org", null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org",
|
||||||
VCloudMediaType.CATALOG_XML, URI
|
"description", ImmutableMap.<String, ReferenceType> of(
|
||||||
|
"catalog",
|
||||||
|
new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML, URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
|
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
|
||||||
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, URI
|
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML,
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap
|
||||||
.<String, ReferenceType> of("network", new ReferenceTypeImpl("network",
|
.<String, ReferenceType> of(
|
||||||
VCloudMediaType.NETWORK_XML, URI
|
"network",
|
||||||
|
new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML, URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))),
|
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))),
|
||||||
new ReferenceTypeImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI
|
new ReferenceTypeImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList
|
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList
|
||||||
|
@ -988,13 +1010,16 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||||
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
|
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
|
||||||
|
|
||||||
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", "type",
|
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
|
||||||
|
"catalog",
|
||||||
|
new CatalogImpl("catalog", "type",
|
||||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description",
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description",
|
||||||
ImmutableMap.<String, ReferenceType> of("item", new ReferenceTypeImpl("item",
|
ImmutableMap.<String, ReferenceType> of(
|
||||||
"application/vnd.vmware.vcloud.catalogItem+xml", URI
|
"item",
|
||||||
|
new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
|
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
|
||||||
"template", new ReferenceTypeImpl("template",
|
"template",
|
||||||
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))),
|
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))),
|
||||||
ImmutableList.<Task> of(), true)));
|
ImmutableList.<Task> of(), true)));
|
||||||
}
|
}
|
||||||
|
@ -1008,25 +1033,14 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||||
return ImmutableMap
|
return ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||||
.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
"org", ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||||
"org",
|
"catalog", ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
||||||
ImmutableMap
|
|
||||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
|
||||||
"catalog",
|
|
||||||
ImmutableMap
|
|
||||||
.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
|
||||||
"template",
|
"template",
|
||||||
new CatalogItemImpl(
|
new CatalogItemImpl("template", URI
|
||||||
"template",
|
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description",
|
||||||
URI
|
new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"),
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
|
||||||
"description",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"template",
|
|
||||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
|
||||||
URI
|
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
|
|
||||||
ImmutableMap.<String, String> of()))));
|
ImmutableMap.<String, String> of()))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
VAppTemplate template = null;
|
VAppTemplate template = null;
|
||||||
|
|
||||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
options.processorCount(1).memory(512).disk(1024);
|
|
||||||
|
|
||||||
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
|
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.options;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||||
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.customizeOnInstantiate;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
|
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||||
|
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code InstantiateVAppTemplateOptions}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class InstantiateVAppTemplateOptionsTest {
|
||||||
|
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddNetworkConfig() {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED));
|
||||||
|
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
|
||||||
|
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
|
||||||
|
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddNetworkConfigStatic() {
|
||||||
|
InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default",
|
||||||
|
URI.create("http://localhost"), FenceMode.BRIDGED));
|
||||||
|
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
|
||||||
|
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
|
||||||
|
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCustomizeOnInstantiate() {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
options.customizeOnInstantiate(true);
|
||||||
|
assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCustomizeOnInstantiateStatic() {
|
||||||
|
InstantiateVAppTemplateOptions options = customizeOnInstantiate(true);
|
||||||
|
assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
<Item xmlns="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"><rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits><rasd:Description>Number of Virtual CPUs</rasd:Description><rasd:ElementName>2 virtual CPU(s)</rasd:ElementName><rasd:InstanceID>4</rasd:InstanceID><rasd:ResourceType>3</rasd:ResourceType><rasd:VirtualQuantity>2</rasd:VirtualQuantity><rasd:Weight>0</rasd:Weight></Item>
|
|
@ -0,0 +1 @@
|
||||||
|
<Item xmlns="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"><rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits><rasd:Description>Memory Size</rasd:Description><rasd:ElementName>512 MB of memory</rasd:ElementName><rasd:InstanceID>5</rasd:InstanceID><rasd:Reservation>0</rasd:Reservation><rasd:ResourceType>4</rasd:ResourceType><rasd:VirtualQuantity>512</rasd:VirtualQuantity><rasd:Weight>0</rasd:Weight></Item>
|
|
@ -202,4 +202,13 @@ public interface VCloudMediaType {
|
||||||
*/
|
*/
|
||||||
public final static MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml");
|
public final static MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.rasdItem+xml"
|
||||||
|
*/
|
||||||
|
public final static String RASDITEM_XML = "application/vnd.vmware.vcloud.rasdItem+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.rasdItem+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType RASDITEM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.rasdItem+xml");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue