我有获取虚拟机容量(名称等)的代码。但有一个问题:我需要获取此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
答案 0 :(得分:0)
这应该做到:
print(child.summary.runtime.host.parent.name)