Installing Junos PyEZ
Junos PyEZ is a Python library that enables you to manage and automate devices running Junos OS. You can install Junos PyEZ on a UNIX-like operating system or on Windows.
Juniper Networks also provides a Junos PyEZ Docker image that enables you to run Junos PyEZ as a Docker container. The Docker container is a lightweight, self-contained system that bundles Junos PyEZ, its dependencies, and Python into a single portable container. The Docker image enables you to quickly run Junos PyEZ in interactive mode, as an executable package, or as a terminal on any platform that supports Docker.
To manually install Junos PyEZ and its dependencies, see the following sections:
To use the Junos PyEZ Docker image, see the following section:
Installing Junos PyEZ Dependencies
Before you install the Junos PyEZ package on the configuration management server, ensure that the server has the following software installed:
Python 2.6, Python 2.7, or Python 3.4 or later
All dependencies for the given operating system, which are outlined in Table 1
Python 3.x is only supported in Junos PyEZ Release 2.0 and later releases.
Table 1: Junos PyEZ Dependencies
If Junos PyEZ does not successfully install using
Installing the Junos PyEZ Package
After you install the Junos PyEZ dependencies on the configuration management server, you can install the latest release of Junos PyEZ from the Python Package Index (PyPI). You can also download the latest version of the code from the Junos PyEZ GitHub repository. To install Junos PyEZ from GitHub, you must have Git installed on the configuration management server.
To install the current release of Junos PyEZ from PyPI, execute the following command on the command line (use sudo pip where appropriate):
user@server:~$ sudo pip install junos-eznc
To upgrade an existing version of Junos PyEZ, include the -U or --upgrade option when executing the pip install command.
To install Junos PyEZ from the GitHub project master branch, execute the following command on the command line (use sudo pip where appropriate):
user@server:~$ sudo pip install git+https://github.com/Juniper/py-junos-eznc.git
The latest code in the GitHub source repository is under active development and might not be stable.
The pip command name might vary depending on your operating system and version of Python. Before installing Junos PyEZ using pip, use the pip -V command to display the version, and verify that the pip command corresponds to the version of Python that you are using for Junos PyEZ on your system. If the version is not the same as the Python version used for Junos PyEZ, then try using the pip2 or pip3 commands instead of pip.
For additional information about installing Junos PyEZ and any
required dependencies, including additional installation options,
INSTALL file for your specific
operating system in the Junos PyEZ GitHub repository at https://github.com/Juniper/py-junos-eznc.
Using the Junos PyEZ Docker Image
Docker is a software container platform that is used to package and run an application and its dependencies in an isolated container. Juniper Networks provides a Junos PyEZ Dockerfile as well as Junos PyEZ Docker images, which are automatically built for every Junos PyEZ release. Starting in Junos PyEZ Release 2.1.8, the Docker images include Python 3.6. In earlier release, the images include Python 2.7.x.
You can customize and use the Dockerfile to build your own Junos PyEZ Docker image, or you can use one of the prebuilt Docker images, which are stored on Docker Hub, to run Junos PyEZ as a Docker container. You can run the container in interactive mode, as an executable package, or as a terminal.
To use a prebuilt Junos PyEZ Docker image on your configuration management server:
- Install Docker.
See the Docker website at https://www.docker.com for instructions on installing and configuring Docker on your specific operating system.
- Download the juniper/pyez Docker image from Docker Hub.
To download the latest image, issue the following command:user@server:~$ docker pull juniper/pyez
The latest Junos PyEZ Docker image is built using the most recently committed code in the Junos PyEZ source repository, which is under active development and might not be stable.
To download a specific image, append the appropriate release tag to the image name, for example, 2.1.2.user@server:~$ docker pull juniper/pyez:tag
- Move to the local directory that contains your scripts.
When you run the Docker container, the local scripts are mounted to
/scriptsin the container.
- Run the container.
For instructions on running the container, see the official usage examples at DOCKER-EXAMPLES.md.