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.
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.
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
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.
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
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.
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.
I've solved this issue recently too, and couldn't find a nicer way.