VMware Cloud Community
SteveCSchofield
Enthusiast
Enthusiast

debugging, developing script blocks within vRO

I'm a scripter who has used other languages. How does a person develop / test, debug and validate script blocks that get put into script blocks. I'm still on the newbie side of vRO, but have written scripts in javascript, vbscript, powershell, some batch files etc.. This is a different thing.


When writing scripts, I try to write little "blocks of script" to ensure syntax is correct, debugged before making them more complex.  Is there a step by step feature like other tools?

6 Replies
iiliev
VMware Employee
VMware Employee

At the moment, there is no Javascript line-level debugger in vRO. You can set breakpoints and stop/inspect/resume execution on item level only in workflow designer.

For finer-grained debugging of your script code, you can use so called printf() debugging technique - by adding System.log(...) statements to output variable values/etc. at key points in your script flow. A bit primitive Smiley Happy but usually works good enough.

Reply
0 Kudos
SteveCSchofield
Enthusiast
Enthusiast

Thanks for the answer.  That is what I thought, but wanted to ask.  How do you develop scripts from scratch.  I'm a "scripter type" and when switching languages my biggest hurdle getting the syntax correct.   Since I'm new to JavaScript, I'm not sure how best to develop from scratch.  With other languages like Python, Powershell I've used, I could use notepad, a CLI to do "trial and error" development Smiley Happy    I'm thinking for now I'll write in a language I know and convert to JavaScript until I get better acquainted with JavaScript Object model and all objects available within vRO.

I'm going through a couple books written on vRO and seem to provide direction so maybe the "light bulb" will go on.   take care.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

There are some videos on YouTube that might be helpful; just open youtube.com and search for vro workflow.

Javascript syntax is simple so if you are familiar with other programming languages you'll get acquainted with it quickly. You can take a look at scripting actions that come out of the box with vRO installation - just open vRO Java client, switch perspective from 'Run' to 'Design' using the dropdown in the top area, ans select the second tab in the panel on the left.

For trial and error development, you may create a new workflow, drop a 'Scriptable task' element in it, write some scripting code inside the scriptable task editor, and run the workflow to check what will happen. Then repeat.

To see what scripting objects are available, check the API explorer - Java client -> Tools -> API Explorer.

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso

One tool that it sounds like you will enjoy is the vRO CLI plugin.  You'll have to install it as it is not (yet) included out of the box but I think it may be close.  It will give you a lot of what other REPL style shells do for other languages.  I use it for exploration of vRO plugins and scriptable objects in a similar fashion to how I use the node cli to explore javascript.  You can download it here vCO-CLI and you'll also want to take a look at some of the blog posts on how to use it.  This is a really good one vCO CLI Fling User Guide - Elastic Skies .  I'd also suggest getting a good json tool like Power JSON Editor or something similar if you haven't done much work with javascript objects.

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso

Ack... I just realized I didn't give you the correct link for the cli... you will want the one here Technical Preview of the Command Line Interface for VMware vCenter Orchestrator 7.0.0 and above

Reply
0 Kudos
hyperVisorGuy
Contributor
Contributor

new to vro here and gosh what a nightmare of an IDE (I wouldn't even call it that). So I'm having a hard time understanding from your posts here - is this "Command Line Interface for VMware vCenter Orchestrator" going to help in anyway for stepping through the actual javascript code in scriptable tasks within a workflow? If not - there HAS to be a way to build up some sort of IDE and mock the input params and debug this rhino javascript right? Any direction you can give me is much appreciated!

Here is where my head is at: I'm sorry...but yes while rhino javascript is 'simple' syntactically - statically analyzing hundreds of thousands of lines of code with different styles from different developers

(some from vmware!!!!) - nah thanks.

I debug / step through my new greenfield code to prevent bugs.

Same for existing / brownfield code - step through it!

I have tests which validate my code - I step through that, too!

That is how we write software that doesn't suck Smiley Happy

How did vmware product team get away with saying "javascript is going to be the engine for scriptable tasks and oh by the way we're not going to have debugging support for it - but you can just litter your code with debug and log statements and you can debug it's wrapping workflow! (as they pop the champagne cork)" (I've never found debugging a workflow to be very useful yet btw).

Here are their own guidelines:
https://docs.vmware.com/en/vRealize-Automation/7.3/vrealize_orchestrator_coding_design_guide.pdf

the vro product does not provide features to allow for much of this. That said, I'd still like to hack up some kind of rhino specific IDE and be able to step through scriptable tasks from workflows, packages, whatever. Unless this CLI for vro is going to help me in some way here?

Thanks!