I have a Linux guest image that starts up, with only the OS drive. The actual ESX server has many VMDKs (I know the IDs of them). In my workflow, I need to on demand, from within the guest, attach one of those VMDKs to the guest instance. How can I do this?
From a high level perspective:
- Pick your favorite language/tool to access the VMware API with and embed it in the image
- Have a way for the image to get credentials needed to perform the action against VMware (embedded in the image or retrieved from a secrets vault). If the script is being run interactively, this could also just be from memory from the user.
- Write your script that utilizes the VMware API and credentials to attach the VMDK
In other words, exactly the same way you would do it programmatically not from within the guest.