pythonvcenterpyvmomi

PySphere/pyvmomi how to retrieve the DNS and Routing settings of an EXSi host?


detUsing PySphere library How could it possible to retrive the 'DNS and Routing' configuration of an EXSi host.

Here I need to retrieve the Name attribute under DNS and Routing -udm00esx04


Solution

  • On the VMware pyvmomi page, there is a link to the vSphere WS SDK API documentation.

    While that documentation is not always intutitive, it is where I find answers to questions like this.

    To answer your question, you need to obtain the host object, and then get the network properties (attributes) you want. Assuming "esxi" is an object of type vim.HostSystem, the following will get the information you want:

     # dns name
     esxi.config.network.dnsConfig.hostName
     # domain name
     esxi.config.network.dnsConfig.domainName