vRO – get wwpn from HBAs

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

Published by txusa

VMware Certified Design Expert - VCDX 92. VMware Architect, automation enthusiast.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: