A frequently asked question is How to find the name of the host from inside a guest VM.
https://communities.vmware.com/t5/Virtual-Machine-Guest-OS-and-VM/How-to-find-the-host-on-which-VM-i... https://communities.vmware.com/t5/ESXi-Discussions/Get-host-name-from-inside-guest-os/td-p/1365645 https://communities.vmware.com/t5/ESXi-Discussions/Extract-ESXi-host-information-from-vm-guest-serve... https://communities.vmware.com/t5/vSphere-Guest-SDK-Discussions/Question-on-finding-the-Hostname-fro...
Many years ago it was doable but is no longer so allegedly for security reasons. There *is* a supported way of "Finding the ESX/ESXi host on which a virtual machine is running" (https://kb.vmware.com/s/article/2004187 ). But you have to have access to the vCenter Server database, not from inside the guest. The same question is also often asked on the forums for Oracle Virtualboxes and Microsoft VMs. Only MS VMs publicly support this feature.
At our shop we'd like to prevent this situation from happening: a software cluster, such as Oracle RAC or MySQL cluster, has all nodes (VM guests) on the same ESXi host. If this happens, HA (high availability) is somewhat compromised because if the host crashes, all cluster nodes crash. It would be nice if the admins managing these clusters running on their VMs were given permission to find such situations without given access to the hosts. No need to find the actual hostnames or IPs of the hosts. Any clue to this situation would be more than enough.
DRS rules can stop certain VMs from being on the same host, assuming your host cluster is enabled for DRS.
yes exactly, affinity rules will help to solve the problem