VMware Cloud Community
joehilarious
Contributor
Contributor
Jump to solution

PowerCLI and RDM from a recovery center

We have a scenario where we have 2 Compellent SANs that replicate important data to a DR site. When writing scripts for VMware, we need to create RDM mappings using the latest Replays (These are snapshots on the SAN). I was able to determine the ScsiCanonical name amongst other properties when testing my failover, and it worked...once. The next time, using the next day's SAN snapshot, resulted in a failure to add the RDM drives. I discovered that the Canonical name had changed. Since each replay is a unique representation of the volume, this appears to be a changing number, making it difficult to write a script to accomodate this change. The only static property that I can find is the LUN number (0,1,2,3,etc...), however, I have not found a good way to pull this number from the host. In this environment, the LUN number is only presented to DR host, and the script has to identify that RDM and Create a new disk to the VM in question. Anyone have any ideas on how to retrieve all the LUN numbers on the host? The VMHBA name would be unique as well, but all of my volumes attache with an naa.000 type of format.

Tags (5)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Yes, you're right.

I suspect the script in is closer to what you're looking for.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

Did you already check out the script in ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
joehilarious
Contributor
Contributor
Jump to solution

Yes, I did play with it a bit, however, I think it assumes that the RDM I am interested in is already added to a VM, however, the raw device I need the LUN for is yet to be associated to a VM. Hope that makes sense.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, you're right.

I suspect the script in is closer to what you're looking for.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
joehilarious
Contributor
Contributor
Jump to solution

Looks promising. Running as is I am finaly seeing LUN numbers from the $target.Lun | select LUN, but not all of them. I will play with the property. I think it is what I am looking for. Thanks a lot for your help.

0 Kudos
joehilarious
Contributor
Contributor
Jump to solution

Here is the portion I was ultimately able to use. The end echoes out all the luns present that are Fiber Channel. I can use these properties to select the proper disk and create a new RDM. Thanks again!!

$hashTab = @{}

$lunTab = @{}

$esx = Get-VMHost -Name pcsvm1.pinncomp.local | Get-View

foreach($lun in $esx.Config.StorageDevice.ScsiLun){

$lunTab[http://$lun.Key|http://$lun.Key] = $lun.CanonicalName

}

foreach($hba in $esx.Config.StorageDevice.ScsiTopology.Adapter){

if($hba.Adapter -like "FibreChannelHba"){

foreach($target in $hba.Target){

foreach($lun in $target.Lun){

$key = $lunTab[http://$lun.ScsiLun|http://$lun.ScsiLun] + "@" + $esx.Name

}

}

}

}

foreach ($mylun in $target.Lun) {

echo $mylun.Lun

}

0 Kudos
Hypnotoad
Contributor
Contributor
Jump to solution

Hey Joe,

I'm doing the same thing as you. I have a two Compellent SANs and replicating to a DR site. That script you posted is great but only shows half of my LUNs. I'm trying to figure our why. I have two port HBAs and two ESXi servers at my DR site and I suspect that this has something to do with that.

--Patrick

0 Kudos
joehilarious
Contributor
Contributor
Jump to solution

Hypno,

I actually had to reference this post for myself. My appologies for not responding to your post, not sure how I missed the email notification.

Ironically, I am seeing the symptoms you mentioned now, possibly an upgrade has caused this. Did you ever find a solution?

0 Kudos
joehilarious
Contributor
Contributor
Jump to solution

I got it figured out. Not sure what caused this to start, but I cleaned up the script with what appears to be needed.

0 Kudos
Hypnotoad
Contributor
Contributor
Jump to solution

Joe,

Here is the thread where we got this all sorted. Maybe it will help.

http://communities.vmware.com/message/1687131#1687131

--Patrick

0 Kudos
Wolfee
Contributor
Contributor
Jump to solution

We're doing something very similar. (Compellent & replay as RDM to VMs.) - We're using an enterprise job automation app to attach replays to VMs daily. To get the naa.id - We have the storage team "dump" a csv file which we read in to do the mapping. Compellent offers PowerShell snap-ins which we orginally used to directly query the array but now we simply let the storage team dump the file and we read it in to do the Replay mapping.

0 Kudos