How to write a workflow to check all Esxi storage paths

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).

Click on “New wokflow”

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.

host – Type: VC:HostSystem:

It will include a specific host so it doesnt need to be an array.

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

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.

In the Visual Binding tab I connect actionResult to the hosts attribute which I already created.This will put all hosts to this array.

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”?


I assign “hosts” and “i” attributes to the “IN” section of custom decision because it is kind of Input.

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

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”

I assign the “hosts” and “i” attributes in “IN” section

And put the “host” in “OUT” section. because host is my output in this script.

The final visual binding is like below:

I select the host by this code:

host = hosts[i];

After that I put new script name “Check host paths”

I assign “host” as an input here

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);
}
}

Now I just need a increase counter to increase the “i” value from 0 to “host.length”.

You can start the workflow and see the result.

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 73 = 76