cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Cisco Community Designated VIP Class of 2020

Five APIC-EM API to improve network engineer productivity – part 3

915
Views
6
Helpful
0
Comments
Cisco Employee

Five APIC-EM API to improve network engineer productivity – part 3

Welcome to part 3 of the "APIC-EM API productivity series" for network engineers getting started in API and scripting.

Earlier blogs on APIC-EM covered

  1. /network-device – all attributes of network-devices
  2. /interface/network-device – all interfaces  (and hosts) on a network-device e.g. a switch

First a bit about swagger

Swagger is an API documentation tool.  The "API" button in the top right brings up the swagger pages.  The great thing is you can click on the "try it out" button for an API and run the REST API call directly on the controller. You get to see that REST call that was made plus the full response.

Swagger-API.png

#3 network-device licenses

As mentioned in previous blogs, APIC-EM builds an inventory of the network.  In addition to network-device topology, it also collects license information from the network-devices.  This is a new feature as of APIC 1.2.  If you are running an older version of the controller this API is not supported.

This is an example where the API is more powerful than the User Interface (UI).  This information is not currently available via the UI.  The cool thing about this is that it is available today via the API.  The user interface will add support for this in the future.

Swagger

Once in swagger on the controller UI,  navigate to the "inventory" API group.

Navigate to the license URL and goto the "/license-info/network-device/{deviceid}"

licence-nav2.png

Enter the same deviceId used in earlier examples 4ac6aa8-7759-44d5-90a3-00c83e96583d

Put in scope of "all"

Press "Try it Out"

licence-params.png

You will see all of the license information.

license-result.png

Downloading scripts from github

The scripts are published on github.  Here are the steps you need to take to download them in a terminal session.

git clone https://github.com/CiscoDevNet/apic-em-samples-aradford.git

cd apic-em-samples-aradford/

cd sample_code/Top5

Here is what the output should look like  when you run the commands above in a terminal window.

$ git clone https://github.com/CiscoDevNet/apic-em-samples-aradford.git

Cloning into 'apic-em-samples-aradford'...

remote: Counting objects: 409, done.

remote: Total 409 (delta 0), reused 0 (delta 0), pack-reused 409

Receiving objects: 100% (409/409), 580.75 KiB | 523.00 KiB/s, done.

Resolving deltas: 100% (198/198), done.

Checking connectivity... done.

$ cd apic-em-samples-aradford/

$ cd sample_code/Top5/

$ ls

01_network_device.py  03_device_license.py  05_path_trace.py util.py

02_interface_device.py       04_find_host.py              __init__.py

Script

The "03_device_license.py" script will display all of the license information for the network-device.  You can see the licenses, their status, the type and maxusagecount/usageCountRemaining for each license on the device.

device license output 1.png

This also applies to Wireless Lan Controllers.  Below you can see the base-ap-count license has a maximum of 12 licenses and 11 remaining.

device-license-output2.png

Looking at the code

This code is very simple. There is a single rest API call to "license-info/network-device/< deviceid>".  As with earlier examples we convert the network-device IP address into a UUID.

def get_interfaces(id):
return get_url("license-info/network-device/%s" % id)

This is quite a simple example, but very useful as the licensing information can be integrated into other systems. Licensing information can now be extracted from the network-devices and centrally managed.   The uses of this information include:

  • licensing overview and status (network-wide)
  • licence capacity planning… proactively look for network-devices that are running close to the licence limit (e.g. Wireless LAN Controller)
  • understanding device capabilities (based on the license configured)

What Next?

This blog covered the third of the useful API /license-info.  The next blog in the series will look at /host and a tool for finding a host by IP address or MAC address on the network.

In the meantime, if you would like to learn more about APIC-EM, you could visit Cisco Devnet.  All of the code samples can be found in this  Github repository.

Thanks for reading

@adamradford123

Content for Community-Ad
FusionCharts will render here