Relocate VM
If vSphere APIs begin with /rest (vs /api), any maps are consumed/returned instead as arrays of objects, each containing a key and a value property field.
Relocates a virtual machine based on the specification. The parts of the virtual machine that can move are: FOLDER, RESOURCE_POOL, HOST, CLUSTER and DATASTORE of home of the virtual machine and disks.
if you do not have all of the privileges described as follows: - The resource VirtualMachine referenced by the parameter vm requires Resource.ColdMigrate. - The resource ResourcePool referenced by the attribute VM.RelocatePlacementSpec.resource-pool requires Resource.AssignVMToPool.
Request
URLURL
https://{api_host}/rest/vcenter/vm/{vm}?action=relocate
Parameters
Parameters
string
vm
Required
Existing Virtual machine to relocate.
The parameter must be an identifier for the resource type: VirtualMachine.
Header Parameters
Header Parameters
string
vmware-api-session-id
Required
Required session ID, obtained by first calling Create Session API
Example: b00db39f948d13ea1e59b4d6fce56389
Request Body
Request Body
VMRelocateRequestBody of type application/json (required){
"spec": {
"disks": [
{
"key": "key1",
"value": {
"datastore": "string"
}
}
],
"placement": {
"cluster": "string",
"datastore": "string",
"folder": "string",
"host": "string",
"resource_pool": "string"
}
}
}
cURL Command
curl -X POST -H "vmware-api-session-id: b00db39f948d13ea1e59b4d6fce56389" -H "Content-Type: application/json" -d '{"spec":{"disks":{"key":{"datastore":"string"}},"placement":{"cluster":"string","datastore":"string","folder":"string","host":"string","resource_pool":"string"}}}' https://{api_host}/rest/vcenter/vm/{vm}?action=relocate
Errors
400
com.vmware.vapi.std.errors.invalid_argument : if any of the specified parameters are invalid.
401
com.vmware.vapi.std.errors.unauthenticated : if the user can not be authenticated. | com.vmware.vapi.std.errors.unauthorized : if the user doesn't have the required privileges.
404
com.vmware.vapi.std.errors.error : if the system reports an error while responding to the request. | com.vmware.vapi.std.errors.not_found : if any of the resources specified in spec or the given "vm" could not be found | com.vmware.vapi.std.errors.resource_inaccessible : if a specified resource (eg. host) is not accessible.
503
com.vmware.vapi.std.errors.service_unavailable : if the system is unable to communicate with a service to complete the request.
On This Page
VM Operations
get
post
delete
get
post
post
post
post
post
post
post