Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Junos PyEZ Modules Overview

SUMMARY The Junos PyEZ Python library provides modules that you can use to connect to and perform operations on Junos devices.

Junos PyEZ is a microframework for Python that enables you to manage and automate Junos devices. Junos PyEZ consists of the jnpr.junos package, which contains modules that handle device connectivity and provide operational and configuration utilities.

Table 1 outlines the primary Junos PyEZ modules that are used to manage Junos devices. For detailed information about each module, see the Junos PyEZ API Reference at http://junos-pyez.readthedocs.org/.

Table 1: Junos PyEZ Modules

jnpr.junos Modules

Description

device

Defines the Device class, which represents the Junos device and enables you to connect to and retrieve facts from the device.

command

Includes predefined operational Tables and Views that can be used to filter unstructured output returned from CLI and vty commands and convert it to JSON.

exception

Defines exceptions encountered when accessing, configuring, and managing Junos devices.

factory

Contains code pertaining to Tables and Views, including the loadyaml() function, which is used to load custom Tables and Views.

facts

A dictionary-like object of read-only facts about the device. These facts are accessed using the facts attribute of a Device object instance.

op

Includes predefined operational Tables and Views that can be used to filter structured (XML) output returned from RPCs.

resources

Includes predefined configuration Tables and Views representing specific configuration resources, which can be used to programmatically configure Junos devices.

transport

Contains code used by the Device class to support the different connection types.

utils

Includes configuration utilities, file system utilities, shell utilities, software installation utilities, and secure copy utilities.

In Junos PyEZ, each device is modeled as an instance of the jnpr.junos.device.Device class. The device module provides access to Junos devices through a serial console connection, telnet, or SSH and also supports connecting to the device through a telnet or SSH connection to a console server that is connected to the device’s CONSOLE port. All connection methods support retrieving device facts, performing operations, and executing RPCs on demand. Support for serial console connections and for telnet and SSH connections through a console server enables you to connect to and initially configure new or zeroized devices that are not yet configured for remote access. Facts about the device are accessed using the facts attribute of the Device object instance.

The utils module defines submodules and classes that handle software installation, file system and copy operations, and configuration management. The exception module defines exceptions encountered when managing Junos devices.

The command, op, resources, and factory modules pertain to Tables and Views. The command and op modules contain predefined operational Tables and Views that can be used to extract specific information from the output of common operational commands and RPCs on Junos devices. The resources module contains predefined configuration Tables and Views that can be used to configure specific resources on Junos devices. The factory module contains methods that enable you to load your own custom Tables and Views in Junos PyEZ applications.