Hi all
Few days ago I installed vRA 8.4 for POC into our test environment. I was able to create a "Cloud template" for VM provisioning and it works fine.
Now I would like to run some vRO workflows after VM is provisioned. For example "Run Program in guest". It seems that I have to use Subscriptions for this and this part is also implemented. The workflow will run after VM is deployed, but it fails.
Now my question is - how can I pass VM name variable created by vRA to vRO workflow? I know that I have to use keywords "inputProperties" and resourceNames and change a bit Scriptable task in workflow, but how?
I found this blog post, but it is still unclear how to do it 😞
https://vbombarded.wordpress.com/2019/11/14/my-first-vrealize-automation-8-extensibility-workflow-vr...
Please, could you led me to any good tutorial, blog post or video what helps to solve me this issue.
Answer for my question. You have to convert string to VC:VirtualMachine object, before you can use it on this workflow
And I just added next rows into predefined vRO workflow:
var vmName = inputProperties.resourceNames[0];query = "xpath:name='" + vmName + "'";
I could try to find a video, maybe there is one out there. But I will say that the blog post was pretty decent. Are you familiar with workflows and scriptable tasks at all? Or is this your first time working with them? Are you familiar with javascript? That might help us determine how many details you need or other education that might be helpful.
Also note that if you look at a particular run of your workflow (On your workflow, Choose All Runs, Click on a run), there is a Variables section. If you click on that section you should be able to find the inputProperties variable and expand/explore it. And essentially whatever is in there, is what you'll have access to in your script when you add inputProperties as an Input. So maybe review some of your failed runs just to see what you have available there.
Again, if your new to all of this, you may need some initial education on how to use workflows
var vmName = inputProperties.resourceNames[0];
var customProperties = inputProperties.customProperties;
var myProp = customProperties.myProp;
System.log("VM Name: " + vmName);
System.log("My Prop: " + myProp);
Check out Scott's Extensibility 101 - YouTube series. The second part is about vRO.
Thank you for quick answer!
True, I'm not familiar with javascript, but I can learn. And this was the reason, why I wanted at firts to use predefined (Run program in guest) vRO workflows. Your example works (inside subscription) without any problem and it logs the VM name.
But in my workflow I need this name as a type "VC:VirutalMachine" and not a String
I modified predefined script a bit and put it into Subscription Workflow , but without any success:
// var host = vm.sdkConnection;
var vm = inputProperties.resourceNames[0];
var host = vm.sdkConnection;
var guestOperationsManager = host.guestOperationsManager;
....
Running that script gives me an error:
TypeError: Cannot read property "guestOperationsManager" from undefined (Workflow:Copy of Run program in guest / Scriptable task (item1)#7)
Answer for my question. You have to convert string to VC:VirtualMachine object, before you can use it on this workflow
And I just added next rows into predefined vRO workflow:
var vmName = inputProperties.resourceNames[0];query = "xpath:name='" + vmName + "'";
Glad you got it working. I also think there may be an out-of-the-box workflow that does something similar - Get VM by Name, or something to that effect. So you could get the vm's name in the scriptable task, make sure that variable is Output of the scriptable task and pass it into that workflow.....which would then output the matching VMs.