VMware {code} Community
samsvmware
Enthusiast
Enthusiast

how to get the dns name of vm ?

i need a perl api script to get the dns name of vm from vshere webclient ..

Reply
0 Kudos
2 Replies
stumpr
Virtuoso
Virtuoso

The DNS name, as reported by the Guest Tools, is available through the GuestInfo properties of the VirtualMachine in the API.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
MR-Z
VMware Employee
VMware Employee

You would need to look the managed object "VirtualMachine" to figure out where properties have the information you need. For example, the "guest" property.

https://www.vmware.com/support/developer/converter-sdk/conv51_apireference/vim.VirtualMachine.html#f...

To find out what information is provided within the "guest" property, notice that the property is of the "guestinfo" data type. Look up that datatype and notice the "hostName" property. That is the dns Name of the guest.

https://www.vmware.com/support/developer/converter-sdk/conv51_apireference/vim.vm.GuestInfo.html


Here are some sample codes:

my $vms = Vim::find_entity_views(view_type => 'VirtualMachine',properties => ['name', 'guest'], filter => {"name" => qr/^$vmName/i});

print "\nName: <$vm->{'name'}>\n";

my $DNSname = $vm->guest->hostName;

Reply
0 Kudos