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.
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.
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.
Juniper Tech Library: Junos PyEZ*1 slide share: Start with PC vSRX * 2 PyEz Techwiki Python EZ Google
Recommended Posts