4.2

Table Of Contents
Access Managed Object Reference Types
The following JavaScript example allows Orchestrator to access data objects with the return type
ManagedObjectReference. Getters and setters that end with
_ManagedOjects
return
ManagedObject
or
List<ManagedObjects>
.
// virtualMachine is a workflow input parameter
var virtualMachineSnapshotInfo = virtualMachine.snapshot;
var virtualMachineSnapshot = virtualMachineSnapshotInfo.currentSnapshot;
// The reverse operation
virtualMachineSnapshotInfo.currentSnapshot = virtualMachineSnapshot;
In versions of Orchestrator earlier than 4.1, you must use the toManagedObject() method to convert object
references, for example workflow input parameter objects, to managed objects. The following JavaScript
operation works in Orchestrator 4.1, but it is no longer necessary.
// vCenter Server 4.0 plug-in code
var virtualMachineSnapshot = VcPlugin.toManagedObject(
virtualMachine, virtualMachineSnapshot);
Handle Enumeration Types
The following JavaScript example allows Orchestrator to use scripting to handle vCenter Server enumerations
through the vCenter Server plug-in.
// a VcSharesLevel FINDER ENUMERATION TYPE, for example
// received from an input parameter
var sharesLevel = ...
// get the String value of the FINDER ENUMERATION TYPE
var sharesLevelString = sharesLevel.value;
// Assign to a DataObject
var sharesInfo = new VcSharesInfo();
sharesInfo.level = sharesLevel;
Discover Host Machines and Virtual Machines
The following JavaScript example allows Orchestrator to use scripting to find host machines and virtual
machines through the vCenter Server plug-in.
var sdkConnections = VcPlugin.allSdkConnections;
System.log(sdkConnections.length + " SdkConnections found");
for (var i = 0; i < sdkConnections.length; i++) {
var sdkConnection = sdkConnections[i];
System.log("SdkConnection '" + sdkConnection.id + "'");
// Hierarchy entry point
var rootFolder = sdkConnection.rootFolder;
// Get the property 'name'
var name = rootFolder.name;
System.log("--- Root folder '" + name + "'");
// Get the folder's data centers
Chapter 2 Using the vCenter Server 4.1 Plug-In
VMware, Inc. 17