Scripting and environments
- 4.1JavaScript in Orchestrator: the Rhino engine
- 4.2Writing and reusing actions
- 4.3Python actions and environments
- 4.4Node.js actions
- 4.5PowerShell and PowerCLI actions
- 4.6Logging from scripts
- 4.7Working with configuration elements in code
- 4.8Scripts that read well
- 4.9Reading inputs in Python, Node.js and PowerShell
Chapter 3 drew workflows. This chapter is about the code inside them. Every scriptable task, action, scripted decision, and form action is a script, and the quality of those scripts decides whether a workflow is easy to trust and change, or a puzzle for whoever opens it next.
Recipe 4.1 starts with the engine that runs your JavaScript, and why this book keeps to plain ES5.1. Recipe 4.2 turns scripts into a library of small actions that other workflows call, and shows how to change them without breaking anything. Recipe 4.3 steps outside JavaScript to Python, and to the environments that give a script its packages. Recipes 4.4 and 4.5 do the same for Node.js, with its callbacks, and for PowerShell and PowerCLI, with their habit of returning more than you meant. The last two recipes are about habits that apply in every language: recipe 4.6 makes scripts leave a useful log behind, and recipe 4.7 moves settings and credentials out of code and into configuration elements. Recipe 4.9 goes back to the three other runtimes side by side, to show how each input type reaches a Python, Node.js or PowerShell script.
The examples
Section titled “The examples”Most examples in this chapter are actions, so they go in one module:
| Object | Name |
|---|---|
| Action module | com.vcfguide.chapter4 |
| Workflow folder, for anything that needs one | VCF Orchestrator Guide/Chapter 4 |
| Environments | vcfguide_python_crypto, vcfguide_node_semver |
| Configuration elements, in the folder VCF Orchestrator Guide/Chapter 4 | vcfguide-settings, and vc01.vmw.lab in the subfolder vCenters |
Like Chapter 3, the examples only read from the lab: the vCenter vc01.vmw.lab, its VMs and snapshots, and the TLS certificate it presents. The PowerCLI examples connect to it with a read-only account, svc-vcfguide-ro@vsphere.local. JavaScript samples, including those for the Node.js runtime, are plain ES5.1, except where recipe 4.9 shows Node.js promises and async on purpose. Python samples are ordinary Python 3.14, and PowerShell samples run in PowerShell 7.6.
What changed since vRO 7
Section titled “What changed since vRO 7”Writing JavaScript in Orchestrator has hardly changed. Almost everything around it has.
