While PI (Prime Infrastructure) provides a lot of flexible options to deploy configuration templates, or to report information about your devices, you may want to tune it up in a way which is not possible yet, even with the latest version (see Seppi’s post about PI 2.1).
Why should you wait for the next development milestone?
Application API gives the opportunity to interact with PI in a robust and efficient manner, allowing the addition of reporting and configuring capabilities to the platform :
- Access to device related information, such as physical and logical details, but also credentials, alarms and events.
- Report access, where you can trigger and collect result of any report defined in the system.
- Template configuration access, to manage, and deploy CLI templates.
The API is an entirely HTTPS-based RESTful resource which supports XML or JSON data formats, depending on the various cases. Authentication is required, with an user account part of the admin group, and subject to “virtual domains” scoping.
Filtering, sorting, and paging are available for most of the REST resources. This allows control of the amount of data being returned by a request.
API usage is rate limited to protect Prime Infrastructure itself, and ensure fair access for all clients.
The URL for the API contains a segment for the major version (currently v1). Future any changes that result in a modification of behavior will result in the release of a new major version of the API. The previous behavior will be maintained for some time to permit a smooth migration path.
The choice of the development platforms is up to you ! The documentation provides examples in Java, cURL, Perl, Ruby (see Cisco Prime Infrastructure 2.0 API Reference Guide), but you can choose python or whatever language you are used to !
Using the API for triggering and downloading PI reports is a good start : it is foolproof for the system, and a good opportunity also to learn about that solution :
- Create a report from the GUI
- Launch an API request to retrieve the output, which comes as XML data, instead of a pdf or csv file when initiated from the GUI : XML parsing offers a much more robust way to extract data.
Need a suggestion to start ? I propose to write a program which uses the standard PI “Wired Port Attribute” report, stores results over a period of time, then computes the statistics about port usage (how many switches with less than 5% of free -unused- ports over a week or month ?)
Let me know about your findings ! I can share my python script, if you want to compare our results with mine …
And don’t forget : there are 22,038 results for an “API reference guide” search on the CCO, so a lot of other opportunities to work with Cisco application API!
For your reference : Tutorial on REST API (external)