2

Is there a way to get a VM's name or UUID from within the VM itself, for a VM that is running on a VMWare ESX server? If so, what is the way?

My use case is: I'm cloning a bunch of VMs. A program running inside the clones connects to a server. I want to know which cloned VM that program is running on. What would be the best way to do that? I can assign it a number from the server automatically, print it out from the VM, and type it in manually, but that seems lame.

2 Answers 2

3

Run dmidecode and grep for UUID.

# /usr/sbin/dmidecode | grep UUID
        UUID: 56XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

This should be the same UUID assigned to the uuid.bios of the VM.

1
  • is there any way user can change this or reset?
    – asvignesh
    May 24, 2018 at 7:17
1

When you clone the VMs are you not connecting to them to change their hostname and IPs anyway? in which case just go off the hostname. If you're not changing their hostnames and IPs then you could just do an nslookup of the DHCP-provided IP address and use that? You can get the VM name via the APIs but it's not always the best way of achieving what you want.

2
  • i want this to be done entirely automatically. basically, i want the server to have a list of the VMs indexed by unique number. user can then, from the server, set what hostname and ip the vm should have. then a program running on the VM will get that info from the server and set them automatically (along with doing some other things). so i'll clone say 20 vms, assign them a few things in one location, and have them set themselves up the rest of the way. it seems, to do that, i need to link the VM name to the auto-assigned number on the server
    – Claudiu
    Aug 8, 2011 at 17:30
  • when assigning the unique numbers to IPs and such, it doesn't matter what the hostname is.. but i might have to change some VM settings (like the internal network of the VM) based on those, so for that i need to identify the VM itself.. otherwise i could just do it all from the program that gets the number anyway
    – Claudiu
    Aug 8, 2011 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .