Today I need to write a workflow to check all storage path status and make a report. In this article I just show how to write scripts and configure the workflow.
First of all I need to create a workflow in vRealize Orchestrator (vRO).
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/1.jpg)
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/2-1024x586.jpg)
I call it “PathCheck”.Now I need to define some attributes:
hosts – Type: Array of VC:HostSystem:
This will include all hosts in the vCenter server, so I need to configure it as an Array.I dont fill it with any values because it will propagate with an action.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/3-1024x603.jpg)
host – Type: VC:HostSystem:
It will include a specific host so it doesnt need to be an array.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/5-1024x591.jpg)
i- Type: number:
It starts from 0 and select each of my array (hosts) value, one by one.So i defined a value of 0 for it
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/6-1-1024x611.jpg)
In this part I need an action to get all of my hosts in cluster.This action is already done by VMware, I use getAllHostSystem action and drag it to my workflow.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/7-1024x595.jpg)
In the Visual Binding tab I connect actionResult to the hosts attribute which I already created.This will put all hosts to this array.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/8-1024x598.jpg)
I need a custom decision here, to define whether the workflow needs to keep running or not so I create a custom decision named “Next host”?
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/9-1024x595.jpg)
I assign “hosts” and “i” attributes to the “IN” section of custom decision because it is kind of Input.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/10-1-1024x547.jpg)
In the scripting section I need a code to make the workflow understand to how long it should be running.
If I become more than the number of hosts in vCenter server it will stop the workflow
return i < hosts.length
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/11-1024x591.jpg)
In this part of workflow I need to select a host from “hosts” array.
So I select the host in this way:
I create a script and named it “Select a host”
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/12-1024x588.jpg)
I assign the “hosts” and “i” attributes in “IN” section
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/13-1024x593.jpg)
And put the “host” in “OUT” section. because host is my output in this script.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/14-1024x562.jpg)
The final visual binding is like below:
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/15-1024x626.jpg)
I select the host by this code:
host = hosts[i];
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/16-1024x623.jpg)
After that I put new script name “Check host paths”
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/17-1024x622.jpg)
I assign “host” as an input here
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/18-1024x620.jpg)
And my code to check the status of path on every single host
for each (var path in host.configManager.storageSystem.multipathStateInfo.path){
if (path.pathState != "active"){
System.log("Path name is : " + path.name)
System.error("Path state is : " + path.pathState);
}
}
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/19-1-1024x620.jpg)
Now I just need a increase counter to increase the “i” value from 0 to “host.length”.
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/20-1024x624.jpg)
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/21-1024x620.jpg)
![](https://www.vmehrabi.com/wp-content/uploads/2019/10/22-1024x624.jpg)
You can start the workflow and see the result.