Try Juniper JUNOS PyEz (python library) Memo 1 ~ PyEz Overview ~

1. Overview

In recent years, attention has been increasing to AI, robots, automation, etc., and automation / automation, scripting are also attracting attention in networks. Juniper Networks, one of the major network vendors, publishes various tools and APIs on the network OS JUNOS with the following automation stack to provide an environment that can respond to various automation requirements.

image

This time, I will try PyEz, which is a Python framework that I couldn't find much information in Japanese. PyEz seems to be able to use Python for Easy, and even non-skilled programmers can easily acquire / extract information and change settings remotely with python.

The Juniper documentation states that PyEz will provide: * 1

The documents that can be searched are only in English, but [PyEz Techwiki](http://forums.juniper.net/t5/Automation/Where-can-I-learn-more-about-Junos-PyEZ/ta-p / 280496) and Python EZ Google, so you can check and ask questions there.

2. Environmental preparation

This time, using vSRX * 2 which can be tried for free and a server (Amazon Linux AMI 2016.03.3) that can be used in the free frame of AWS EC2, try setting confirmation and setting change with PyEz.

To use PyEz, you need to install a package called junos-eznc, which is why [Junos PyEZ Dependencies](https://www.juniper.net/techpubs/en_US/junos-pyez1.2/topics/ Install the package according to the OS used by referring to task / installation / junos-pyez-server-installing.html).

The AWS Linux AMI is a Linux OS originally provided by AWS based on RHEL, so the packages required for CentOS are installed.

However, when I tried to install the PyEz package with the pip command (# pip install junos-eznc), I got "fatal error: openssl / opensslv.h: No such file or directory". Therefore, if you also install openssl-devel, you can also install junos-eznc.

The current PyEz supports python 2.6 or 2.7, and the AWS Linux AMI comes with Python 2.7 pre-installed.

If the installation is successful, pytyon will be able to import the following PyEz related modules.

$ python
>>> from jnpr.junos import Device
>>> 

If the installation is not successful, for example, the following error.

>>> from jnpr.junos import Device
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named jnpr.junos

For each module, refer to here.

Since the actual connection uses netconf over SSH, JUNOS also needs to be set in advance.

user@host# set system services netconf ssh port 22
user@host# commit

Now that the environment is ready, next time I will try to get information and change settings of JUNOS.

Reference link:

Juniper Tech Library: Junos PyEZ*1  slide share: Start with PC vSRX * 2  PyEz Techwiki  Python EZ Google

Recommended Posts

Try Juniper JUNOS PyEz (python library) Memo 1 ~ PyEz Overview ~
Try Juniper JUNOS PyEz (python library) Memo 3 ~ Change settings with PyEz ~
Try Juniper JUNOS PyEz (python library) Memo 2 ~ Get information with PyEz ~
Python memo
python memo
Try python
Try using Junos On-box Python # 2 Commit Script
python memo
Python memo
Python standard library: second half (Python learning memo ⑨)
Try using Junos On-box Python # 1 Op Script
Python memo
Python standard library: First half (Python learning memo ⑧)
Python memo
[Personal memo] julia --Using Python library with julia using PyCall
Try operating Studio Library from Python. [Anim Save]
Python & Machine Learning Study Memo ②: Introduction of Library
Python 3.6 email library
[Python] Memo dictionary
Python ast library
python beginner memo (9.2-10)
Python> try: / except:
★ Memo ★ Python Iroha
[Python] EDA memo
Python 3 operator memo
Python Library notes
[My memo] python
Python3 metaclass memo
[Python] Basemap memo
Python beginner memo (2)
[Python] Numpy memo