VMware Cloud Community
vin01
Expert
Expert
Jump to solution

Lun CanonicalName and display Name

Hi

Why I am not able to write any output. I know there are two luns which are not roundrobin but not writing any output.

foreach($VMhost in Get-VMHost "Esxi1"){

foreach($lun in (Get-VMHostHba -VMHost $VMhost -Type FibreChannel |Get-ScsiLun -LunType disk |where {$_.Multipathpolicy -ne "RoundRobin"})){

foreach($ds in (Get-Datastore -VMHost $VMhost)){

$ds.ExtensionData.Info.Vmfs.Extent | %{ if($_.diskName -eq $lun.CanonicalName){

""|Select @{N="Cluster";E={$VMhost.Parent.Name}},

@{N="VMhost";E={$VMhost.Name}},

@{N="DatastoreName";E={$ds.Name}},

@{N="CanonicalName";E={$lun.CanonicalName}},

@{N="PathPolicy";E={$lun.MultipathPolicy}}                      

}

}

}       

}

}

Regards Vineeth.K
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Can you run the following, and compare the two resulting lists based on the CanonicalName?

Are the LUNs with the MostRecentlyUsed policy appearing in any of the datastores?

Get-Datastore |

Select Name,@{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join '|'}}

Get-VMHostHba -Type FibreChannel | Get-ScsiLun -LunType disk |

Select CanonicalName,MultiPathPolicy


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

View solution in original post

11 Replies
LucD
Leadership
Leadership
Jump to solution

Did you try leaving out the Where-clause, and including the Multipathpolicy as a property on the Select-Object?

Does that list those LUNs, with the assumed Path Policy?

foreach($VMhost in Get-VMHost "Esx*"){ 

    foreach($lun in (Get-VMHostHba -VMHost $VMhost -Type FibreChannel |Get-ScsiLun -LunType disk)){ 

        foreach($ds in (Get-Datastore -VMHost $VMhost)){ 

            $ds.ExtensionData.Info.Vmfs.Extent | %{

                if($_.diskName -eq $lun.CanonicalName){ 

                    ""|Select @{N="Cluster";E={$VMhost.Parent.Name}}, 

                        @{N="VMhost";E={$VMhost.Name}}, 

                        @{N="DatastoreName";E={$ds.Name}}, 

                        @{N="CanonicalName";E={$lun.CanonicalName}},

                        @{N='MultiPathPolicy';E={$lun.MultiPathPolicy}}                  

                } 

            } 

        }         

    } 

}  


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

vin01
Expert
Expert
Jump to solution

I tried leaving where-clause here I can able to view the output of all the luns except the luns which are using path policy as most recently.

Where I need to do select-object?

If I try like this

Get-VMHostHba -VMHost $vmhost -Type FibreChannel |Get-ScsiLun -LunType disk |where {$_.Multipathpolicy -ne "RoundRobin"}

Output:

pastedImage_5.png

Regards Vineeth.K
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The MultiPathPolicy property is already in the output (last column).

Looks like those LUN are not using RoundRobin, but MostRecentlyUsed.


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

0 Kudos
vin01
Expert
Expert
Jump to solution

Yes LucD. But when I execute below script on the same host its not showing any output.

foreach($VMhost in Get-VMHost ){

foreach($lun in (Get-VMHostHba -VMHost $VMhost -Type FibreChannel |Get-ScsiLun -LunType disk |where {$_.Multipathpolicy -ne "RoundRobin"})){

foreach($ds in (Get-Datastore -VMHost $VMhost)){

$ds.ExtensionData.Info.Vmfs.Extent | %{ if($_.diskName -eq $lun.CanonicalName){

""|Select @{N="Cluster";E={$VMhost.Parent.Name}},

@{N="VMhost";E={$VMhost.Name}},

@{N="DatastoreName";E={$ds.Name}},

@{N="CanonicalName";E={$lun.CanonicalName}},

@{N="PathPolicy";E={$lun.MultipathPolicy}}                      

}

}

}       

}

}

Regards Vineeth.K
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That could only mean that the LUNs which do not have RoundRobin are not used in any of the datastores.

Can you check that?


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

0 Kudos
vin01
Expert
Expert
Jump to solution

So you mean to say this lun is mapped to the host but not in use right?

But that is not visible even while adding the datastore.

Should i need to check something else?

Regards Vineeth.K
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you run the following, and compare the two resulting lists based on the CanonicalName?

Are the LUNs with the MostRecentlyUsed policy appearing in any of the datastores?

Get-Datastore |

Select Name,@{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join '|'}}

Get-VMHostHba -Type FibreChannel | Get-ScsiLun -LunType disk |

Select CanonicalName,MultiPathPolicy


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

vin01
Expert
Expert
Jump to solution

Yes those two naa id are not reported when I executed get-datastore.

Regards Vineeth.K
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, then it looks normal that you don't see them in your script at the top.

The LUNs will pass your Where-clause, but then, since they are not used in datastore, they will not pass that test.


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

0 Kudos
vin01
Expert
Expert
Jump to solution

Yes. I am sorry killing your time.

Regards Vineeth.K
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No problem, you're welcome :smileygrin:


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

0 Kudos