8 Replies Latest reply on Dec 28, 2018 8:01 AM by shallriseagain

    Get Active FC Path WWN of all datastores

    shallriseagain Novice

      Hello. I need to turn off one of the FC switch for maintenance. To turn off the switch smoothly, I want to set the manual path selection mode and switch all datastores to the second switch. I have a lot of datastores, so I wanted to create a csv file in which I could see invofrmation to be sure that I did not miss anything: For example:

      Host         | Datastore | Active Target 192.168.1.2  | DS-01     | 21:00:00:1b:32:8f:d0:a5 

      Unfortunately, all that I found on the Internet and tried to do it myself is to get HBAName, Target and State. I dont know how to comapre HBAName like "vmhba1:C0:T4:L1" with Identifier of Datastore and convert this to Datastore Name in one csv file.

      Please, halp :)

        • 1. Re: Get Active FC Path WWN of all datastores
          LucD Guru
          vExpertUser ModeratorsCommunity Warriors

          Does this help?

           

          Get-VMHost | ForEach-Object -Process {

              $esxcli = Get-EsxCli -VMHost $_.Name -V2

              $esxcli.storage.core.device.list.Invoke() |

              where{$_.IsSharedClusterwide -and $_.DeviceType -eq 'Direct-Access' -and $_.IsLocal -ne 'true'} |

              ForEach-Object -Process {

                  $device = $_

                  $esxcli.storage.core.path.list.Invoke() |

                  where{$_.State -eq 'active' -and $_.Device -eq $device.Device} |

                  Select @{N='Host';E={$esxcli.VMHost.Name}},

                      @{N='Datastore';E={$device.DisplayName}},

                      @{N='RuntimeName';E={$_.RuntimeName}},

                      @{N='PathState';E={$_.State}},

                      @{N='WWNN';E={$_.TargetTransportDetails.Split(' ')[1]}},

                      @{N='WWPN';E={$_.TargetTransportDetails.Split(' ')[3]}}

              }

          }

           

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Get Active FC Path WWN of all datastores
            a.p. Guru
            User ModeratorsCommunity WarriorsvExpert

            To turn off the switch smoothly, I want to set the manual path selection mode and switch all datastores to the second switch.

            Please don't mind me asking, but what's the reason for this? Did you have issues in the past?

            What type/model of storage system do you use, and which path policy (PSP) is in place for the LUNs?

            I've been working with FC environments for years (different switches, different storage vendors), and never had any issues, neither with updating firmware, reboots for other reasons, switch replacements, ...

            If at least one path to the target remains active, you shouldn't need to manually switch paths.

             

            André

            • 3. Re: Get Active FC Path WWN of all datastores
              shallriseagain Novice

              Thank you for reply!

              I'm sorry, I incorrectly asked a question. They are all active.

              Also i have a 4 paths

              50:00:00:e0:da:7c:01:20

              50:00:00:e0:da:7c:01:21

              50:00:00:e0:da:7c:01:30

              50:00:00:e0:da:7c:01:31

              They are all active. I need to find Preffered Active Path of datastore and target WWN of this Path.

              Also in your script i got datastore name like:  FUJITSU Fibre Channel Disk (naa.600000e00d29000000293c0100020000)"

              It`s possible to change it to Fujitsu-01-Vol01 For example how I see it in the vCenter?

              • 4. Re: Get Active FC Path WWN of all datastores
                shallriseagain Novice

                Yes, i have a trouble in the past. If I turn off the Brocade, and the active path went through it, then it will take a little time to rebuild to another path, and I will get a small lag of I/O operations.

                I have a lot of datastores like Fujitsu, HP, and self-assembly Supermicro storages.

                • 5. Re: Get Active FC Path WWN of all datastores
                  LucD Guru
                  vExpertCommunity WarriorsUser Moderators

                  Can you try like this?

                   

                  Get-VMHost | ForEach-Object -Process {

                      $esxcli = Get-EsxCli -VMHost $_.Name -V2

                      $esxcli.storage.core.device.list.Invoke() |

                      where{$_.IsSharedClusterwide -and $_.DeviceType -eq 'Direct-Access' -and $_.IsLocal -ne 'true'} |

                      ForEach-Object -Process {

                          $device = $_

                          $dsName = $esxcli.storage.vmfs.extent.list.Invoke() |

                              where{$_.DeviceName -eq $device.Device} |

                              select -ExpandProperty VolumeName

                          $esxcli.storage.nmp.path.list.Invoke() |

                              where{$_.Device -eq $device.Device -and $_.PathSelectionPolicyPathConfig -match 'preferred: yes'} |

                          Select @{N='Host';E={$esxcli.VMHost.Name}},

                              @{N='Datastore';E={$dsName}},

                              @{N='RuntimeName';E={$script:rt = $_.RuntimeName; $script:rt}},

                              @{N='CanonicalName';E={$device.Device}},

                              @{N='WWNN';E={($esxcli.storage.core.path.list.Invoke() |

                                  where{$_.DeviceDisplayName -eq $dsName -and $_.RuntimeName -eq $script:rt}).TargetTransportDetails.Split(' ')[1]}},

                              @{N='WWPN';E={($esxcli.storage.core.path.list.Invoke() |

                                  where{$_.DeviceDisplayName -eq $dsName -and $_.RuntimeName -eq $script:rt}).TargetTransportDetails.Split(' ')[3]}}

                      }

                  }

                   

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  • 6. Re: Get Active FC Path WWN of all datastores
                    shallriseagain Novice

                    hmm.

                    Now it looks like

                    Host          : 10.234.1.129

                    Datastore     : IBM-SSD-SCST

                    RuntimeName   : vmhba2:C0:T4:L0

                    CanonicalName : eui.3639343936643533

                    WWNN          :

                    WWPN          :

                     

                    Also, a lot of records has no names in Datastore string =(

                    Host          : 10.234.1.129
                    Datastore     : IBM-SSD-SCST
                    RuntimeName   : vmhba2:C0:T4:L0
                    CanonicalName : eui.3639343936643533
                    WWNN          :
                    WWPN          :
                    • 7. Re: Get Active FC Path WWN of all datastores
                      LucD Guru
                      User ModeratorsvExpertCommunity Warriors

                      Ok, in that case try with the (much) slower cmdlets.

                       

                      Get-Datastore -PipelineVariable ds |

                      where{$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess } |

                      Get-ScsiLun -PipelineVariable lun |

                      Get-ScsiLunPath |

                      where{$_.Preferred} |

                      Select @{N='VMHost';E={$lun.VMHost.Name}},

                          @{N='Datastore';E={$ds.Name}},

                          ScsiLun,LunPath,SanId

                       

                       

                       

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      • 8. Re: Get Active FC Path WWN of all datastores
                        shallriseagain Novice
                        Very slow, but works like a charm. Thank you so much, you saved my day :)