Junos EZNC is a Python library for automating Juniper Junos devices, simplifying network management tasks for non-programmers. It provides a high-level API to connect to devices, retrieve facts, execute commands, and manage configurations using NETCONF. The current version is 2.7.6, with releases occurring periodically to add features, fix bugs, and ensure compatibility with newer Python versions and underlying dependencies.
pip install junos-ezncVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to establish a connection to a Junos device, retrieve basic facts, and properly close the connection. It uses environment variables for credentials, making it safer for sharing. For production environments, `hostkey_verify` should be set to `True` for secure SSH connections.
Review release notes for 2.6.8 and update your code to use the new field names (e.g., `vlan-name` instead of `name` for VlanTable, `client-name` for BfdSessionTable).
Always use a `try...finally` block to ensure `dev.close()` is called, even if errors occur during the connection lifetime. Alternatively, consider using `with Device(...) as dev:` for automatic resource management if your PyEZ version supports it (check documentation).
Ensure you are using `junos-eznc` version 2.7.6 or newer for official Python 3.12+ compatibility. Always check `requires_python` in `pyproject.toml` or PyPI.
Upgrade to `junos-eznc` 2.6.7 or later to gain explicit control over `look_for_keys` parameter, allowing `True`/`False` to enable/disable SSH agent lookup.
Ensure `junos-eznc` is installed via `pip install junos-eznc` in your active virtual environment. Verify the import statement: `from jnpr.junos import Device`.
Double-check credentials (username/password, SSH key path). Ensure the user is configured for NETCONF access on the Junos device. Verify network connectivity to the device's SSH port (22).
Examine the full RPC error message for details. This often includes `error-message` and `error-path`. Consult Junos documentation for the correct syntax of the command or configuration being applied.
Call `dev.open()` before attempting to access `dev.facts` or other device attributes. Ensure connection success by handling `ConnectError`.