VMware Cloud Community
vihar1
Enthusiast
Enthusiast
Jump to solution

Gather Edge information

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.

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
vihar1
Enthusiast
Enthusiast
Jump to solution

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.

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
vihar1
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Moved the thread to the vCloud Director PowerCLI community.

For a minute I thought you were referring to NSX edges :smileygrin:


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

Reply
0 Kudos
vihar1
Enthusiast
Enthusiast
Jump to solution

Partly Smiley Happy 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.

Reply
0 Kudos
vihar1
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
AdamRushUK
Enthusiast
Enthusiast
Jump to solution

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

VCP-Cloud | VCP5-DCV | MCITP:EA | MCSE | CCNA | CCAA LinkedIn: https://www.linkedin.com/in/adamrushuk | Twitter : @adamrushuk
Reply
0 Kudos