Understanding Junos PyEZ Tables and Views


Junos PyEZ Tables and Views enable you to extract operational information and configuration data from devices running Junos OS as well as configure devices running Junos OS. To extract information, you use predefined or custom Tables and Views to map command output or configuration data to a table, which consists of a collection of items that can then be examined as a View. Starting in Junos PyEZ Release 2.0, you can also use Tables and Views to define structured configuration resources. When you add a configuration Table to the Junos PyEZ framework, Junos PyEZ dynamically creates a configuration class for the resource, which you can use to programmatically configure the resource on a device. Tables and Views are defined using YAML, so no complex coding is required to create your own custom Tables and Views.

Tables and Views provide a simple and efficient way to extract information from complex operational command output or configuration data and map it to a Python data structure. Operational (op) Tables select items from the RPC reply of an operational command, and configuration Tables select data from specific hierarchies in the selected configuration database. Each Table item represents a record of data and has a unique key. A Table also references a specific View, which is used to map the tag names in the data to the variable names in the Python data structure.

For example, the following op Table retrieves output for the get-arp-table-information RPC with the no-resolve option, which corresponds to the show arp no-resolve command in the Junos OS CLI. The Table extracts arp-table-entry elements from the output, and the corresponding View selects three fields from each arp-table-entry item by mapping the user-defined field name to the XPath expression that corresponds to the location of that data in the Junos XML output. In this case, mac-address, ip-address, and interface-name are child elements of arp-table-entry.

Junos PyEZ configuration Tables can be used to both retrieve and modify configuration data on devices running Junos OS. Configuration tables that define the get property can only retrieve configuration data. Configuration Tables that define the set property can both retrieve and configure the statements defined in the corresponding View.

For information about creating and using operational Tables and Views, see the following topics:

For information about creating and using configuration Tables and Views, see the following topics:

For information about loading or importing custom Tables and Views in your Junos PyEZ application or about saving data to files, see the following topics: