• Stars
    star
    666
  • Rank 67,706 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python library for Junos automation

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:

  • Remote connectivity and management of Junos devices via NETCONF
  • Provide "facts" about the device such as software-version, serial-number, etc.
  • Retrieve "operational" or "run-state" information as Tables/Views
  • Retrieve configuration information as Tables/Views
  • Make configuration changes in unstructured and structured ways
  • Provide common utilities for tasks such as secure copy of files and software updates

NOTICES

  • As of release 2.0.0, Junos PyEZ requires ncclient version 0.5.2 or later.
  • When using the ssh_private_key_file argument of the Device constructor on MacOS Mojave and higher, ensure that the SSH keys are in the RSA format, and not the newer OPENSSH format.
    • New key: ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
    • Convert an existing OPENSSH key: ``ssh-keygen -p -m PEM -f ~/.ssh/private_key`
    • Check if a given key is RSA or OPENSSH format: head -n1 ~/.ssh/private_key
      • RSA: -----BEGIN RSA PRIVATE KEY-----
      • OPENSSH: -----BEGIN OPENSSH PRIVATE KEY-----

INSTALLATION

PIP

Installation requires Python >=3.5 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

Interactive Docker Usage

Move to the local directory which contains your script(s) and run the container. Running the container in this manner will put you into an interactive Bash session.

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

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

Microservice Usage

This image can also be used as a Python "executable" with the required Python PyEZ libraries pre-installed. To use the image in this way, mount the volume which contains the Python script and pass the script name as an argument to docker run. Optionally, you may also pass in a requirements.txt file to install additional python packages via pip. To add OS packages (Alpine Linux), provide a file with a list of packages --one per line-- and either reference it as an env var ($APK) or mount it to the container /extras/apk.txt. To add additional Python packages (via pip), provide a requirements.txt file and pass it in as an env var ($REQ) or mount it to the container at /extras/requirements.txt.

Usage: docker run -it [ --rm ] -v some/dir:/scripts juniper/pyez [ myscript.py ]`

Example:

$ docker run -it --rm -v $PWD:/scripts juniper/pyez tmp.py
tmp.py
{'2RE': False, 'HOME': '/var/home/lab', 'RE0': {'mastership_state': 'master', 'status': 'OK', 'model': 'RE-SRX210H-POE', 'last_reboot_reason': '0x1:power cycle/failure', 'up_time': '36 days, 11 hours, 49 minutes, 59 seconds'}, 'RE1': None, 'RE_hw_mi': False, 'current_re': ['master', 'node', 'fwdd', 'member', 'pfem', 'backup', 're0', 'fpc0.pic0'], 'domain': None, 'fqdn': 'fw1.localdomain', 'hostname': 'fw1.localdomain', 'hostname_info': {'re0': 'fw1.localdomain'}, 'ifd_style': 'CLASSIC', 'junos_info': {'re0': {'text': '12.1X44-D40.2', 'object': junos.version_info(major=(12, 1), type=X, minor=(44, 'D', 40), build=2)}}, 'master': 'RE0', 'model': 'SRX210H-POE', 'model_info': {'re0': 'SRX210H-POE'}, 'personality': 'SRX_BRANCH', 're_info': {'default': {'0': {'mastership_state': 'master', 'status': 'OK', 'model': 'RE-SRX210H-POE', 'last_reboot_reason': '0x1:power cycle/failure'}, 'default': {'mastership_state': 'master', 'status': 'OK', 'model': 'RE-SRX210H-POE', 'last_reboot_reason': '0x1:power cycle/failure'}}}, 're_master': {'default': '0'}, 'serialnumber': 'AE3009AA0101', 'srx_cluster': False, 'srx_cluster_id': None, 'srx_cluster_redundancy_group': None, 'switch_style': 'VLAN', 'vc_capable': False, 'vc_fabric': None, 'vc_master': None, 'vc_mode': None, 'version': '12.1X44-D40.2', 'version_RE0': '12.1X44-D40.2', 'version_RE1': None, 'version_info': junos.version_info(major=(12, 1), type=X, minor=(44, 'D', 40), build=2), 'virtual': False}
done

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.

from pprint import pprint
from jnpr.junos import Device

with Device(host='my_host_or_ipaddr', user='jeremy', password='jeremy123' ) as dev:
    pprint( dev.facts )

Example output for an SRX-210 device:

