When running the following workflow /Library/vCenter/Batch/Run a workflow on a selection of objects
How do you import a list of VMs to populate the virtual machines array ?
Right now we're manually selecting the VMs and adding them to the array individually which is very tedious. We'd like to just import a list.
There are quite a few ways you could do what you are trying to do but from your description it sounds like a wrapper will work best. I am attaching a simple workflow that loads the array from a csv. There is no error checking going on but it should get you started and you can expand upon it from there.
How can you do this depends on how you triggers workflow runs. You can use a wrapper workflow which gathers VMs in an Array based on some condition. Then this array is passed to Run a workflow on a selection of objects workflow.
We trigger workflow runs manually and would like to pass a list of VMs to populate the array instead of selecting each one manually. A wrapper workflow would work but how to import the list of VMs?
This wrapper workflow can collect VMs based on a condition. The same condition you use to collect VMs manually
Can you please explain in more detail. Specifically what you mean by 'collect VMs based on a condition'.
When we populate the VM array each VM is selected from the list presented in orchestrator.
How this list is collected in Orchestrator? Can you describe this? Screenshot may help also. By condition I meant name pattern, power state, performance metrics like CPU usage, or anything else that you are using to collect VM base on it.
The list is not collected in orchestrator and is not based on any condition. The VM list is a manually created csv that contains VM names.
For example, I want to run a workflow on a few VMs. I create a csv (test1.csv) with the VMs entered manually.
test1.csv contains:
testvm1, testvm2, testvm3, testvm4, testvm5
Now we have a workflow that we want to run on all the VMs in this list.
Ideally the file will be ask for when I run the workflow (browse file) or a UNC path already configured in the workflow. Is this possible?
It is. You should use a script to read a file then covert this list of names to array and make a request to REST API to run the workflow with this array of names. Then workflow will collect VMs with given names and pass it to batch workflow. Look at https://[orchestrator]:8281/develop.jsp for REST API definitions. Also look at Using the vRealize Orchestrator REST API.
Ok, thanks for the info. Do you have a sample script/workflow that does this?
Unfortunately, no. That's why I pointed you to docs. You can search in community for curl examples how to run workflow but I am not sure there is something how to parse csv file and create an array from the content
Ok will do. I'm new to VCO and find it hard to believe that no one else has run into this situation before. It seems like an obvious and common use case.
There are quite a few ways you could do what you are trying to do but from your description it sounds like a wrapper will work best. I am attaching a simple workflow that loads the array from a csv. There is no error checking going on but it should get you started and you can expand upon it from there.
Thanks for the sample workflow. It's exactly what we're looking for.
No problem... getting going with vRO can be a little rough but once you come up to speed its pretty awesome. There is a ton of talent in the forums that can help you out!
That's good to hear.
I've been having problems integrating your code into the /Library/vCenter/Batch/Run a workflow on a selection of objects workflow. I've attached a copy.
How do you get the array that is created by your load vms from csv workflow into this one?
Well you wouldn't integrate it into the "Run a workflow on a selection of objects" workflow you would insert another step in the workflow that is gathering the vm objects or create a 3rd workflow that has two steps in it the first step would be calling the workflow that gathers the vm's and the second step would run the "Run a workflow on a selection of objects". You just need to connect the inputs and outputs. If I get a chance tomorrow morning I'll upload a sample for you.
You would greatly benefit from spending a few hours going through some of the instructional videos and/or reading through one or the Orchestrator books that are out there if you haven't already. They do a much better job than I can at explaining how all the plumbing works.
Ok, thanks for the info. Whatever method that works is fine. If you don't mind uploading a working sample, it would be much appreciated.
Thank You! The sample is very helpful. I'm sure others will benefit as well. It seems like a common question in the forum that does not have a definitive answer/solution.