This weeks vRealize Orchestrator snippet will show how to get the wwpn from the HBAs of each hosts in the cluster. Input parameter is a cluster object (VcClusterComputeResource), here named cluster.
//input parameter is cluster of type VcClusterComputeResource
//First we will get an array of all hosts in the cluster
var hosts = cluster.host;
//Lets do this for each host
for each (var host in hosts)
{
//This will give us an array of all HBAs of the host
var hbas = host.configManager.storageSystem.storageDeviceInfo.hostBusAdapter;
//Lets do this for each HBA of the host.
for each(var hba in hbas)
{
//We are only interested in Fibre Channel HBAs so only do this if HBA is of type VcHostFibreChannelHba.
if (hba instanceof VcHostFibreChannelHba)
{
//This will give us the WWPN
var wwpn = hba.portWorldWideNameHex;
//Lets get the device (example vmhba1)
var device = hba.device;
//Output will be like: Hostname: myesx.txusa.cloud Device: vmhba1 wwpn: 21:00:00:26:b6:02:c1:01
System.log("Hostname: " + host.name + " Device: " + device + " wwpn: " + wwpn);
}
}
}