Virtual Machine Relocate VM Task

Virtual Machine Relocate VM Task

Relocates a virtual machine to the location specified by VirtualMachineRelocateSpec.

Starting from VCenter 5.1, this API also supports relocating a template to a new host should the current host become inactive. Starting from vCenter 6.0 this API also supports relocating a VM to a new vCenter service.

Requires the following additional permissions:

  • Resource.HotMigrate if the virtual machine is powered on.
  • Datastore.AllocateSpec if the virtual machine or its disks are being relocated to a new datastore.
  • Resource.AssignVMToPool if the resource pool is changing.
  • VirtualMachine.Inventory.Register against the destination folder if the virtual machine is moving to a new vCenter service.
  • VirtualMachine.Inventory.Move against the virtual machine, source folder, and destination folder if the virtual machine is changing folders within the same vCenter service.
  • Network.Assign against the new network if the virtual machine is changing networks.

If this virtual machine is configured with a VirtualNVDIMM device, and if the virtual machine will be moved to a different host, the VirtualNVDIMM will be automatically relocated to the destination host's Non-Volatile Memory storage. If this Virtual machine is configured with virtual disks via persistent memory storage profile:

  • If spec specifies only compute location change, these virtual disks will be automatically moved to a persistent memory storage in destination host that supports the profile.
  • If spec specifies primary datastore change via datastore, unlike regular virtual disks, these disks will not be automatically moved to the specified datastore, instead they will stay on a persistent memory storage in destination host that supports the profile.
  • To explicityly move these disks to a location other than persistent memory storage, use disk locator to specify the new destination datastore along with a storage profile that removes the persistent memory storage requirement. Note that this downgrades the disk I/O performance.
  • On the other hand, to move a virtual disk from a regular storage to persistent memory, use deviceChange to specify a storage profile of persistent memory storage. Note that this upgrades the disk I/O performance.

Required privileges: Resource.ColdMigrate

Request
URI
POST
https://{vcenter-host}/sdk/vim25/{release}/VirtualMachine/{moId}/RelocateVM_Task
COPY
Path Parameters
string
moId
Required

The unique identifier for the managed object to which the method attaches; the serialized managed object reference for a request has the form moType/moId, in this case VirtualMachine/{moId}.

string
release
Required

The vSphere release schema. The current specification covers vSphere 8.0.2.0 APIs.


Request Body
RelocateVMRequestType of type(s) application/json
Required
{
    "spec": {
        "_typeName": "string",
        "service": {
            "_typeName": "string",
            "instanceUuid": "string",
            "url": "string",
            "credential": {
                "_typeName": "string"
            },
            "sslThumbprint": "string"
        },
        "folder": {
            "_typeName": "string",
            "type": "string",
            "value": "string"
        },
        "datastore": {
            "_typeName": "string",
            "type": "string",
            "value": "string"
        },
        "diskMoveType": "string",
        "pool": {
            "_typeName": "string",
            "type": "string",
            "value": "string"
        },
        "host": {
            "_typeName": "string",
            "type": "string",
            "value": "string"
        },
        "disk": [
            {
                "_typeName": "string",
                "diskId": 0,
                "datastore": {
                    "_typeName": "string",
                    "type": "string",
                    "value": "string"
                },
                "diskMoveType": "string",
                "diskBackingInfo": {
                    "_typeName": "string"
                },
                "profile": [
                    {
                        "_typeName": "string"
                    }
                ],
                "backing": {
                    "_typeName": "string",
                    "parent": "VirtualMachineRelocateSpecDiskLocatorBackingSpec Object",
                    "crypto": {
                        "_typeName": "string"
                    }
                },
                "filterSpec": [
                    {
                        "_typeName": "string"
                    }
                ]
            }
        ],
        "transform": "string",
        "deviceChange": [
            {
                "_typeName": "string",
                "operation": "string",
                "fileOperation": "string",
                "device": {
                    "_typeName": "string",
                    "key": 0,
                    "deviceInfo": {
                        "_typeName": "string",
                        "label": "string",
                        "summary": "string"
                    },
                    "backing": {
                        "_typeName": "string"
                    },
                    "connectable": {
                        "_typeName": "string",
                        "migrateConnect": "string",
                        "startConnected": false,
                        "allowGuestControl": false,
                        "connected": false,
                        "status": "string"
                    },
                    "slotInfo": {
                        "_typeName": "string"
                    },
                    "controllerKey": 0,
                    "unitNumber": 0,
                    "numaNode": 0,
                    "deviceGroupInfo": {
                        "_typeName": "string",
                        "groupInstanceKey": 0,
                        "sequenceId": 0
                    }
                },
                "profile": [
                    {
                        "_typeName": "string"
                    }
                ],
                "backing": {
                    "_typeName": "string",
                    "parent": "VirtualDeviceConfigSpecBackingSpec Object",
                    "crypto": {
                        "_typeName": "string"
                    }
                },
                "filterSpec": [
                    {
                        "_typeName": "string"
                    }
                ],
                "changeMode": "string"
            }
        ],
        "profile": [
            {
                "_typeName": "string"
            }
        ],
        "cryptoSpec": {
            "_typeName": "string"
        }
    },
    "priority": "string"
}
spec
Required

