'Can't seem to script adding virtual disks to existing VM's. (Fusion Pro 12)

I'm developing some automation to create vmware vm's and trying to create additional data disks for each vm. I can create the disks fine using vmware-vdiskmanager:

Example:

vmware-vdiskmanager -c -a nvme -s 10GB -t 0 datadisk01.vmdk
vmware-vdiskmanager -c -a nvme -s 10GB -t 0 datadisk02.vmdk

I then add the following to the *.vmx file (while the vm is powered down)

nvme1:0.fileName = "datadisk01.vmdk"
nvme1:0.present = "TRUE"
nvme2:0.fileName = "datadisk02.vmdk"
nvme2:0.present = "TRUE"

When I start the vm, both the entries above are immediately changed to "FALSE" while the vm is "posting".

So I then tried setting specific nvme subnqnUUID's:

nvme1.subnqnUUID = "52 92 88 43 5b 51 06 72-0a bb ad 61 ea 55 11 29"
nvme2.subnqnUUID = "52 92 88 43 5b 51 06 72-0a bb ad 61 ea 55 11 30"

Same problem.

Is there anyway to automate this? Seems silly they have a command line tool to create virtualdisks but no way to assign them.

I even tried creating the virtual disks as above, and them manually adding them to the vm using the virtual machine library BUI, I click "add device", "existing disk", select my virtual disk and click apply. What is does it creates a copy of the disk with the name "datadisk01 2.vmdk" (yes, it puts a space in the name also, LMAO)

I can't find any way to make disks available to a vm without using the virtual machine library BUI.

Thx for any help



Sources

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

Source: Stack Overflow

Solution Source