4.0

Table Of Contents
}
// Method to get all the host systems in a vCenter Server host
var hostSystems = vimHost.getAllHostSystems();
if (hostSystems != null) {
for (var j = 0; j < hostSystems.length; j++) {
var hostSystem = hostSystems[j];
System.log("--- HostSystem '" + hostSystem.id + "'");
}
}
// Method to get all the virtual machines in a vCenter Server host
var vms = vimHost.getAllVirtualMachines();
if (vms != null) {
for (var j = 0; j < vms.length; j++) {
var vm = vms[j];
System.log("--- VM '" + vm.id + "'");
System.log("--- VM '" + vm.getName() + "'");
var guestInfo = vm.guest;
System.log("--- VM guestInfo '" + guestInfo + "'");
if (guestInfo != null) {
System.log("--- VM guestInfo.guestFamily '" + guestInfo.guestFamily + "'");
}
}
}
}
Set vCenter Server Option Values
The following JavaScript example allows Orchestrator to set vCenter VcOptionManager option values.
var myVcOptionValue = new VcOptionValue();
myVcOptionValue.key = VimAdvancedOptionKey;
myVcOptionValue.value_LongValue = VimAdvancedOptionValue;
You can set the following optional value types as VcOptionValue attributes.
value
Attribute is a string value.
value_FloatValue
Attribute value is a float value.
value_IntValue
Attribute value is an integer value.
value_LongValue
Attribute value is a long value.
Workflow Scripting Examples
Workflow scripted elements, actions, and policies require scripting examples of common workflow tasks. You
can cut, paste, and adapt these examples into your scripted elements.
Return All Workflows Run by the Current User
The following JavaScript example obtains all workflow runs from the server and checks whether they belong
to the current user. You can use this scripting with Webview components, for example.
var allTokens = Server.findAllForType('WorkflowToken');
var currentUser = Server.getCredential().username;
var res = [];
for(var i = 0; i<res.length; i++){
Chapter 4 Scripting
VMware, Inc. 129