问题
Let's say I have multiple Citrix XenServer VMs with the same name. Or, the names are garbage, doesn't matter.
From the guest OS on one of those VMs, how can I programatically determine the ID of the VM? I was hoping the UUID of the VM would should as the guest OS's BIOS serial number, but it doesn't. Have looked everywhere, registry, WMI, you name it.
Now, the reason I won't just use the hostname, is that I might have multiple machines with same hostname (e.g. a full lab with copies of VMs).
Using XenServer 5.x and 6.x.
Cheers.
回答1:
Ah, you can get the UUID from the guest this way (as I hoped) in Xen Server v6.x: Serial number of the BIOS. For a Windows guest, you can use WMI to query that either locally or remotely. I suspect this ID-as-BIOS-serial was only introduced in Xen Server v5.6.
For earlier versions, you can get the UUID from the guest by running the old client tools. For a Windows guest, the executable is xenstore_client.exe, run that with parameter of 'read vm'. The output of that is a string, and the part after the forward slash is the UUID. Note you could use PSEXEC to remotely execute xenstore_client.exe.
来源:https://stackoverflow.com/questions/15802876/how-to-get-unique-id-of-a-citrix-xenserver-vm-from-the-guest-os