Script Debugger

Hmmmmm… finished 🙂
Unfortunately, there is no built-in debugging tool for scripting elements. So no breakpoints, no variable inspection, no tracing.
As a workaround, the only way to see the content of variables is to log them, e.g. to System.debug. Example:
</div>
<div>//vm is an input parameter with type VcVirtualMachine)
 System.debug("vm: " + vm);
 var vmname = vm.name;
 System.debug("vmname: " + vmname);
 var numvcpus = vm.summary.config.numCpu;
 System.debug("VM " + vmname + " has " + numvcpus + " vCPUs");</div>
<div>
Gives following output in script-log.log in $INSTALLDIR\app-server\server\vmo\log:
2011-02-26 17:09:59.010+0100 DEBUG [SCRIPTING_LOG] vm: DynamicWrapper (Instance) : [VcVirtualMachine]-[class com.vmware.vmo.plugin.vi4.model.VimVirtualMachine] -- VALUE : VirtualMachine<vm-128>'lab-db'
2011-02-26 17:09:59.011+0100 DEBUG [SCRIPTING_LOG] vmname: lab-db
2011-02-26 17:09:59.015+0100 DEBUG [SCRIPTING_LOG] VM lab-db has 1 vCPUs
You can see the timestamp (see log4j-config for format), the loglevel DEBUG. For numbers and strings you can see the plain content, for complex data type you can see the type of the variable (e.g. [VcVirtualMachine]-[class com.vmware.vmo.plugin.vi4.model.VimVirtualMachine]) and it’s toString() implementation (VALUE : VirtualMachine’lab-db’).