Using Scripting Objects

Scripting Objects are JavaScript classes that can be used in any Scriptable Task and/or Action. They can be browsed from the API explorer and comes from vRealize Orchestrator core as well as the plugins.

Create a new workflow

  1. Select Workshop folder
  2. Click the New Workflow button
  3. Enter the workflow name: Show VM IP

Add an input

  1. Select Inputs tab
  2. Click the Add Parameter button
  3. Change the parameter name to vm
  4. Change the parameter type to VC:VirtualMachine

Add a scriptable task

  1. Select Schema tab
  2. Drag and Drop Scriptable Task to the workflow schema
  3. Select Visual Binding tab
  4. Drag and Drop the input parameter vm to IN


Select "show ip" scriptable task

  1. Select the scriptable task
  2. Select the Scripting tab

From the scripting tab you can use JavaScript code.  You also have the ability to leverage the API explorer to view the vRealize Orchestrator types available and what type of data is available and can be scripted against.  In your workflow we will be leveraging the VC:VirtualMachine type.

  1. Click the Search API icon
  1. Type VC:VirtualMachine in the Containing text field
  2. Click the Search button
  3. Click on Name column to sort the result by name.
  4. Select VC / VC:VirtualMachine
  5. Click Go to selection
  6. Click the Close button

Undock Scripting tab

  1. Click on Undock icon

API Explorer: Browsing

VC:VirtualMachine Type should be selected in the type list, below there is a description of the object type.

  1. Scroll up if necessary
  2. Click the Scripting Object VcVirtualMachine

A scripting object is the javascript object that can be used in a scriptable task.

API Explorer: Browsing

  1. Click the arrow to expand VcVirtualMachine

This shows all properties and methods in the VcVirtualMachine scripting object.  Take a moment to click on some of the properties.  When a property or method is selected, the lower panel displays details about this property or method.

API Explorer: Browsing

  1. Scroll down until guest attribute is visible
  2. Select the guest attribute.
  3. Click on the VcGuestInfo Return Type

Return Types are the value we can pull via the API for the given object type and property.

Find ipAddress

  1. Expand VcGuestInfo by clicking on the arrow.
  2. Expand the panel by drag and drop the bottom part
  3. Observe all the available attributes, ipAddress is listed as one of the information

Show IP address

If we summarize, we started at the VC:VirtualMachine object which points toward the Scripting class VcVirtualMachine, followed by guest, then ipAddress.
From a javascript standpoint, it is written like this: VM.guest.ipAddress

  1. Enter the following code:

This code writes the IP address of the machine in the log.

  1. Click on the X icon to close the window and dock it back.

Launch Workflow

  1. Click on Run button

Set Virtual Machine input

  1. Click on Not Set

Select Virtual Machine

  1. Navigate to vSphere vCenter Plugin > https://vcsa-01a.corp.local:443/sdk > Datacenters > RegionA01 > vm > util-01a
  2. Click Select

Submit the workflow

  1. The machine selected in the previous step should be visible
  2. Click Submit

Find the IP Address

The IP Address of the VM selected when you ran the workflow is shown in the logs.

Close the workflow editor

  1. Click on Save and close to close the workflow editor and come back to the workflow list.