6 Replies Latest reply on Jul 27, 2017 10:18 PM by AdamRushUK

    Gather Edge information

    vihar1 Novice

      Dear Community,

       

      I'm in need of a script which can gather the following information:

       

      - versions of all Edges (adminVAppNetwork, adminOrgNetwork and edgeGateway)

      - type of Edge

      - organizations they are located in

       

      Looked pretty simple but it isn't, at least for me.

       

      I am able to gather the versions in one script (Get-VM | Get-View). I can gather different types in another, using API, and of course I can gather the list or organizations but I am currently unable to match them.

       

      Can you help me out please?

      Thank you.

        • 1. Re: Gather Edge information
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          Could you show us what you already have, so we cna have an idea what you are after, and help to consolidate the data.

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Gather Edge information
            vihar1 Novice

            Of course, I use this script to get the versions: List Edge Gateways and their version - PowerCLI

            And I use similar queries to get the different types: "https://vcloud.com/api/query?type=$querytype where

            $querytype is "adminVAppNetwork" or "edgeGateway" or "adminOrgNetwork"

             

            I can see the org href in the above API call, but for some reason I cannot match them with the Get-Org | select href command output.

            • 3. Re: Gather Edge information
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Moved the thread to the vCloud Director PowerCLI community.

               

              For a minute I thought you were referring to NSX edges

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: Gather Edge information
                vihar1 Novice

                Partly We are currently upgrading the Edges and therefore we need the versions and affected orgs as not everything went smooth and we need to have a bit more overlook on the status.

                • 5. Re: Gather Edge information
                  vihar1 Novice

                  I managed to get the information, using below method:

                   

                  Get the orgs like this:

                  $orgs = search-cloud -QueryType Organization

                   

                  Issue an API request to this URL:

                  $Request = https://$NSXManager/api/4.0/edges/

                  $r = Invoke-RestMethod -Uri ($Request) -Headers $head -ContentType "application/xml"

                   

                  Get every single edge and match their tenant ID to the org ID, select their name:

                  foreach ($edge in $r.pagedEdgeList.edgePage.edgeSummary)

                  {

                  $orgs | where {$_.Id.replace("urn:vcloud:org:","") -eq $edge.tenantId} | select -expandproperty name

                  }

                   

                  There was one issue, the query returns pages, which you can overcome by changing the start index in the URL:

                   

                  $pagesize = $r.pagedEdgeList.edgePage.pagingInfo.pageSize

                  $r = Invoke-RestMethod -Uri ($Request+"?startIndex=$index&pageSize=$pageSize") -Headers $head -ContentType "application/xml"

                  $index = $index + $pageSize

                   

                  There must be a nicer way but  this suits my need.

                  • 6. Re: Gather Edge information
                    AdamRushUK Enthusiast

                    I've solved this issue recently too, and couldn't find a nicer way.