Summary

In conjunction with the announcement of BIG-IQ 5.0 we are excited to bring the field greater flexibility when centrally managing BIG-IP devices utilizing well defined workflows and the BIG-IQ iControl REST API. We understand that automation and programmability is becoming more the norm these days as the network is evolving into a software defined application aware environment.

This article is an addendum to “BIG-IQ Central Management API automation and programmability – Discovery, Import and Re Import” and will demonstrate licensing using a Purchased License Pool. There are two approaches used in these examples. The first is a Python OO example that abstracts the actual licensing work.The second is a self-contained script intended to be used as standalone utility that will run directly on the BIG-IQ for adding devices to inventory in a sequential yet automated fashion.

As in the Python versions of this code the API referenced Uri’s are the same.

 

API Reference -

License Pools: GET - https://'bigiq-ip'/mgmt/cm/shared/licensing/pools

License Pool Member: POST - https://'bigiq-ip'/mgmt/cm/shared/licensing/pools/'member_uuid'/members

 

Let’s get started –

Python -

Contents:

../config/license.config

../src/pyhton/licensePool.py

../lib/license.py

The python code will initially read a configuration file used to define bigiq / bigip credentials as well as the base registration key used to identify the correct license pool you want to add this device too.

Once the License.license_pool() method is called in licensePool.py will GET the license pool uuid:

uri = 'https://' + iq + '/mgmt/cm/shared/licensing/pools'

response = requests.get(uri, auth=(username, password), verify=False)

Using the license pool uuid retrieved from the GET above a POST is made to REST end point (license pool member) resulting in adding the BIGIP to the pool. BIGIQ will invoke the POST to BIGIP licensing the device.

uri = 'https://' + iq + '/mgmt/cm/shared/licensing/pools/' + member_uuid + '/members'

lic_json = {"deviceAddress": ip,"username": username,"password": password}       

response = requests.post(uri, data=str(lic_json), auth=(username, password), verify=False)

 

Perl -

Contents:

../config/bulk_license.csv

../src/perl/licensePool.pl

When using the BIG-IQ it is suggested to make a directory called scripts under /shared and securely copy this distribution into /shared/scripts/.

Everything is predicated by a main loop which will invoke each task by calling supporting Perl subroutines self-contained in the script. All rest calls, using curl (https://curl.haxx.se/), made are highlighted below.

In this case for all devices listed in ../config/*.csv this loop calls a perl routine called licenseDevice().

if (licenseDevice($mip, $user, $pw, $base_reg_key)) {

Like the python script we get member id (uuid) of purchased license pool.

curl -s -k -u $bigiqCreds -H \"$contType\" -X GET \"https://localhost/mgmt/cm/shared/licensing/pools\ 

Then POST to pool members REST end point using uuid retrieved.

my $licenseCmd = "curl -s -k -u $bigiqCreds -H \"$contType\" -X POST  -d \'$postBodyJson\' \"https://localhost/mgmt/cm/shared/licensing/pools/$member_uuid/members\""; 

 

If you are interested in this code for collaboration or solution, search on key words "bigiq" "api" "python" or "perl" in code share section on dev central or here is the reference link:

https://devcentral.f5.com/codeshare/big-iq-big-ip-rest-api-licensing-932 - bulk (Able to run in BIGIQ shell, licensing of > 1 device defined in a csv)

https://devcentral.f5.com/codeshare/big-iq-big-ip-rest-api-device-licensing-httplib-970 - httplib (Able to run in BIGIQ shell)

https://devcentral.f5.com/codeshare/big-iq-licensing-of-big-ip-using-rest-api-python-oo-974 - requests (python oo version)