【问题标题】:How to get vm cluster name via vmware SDK (pyvmomi)如何通过 vmware SDK (pyvmomi) 获取 vm 集群名称
【发布时间】:2019-05-03 15:47:54
【问题描述】:

我有获取 VM 容量(名称等)的代码。但有一个问题:我需要获取此 VM 的集群名称。如我所见,我们只能获取 LUN 名称,但不能获取集群名称。

                """Getting data from vCenter and parsing It"""

                try:
                   serviceInstance = connect.SmartConnectNoSSL(host=datacenter,user=user,pwd=password)
                except:
                   print "Connection error or cannot retrieve data"

                content = serviceInstance.RetrieveContent()
                viewType = [vim.VirtualMachine]
                recursive = True
                container = content.rootFolder
                containerView = containerView = content.viewManager.CreateContainerView(container, viewType, recursive)
                children = containerView.view
                return children

        def data_processing(self):
                vcContent = self.getting_data()
                for child in vcContent:
                        print child.summary.config

【问题讨论】:

    标签: python pyvmomi


    【解决方案1】:

    应该这样做:

    print(child.summary.runtime.host.parent.name)
    

    【讨论】:

      猜你喜欢
      • 2020-04-22
      • 2019-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 2016-11-09
      相关资源
      最近更新 更多