vSphere

 View Only
  • 1.  Getting VM Name from Inside the VM

    Posted Jun 24, 2008 10:12 PM

    Is it possible to somehow get the name of the VM from inside the VM itself that's running on an ESX server?

    Thanks,

    M



  • 2.  RE: Getting VM Name from Inside the VM
    Best Answer

    Broadcom Employee
    Posted Jun 24, 2008 11:30 PM

    Go to the commandline of the VM and run "hostname" and this works for both Windows and Linux



  • 3.  RE: Getting VM Name from Inside the VM

    Posted Jun 25, 2008 06:19 AM

    I think the original poster was refering to the VMware host the machine is running on not the actual VM guest. and the answer no. that would be considered escaping the VM and is very bad. a VM is not aware that it is running over ESX, a user can figure out they are in a VM guest be looking for certain drivers or VMTools but that is about it.

    Tom Howarth

    VMware Communities User Moderator



  • 4.  RE: Getting VM Name from Inside the VM

    Posted Jun 25, 2008 06:20 AM

    Well I stand corrected :smileyshocked:

    Tom Howarth

    VMware Communities User Moderator



  • 5.  RE: Getting VM Name from Inside the VM

    Posted Jun 25, 2008 06:31 AM

    Tom,

    You're correct in your original post. We are looking for the actual VM name but we can live with the hostname as that's visible from the VC. The reason for us wanting VM name is to have the app we have running inside VM let us know when it has a problem and we need to know which VM is the one with the problem, as we have multiple clones running at the same time.

    -M



  • 6.  RE: Getting VM Name from Inside the VM

    Posted Aug 07, 2008 06:03 PM

    Sorry guys I posted the same question just a sec ago. I didn't see this posting. Can a moderator please delete it?

    I'd like to do the same thing so I can do my own post configuration on my Citrix servers. I've found the new sysprep in VC2.5 to be EXTREMELY lacking compared to 2.0 so I'd like to be able to pull the VM name to configure the VM's hostname and join the domain via script upon runonce.



  • 7.  RE: Getting VM Name from Inside the VM

    Posted Aug 07, 2008 08:24 PM

    The way we ended up doing it is somewhat round about but works well for us.

    We create clones from a standard template. We then run a script to change the hostname and computer name (you can do all the other changes and configurations at this point). We then reboot the clone and its a new machine. Then we use the ESX scripting to get the DNS nameof the computer, which is he hostname we just assigned to it and store the VMName and the Hostname into a database table... I can provide more details in a PM if needed.



  • 8.  RE: Getting VM Name from Inside the VM

    Posted Aug 07, 2008 09:12 PM

    I was trying to avoid the user interaction. We have a similar post config app I wrote in vb.net for our physical servers that pulls a xml file from a webserver (to avoid duplicate name issues) looks up the info by the mac address and then renames the server / sets IP / and then joins the domain. This doesn't work so well with the dynamic macs on the VMs so I was hoping to pull the vmname. VMWare does it somehow with thier sysprep process but I haven't see how to do it in code...