With PANDAS & “REST”, MY CUSTOMER & I MANAGED TO REST!

Pandas? No, I am not talking about real Pandas but I am talking about the pandas package in Python! It is a real gem that can simplify data analysis. For me, it is like “Excel” but-on-steroids since you call it via Python code which makes it very flexible & easy to use.  As for the first REST, it is for the REST APIs that Aruba Central supports; they offer you a programmatic access to configure or read info from Central. This is how I used Pandas & REST APIs to meet the customer requirements.

The Motive – Need Better Visibility

One of my customers needed some clarifications on their license usage in Central. For the past couple of years, they were adding devices & their associated licenses in their account . However, due to Covid19, they now had to decommission many sites, leaving them with more licenses  than their active devices. The customer wanted to

  1. Better understand their current license usage
  2. Determine when do they need to renew their existing licenses

Although this information is available in Central, it requires a couple of clicks to extract this information and some manual work is needed to analyze the various licenses’ expiry dates.

To support the customer, I recommended to use Aruba Central REST APIs. This will make it easier for both the customer and me! This is the solution that I build for them.

The Solution – A Small Python Code to the Rescue

I didn’t want to reinvent the wheel so I used the code written by Mitchell Pompe that was part of SD-Branch Virtual Lab in an hour. I really liked the way he organized his code so I leveraged the same modules for all the back-end authentication and configuration validation. While checking Mitchell’s code, I discovered a gem, the pandas package, which made my task very simple. It is really powerful and feature-rich and it really helps in data analysis. Thank you Mitchell for sharing your code, you made my task easier!

To meet the client requirements, I wrote a code for the inventory module where I defined several methods to collect the required info from the customer’s environment. Some of these methods are helper functions to simplify my code in case the customer wanted detailed device info like get_iap_device_name_group and get_switch_device_name_group_site

Then, in the main central_script,

  1. I check the config.cfg file which contains the customer info, central instance details, username/password and client id /secret (thank you Mitchel for this)
  2. I reuse the existing access token or fetch a new one if needed (thank you Mitchel for this)
  3. I call a method to fetch IAP inventory – This gives me the count of licensed and unlicensed devices along with cloud guest licenses used
  4. I call a method to fetch Switches inventory – This gives me the count of licensed and unlicensed devices
  5. I call a method to fetch Subscriptions inventory
  6. I finally call a method to analyze the device license usage, followed by service license usage (cloud guest)

The output of this code looks something like the below. Several CSV files containing the details for the IAP inventory, Switches Inventory, Subscriptions inventory, device licenses, service licenses are saved.

The python script output is also shown in the below recording.

At the end, the script specifies the dates till which the customer can utilize the existing licenses (for both device and service (cloud guest) licenses).

One of the interesting outputs is the detailed breakdown per day where the customer now has a detailed view of the licenses available on any given day (between the initial start date where he purchased the first license up till the expiry of the latest license). For example, on 21/2/2022, customer will have 456 device licenses.

Final Note – Python should be a tool in your Arsenal

Please note that I am not a developer, but I am trying to use the tools that can simplify my job. Python is definitely a useful tool that I am learning & adding to my arsenal. You can download the code from the link below. Feel free to report any issues / recommendations.

Leave a Reply