JNCIA-DevOps · domain
Python And PyEZ
This domain covers automating Junos devices with Python and the PyEZ library. Questions present short scripting scenarios: loading and committing configuration, handling exceptions, using the SW utility for image installs, and running JSNAPy checks. You must know the correct classes, methods, and parameters to accomplish each task programmatically.
Focused practice
Practice Python And PyEZ questions
Scored sessions drawing only from this domain — pick a length below.
Start 20-question practice test →What this domain covers
What to know about Python And PyEZ
Be able to write PyEZ scripts that load, merge, and commit configuration, catch CommitError and read its message, install images with the SW utility, and invoke JSNAPy checks in code. Getting the exact method names and parameters right is essential.
Using Config and commit_check with load merge to apply candidate configuration via PyEZ
Retrieving device error text from CommitError and RpcError exception objects
Installing Junos images with the PyEZ SW utility and its reboot parameter
Running JSNAPy snapshot comparisons programmatically by importing and instantiating the appropriate class
Watch out for
Common Python And PyEZ exam traps
- ▸Confusing load merge with load replace or load override, which changes how candidate configuration is combined
- ▸Assuming commit failures raise a generic exception rather than CommitError with device message details
- ▸Forgetting that the SW utility reboot behavior is controlled by a method parameter, not automatic
Question index
All Python And PyEZ questions (53)
Click any question to see the full explanation, or start a practice session above.
In a Jinja2 template designed for Junos configuration, how do you correctly output the value of a variable named 'hostname'?
Medium2Which PyEZ utility module should you import if you need to upgrade the Junos operating system on a remote device via a Python script?
Easy3You are developing a PyEZ script that loads a configuration snippet onto a Junos device. You want to ensure the configuration is merged with the existing candidate configuration and then committed. Which sequence of PyEZ methods should you use?
Hard4Which TWO statements are true regarding PyEZ Table and View definitions? (Choose two)
Medium5Which THREE advanced features or methods are available on a PyEZ Device instance for session management and inspection? (Choose three)
Hard6When using PyEZ to push a configuration, you want to log out all NETCONF XML traffic exchanged between the script and the Junos device for debugging purposes. How do you enable this logging in Python?
Hard7What is JSNAPy primarily used for in Junos network automation?
Easy8What Jinja2 feature allows you to include the contents of another template file into your main configuration template?
Easy9An automation script needs to compare pre- and post-change states on a Junos device using JSNAPy (Junos Snapshot Administrator). Which configuration file format is used by JSNAPy to define snapshot checks and test assertions?
Medium10Which Jinja2 construct is used to define reusable blocks of template code that can be called with arguments like a function?
Easy11You are developing a Python script using Junos PyEZ to retrieve and process operational data. You need to handle exceptions that may occur during device interaction. Which two exceptions are raised by PyEZ when a connection or authentication issue occurs? (Choose two.)
Hard12Which TWO commands or tools are associated with running JSNAPy snapshot verifications from a CLI environment? (Choose two)
Medium13You are writing a script that performs multiple configuration changes inside a single PyEZ Config context. How can you verify that the candidate configuration has syntax errors before committing it?
Hard14Which TWO actions can be performed using the JSNAPy command-line interface (CLI) tool during network verification workflows?
Medium15You are writing a PyEZ script that must retrieve interface statistics from a Junos device. You want to use a predefined PyEZ Table to avoid writing custom parsing logic. Which predefined Table should you use to get operational status and statistics for all interfaces?
Medium16An automation engineer is writing a Python script using Junos PyEZ to connect to a device. Which module and class must be imported to instantiate a device object representing the Junos target?
Easy17You have captured a baseline snapshot using JSNAPy and want to compare a newly taken snapshot against that baseline. Which JSNAPy command-line action executes this comparison?
Medium18What is the primary templating engine used alongside Python for generating structured Junos configuration text in network automation workflows?
Easy19An engineer is applying a candidate configuration using PyEZ and needs to load it from an external text file named 'interfaces.conf'. Which Config method should be used?
Medium20Which THREE exceptions can be raised by PyEZ during script execution when interacting with a Junos device? (Choose three)
Hard21You are writing a PyEZ script that must connect to a Junos device and run several RPCs, but you need the connection to automatically recover if the NETCONF session drops during a long-running task. Which PyEZ connection parameter should you configure to enable this behavior?
Medium22When implementing Jinja2 templates for Junos configuration generation, which THREE features or syntax constructs are natively supported by the Jinja2 engine?
Hard23Which TWO characteristics describe JSNAPy snapshot operations? (Choose two)
Medium24When using Jinja2 templates in Python to generate configurations, how can you load a template file from disk prior to rendering it with variables?
Medium25When modifying a Junos device configuration using the PyEZ Config table-driven or Context manager (with Config(dev) as cu:), what is the default behavior regarding locking the candidate configuration?
Hard26You are utilizing PyEZ Table and View abstractions to parse interface statistics. Which base class must your custom Table class inherit from to map to Junos XML output?
Medium27You want to run a JSNAPy verification test via Python code. Which Python class should you import and instantiate to execute the snapshot comparison programmatically?
Hard28In JSNAPy, what file format is used to define test cases and expected operational states?
Easy29You are writing a PyEZ script to retrieve the configured hostname from a Junos device. You want to use the simplest method that returns the hostname as a string without parsing XML manually. Which PyEZ feature should you use?
Easy30You are writing a Python script that uses PyEZ to connect to a Junos device. After calling `dev.open()`, you need to verify that the NETCONF session is active before performing operational commands. Which statement correctly checks the connection status and returns a Boolean value?
Medium31You are writing a script that uses PyEZ to load a partial configuration merge. By default, what configuration database mode does the Config utility lock and load into?
Hard32When writing a Python script that connects to multiple Junos devices concurrently using PyEZ, which Python module is commonly used to manage thread pooling and parallel execution?
Medium33An automation engineer is writing a Python script using Juniper PyEZ to connect to a Junos device. Which context manager approach is best practice to ensure the Device session is properly closed even if an exception occurs?
Easy34When using Jinja2 inheritance, which tag is placed in a base template to indicate where child templates can insert their custom content?
Medium35You are using PyEZ to retrieve the operational status of all interfaces on a Junos device. You want to get the output in a structured Python dictionary rather than raw XML. Which method should you use on the Device object?
Easy36Which TWO tasks are typically automated using Python and PyEZ in a network DevOps pipeline? (Choose two)
Medium37A Python script using PyEZ loads a configuration from a file and commits it on a Junos device. The commit fails with a `CommitError` exception. You need to retrieve the specific error message returned by the device. Which method or attribute should you use to obtain the detailed error text?
Hard38You are writing a script that uses Jinja2 to dynamically render a Junos interface configuration. Which Python module and function are required to load a template from the local filesystem and render it with a dictionary of variables?
Easy39You are using the PyEZ SW utility to install a new Junos image on a device. Which method parameter allows the script to automatically reboot the device after a successful installation?
Medium40You are developing a Python script using PyEZ to load a configuration onto a Junos device. You need to ensure that the configuration is merged with the existing candidate configuration, and that the load operation does not perform a commit check automatically. Which method should you use to load the configuration from a file?
Medium41Which TWO of the following are valid ways to instantiate a PyEZ Device object in Python, providing connection parameters? (Choose two)
Medium42In a Python script utilizing PyEZ, what method must be called on the Device instance after all configuration and operational tasks are complete to properly terminate the NETCONF session?
Easy43What is the primary benefit of using PyEZ Table and View abstractions over raw RPC XML parsing in Python scripts?
Easy44You need to execute a custom remote procedure call (RPC) in PyEZ to retrieve the Ethernet switching table. The tag in Junos XML API is get-ethernet-switching-table-information. How should you write this method call in Python?
Hard45You are writing a PyEZ script that needs to handle exceptions when connecting to a Junos device and executing RPCs. Which TWO exceptions are raised by PyEZ when authentication fails or when the device is unreachable? (Choose two.)
Medium46Which TWO benefits are gained by using Python virtual environments when developing PyEZ and Jinja2 automation scripts? (Choose two)
Medium47When developing Python scripts that utilize PyEZ and Jinja2, which THREE best practices ensure robust and maintainable automation code? (Choose three)
Hard48When executing an RPC call in PyEZ, what format is typically returned by default if you do not parse it into another structure?
Easy49You are writing a Python script using PyEZ to retrieve and process operational data from a Junos device. Which TWO statements correctly describe the use of PyEZ Table and View for parsing operational data? (Choose two.)
Hard50When writing a Python script to interact with Junos devices, you want to ensure that password credentials are not hardcoded in the source code. What is a recommended best practice supported by PyEZ?
Medium51You are automating the retrieval of operational data from a Junos device using PyEZ. You write a Python script that calls the RPC method `get_interface_information` with the argument `terse=True` on a `Device` object. The script executes successfully, but the returned XML contains only a subset of interface details, missing fields like `admin-status` and `oper-status`. You need the full operational status for each interface. What should you do to obtain the complete data?
Medium52You are writing a Python script to gather operational state information from a Junos device using PyEZ. Which method should you call on an open Device instance to retrieve standard hardware and OS inventory facts into a dictionary?
Medium53An automation script needs to check if a Junos device supports a specific feature before executing an RPC. Which PyEZ property can be checked to inspect the software version loaded on the device?
MediumOther domains
All JNCIA-DevOps exam domains
Frequently asked questions
- What does the Python And PyEZ domain cover on the JNCIA-DevOps exam?
- Be able to write PyEZ scripts that load, merge, and commit configuration, catch CommitError and read its message, install images with the SW utility, and invoke JSNAPy checks in code. Getting the exact method names and parameters right is essential.
- How many questions are in this domain?
- This page lists all 53 Python And PyEZ questions in the JNCIA-DevOps question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
- What is the best way to practise this domain?
- Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
- Can I practise only Python And PyEZ questions?
- Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.