I'm needing to script the process of cloning a VMDK from a VM and attaching the clone back to the VM using the vMA (vCLI). The clone via vmkfstools works fine.
However, I'm having trouble adding the VMDK back to the VM. It looks like both the 'vdiskcreate.pl and the 'vmreconfigure.pl' scripts only create a new VMDK and don't accept an existing one.
vdiskcreate.pl
./vdiskcreate.pl --filename 'clone.vmdk' --host esxi01.demo.local --vmname myvm
Adding Virtual Disk on Virtual machine myvm in the host esxi01.demo.local
Operation failed because file already exists.
vmreconfig.pl
vmreconfig.pl --filename ~/scripts/vmreconfig.xml
Argument "" isn't numeric in multiplication (*) at ./vmreconfig.pl line 450.
Adding new hard disk with file name [RTP01]/myvm/clone.vmdk . . .
Reconfiguration failed:
Operation failed because file already exists
XML contains:
<Reconfigure-Virtual-Machine>
<Name>myvm</Name>
<Host>esxi01.demo.local</Host>
<Add-Device>
<Hard-Disk>
<Name>clone.vmdk</Name>
</Hard-Disk>
</Add-Device>
</Reconfigure-Virtual-Machine>
Appreciate any insight or direction.