Is there any way to determine the vSphere virtual machine ID or name or UUID from a linux guest? I have administrative access to the guest, and would like to coordinate some maintenance actions between the guest and vCenter via the vCenter API. To use the vCenter API, I need to identify which VM I'm operating on.

For one-off operations I can find the VM's information from the vCenter GUI or API because I can interpret the VM naming convention, but I'd like to be able to script these operations starting from the guest OS. Basically, given a guest VM: determine the vSphere ID of the VM from the guest, then use that ID to manipulate the VM via the vCenter API.

I read that there is a way to cron a script on each hypervisor host to set guestinfo variables on each running guest which would then be accessible from the guest via open-vm-tools. It might be difficult for me to get admin access to the hypervisor hosts themselves to install such a script, hence my hope that their may be a more generic way.

  • I have admin access to both, which is why I can find the VM name (I can correlate the VM naming convention with the hostname convention, but it's not an exact science) for one-off tasks. I need to automate these tasks, and my starting point is guest access.
    – brett
    Jun 25 '19 at 12:48
  • I should clarify - I have admin access to both in our labs, but less than full admin access to vCenter in production. I only have vCenter API permissions to do what I need to do, but not to install scripts on the hypervisor hosts.
    – brett
    Jun 25 '19 at 13:46

We found a way to do it.

On the guest:

#dmidecode -s system-serial-number
VMware-42 39 51 fb 85 54 7c 91-ac 25 e0 d5 f7 6b 13 b2

This serial number is vCenter's "BIOS UUID" for the guest VM, albeit in a slightly different format:

Bios UUID     :  423951fb-8554-7c91-ac25-e0d5f76b13b2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.