Hi All,
I've got multiple TXT files which containts the dump like below:
NAA PSP PathCount IOPSValue ATSMode
--- --- --------- --------- -------
naa.624a937095607650b5eaec0800010002 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010003 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010004 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010005 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010007 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010008 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010009 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001000a RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001000b RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001000c RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001000d RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001000e RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800010010 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011022 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011023 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011025 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011026 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011027 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011028 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec0800011029 RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001001f RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001102a RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001102b RoundRobin 4 1000* N/A
naa.624a937095607650b5eaec080001102c RoundRobin 4 1000* N/A
So how can I convert that NAA column into the VMFS data store display name so that I can identify easily ?
Thanks,
If you don't have powerCLI download and install it (in the header): VMware vSphere™ PowerCLI
Then open Powershell and:
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop
Connect-VIServer @IPofYourvCenter -Credential (get-credential)
Once you are connected to your vCenter:
Copy and paste my scripts in your shell.
For the list of all your datastores with their luns
Get-Datastore | Convert-DSToCanonical
If you want to check only the ones in your text file, Remove everything in the text file except the naa.*, one per line. say it's called IQN.txt in your current directory.
Get-content .\IQN.txt | Convert-CanonicalToDS
Should do, let me know it goes.
I actually already have a function I wrotein my profile that I use quite often.
input for DS to Can is a datastore object.
Input for Can to DS is a string.
Here it is for you:
[EDIT: Functions improved, see below]
Now it takes multiple inupts in both directions with pipeline and gives the can name with the ds name (makes more sense than before).
So you'll just need to put all your canonical names in a variable like $CanName.
$CanName | Convert-CanonicalToDS
Nice functions!
You might have an issue with Convert-DSToCanonical when a datastore has two or more extents.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Good point, I actually have no datastores with multiple extent, I haven't needed it yet and try to keeps things as simple as possible so I didn't make that test.
I expect it to:
To confirm though, my lab runs on workstation so I couldn't add an extent to my datastore because of ATS support ...
I'd be curious to see what's the output.
I just improved it a little, the output now makes more sense and runs faster. Also take multiple canonical names.
Function Convert-DSToCanonical {
param(
[Parameter(Mandatory = $True,ValueFromPipeline=$True)]
[VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl[]]
$datastore
)
Process {
$datastore | where type -eq VMFS | ForEach-Object {
$CanonicalName = (Get-View $_).Info.Vmfs.Extent.diskname
[pscustomobject]@{
CanonicalName = $CanonicalName
Datastore = $_.name
}
}
}
}
Function Convert-CanonicalToDS {
param(
[Parameter(Mandatory = $True,ValueFromPipeline=$True)]
[string[]]
$canonicalname
)
Begin {
$Table = Convert-DSToCanonical (get-datastore | where type -eq VMFS)
}
Process{
$canonicalname | ForEach-Object {
$Table | where CanonicalName -eq $_
}
}
}
Hi Vxav, how to execute the function to convert the text file with canonical name to VMFS datastore label ?
If you don't have powerCLI download and install it (in the header): VMware vSphere™ PowerCLI
Then open Powershell and:
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop
Connect-VIServer @IPofYourvCenter -Credential (get-credential)
Once you are connected to your vCenter:
Copy and paste my scripts in your shell.
For the list of all your datastores with their luns
Get-Datastore | Convert-DSToCanonical
If you want to check only the ones in your text file, Remove everything in the text file except the naa.*, one per line. say it's called IQN.txt in your current directory.
Get-content .\IQN.txt | Convert-CanonicalToDS
Should do, let me know it goes.
many thanks for the assistance and the solution here Xavier b
it works great.