0 Replies Latest reply: Jun 6, 2016 5:35 PM by Chris Lionetti RSS

    Need Get-FibreChannelInterface, Rest API makes easy to roll your own.

    Chris Lionetti Newbie

      So I found that a few operational commands just dont exist in the toolkit yet. An example would be a powershell command to return the World Wide Port Names of the Target Ports on my controllers.

      Thanks Julian as he has shown me the way to quickly get this information. In this case I know that the data exists, I just dont know where to get it. So I used Julians API.zip file and ran the Get-Array PowerShell command and just looked at what API call it was going to use, and hijacking that call to get what I want instead I simply replaced the ":5392/v1/arrays/details" with ":5392/v1/fibre_channel_configs/detail" and the data that it gave me. Note: You can get the list of all valid API calls from the REST API guide. Since it returns the object, we can issue the command and explore the entire dataset that it returns by using the following syntax;

      PS:> .\get-fcinterfaces.ps1 | fc *

       

      explorer.jpg

      Notice how I can find the information I want, its down the tree a little, but I can reformat the script to pull it forward and present me my data is a more readable way.

      I can then choose to have my command walk through each Array in my array group, and then each controller in my individual arrays and expose these WWPNs. Also note the controller and arrayname did not exist at the same level as the data I want, so to make it more readable, I add both of these back into the lower object so that I have the view I want.

      foreach($MyArray in $result.data.array_list) {

          foreach($inter in (($MyArray).ctrlr_a_fc_config).fc_interface_list) {

              $outer = add-member -inputobject $inter -membertype NoteProperty -name ArrayName -value $MyArray.array_name

              $outer = add-member -inputobject $inter -membertype NoteProperty -name Controller -value "ctrlr_a_fc_config"

              $outer

          }

          foreach($inter in (($MyArray).ctrlr_b_fc_config).fc_interface_list) {

              $outer = add-member -inputobject $inter -membertype NoteProperty -name ArrayName -value $MyArray.array_name

              $outer = add-member -inputobject $inter -membertype NoteProperty -name Controller -value "ctrlr_b_fc_config"

              $outer

          }

      }

      With this output I can now get my WWPNs in a list. Note that this is a true object that is returned, so I dont need to write any text parsers, I can select and sort based on the data itself.


      Get-FCInterface.jpg