Juniper/py-junos-eznc

Name: py-junos-eznc

Owner: Juniper Networks

Description: Python library for Junos automation

Created: 2013-10-12 22:21:38.0

Updated: 2018-03-31 17:16:25.0

Pushed: 2018-02-21 14:31:02.0

Homepage:

Size: 2386

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

PyPi Version Documentation Status Coverage Status UnitTest Status

The repo is under active development. If you take a clone, you are getting the latest, and perhaps not entirely stable code.

DOCUMENTATION

Official Documentation with examples, here

API Documentation hosted by readthedocs

Junos PyEZ wiki page, here.

ABOUT

PyEZ logo

Junos PyEZ is a Python library to remotely manage/automate Junos devices. The user is NOT required: (a) to be a “Software Programmer?“, (b) have sophisticated knowledge of Junos, or (b) have a complex understanding of the Junos XML API.

This library was built for two types of users:

For “Non-Programmers” - Python as a Power Shell

This means that “non-programmers”, for example the Network Engineer, can use the native Python shell on their management server (laptop, tablet, phone, etc.) as their point-of-control for remotely managing Junos devices. The Python shell is an interactive environment that provides the necessary means to perform common automation tasks, such as conditional testing, for-loops, macros, and templates. These building blocks are similar enough to other “shell” environments, like Bash, to enable the non-programmer to use the Python shell as a power-tool, rather than a programming language. From the Python shell a user can manage Junos devices using native hash tables, arrays, etc. rather than device-specific Junos XML or resorting to 'screen scraping' the actual Junos CLI.

For “Programmers” - Open and Extensible

There is a growing interest and need to automate the network infrastructure into larger IT systems. To do so, traditional software programmers, DevOps, “hackers”, etc. need an abstraction library of code to further those activities. Junos PyEZ is designed for extensibility so that the programmer can quickly and easily add new widgets to the library in support of their specific project requirements. There is no need to “wait on the vendor” to provide new functionality. Junos PyEZ is not specifically tied to any version of Junos or any Junos product family.

SUPPORT

For questions and general support, please visit our Google Group

You can also post your query on stackoverflow with pyez tag

For documentation and more usage examples, please visit the Junos PyEZ project page, here.

Issues and bugs can be opened in the repository.

FEATURES

Junos PyEZ is designed to provide the same capabilities as a user would have on the Junos CLI, but in an environment built for automation tasks. These capabilities include, but are not limited to:

NOTICE

As of release 2.0.0, Junos PyEZ requires ncclient version 0.5.2 or later.

INSTALLATION

PIP

Installation requires Python 2.7 or >=3.4 and associated pip tool

pip install junos-eznc

Installing from Git is also supported (OS must have git installed).

To install the latest MASTER code
pip install git+https://github.com/Juniper/py-junos-eznc.git
-or-
To install a specific version, branch, tag, etc.
pip install git+https://github.com/Juniper/py-junos-eznc.git@<branch,tag,commit>
Docker

Move to the local directory which contains your script(s) and run the container

docker run -it --rm --name pyez -v $PWD:/scripts juniper/pyez sh

Your local scripts will be mounted to /scripts in the container

cd scripts

See DOCKER-EXAMPLES.md for some example usage.

Upgrade

Upgrading has the same requirements as installation and has the same format with the addition of -UPGRADE

pip install -U junos-eznc
HELLO, WORLD

The following is a quick “hello, world” example to ensure that the software was installed correctly. This code will simply connect to a device and display the known facts of the device, like serial-number, model, etc.

 pprint import pprint
 jnpr.junos import Device

= Device(host='my_host_or_ipaddr', user='jeremy', password='jeremy123' )
open()

nt( dev.facts )

close()

Example output for an SRX-210 device:

pprint(dev.facts)
E': False,
0': {'last_reboot_reason': '0x20:power-button soft power off',
     'model': 'RE-SRX210H',
     'status': 'OK',
     'up_time': '10 minutes, 3 seconds'},
main': 'workflowsherpas.com'         
dn': 'srx210.workflowsherpas.com',
stname': 'srx210',
d_style': 'CLASSIC',
del': 'SRX210H',
rsonality': 'SRX_BRANCH',
rialnumber': 'AD2909AA0096',
itch_style': 'VLAN',
rsion': '12.1X44-D10.4',
rsion_info': junos.versino_info(major=(12, 1), type=X, minor=(44, 'D', 10), build=4)}

LICENSE

Apache 2.0

CONTRIBUTORS

Juniper Networks is actively contributing to and maintaining this repo. Please contact jnpr-community-netdev@juniper.net for any queries.

Contributors:

Nitin Kumar, Edward Arcuri, Stacy Smith, Stephen Steiner

Former Contributors:

Jeremy Schulman, Rick Sherman


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.