vmware / pyvmomi-community-samples

A place for community contributed samples for the pyVmomi library.
Apache License 2.0
1.02k stars 923 forks source link

Sample: Work with views that need UpdateViewData-like calls #40

Open hartsock opened 10 years ago

hartsock commented 10 years ago

Demonstrate something similar to:

ds = get_datastore_by_name('datastore_1') ds.update_view_data(name='datastore_01')

hartsock commented 10 years ago

NOTE: This is kind of an interesting problem UpdateViewData is provided as an addon tool in both the Perl SDK and in the Power CLI product lines. The Perl SDK source is visible and should be reproducible in Python.

EDIT: I'm tracing out how the Perl SDK handles this problem and I may pull in help from the Perl team to finish the sample. This will be submitted as a pull request from my own repo since it is unlikely I'll be able to make this work cleanly in my first attempt.

hartsock commented 10 years ago

I've spent the last two work days tracing the inside of the VmomiSupport.py and related tools. In short, each object you have (for example if I did get a vim.Datastore object) has a set of dynamic SOAP handlers associated with it. The trick is to be able to invoke the rename task and then re-invoke the original property collector that retrieved the object.

There's a couple interesting edges here...

I am slowly making progress on this and learning the VmomiSupport internals as I go.

Edit:

See also vim.host.NetworkInfo