Clone VM Task
Creates a virtual machine from an existing virtual machine.
if you do not have all of the privileges described as follows: - The resource Datastore referenced by the attribute VM.DiskCloneSpec.datastore requires Datastore.AllocateSpace. - The resource Datastore referenced by the attribute VM.ClonePlacementSpec.datastore requires Datastore.AllocateSpace. - The resource Folder referenced by the attribute VM.ClonePlacementSpec.folder requires VirtualMachine.Inventory.CreateFromExisting. - The resource ResourcePool referenced by the attribute VM.ClonePlacementSpec.resource-pool requires Resource.AssignVMToPool. - The resource VirtualMachine referenced by the attribute VM.CloneSpec.source requires VirtualMachine.Provisioning.Clone.
Request
URLURL
Header Parameters
Header Parameters
Required session ID, acquired from Create Session API under CIS product
vmware-api-session-id example
"b00db39f948d13ea1e59b4d6fce56389"
Request Body
{
"name": "string",
"source": "string"
}
Virtual machine to clone from. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: VirtualMachine. When operations return a value of this structure as a result, the field will be an identifier for the resource type: VirtualMachine.
Virtual machine name.
Map of Disks to Update. If unset, all disks will copied to the datastore specified in the VM.ClonePlacementSpec.datastore field of VM.CloneSpec.placement. If the same identifier is in VM.CloneSpec.disks-to-remove InvalidArgument fault will be thrown. When clients pass a value of this structure as a parameter, the key in the field map must be an identifier for the resource type: com.vmware.vcenter.vm.hardware.Disk. When operations return a value of this structure as a result, the key in the field map will be an identifier for the resource type: com.vmware.vcenter.vm.hardware.Disk.
Guest customization spec to apply to the virtual machine after the virtual machine is deployed. If unset, the guest operating system is not customized after clone.
Virtual machine placement information. If this field is unset, the system will use the values from the source virtual machine. If specified, each field will be used for placement. If the fields result in disjoint placement the operation will fail. If the fields along with the placement values of the source virtual machine result in disjoint placement the operation will fail.
Attempt to perform a VM.CloneSpec.power-on after clone. If unset, the virtual machine will not be powered on.
Set of Disks to Remove. If unset, all disks will be copied. If the same identifier is in VM.CloneSpec.disks-to-update InvalidArgument fault will be returned. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: com.vmware.vcenter.vm.hardware.Disk. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: com.vmware.vcenter.vm.hardware.Disk.
Authentication
Response
Response BodyResponse Body
An identifier for the task created by this API invocation will be returned. If the non-async version of the operation returns a value, this id can be used with the CIS Get Task operation to fetch that value. The normal description of this operation’s return value will follow if one exists. ID of newly-created virtual machine. The result will be an identifier for the resource type: VirtualMachine.
Errors
com.vmware.vapi.std.errors.already_exists : if a virtual machine with the specified name already exists. | com.vmware.vapi.std.errors.invalid_argument : if any of the specified parameters are invalid.
com.vmware.vapi.std.errors.unauthorized : if the user doesn’t have the required privileges.
com.vmware.vapi.std.errors.not_found : if any of the resources specified in spec could not be found
com.vmware.vapi.std.errors.error : if the system reports an error while responding to the request. | com.vmware.vapi.std.errors.resource_inaccessible : if a specified resource (eg. host) is not accessible. | com.vmware.vapi.std.errors.unable_to_allocate_resource : if any of the resources needed to clone the virtual machine could not be allocated.
com.vmware.vapi.std.errors.service_unavailable : if the system is unable to communicate with a service to complete the request.
‘Default’ means this response is used for all HTTP codes that are not covered individually for this operation.
Code Samples
PowerCLI Client SDK Example
PowerCLI Client SDK All Parameters Example
cURL Command
Vendor Extensions
x-vmw-doc-deprecated-method: post
x-vmw-doc-deprecated-path: /rest/vcenter/vm?action=clone&vmw-task=true
x-vmw-doc-operation: clone_task