VMware {code} Community
addix
Contributor
Contributor
Jump to solution

Getting IP assignment of an External Network

Hi,

as said above, I want wo query the IP assignment of organisation for a given external network.

As a goal I want to know, which number of external IPs (of a certain external network) is assigned to each organisation.

Is it possible to do this via REST API?

Thanks in advance!

Reply
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

This was something I recently had looked into after a colleague had asked about it.

The eaiest way IMHO is to use the vCloud API Query Service (http://blogs.vmware.com/vsphere/2012/04/quickly-finding-objects-using-the-vcloud-api-query-service.h...)

Here's a screenshot of an External Network called "Ext-Network-1" for a VCD 5.1 deployment

external-network-ip-allocation-0.png

Step 1 - Perform a GET on the following URL: https://[VCD-IP]/api/query?type=externalNetwork

Step 2 - This should return a list of NetworkRecords which will be your available external networks, here's a screenshot using FF RestClient

external-network-ip-allocation-1.png

Step 3 - Once you have identified the "name" property of your External Network, you will need to do a GET on it's HREF

Step 4 - From here, you can clearly see the current IP Range as well as the allocated IP Addresses

network-ip-allocation-2.png

If you want more details on the allocated IP Addresses, you'll see in the "Link" there is /allocatedAddresses that you can perform a GET on that URL which will give you further details

network-ip-allocation-3.png

Hopefully this helps you get what you're looking

View solution in original post

Reply
0 Kudos
10 Replies
andypowe11
Contributor
Contributor
Jump to solution

Use https://whatever.whatever/api/admin/extension/orgNetworks/query to build a list of org networks. For each AdminOrgNetworkRecord returned this gives you the 'OrgName' and the 'linkNetworkName' (external network).

For each AdminOrgNetworkRecord returned, issue a GET against the 'href' (of the form https://whatever.whatever/api/network/04f98e5b-90bb-493c-9e0d-7e9e154f0f7e). In the returned XML, look for

AllowedExternalIpAddresses->IpAddress

Does that give you what you want?

Andy

addix
Contributor
Contributor
Jump to solution

Hi,

thanks for your reply.

I used the https://whatever.whatever/api/admin/extension/orgNetworks/query and received the list you told. After that I used the href URL via GET, but the followed XML did not included any "AllowedExternalIpAddresses" or something like that (https:///bla.bla/api/network/47add117-877f-46a9-ae9c-59f2ce93bdf4).

The only item which nearly converges with that point is "type="application/vnd.vmware.vcloud.allocatedNetworkAddress+xml" at the final xml.

I'm working with the vCloud .NET SDK. Maybe it is easier with the SDK.

Reply
0 Kudos
andypowe11
Contributor
Contributor
Jump to solution

Hmmm... not sure I can be of much further use.

I'm coding directly against the API, not using an SDK. I also tend to use the Firefox RESTClient plugin to experiment.

You should be getting back an '<OrgNetwork ...>' XML record when you issue the GET request against the 'href' ??

Given the name, 'AllowedExternalIpAddresses', I guess it's possible that nothing is listed unless you've configured a NAT rule using one of your IP assignments.

Sorry.

Andy

Reply
0 Kudos
addix
Contributor
Contributor
Jump to solution

I'm getting an "OrgVdcNetwork" object.

For testing purposes, I'm using the RESTClient browser plugin, too.

Just to get it clearly: I take the "href URL" from the "AdminOrgNetworkRecord" object. After that, I issue an GET request against the URL. As a result I get an "OrgVdcNetwork" object (also of Orgs, which definitely have at least two ext assigned IPs).

Thanks anyway Smiley Happy

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

This was something I recently had looked into after a colleague had asked about it.

The eaiest way IMHO is to use the vCloud API Query Service (http://blogs.vmware.com/vsphere/2012/04/quickly-finding-objects-using-the-vcloud-api-query-service.h...)

Here's a screenshot of an External Network called "Ext-Network-1" for a VCD 5.1 deployment

external-network-ip-allocation-0.png

Step 1 - Perform a GET on the following URL: https://[VCD-IP]/api/query?type=externalNetwork

Step 2 - This should return a list of NetworkRecords which will be your available external networks, here's a screenshot using FF RestClient

external-network-ip-allocation-1.png

Step 3 - Once you have identified the "name" property of your External Network, you will need to do a GET on it's HREF

Step 4 - From here, you can clearly see the current IP Range as well as the allocated IP Addresses

network-ip-allocation-2.png

If you want more details on the allocated IP Addresses, you'll see in the "Link" there is /allocatedAddresses that you can perform a GET on that URL which will give you further details

network-ip-allocation-3.png

Hopefully this helps you get what you're looking

Reply
0 Kudos
andypowe11
Contributor
Contributor
Jump to solution

Ah. I'm still using the vCloud Director 1.5 API. I think that's probably where the difference comes from.

Andy

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

I don't have a 1.5 enviroment ... but the External Network query should be the same. In VCD 5.1

Reply
0 Kudos
addix
Contributor
Contributor
Jump to solution

Thanks a lot lamw, that was the answer which solved my "issue".

I will look more attentively through the query service so I dont have to ask such questions anymore Smiley Happy

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Great to hear! The vCloud Query Service API is very powerful!

Reply
0 Kudos
samjbentley
Contributor
Contributor
Jump to solution

I'm trying to to do the exact same thing the OP has attempted (obviously years ago).

I'm able to authenticate with the API and send the GET for " https://my.vcd.cells/api/query?type=externalNetwork ", but for some reason I seem to be only getting a subset of the External Networks in my environment.

Any ideas what I'm doing wrong?

It's worth noting that until half an hour I had never even authenticated with the vCD API, let alone obtained any useful information using it.

I'm running vCD 9.1 and using version 30 of the API.


I have 39 external networks in vCD. My XML output for the GET only lists 25 networks.

Reply
0 Kudos