Specification for moving or copying a virtual machine to a different datastore or host.

priority
Optional

MovePriority is an enumeration of values that indicate the priority of the task that moves a virtual machine from one host to another or one storage location to another.

Note this priority can affect both the source and target hosts.

Possible values:

  • lowPriority: The task of moving this virtual machine is low priority.
  • highPriority: The task of moving this virtual machine is high priority.
  • defaultPriority: The task of moving this virtual machine is the default priority.
Possible values are : lowPriority, highPriority, defaultPriority,
Authentication
This operation uses the following authentication methods.
Responses
200

This method returns a Task object with which to monitor the operation.

Returns MoRefTask of type(s) application/json
This response body class contains all of the following: MoRefExtensibleManagedObject
{
    "_typeName": "string",
    "type": "string",
    "value": "string"
}

500

InvalidArgument: in the following cases:

  • the target host and target pool are not associated with the same compute resource
  • the target pool represents a cluster without DRS enabled, and the host is not specified
  • the virtual machine is powered on, its home or any of its disks will change storage location, and the host is not specified
  • Datastore is not accessible in a cross-datacenter move
  • Datastore in a diskLocator entry is not specified
  • the specified device ID cannot be found in the virtual machine's current configuration

NotSupported: if the virtual machine is marked as template and the datastore is changing or if it is a cross vCenter vMotion operation.

Timedout: if one of the phases of the relocate process times out.

InvalidState: if the operation cannot be performed because of the host or virtual machine's current state. For example, if the host is in maintenance mode, or if the virtual machine's configuration information is not available.

InvalidDatastore: if the operation cannot be performed on the target datastores.

FileFault: if there is an error accessing the virtual machine files.

VmConfigFault: if the virtual machine is not compatible with the destination host. Typically, a specific subclass of this exception is thrown, such as IDEDiskNotSupported.

MigrationFault: if it is not possible to migrate the virtual machine to the destination host. This is typically due to hosts being incompatible, such as mismatch in network polices or access to networks and datastores. Typically, a more specific subclass is thrown.

InsufficientResourcesFault: if this operation would violate a resource usage policy.

DisallowedOperationOnFailoverHost: if the virtual machine is powered on and is being migrated to a failover host. See ClusterFailoverHostAdmissionControlPolicy.

Returns VimFault of type(s) application/json
This response body class contains all of the following: MethodFault
{
    "_typeName": "string",
    "faultCause": "MethodFault Object",
    "faultMessage": [
        {
            "_typeName": "string",
            "key": "string",
            "arg": [
                {
                    "_typeName": "string",
                    "key": "string",
                    "value": {
                        "_typeName": "string"
                    }
                }
            ],
            "message": "string"
        }
    ]
}

Virtual Machine Operations
POST
Virtual Machine Acquire Mks Ticket
POST
Virtual Machine Acquire Ticket
POST
Virtual Machine Answer VM
POST
Virtual Machine Apply Evc Mode VM Task
POST
Virtual Machine Attach Disk Task
POST
Virtual Machine Check Customization Spec
POST
Virtual Machine Clone VM Task
POST
Virtual Machine Consolidate VM Disks Task
POST
Virtual Machine Create Screenshot Task
POST
Virtual Machine Create Secondary VM Task
POST
Virtual Machine Create Secondary VM Ex Task
POST
Virtual Machine Create Snapshot Task
POST
Virtual Machine Create Snapshot Ex Task
POST
Virtual Machine Crypto Unlock Task
POST
Virtual Machine Customize VM Task
POST
Virtual Machine Defragment All Disks
POST
Virtual Machine Destroy Task
POST
Virtual Machine Detach Disk Task
POST
Virtual Machine Disable Secondary VM Task
POST
Virtual Machine Drop Connections
POST
Virtual Machine Enable Secondary VM Task
POST
Virtual Machine Estimate Storage For Consolidate Snapshots Task
POST
Virtual Machine Export Vm
POST
Virtual Machine Extract Ovf Environment
GET
Virtual Machine Get Alarm Actions Enabled
GET
Virtual Machine Get Available Field
GET
Virtual Machine Get Capability
GET
Virtual Machine Get Config
GET
Virtual Machine Get Config Issue
GET
Virtual Machine Get Config Status
GET
Virtual Machine Get Custom Value
GET
Virtual Machine Get Datastore
GET
Virtual Machine Get Declared Alarm State
GET
Virtual Machine Get Disabled Method
GET
Virtual Machine Get Effective Role
GET
Virtual Machine Get Environment Browser
GET
Virtual Machine Get Guest
GET
Virtual Machine Get Guest Heartbeat Status
GET
Virtual Machine Get Layout
GET
Virtual Machine Get Layout Ex
GET
Virtual Machine Get Name
GET
Virtual Machine Get Network
GET
Virtual Machine Get Overall Status
GET
Virtual Machine Get Parent
GET
Virtual Machine Get Parent V App
GET
Virtual Machine Get Permission
GET
Virtual Machine Get Recent Task
GET
Virtual Machine Get Resource Config
GET
Virtual Machine Get Resource Pool
GET
Virtual Machine Get Root Snapshot
GET
Virtual Machine Get Runtime
GET
Virtual Machine Get Snapshot
GET
Virtual Machine Get Storage
GET
Virtual Machine Get Summary
GET
Virtual Machine Get Tag
GET
Virtual Machine Get Triggered Alarm State
GET
Virtual Machine Get Value
POST
Virtual Machine Instant Clone Task
POST
Virtual Machine Make Primary VM Task
POST
Virtual Machine Mark As Template
POST
Virtual Machine Mark As Virtual Machine
POST
Virtual Machine Migrate VM Task
POST
Virtual Machine Mount Tools Installer
POST
Virtual Machine Power Off VM Task
POST
Virtual Machine Power On VM Task
POST
Virtual Machine Promote Disks Task
POST
Virtual Machine Put Usb Scan Codes
POST
Virtual Machine Query Changed Disk Areas
POST
Virtual Machine Query Connections
POST
Virtual Machine Query Fault Tolerance Compatibility
POST
Virtual Machine Query Fault Tolerance Compatibility Ex
POST
Virtual Machine Query Unowned Files
POST
Virtual Machine Reboot Guest
POST
Virtual Machine Reconfig VM Task
POST
Virtual Machine Refresh Storage Info
POST
Virtual Machine Reload
POST
Virtual Machine Reload Virtual Machine From Path Task
POST
Virtual Machine Relocate VM Task
POST
Virtual Machine Remove All Snapshots Task
POST
Virtual Machine Rename Task
POST
Virtual Machine Reset Guest Information
POST
Virtual Machine Reset VM Task
POST
Virtual Machine Revert To Current Snapshot Task
POST
Virtual Machine Send NMI
POST
Virtual Machine Set Custom Value
POST
Virtual Machine Set Display Topology
POST
Virtual Machine Set Screen Resolution
POST
Virtual Machine Shutdown Guest
POST
Virtual Machine Standby Guest
POST
Virtual Machine Start Recording Task
POST
Virtual Machine Start Replaying Task
POST
Virtual Machine Stop Recording Task
POST
Virtual Machine Stop Replaying Task
POST
Virtual Machine Suspend VM Task
POST
Virtual Machine Terminate Fault Tolerant VM Task
POST
Virtual Machine Terminate VM
POST
Virtual Machine Turn Off Fault Tolerance For VM Task
POST
Virtual Machine Unmount Tools Installer
POST
Virtual Machine Unregister VM
POST
Virtual Machine Upgrade Tools Task
POST
Virtual Machine Upgrade VM Task