As part of the build process for our product I am trying to script the creation of several virtual machines from a template. Before creating the new virtual machines, I need to delete the old virtual machines from the last build. For that, I am using the command below:
vmrun -T vc -h <vCenterServer> -u <UserName> -p <Password> deleteVM "<PathToVMX>"
In my case "<PathToVMX>" is something along the lines of "[datacenter-2/NFS-datastore] golden/golden.vmx".
The issue that I am facing is that when I delete a virtual machine the .vmx file gets deleted as expected, but the folder that contains the .vmx file is left behind. When I later use vmclone.pl to create a new virtual machine with the same name I end up with a path like "[datacenter-2/NFS-datastore] golden_1/golden.vmx". I don't want my nightly build to create a proliferation of (mostly) empty folders on my datastore.
I am looking for one of the following:
- A way to force vmrun to delete the parent folder when it deletes the .vmx file.
- A command I can run after vmrun to delete the parent folder that vmrun left behind.
- A way to force vmclone.pl to reuse the parent folder that vmrun left behind, rather than creating a new folder with an "_N" suffix.