Blog
        

June 19, 2022

TeraSky How To: Manage IP Assignments using phpIPAM and ABX actions in vRealize Automation 8.6

When there is a need to centrally manage IP address assignments, especially when using automation to deploy many resources across multiple network segments, integrating an IPAM solution with vRA is an excellent solution. vRA 8.x offers out-of-the-box integration with various IPAM providers, and their packages can be retrieved from VMware’s marketplace.

 

 

A different approach

In the following example, we will be demonstrating an alternate approach by integrating a phpIPAM using its API library rather than using the built-in integration option. We’ll use two ABX Python actions along with the IPAM server for managing our IP pools using REST API Requests.

 

 

Prerequisites:

 

1. An IPAM Server with preconfigured subnets that we will use to manage our assignments. You will also need to acquire the relevant API schema for your preferred system and have access to a user account that has sufficient permissions.

2. Internet connection in order to download the ‘Requests’ Python library for sending API requests.

3. A Network Profile in vRA matching the requested subnet in the deployment.

As mentioned above, we will be using the Cloud Assembly Extensibility actions written in python. These actions will later be attached to an Event Subscription that will be executed once a machine is being provisioned.

 

 

Writing the ABX actions:

 

Since we are using Python, and since the ‘requests’ library, which is being used to send API calls, is not built-in with Python, we will need to add it as a dependency for our script. Simply list the libraries you want to use in the known format of ‘requirements.txt. ‘ It’s as easy as that!
Behind the scenes, once the action is being executed, a docker container is created for the purpose of this run, downloads any needed packages, and is deleted once finished.

 

Here is the script for reserving an IP address:

 

 

To quickly break down the code, it can be divided into 3 main sections:

 

Acquiring an API token for authentication. In this example, we are using a basic authentication method against our IPAM server.

Getting the relevant Subnet ID from IPAM. We are using only one network segment here. This of course can be modified to be fully dynamic.

Searching for an available IP address in our desired subnet and reserving it, while also adding the Hostname and description to our POST request.

 

Lastly, the function will output the new IP address. This is where the magic happens: with the help of our event subscriptions, our new address can be attached to the machine that is being provisioned.

 

Here is the script for removing the IP assignment from IPAM, which is a straightforward DELETE REST call.

 

 

Configuring the Event Subscription:

In order to assign the new IP address to our machine, I will be using the ‘Network Configure’ event, which includes the ‘addresses’ property that can be modified during provision. Notice that this property is a 2-Dimensional array, as the output in the script.

 

 

 

 

I have also added a filter for this ABX to run only if we have a custom property in our Cloud Template YAML named ‘ipamweb’ set to the value of ‘true’. This can also be inserted as an input for the end-user to select if he or she wants control over whether or not this action is executed.

The action that will run in this event will be the Python ABX we have just created.

 

 

On removal, we will be using the ‘Compute post removal’ event topic and the ‘Remove IP’ ABX.

 

 

And finally, here is the relevant custom property in our Cloud Template YAML:

 

 

Once the deployment is finished, we can see our new IP assignment in phpIPAM:

 

 

And here is the newly deployed machine!

 

To summarize, we have presented two ways to integrate an IPAM solution in vRA and elaborated on creating the integration using RESTful API and ABX actions, demonstrating that we can integrate almost any system with the vRealize Suite whether it has an OOTB solution or not.

 

This blog was contributed by:
Yev Berman (Hybrid Cloud & Automation Team Leader), Tsachi Benassayag (Hybrid Cloud Solution Specialist), and Sagi Ilan (Hybrid Cloud & Automation Senior Consultant)

Tags:
VMware
vRA
vRealize Suite
Share:

Next Articles

Blog
      

27 March, 2024

AWS Generative AI Challenge!
Read Entry
Blog
      

13 March, 2024

Four Engineers Honored with Prestigious DEXe DEXpert 2024 Award!
Read Entry
Blog
      

11 March, 2024

Navigating the Rise of Cyber Attacks with TeraSky
Read Entry
Skip to content