UCSD: Mapping EMC VNX LUNs to an ESXi cluster

I have been struggling for quite some time with mapping luns from our vnx 5600 to entire clusters in our vCenter. We used to utilize a custom workflow a consultant wrote for us, but that workflow got borked after an update to UCS Director nearly a year ago.
Revisiting the issue i found this example from Cisco: https://communities.cisco.com/docs/DOC-57382

That example seems to work for other people but in our case the custom task in it never gave the correct output, so I had to look for a way around it.

The solution I came up with is overly complicated and can surely be simplified, but my lacking knowledge of javascript limits me quite a bit. My workflow to map luns to vSphere clusters consists roughly of these steps:

  • A powershell task running a script that does the following:
    • Queries vCenter for esxi hosts in given cluster
    • Queries UCS Directors api for a report on storage groups
    • Putting together a storage group identity for each esxi host
    • Returning all storage group identities in a comma separated matter
  • A custom task to parse and convert the output from the powershell task to an output of the emcStorageGroupIdentity type
  • The builtin “add vnx lun to storage group” task

Here’s how I have set it up:


The custom task I use to convert the output from the powershell task is built up the way I describe in this blogpost: http://cloud.kemta.net/cisco-network/ucsd-grabbing-a-string-returned-from-a-powershell-task/

The only difference is the name and type of the output.

Now, let’s look at the workflow user inputs:


In this workflow I haven’t configured any outputs, so let’s move along to the first task: the powershell task.


The reason I have to do a split on the StorageAccount input is that in the script I only want the hostname of the storage system. I could just as well have done it within the script itself.

The powershell script looks like this:

Param (
#Add the vmware snapin
Add-PSSnapin vmware*

#Connecting to vCenter
Connect-VIServer vcenter01 -WarningAction Ignore | out-null

#Getting ESXi hosts
$vmhosts = get-vmhost -location $Cluster

#Polling a report on storage groups from UCS Director
$webrequest = Invoke-WebRequest 'https://ucsd01/app/api/rest?opName=userAPIGetTabularReport&opData={param0:"510",param1:"$($StorageAccount);$($Pod)",param2:"STORAGE-GROUPS-T51"}' -Headers @{"X-Cloupia-Request-Key"="ThisIsNotMyAPIKey"}
#Converting the report from json
$convertedData = $webrequest.content | ConvertFrom-Json

#Creating a blank array to store end result in
$VMhostsArray = @()

#Looping through all esxi hosts found
foreach ($vmhost in $vmhosts) {
    $hostname = (($vmhost.name).split("."))[0] #Removing domain name from esxi host name
    $WWN_Name = ($convertedData.serviceresult.rows | where {$_.Name -like "$($hostname)"}).WWN_Name #Grabbing WWN from UCSD report
    $StorageGroupIdentity = "$($StorageAccount);$($Pod);$($WWN_Name);$($hostname)" #Putting together the storage group identity
    $VMhostsArray += $StorageGroupIdentity #Adding the storage group identity to the array

#Disconnecting from vCenter
Disconnect-VIServer vcenter01 -Confirm:$false

#Returning array to console, comma separated
return $VMhostsArray -join ","

On my test cluster with only two esxi hosts, the output looks like this:


After the custom task has converted the powershell output it looks like this in plain text:


Since the output from the custom task is of the emcStorageGroupIdentity type I can simply map it to the builtin “add vnx lun to storage group” task:


And that’s really all there is to it. If you want to download my example workflow, you can do so here: http://cloud.kemta.net/wp-content/uploads/2015/10/mapVNXLunToESXiCluster.zip


Category(s): Cisco, UCS Director
Tags: , , , , ,

Leave a Reply

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


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