'Relocate VMX file with pyvmomi or REST API

I was able to make this request to relocate a specific vdisk for a VM via REST call in python by running this code :

import requests
import json

url = "https://myvcenter.local/rest/vcenter/vm/vm-12016?action=relocate"

payload = json.dumps({
  "spec": {
    "disks": [
      {
        "value": {
          "datastore": "datastore-11"
        },
        "key": "2000"
      }
    ]
  }
})
headers = {
  'Content-Type': 'application/json',
  'vmware-api-session-id': 'myToken',
}

response = requests.request("POST", url, headers=headers, data=payload)

This works , the vDisk was moved but not the VMX file that is on the same datastore.

I tried also to do something with pyvmomi example to relocate VM , but I was not able to find out how to move the VMX file : https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/relocate_vm.py

The VMX file seems not to be a vim.vm.device.VirtualDisk object.

Do you guys have any pointers for me to achieve a VMX file migration ? pyvmomi or REST call.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source