Courseiva

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.

53 questions14 easy25 medium14 hard

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.

1

In a Jinja2 template designed for Junos configuration, how do you correctly output the value of a variable named 'hostname'?

Medium
2

Which PyEZ utility module should you import if you need to upgrade the Junos operating system on a remote device via a Python script?

Easy
3

You 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?

Hard
4

Which TWO statements are true regarding PyEZ Table and View definitions? (Choose two)

Medium
5

Which THREE advanced features or methods are available on a PyEZ Device instance for session management and inspection? (Choose three)

Hard
6

When 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?

Hard
7

What is JSNAPy primarily used for in Junos network automation?

Easy
8

What Jinja2 feature allows you to include the contents of another template file into your main configuration template?

Easy
9

An 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?

Medium
10

Which Jinja2 construct is used to define reusable blocks of template code that can be called with arguments like a function?

Easy
11

You 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.)

Hard
12

Which TWO commands or tools are associated with running JSNAPy snapshot verifications from a CLI environment? (Choose two)

Medium
13

You 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?

Hard
14

Which TWO actions can be performed using the JSNAPy command-line interface (CLI) tool during network verification workflows?

Medium
15

You 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?

Medium
16

An 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?

Easy
17

You 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?

Medium
18

What is the primary templating engine used alongside Python for generating structured Junos configuration text in network automation workflows?

Easy
19

An 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?

Medium
20

Which THREE exceptions can be raised by PyEZ during script execution when interacting with a Junos device? (Choose three)

Hard
21

You 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?

Medium
22

When implementing Jinja2 templates for Junos configuration generation, which THREE features or syntax constructs are natively supported by the Jinja2 engine?

Hard
23

Which TWO characteristics describe JSNAPy snapshot operations? (Choose two)

Medium
24

When using Jinja2 templates in Python to generate configurations, how can you load a template file from disk prior to rendering it with variables?

Medium
25

When 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?

Hard
26

You 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?

Medium
27

You want to run a JSNAPy verification test via Python code. Which Python class should you import and instantiate to execute the snapshot comparison programmatically?

Hard
28

In JSNAPy, what file format is used to define test cases and expected operational states?

Easy
29

You 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?

Easy
30

You 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?

Medium
31

You 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?

Hard
32

When 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?

Medium
33

An 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?

Easy
34

When using Jinja2 inheritance, which tag is placed in a base template to indicate where child templates can insert their custom content?

Medium
35

You 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?

Easy
36

Which TWO tasks are typically automated using Python and PyEZ in a network DevOps pipeline? (Choose two)

Medium
37

A 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?

Hard
38

You 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?

Easy
39

You 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?

Medium
40

You 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?

Medium
41

Which TWO of the following are valid ways to instantiate a PyEZ Device object in Python, providing connection parameters? (Choose two)

Medium
42

In 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?

Easy
43

What is the primary benefit of using PyEZ Table and View abstractions over raw RPC XML parsing in Python scripts?

Easy
44

You 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?

Hard
45

You 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.)

Medium
46

Which TWO benefits are gained by using Python virtual environments when developing PyEZ and Jinja2 automation scripts? (Choose two)

Medium
47

When developing Python scripts that utilize PyEZ and Jinja2, which THREE best practices ensure robust and maintainable automation code? (Choose three)

Hard
48

When executing an RPC call in PyEZ, what format is typically returned by default if you do not parse it into another structure?

Easy
49

You 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.)

Hard
50

When 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?

Medium
51

You 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?

Medium
52

You 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?

Medium
53

An 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?

Medium

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.
Juniper Networks Automation and DevOps, Associate (JNCIA-DevOps, JN0-224) (JNCIA-DevOps) Python And PyEZ Practice Questions