This is a very broad topic, you should start here and read the links as well
VLAN configuration on virtual switches, physical switches, and virtual machines (1003806) (vmware.co...
We are using LLDP to recieve this kind of information to esxi hosts.