【问题标题】:PySphere/pyvmomi how to retrieve the DNS and Routing settings of an EXSi host?PySphere/pyvmomi 如何检索 EXSi 主机的 DNS 和路由设置?
【发布时间】:2019-09-27 22:39:54
【问题描述】:

Using PySphere 库如何检索 EXSi 主机的“DNS 和路由”配置。

这里我需要检索 DNS and Routing -udm00esx04

下的 Name 属性

【问题讨论】:

    标签: python vcenter pyvmomi


    【解决方案1】:

    VMware pyvmomi page 上,有一个指向vSphere WS SDK API documentation 的链接。

    虽然这些文档并不总是直观的,但我可以在其中找到此类问题的答案。

    要回答你的问题,你需要先获取主机对象,然后获取你想要的网络属性(属性)。假设“esxi”是vim.HostSystem类型的对象,下面会得到你想要的信息:

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

    【讨论】:

      【解决方案2】:
      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
      

      【讨论】:

        猜你喜欢
        • 2014-02-15
        • 2018-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-07
        相关资源
        最近更新 更多