Basic question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Basic question

Moon6
I am having trouble grasping some of the fundamentals of this tool. I have looked over a lot of the examples on the community samples.  They all seem to do tasks on "all" targets of a certain type.

What I am trying to do is list info on VM's in a given DC. eg: for DC X, list VM name, the host it is on, and the datastore it is on.

It looks like in the object hierarchy diagram, these items are in parallel locations and I don't see how they are tied together. Can someone clue me in on how to relate them to each other so I can get this info. Seems easy enough to list all vm's in a dc, list all hosts in a dc, or list all datastores in a dc, but after that I am lost.

Thx,





 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Basic question

nuno.branco


You don't need to work on "separate" objects. You can handle VMs to determine where they reside, compute and storage wise. Example:

content = si.RetrieveContent()
objview = content.viewManager.CreateContainerView(content.rootFolder, [vim.VirtualMachine], True)
vmList = objview.view
objview.Destroy()

for vm in vmList:
  print("VM Name: %s\tESXi Host: %s\tDatastore: %s" % (vm.name, vm.runtime.host.name, vm.config.datastoreUrl[0].name))

You can read the documentation to see the different properties of each object.

Best regards,
Nuno Branco

For secure messages please use the PGP key provided at MIT PGP Database
If you are not familiar with PGP please use this link to send secure messages to me.

On 09/11/2016 06:33 PM, Moon6 [via pyvmomi] wrote:
I am having trouble grasping some of the fundamentals of this tool. I have looked over a lot of the examples on the community samples.  They all seem to do tasks on "all" targets of a certain type.

What I am trying to do is list info on VM's in a given DC. eg: for DC X, list VM name, the host it is on, and the datastore it is on.

It looks like in the object hierarchy diagram, these items are in parallel locations and I don't see how they are tied together. Can someone clue me in on how to relate them to each other so I can get this info. Seems easy enough to list all vm's in a dc, list all hosts in a dc, or list all datastores in a dc, but after that I am lost.

Thx,





 


If you reply to this email, your message will be added to the discussion below:
http://pyvmomi.2338814.n4.nabble.com/Basic-question-tp65.html
To unsubscribe from pyvmomi, click here.
NAML


signature.asc (220 bytes) Download Attachment
Loading...