vmware/pyvmomi-community-samples — pull request #127 by xandercrews (2014-10-16 23:53:12+00:00)
Title: WaitForUpdatesEx sample

### overview

the idea behind this sample is to show how to use pyvmomi to invoke WaitForUpdatesEx and monitor properties for changes in vcenter. it includes a port of the full traversal spec builder from the vijava api, and provides arguments to let you specify which objects to monitor by MOtype and property name in the form:

```
-P [MOtype]:[property],[property.subproperty],...
-P VirtualMachine:name,config.uuid
```

if you really want you can even specify properties with children and they will be stringified by pyvmomi:

```
-P VirtualMachine:config,runtime
```

### usage examples

this will print power state changes for every vm, and only stop on ^C (or an error / connection break):

```
cd samples
python2.7 waitforupdates.py -k -s vcenter -u root -p vmware -P VirtualMachine:runtime.powerState
```

this will stop after one call to WaitForPropertiesEx, printing the results that come back. it fetches a few vm properties and the datacenter name:

```
python2.7 waitforupdates.py -k -s vcenter -u root -p vmware -i 1 -P VirtualMachine:name,summary.config.numCpu,runtime.powerState,config.uuid -P Datacenter:name
```

### dependencies

pyvmomi, python2.7, nothing special