Using tables and views
In this recipe, we’ll make use of a PyEZ framework feature that greatly eases the complexity of calling RPCs and parsing XML result sets with XPath expressions. Tables are used to map data atoms from the XML responses structured returned by RPCs into Python-friendly data structures for easy use and analysis by automation software.
In this case, we’ll use a table and a view in order to inspect the Junos device hardware inventory.
Getting ready
In order to complete this recipe, you’ll need Python 2.7 in a Linux or BSD-based development environment of your choice. You should have already completed:
How to do it…
We’re going to write a new Python script, pyez-hardware.pyez
, that will take an argument a JUNOS device name, and will respond with a list of hardware components within.
pyez-table-hardware.py [-h] [-p port] [-u username...