0

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

user2264738
  • 302
  • 4
  • 18

2 Answers2

1

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
marcus
  • 51
  • 2
0
from pyVim import connect
from pyVmomi import vmodl
from pyVmomi import vim


address = ''
username = ''
password =  ''

con = connect.SmartConnect(host=address, user=username, pwd=password)
content = con.RetrieveContent()

cv = content.viewManager.CreateContainerView(
            container=content.rootFolder, type=[vim.HostSystem], recursive=True)
for child in cv.view:
    print child.name, ": ", child.config.network.dnsConfig.hostName
user2264738
  • 302
  • 4
  • 18