vmware/pyvmomi-community-samples — pull request #83 by mriehl (2014-07-15 07:28:01+00:00)
Title: Sample/simple interaction

This pull request makes simple experiments in an interactive python shell much easier.
It also fixes the gripes I have with the `getallvms` sample:
* uses generators instead of building greedy lists
* in `getallvms`, the function `print_vm_info` also does work of getting VMs (recursion) which is a really bad design example IMHO
* The actual code I have to write just to look at all VMs is too complex

With this module, the following just works for example:

```python
>>> from samples.interactive_wrapper import VVC
>>> vcenter_host = VVC("vcenter-host.invalid")
>>> vcenter_host.connect("mriehl")
Password for vcenter-host.invalid:
>>> for vm in vcenter_host.get_all_vms():
... print("VM has first network interface {1}".format(vm.name, vm.get_first_network_interface_matching(lambda _: True).name))
```

There are docstrings for almost everything and, most importantly, good test coverage.
The few convenience methods that are implemented were useful to us to deal with various automation problems.
I understand it might look a bit awkward to wrap the VIM objects in classes, but I really don't want to be dealing with `childEntity` and whatnot in an interactive session.