0

I have code which gets VM capacity (name etc). But one problem: I need to get cluster name of this VM. As I can see , we only can get LUN name , but not cluster name.

                """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

1 Answers1

1

This should do it:

print(child.summary.runtime.host.parent.name)
Amir Shabani
  • 3,857
  • 6
  • 30
  • 67
marcus
  • 51
  • 2