>>> pprint(dev.facts)
{'2RE': False,
 'RE0': {'last_reboot_reason': '0x20:power-button soft power off',
         'model': 'RE-SRX210H',
         'status': 'OK',
         'up_time': '10 minutes, 3 seconds'},
 'domain': 'workflowsherpas.com'         
 'fqdn': 'srx210.workflowsherpas.com',
 'hostname': 'srx210',
 'ifd_style': 'CLASSIC',
 'model': 'SRX210H',
 'personality': 'SRX_BRANCH',
 'serialnumber': 'AD2909AA0096',
 'switch_style': 'VLAN',
 'version': '12.1X44-D10.4',
 'version_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 [email protected] for any queries.

Contributors:

Nitin Kumar, Stacy Smith, Stephen Steiner

Former Contributors:

Jeremy Schulman, Rick Sherman, Edward Arcuri

More Repositories

1

contrail-controller

Contrail Controller
441
star
2

warp17

The Stateful Traffic Generator for Layer 1 to Layer 7
C
424
star
3

ansible-junos-stdlib

Junos modules for Ansible
Python
302
star
4

libxo

The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.
C
287
star
5

go-netconf

NETCONF implementation in Go.
Go
253
star
6

open-nti

Open Network Telemetry Collector build with open source tools
Python
226
star
7

contrail-vrouter

Contrail Virtual Router
219
star
8

grpc-c

C implementation of gRPC layered on top of core library
C
218
star
9

open-register-design-tool

Tool to generate register RTL, models, and docs using SystemRDL or JSpec input
Verilog
170
star
10

wistar

Wistar is a tool to help create and share network topologies of virtual machines. It is designed to be light weight enough to run on a laptop or a small dedicated server.
JavaScript
154
star
11

junoscriptorium

A repository for scripts and script libraries
XSLT
151
star
12

vqfx10k-vagrant

Vagrant projects for vQFX10k
HTML
133
star
13

jsnapy

Python version of Junos Snapshot Administrator
Python
115
star
14

OpenClos

Python
114
star
15

yang

Junos Yang module
92
star
16

OpenJNPR-Container-vMX

OpenJNPR-Container-vMX
Shell
86
star
17

jxmlease

A Python module for converting XML to intelligent Python data structures, and converting Python data structures to XML.
Python
81
star
18

netconf-java

Java library for NETCONF
Java
72
star
19

junos-terraform

Go
70
star
20

py-junos-netconify

Junos console/bootstrap automation Python module
Python
65
star
21

net-netconf

A Ruby gem for NETCONF
Ruby
64
star
22

contrail-ansible-deployer

Ansible deployment for contrail
60
star
23

juise

juise is the JUNOS User Interface Script Environment, which allows users to develop, test, and execute script outside of JUNOS. For more information about juise, see:
C
53
star
24

libslax

libslax is a C implementation of the SLAX programming language, a dialect of XSLT that is more perl/C-like and easier to read/code/use. For additional information about SLAX, see
C
49
star
25

contrail-docker

Python
48
star
26

contrail

Contrail repo for core components (go based)
Go
44
star
27

contrail-kubernetes

OpenContrail Kubernetes integration
Go
44
star
28

healthbot-rules

Python
43
star
29

ruby-junos-ez-stdlib

A collection of Ruby classes to make Junos automation Easy. This is the "standard library" supported on all devices.
Ruby
35
star
30

YAPT

Yet Another Provisioning Tool
Python
31
star
31

vmx-docker-lwaftr

vMX Lightweight 4over6 Virtual Network Function with Snabb in a Docker Container
Python
30
star
32

contrail-installer

Install scripts for OpenContrail
Shell
30
star
33

jtimon

Junos Telemetry Interface (JTI) client
Go
30
star
34

nita

The parent repo of a framework to automatically build and test networks.
Shell
29
star
35

py-space-platform

Python library for Junos Space APIs
HTML
28
star
36

Intro-to-Using-Ansible-with-Junos-OS

Examples of Using Ansible with Junos Devices
27
star
37

puppet-netdev-stdlib-junos

Junos specific Provider code for "netdev_stdlib". Netdev is a vendor-neutral network abstraction framework developed by Juniper Networks and contributed freely to the DevOps community.
Ruby
25
star
38

vSRX-AWS

vSRX for Amazon Web Services
HCL
24
star
39

junos-snapshot-administrator

Shell
23
star
40

ebplane

eBPF based dataplane prototypes
C++
23
star
41

splitcopy

Improves file transfer rates when copying files to/from JUNOS/EVO/*nix hosts.
Python
22
star
42

docker-saltstack-junos

Dockerfile to create a working Saltstack container for Junos
Python
21
star
43

contrail-vnc

Contrail Virtual Network Controller
21
star
44

netconf-perl

Perl library for Netconf
Perl
20
star
45

meshrr

Hierarchical Route Reflectors and Route Servers @ Scale w/ Juniper cRPD & Kubernetes
Python
20
star
46

contrail-neutron-plugin

Opencontrail Neutron plugin + extensions
18
star
47

contrail-operator

Juniper K8s contrail operator
Go
18
star
48

JP4Agent

Juniper's P4 Runtime server implementation.
C++
18
star
49

telemetry

Juniper Telemetry models, augments and deviations
18
star
50

simple_reg_model

System verilog register model for uvm testbenches.
Perl
18
star
51

vijava

17
star
52

contrail-tripleo-heat-templates

Contrail tripleO heat templates
17
star
53

contrail-container-builder

Build contrail networking control components as micro-services
17
star
54

ruby-junos-ez-srx

Ruby libraries support Junos automation via NETCONF - "SRX library"
Ruby
16
star
55

contrail-web-core

Contrail web ui backend code
16
star
56

juniper-pytest

Juniper Pytest is an automation developer's toolkit. It provides everything an automation developer might need to automate configuration and validation of Juniper network equipment with Python and Ansible.
Makefile
16
star
57

topoviz

A network topology visualisation tool. Creates a force directed graph from the output of a JUNOS cli cmd
Perl
14
star
58

contrail-dev-env

Shell
14
star
59

jet-app-store

App store for Jet Apps
Python
14
star
60

terraform-provider-apstra

Apstra Terraform Provider
Go
14
star
61

netconf-call-home

C
14
star
62

contrail-heat

Openstack heat plugin and resources
13
star
63

contrail-charms

Juju charms for Contrail services.
13
star
64

yangc

YANG Compiler for JUNOS
C
12
star
65

contrail-server-manager

contrail server management
Python
12
star
66

contrail-sandesh

Contrail analytics IDL
C++
12
star
67

contrail-generateDS

Contrail XML schema code generator
Python
12
star
68

virtfs

VirtFS kernel driver for FreeBSD
C
12
star
69

nita-robot

Robot Framework test automation framework, part of the Juniper NITA solution
Python
12
star
70

contrail-kubernetes-docs

12
star
71

nita-webapp

nita-webapp, a lightweight django based webapp that orchestrates jenkins, ansible and robot, part of the Juniper NITA solution
JavaScript
12
star
72

contrail-test

12
star
73

contrail-packages

Build and packaging scripts for OpenContrail.
11
star
74

contrail-helm-deployer

Contrail Helm based deployment
11
star
75

contrail-fabric-utils

packaging
11
star
76

container-networking-ansible

Ansible provisioning for container networking solutions using OpenContrail
Python
11
star
77

contrail-dpdk

dpdk fork
C
11
star
78

lab-doc-convert

Shell
11
star
79

nita-yaml-to-excel

yaml2xls, a library and tools for converting between yaml files and MS excel, part of the Juniper NITA solution
Python
11
star
80

juniper-newrelic-plugin

New Relic Plugin for monitoring Juniper devices
Python
11
star
81

py-jnpr-wlc

EXPERIMENTAL: Python library for Juniper Wireless Lan Controller (WLC) product
Python
10
star
82

contrail-go-api

golang API bindings for OpenContrail
Go
10
star
83

contrail-web-controller

contrail web ui controller code
10
star
84

TelemetryInterface

9
star
85

vSRX-Azure

Python
9
star
86

contrail-packaging

Contrail VNC packaging
9
star
87

contrail-specs

Repository for docs and specs
9
star
88

vmx-heat-templates

vMX Heat templates
Python
8
star
89

healthbot-py-client

Python library that provides REST interface to the HealthBot server
Python
8
star
90

netlink-agent

netlink
C
8
star
91

junos-extension-toolkit

A repository to store JET IDL files
7
star
92

contrail-build

Contrail VNC build tools
7
star
93

jetez

Lightweight alternative to JET
Python
7
star
94

space-ansible-collection

space-ansible-collection
Python
7
star
95

nita-cli

Python
7
star
96

nita-ansible

Ansible, a radically simple IT automation engine, part of the Juniper NITA solution
Jinja
7
star
97

contrail-chef

Contrail Chef Cookbooks
HTML
6
star
98

amt-vlc

Module for the VLC media player leveraging AMT functionality
C
6
star
99

contrail-networking

Automate contrail config provisioning using GitOps based delivery
6
star
100

qfx5100-book

GitHub Repo for the O'Reilly QFX5100 book by Doug Hanks
Ruby
6
star