VMware {code} Community
derevan007
Contributor
Contributor

vCloud API not returning Org Network Allocated IP Addresses

I am trying to get the list of static IP addresses asssigned from the pool for an organization's network using the REST API. I can get them for the External Network, but not the Org Network. The UI is able to show the allocated IP addresses for both. Also, the SDK doc suggests it is available. Does anyone know if there is problem with the SDK?

When I call the API, there is no <AllocatedIPAddresses> tag (in green in the API doc shown below)

<OrgNetwork....

<Configuration>

<IpScope>

<IsInherited>true</IsInherited>

<Gateway>10.147.122.190</Gateway>

<Netmask>255.255.255.192</Netmask>

<Dns1>10.115.120.71</Dns1>

<DnsSuffix>example.com</DnsSuffix>

<IpRanges>

<IpRange>

<StartAddress>10.147.122.100</StartAddress>

<EndAddress>10.147.122.200</EndAddress>

</IpRange>

</IpRanges>

<AllocatedIpAddresses />

</IpScope>

<ParentNetwork

type="application/vnd.vmware.admin.orgNetwork+xml"

name="ExternalNetwork-VC1"

href="https://vcloud.example.com/api/admin/network/7" />

<FenceMode>bridged</FenceMode>

</Configuration>

</OrgNetwork>

Below is what I get:

<OrgNetwork ...>
<Configuration>
        <IpScope>
            <IsInherited>true</IsInherited>
            <Gateway>10.29.102.97</Gateway>
            <Netmask>255.255.255.224</Netmask>
            <Dns1>171.70.168.183</Dns1>
            <Dns2>64.102.6.247</Dns2>
            <DnsSuffix>xxx.com</DnsSuffix>
            <IpRanges>
                <IpRange>
                    <StartAddress>10.29.102.126</StartAddress>
                    <EndAddress>10.29.102.126</EndAddress>
                </IpRange>
            </IpRanges>
        </IpScope>
        <ParentNetwork type="application/vnd.vmware.admin.network+xml" name="net-test" href="https://vcd-2.xxx.com/api/admin/network/07b10773-33ea-4d89-bf50-00c22c201035"/>
        <FenceMode>bridged</FenceMode>
        <RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
        <SyslogServerSettings/>
    </Configuration>
    <AllowedExternalIpAddresses/>
</OrgNetwork>

0 Kudos
8 Replies
rkamal
VMware Employee
VMware Employee

Hi,

You see this only on bridged networks.

Do you get the AllocatedIpAddresses information for the natRouted and isolated networks?.

Regards,

Rajesh Kamal.

0 Kudos
derevan007
Contributor
Contributor

Yes, I can see the allocated IP Addresses for directly connected networks from the UI, but NOT from the API.

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

Do you see the allocared ip addresses for natrouted and isolated networks.

Regards,

Rajesh Kamal.

0 Kudos
derevan007
Contributor
Contributor

I don’t know since currently all networks are bridged.

0 Kudos
SunilKashikar
Contributor
Contributor

Hi,

I also ran into this issue. Found a workaround that works for our requirement.

1. Get IP Ranges defined for Org network

2. Using the Start and End address on each IP Range, populate a list of usable IP addresses

3. Get the Allocated IP addresses from the External Network

4. Remove the Allocated IP addresses from the usable IP addresses -- this gives you a list of available/free IP addresses for that specific Org

5. Add the removed IP addresses to a separate list -- this gives you a list of consumed IP addresses for that specific Org

Thanks,

Sunil Kashikar

jclouds2011
Contributor
Contributor

Any change anyone has a sequence of REST calls to achieve the workaround last noted?

0 Kudos
derevan007
Contributor
Contributor

Only 2 REST Calls are required.

1) First call the REST API with a GET on the Org Network HREF

2) Then call the REST API with a GET on the Parent Network HREF (from the response of #1)

3) My approach is to parse the ranges from #1 and convert IP to integer.

4) I then convert each of the IP Allocations from #2s response to an integer

5) For each #4, I see if it is in one of the ranges from #3

6) For each match in #5, i convert integer back to IP and add to my list of allocated IPs for the Org Network

0 Kudos
abhishek2408
Contributor
Contributor

Thanks... This was very useful.

0 Kudos