rlane/fog — comment on commit 2745ca8c9c96efefe77a0d0cdc4f0703a104e74d
File:  line 0
By rlane:

Sure. Previously, each method call like "vm_mob_ref.summary" resulted in a request to the vSphere server and parsing a lot of XML (the whole summary property). There were about 15 of these requests in the code I replaced. Because these requests are expensive, vSphere allows you to retrieve many properties in a single request.

The collect! method on a ManagedObject retrieves a bunch of properties in one request, and you can specify property paths ('summary.guest.hostName' vs 'summary') to get exactly the data you want.

The new code could be sped up another 3x by getting the data for the 'hypervisor' and 'mac_addresses' attrs in the same request. That's more complicated for 'hypervisor' because 'name' is actually a property on a different managed object, and the 'macs' method does its own request. I just went for the low-hanging fruit.