Hi all,
I'm working on a very intensive QA testing environment which will include 1000 VMs and 1000 RDM devices exposed to each one of the VMs.
I'm looking for a way to expose RDM devices to VMs according to their LUNID and not according to their LUN names (/volumes/.../naa...).
Is there any easy way to do it?
Thanks for the help,
Nir
How will you map the LUNIDs to specific VMs ?
Is there a rule ? Or do you use an external file (.CSV) ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Both options are actually exceptable.
1. All VMs are named according to convention VM1,VM2... so if I could map the 2 lowest LUNIDs to the first VM and the 2 after to second etc. it could do.
2. A CSV is also a good option.
I tried looking for both solutions but couldn't find anything.
Thanks,
Nir
If you create a .csv file VmLuns.csv with the content something like:
VM,Lun
VM1,12
VM1,13
VM2,14
VM2,15
You can use the next script to add the RDM's to the virtual machines:
Import-Csv -Path VMLuns.csv | ForEach-Object { $vm = Get-VM $_.VM $Lun = $_.Lun $deviceName = ($vm | Get-VMHost | ` Get-ScsiLun | ` Where-Object {$_.RunTimeName.Split(":")[3].TrimStart("L") -eq $Lun}).ConsoleDeviceName New-HardDisk -VM $vm -DiskType RawPhysical -DeviceName $deviceName }
Regards, Robert
I'm afraid there are a few flaws in this.
-) The LUNID alone is not enough to distinguish a LUN, you will also need the HBA, the controller, the target and the LunID
-) The Get-ScsiLun cmdlet returns all LUNs, also the ones that are already used by other RDMs or datastores. You will need to check if the LUN is already in use.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
-) Why would I need the HBA if I sepcify the ESX host?
-) As long as I know which LUNs should go to which VM I should be ok, right?
Thanks,
Nir
If you only have 1 HBA per ESX host, then indeed you do not need to specify the HBA.
LUNs can have the same LUNid but use different targets. For example
vmhba1:C0:T0:L0
vmhba1:C0:T4:L0
Which one do you mean with LUNid = 0 ?
Again, if your SAN infra is only using one target, you won't see this case.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
your points make sense. Changing the first point is not difficult. But I can't find a way to check if the LUN is already in use. Do you know how to do that?
Regards, Robert
Hi Luc,
By target you mean storage path right?
by the way, the script does not work for LUNID 0...
Thanks,
Nir
Let me explain that addressing scheme, it has to be interpreted as follows.
hbaname: the name of the adapter
Channel: a specific port on the HBA
Target ID: a storage controller
Lun: a single disk in the given target
Under a specific Target, the LunIds are unique, but not accross multiple targets and channels.
So you see a specific LunId multiple times on a HBA
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference