VMware Cloud Community
Ekiseloff
Contributor
Contributor

IP Allocations on External network

Hi there!

Get me a tip, how I can get an array of alocated IP addresses at External network through VRO (with workflow or any JS script).

Thanks in advance!

0 Kudos
7 Replies
daphnissov
Immortal
Immortal

You will need to provide a LOT more information than this. No idea what you're asking about regarding specifics.

0 Kudos
Ekiseloff
Contributor
Contributor

Ok. I've got a task: I need to create a gateway by VRO. I can do this using standart VRO workflow "vCloud Director/Admin/vDC/Add a gateway", but I have to know an IP address of external network interface for assigning it to the last one (it's a requirement of workflow). When I do this action via vCD web interface, IP address is assigned automaticaly from IP range of external network which I choose.

So I have a point: to get a list of allocated IP address of external network and take the next available address for using in the next step when I add a gateway.

Is it clear?

0 Kudos
daphnissov
Immortal
Immortal

Ok, so you just have to get an IP allocation for a given network. Doesn't really matter what you do with that IP later. Are you using an IPAM system? There are a few different plug-in options available to you if so (namely Infoblox). If not, where are you getting these next available IPs? You're providing the idea of what you want here but not the specifics, and specifics are what are needed to build an actual workflow.

0 Kudos
Ekiseloff
Contributor
Contributor

I don't use any IPAM system.

As you can see at the screenshot near, I don't have to set an IP explicitly when I create a new gateway via vCD web interface.

However when I use VRO for creating a new gateway, I have to set IP for external network (the second screenshot).

I need a workflow for getting the next available IP from the external network range. Futher I will be able to set this address on the next step  of creating a new gateway.

Do you need other information for helping me to find out the solution?

pastedImage_0.png

pastedImage_1.png

0 Kudos
sk84
Expert
Expert

You'll have to program it yourself. It is a requirement of vCD that an external network address must be specified when creating an edge gateway. The vCD GUI handles that internally, but if you want to control the deployment of an edge gateway from the outside (API, vRO, etc.), you must specify this IP address. And as far as I know, there is no existing workflow or mechanism in vRO to get this information. So the only way is to build your own workflow with JS code.

At first you need the reference for the external network you want to use. To get a list of all existing external networks you can use the following query (you need to authenticate as System Administrator for these queries):

GET https://vcloud.example.com/api/admin/extension/externalNetworkReferences

In the body you should get something like this:

...

    <vmext:ExternalNetworkReference href="https://vcloud.example.com/api/admin/extension/externalnet/09a31985-6b4a-4c23-a21b-0fdd956bef94" id="urn:vcloud:network:09a31985-6b4a-4c23-a21b-0fdd956bef94" name="ext-net-name-1" type="application/vnd.vmware.admin.extension.network+xml"/>

    <vmext:ExternalNetworkReference href="https://vcloud.example.com/api/admin/extension/externalnet/5c3c9988-0034-4741-abdb-ee91334fb388" id="urn:vcloud:network:5c3c9988-0034-4741-abdb-ee91334fb388" name="extNet-name-2" type="application/vnd.vmware.admin.extension.network+xml"/>

    <vmext:ExternalNetworkReference href="https://vcloud.example.com/api/admin/extension/externalnet/fd460c2a-b86a-44b0-9cdb-e9aaf5975342" id="urn:vcloud:network:fd460c2a-b86a-44b0-9cdb-e9aaf5975342" name="extNet-name-3" type="application/vnd.vmware.admin.extension.network+xml"/>

...

Now, you can use the href value for another API call:

GET https://vcloud.example.com/api/admin/extension/externalnet/09a31985-6b4a-4c23-a21b-0fdd956bef94

And you will get all information for this external network: Allocated IPs, Gateway, Subnet Mask, etc.

Depending on the network, subnetmask and the list of allocated ip addresses you can find out which addresses are not in use and process one of them in your workflow for creating a new edge gateway.

--- Regards, Sebastian VCP6.5-DCV // VCP7-CMA // vSAN 2017 Specialist Please mark this answer as 'helpful' or 'correct' if you think your question has been answered correctly.
0 Kudos
Ekiseloff
Contributor
Contributor

Thanks, sk84! It's a good idea! I could get an external network xml presentation which contained a sequence of allocated IPs, but now I have to handle it and get the next available IP in an extnet IP range.

Do you know there is some ready method in VRO for getting allocated IPs for external networks, like it is for vdc networks?

pastedImage_0.png

0 Kudos
sk84
Expert
Expert

Sorry, but I don't know a method for that. But we don't use Orchestrator for this. Instead, we use a Python Helper script to directly access the vCD API.

--- Regards, Sebastian VCP6.5-DCV // VCP7-CMA // vSAN 2017 Specialist Please mark this answer as 'helpful' or 'correct' if you think your question has been answered correctly.
0 Kudos