Courseiva

CCNA Python And PyEZ Questions

53 questions · Python And PyEZ · All types, answers revealed

1
MCQmedium

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

A.${hostname}
B.{% hostname %}
C.<< hostname >>
D.{{ hostname }}
AnswerD

Double curly braces denote a Jinja2 expression, so `{{ hostname }}` substitutes the variable's value into the rendered Junos configuration. Single braces or bare names would be emitted literally, failing to satisfy the requirement to output the value.

Why this answer

Jinja2 uses double curly braces {{ }} as the expression delimiter to output the value of a variable into the rendered template. Writing {{ hostname }} substitutes the value of the 'hostname' variable at render time. This is the standard Jinja2 syntax for variable interpolation and is used throughout Junos configuration templates.

Exam trap

JNCIA-DevOps often tests the distinction between Jinja2's expression delimiter {{ }} and its statement delimiter {% %}, and candidates frequently swap them or use shell-style ${} syntax out of habit.

How to eliminate wrong answers

Option A is wrong because ${hostname} is shell/Perl-style variable interpolation, not Jinja2 syntax — Jinja2 does not recognize dollar-brace notation. Option B is wrong because {% hostname %} uses Jinja2's statement delimiter, which is reserved for control structures like if, for, and set, not for outputting variable values. Option C is wrong because << hostname >> is not valid Jinja2 syntax at all — it resembles heredoc or custom placeholder notation and would be rendered literally.

2
MCQeasy

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

A.from jnpr.junos.utils.upgrade import Upgrade
B.from jnpr.junos.utils.config import Config
C.from jnpr.junos.device import OS_Update
D.from jnpr.junos.utils.sw import SW
AnswerD

The SW class in jnpr.junos.utils.sw exposes install() and related methods that push a Junos image to a remote device, satisfying the OS upgrade requirement. Importing it gives the script direct access to software-management RPCs rather than generic configuration handling.

Why this answer

The SW utility module from jnpr.junos.utils.sw is used for software installation and upgrades.

3
MCQhard

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?

A.`dev.load_config()` then `dev.commit_check()` then `dev.commit()`
B.`dev.load()` then `dev.commit()`
C.`dev.load_config(merge=False)` then `dev.commit()`
D.`dev.load_config()` then `dev.commit()`
AnswerD

`dev.load_config()` loads the configuration into the candidate configuration, and by default it performs a merge operation. After loading, `dev.commit()` commits the candidate configuration to make it active. This sequence correctly merges the snippet and commits it, achieving the desired result.

Why this answer

The PyEZ `load_config()` method loads a configuration snippet into the candidate configuration, merging it with existing configuration by default. Calling `commit()` then activates the candidate configuration on the device. This two-step sequence is the standard way to apply configuration changes with PyEZ, ensuring that the snippet is merged and committed as required.

Exam trap

The trap here is confusing the lower-level `load()` method with the higher-level `load_config()`, or mistakenly thinking that `merge=False` is needed for merging when it actually replaces the configuration.

4
Multi-Selectmedium

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

Select 2 answers
A.Tables can only be used to modify device configurations, not read operational state.
B.Tables require Jinja2 templates to parse raw XML output.
C.A View defines how individual fields within the returned XML elements are mapped to Python dictionary keys.
D.Tables are typically defined using YAML configuration files.
E.Views replace the need to instantiate a Device object.
AnswersC, D

A View maps each XML element returned by the device to a named Python dictionary key, so Table output becomes usable Python data. This field-level mapping is exactly what the stem asks about regarding View definitions.

Why this answer

Option C is correct because a PyEZ View specifies the mapping between fields in the returned XML (via XPath expressions) and the corresponding Python dictionary keys, allowing structured access to the data. Option D is correct because PyEZ Tables are commonly defined in YAML files, where you declare the table's XPath, view, and key/column mappings. Option A is wrong because Tables are primarily used to retrieve and parse operational state, not to modify configuration.

Option B is wrong because Tables parse XML directly using their View definitions; Jinja2 templates are used for configuration templating, not for Table parsing. Option E is wrong because a View is only a schema/mapping definition and still requires a Device object (or an equivalent connection) to fetch data from the device.

Exam trap

JNCIA-DevOps often tests the misconception that Tables require Jinja2 templates or are only for configuration — in reality, Tables are YAML-defined and primarily used for reading operational state.

5
Multi-Selecthard

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

Select 3 answers
A.dev.timeout property to get or set NETCONF RPC timeout values
B.dev.connected property to check if the session is active
C.dev.capabilities list showing NETCONF server capability URIs
D.dev.reload_session() for refreshing device facts
E.dev.commit_timeout for software installation timing
AnswersA, B, C

The dev.timeout property reads or sets the NETCONF RPC timeout on a PyEZ Device instance, controlling how long the library waits for a response. This satisfies the session-management requirement by letting scripts tune RPC timeouts for slow or long-running operations.

Why this answer

Option A is correct because a PyEZ Device object exposes a timeout property that lets you get or set the NETCONF RPC timeout value used for requests. Option B is correct because the connected property returns a boolean indicating whether the NETCONF session to the device is currently active. Option C is correct because the capabilities attribute returns the list of NETCONF server capability URIs advertised by the device, useful for feature inspection.

Option D is not a real PyEZ Device method; refreshing facts is done via facts_refresh(), not reload_session(). Option E is not a valid PyEZ Device attribute; commit timeouts are handled through configuration/commit options rather than a commit_timeout property.

Exam trap

JNCIA-DevOps often tests the exact names of PyEZ Device properties and methods — candidates confuse valid attributes like dev.timeout with non-existent ones like dev.commit_timeout.

6
MCQhard

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?

A.import jnpr.junos.debug; jnpr.junos.debug.enable()
B.dev.rpc.trace(enabled=True)
C.Configuring Python logging for the 'jnpr.junos' logger with DEBUG level
D.dev.debug = True
AnswerC

PyEZ uses Python's standard logging framework, emitting NETCONF XML traffic through the jnpr.junos logger. Setting that logger to DEBUG level captures the full request and reply exchange between script and device, satisfying the stem's debugging requirement.

Why this answer

PyEZ uses Python's standard `logging` module and emits all NETCONF XML traffic under the `jnpr.junos` logger hierarchy. Setting that logger to DEBUG level (via `logging.getLogger('jnpr.junos').setLevel(logging.DEBUG)` plus a handler) causes the full request/response XML to be logged. There is no PyEZ-specific debug flag or `dev.debug` attribute that performs this function.

Exam trap

JNCIA-DevOps often tests whether candidates invent PyEZ-specific debug APIs (`dev.debug`, `jnpr.junos.debug`) instead of recognizing that PyEZ relies on the standard Python `logging` module and the `jnpr.junos` logger namespace.

How to eliminate wrong answers

Option A is wrong because there is no `jnpr.junos.debug` module or `enable()` function in PyEZ — debugging is done through the standard Python logging framework. Option B is wrong because `dev.rpc.trace()` is not a PyEZ API; `dev.rpc` exposes Junos RPC methods, not a tracing toggle. Option D is wrong because `dev.debug = True` is not a recognized PyEZ attribute and would simply set an unused instance variable without enabling any logging.

7
MCQeasy

What is JSNAPy primarily used for in Junos network automation?

A.Taking operational state snapshots and verifying device health
B.Compiling Junos CLI operational commands into Python bytecode
C.Performing automated firmware upgrades across clusters
D.Generating static configuration templates
AnswerA

JSNAPy takes snapshots of operational state and compares them against stored or expected values, verifying device health and configuration compliance. It satisfies the stem by providing snapshot-and-check automation rather than configuration pushing or RPC execution.

Why this answer

JSNAPy (Junos Snapshot Administrator in Python) is a Python tool that captures operational state snapshots from Junos devices and compares them against a baseline to verify health and detect drift. It is commonly used for pre/post-change validation and compliance checks. It does not compile CLI commands, perform firmware upgrades, or generate configuration templates.

Exam trap

JNCIA-DevOps often tests whether candidates confuse JSNAPy's operational-state verification role with configuration-generation or upgrade tools, so distractors describing templating or firmware tasks look plausible.

How to eliminate wrong answers

Option B is wrong because JSNAPy does not compile Junos CLI commands into Python bytecode — that description does not match any Junos tool; JSNAPy works with YAML-defined checks and RPC calls. Option C is wrong because automated firmware upgrades are handled by tools like Junos Space, Ansible, or PyEZ scripts, not JSNAPy. Option D is wrong because static configuration template generation is the domain of Jinja2, Ansible templates, or PyEZ config utilities — JSNAPy focuses on operational state, not configuration generation.

8
MCQeasy

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

A.{% insert 'filename.j2' %}
B.{% import 'filename.j2' %}
C.{{ load_template('filename.j2') }}
D.{% include 'filename.j2' %}
AnswerD

The `{% include 'filename.j2' %}` tag performs template composition, pulling the referenced file's rendered contents directly into the parent template at that point. This satisfies the stem's requirement to embed another template file's contents, unlike `{% import %}` or `{% extends %}`, which handle macros and inheritance respectively rather than inline inclusion.

Why this answer

Jinja2's {% include 'filename.j2' %} statement renders the contents of another template file inline at that point in the parent template. This is the standard mechanism for modularizing templates — common config blocks (e.g., standard interface settings, SNMP communities) can be stored in separate files and included where needed. The included template shares the parent's variable context.

Exam trap

JNCIA-DevOps often tests the distinction between {% include %} (renders inline with shared context) and {% import %} (loads macros into a namespace without rendering) — candidates who pick import for inline inclusion get it wrong.

How to eliminate wrong answers

Option A is wrong because {% insert 'filename.j2' %} is not Jinja2 syntax — there is no 'insert' statement in Jinja2. Option B is wrong because {% import 'filename.j2' %} is used to import macros and variables from another template into the current namespace, not to render the file's contents inline; import requires the imported file to define macros. Option C is wrong because {{ load_template('filename.j2') }} is not a Jinja2 function — load_template is not part of Jinja2's global namespace, and using {{ }} would attempt to evaluate it as an expression, not a statement.

9
MCQmedium

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?

A.YAML
B.XML
C.JSON
D.INI
AnswerA

JSNAPy defines snapshot checks and test assertions in YAML files, satisfying the requirement to compare pre- and post-change states. Its configuration files (config.yaml, test files) use YAML syntax, letting the script declare which commands to snapshot and which assertions to run against the captured device state.

Why this answer

JSNAPy uses YAML files to define snapshots and test assertions. Snapshot files (for example, `snapshot.yaml`) list the commands or RPCs to capture, and test files (for example, `test.yaml`) define assertions using operators like `is-equal`, `is-greater-than`, and `contains`. YAML's human-readable structure makes it the standard format for JSNAPy configuration.

Exam trap

JNCIA-DevOps often tests the distinction between the data format returned by Junos (XML) and the configuration format used by JSNAPy (YAML), so candidates who conflate the two pick XML incorrectly.

How to eliminate wrong answers

Option B is wrong because XML is the format of the data returned by Junos RPCs, not the format JSNAPy uses to define snapshot or test files. Option C is wrong because JSON is not the configuration format for JSNAPy snapshot or test definitions — JSNAPy parses YAML. Option D is wrong because INI is a legacy key-value format not used by JSNAPy for snapshot or assertion configuration.

10
MCQeasy

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

A.{% def %} ... {% enddef %}
B.{% block %} ... {% endblock %}
C.{% macro %} ... {% endmacro %}
D.{% function %} ... {% endfunction %}
AnswerC

The `{% macro %}` construct defines reusable template blocks that accept arguments, functioning like a function within Jinja2. It satisfies the stem's requirement for callable, parameterised code reuse, unlike `{% include %}` or `{% import %}`, which pull in external templates without argument passing.

Why this answer

Macros in Jinja2 act like functions for templates.

11
Multi-Selecthard

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

Select 2 answers
A.ConnectError
B.AuthError
C.RpcError
D.ConfigError
E.TimeoutError
AnswersA, B

ConnectError is raised when PyEZ fails to establish a connection to the Junos device, such as due to network issues, incorrect hostname, or SSH port problems. It indicates a failure before authentication, making it a key exception for connection handling.

Why this answer

PyEZ raises ConnectError for general connection failures and AuthError for authentication failures. AuthError is a subclass of ConnectError, so catching ConnectError will also catch AuthError. These exceptions are essential for robust error handling in automation scripts that interact with Junos devices.

Exam trap

The trap here is assuming that RpcError or ConfigError are related to connection issues, when they actually occur after a session is established.

12
Multi-Selectmedium

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

Select 2 answers
A.pyez-snap --run
B.jsnapy --snap
C.junos-snapshot --verify
D.juniper-snapshot-admin --test
E.jsnapy --check
AnswersB, E

The jsnapy --snap command captures a snapshot of device operational state for later comparison, forming the baseline half of JSNAPy verification. Running it from the CLI generates the snapshot files that subsequent check commands compare against.

Why this answer

Option B, `jsnapy --snap`, is correct because JSNAPy's snapshot mode is invoked with the `--snap` flag, which collects the current device state defined in the test file and stores it as a snapshot for later comparison. Option E, `jsnapy --check`, is correct because the `--check` flag runs the verification step, comparing a previously taken snapshot against the current device state to validate that operational values match expectations. Together these two commands form the standard JSNAPy CLI workflow of taking a baseline snapshot and then checking against it.

The remaining options do not belong: `pyez-snap --run` (A) is not a real JSNAPy command, `junos-snapshot --verify` (C) is not a JSNAPy CLI tool, and `juniper-snapshot-admin --test` (D) is a fabricated command name not associated with JSNAPy.

Exam trap

The trap here is that candidates may invent plausible-sounding command names (pyez-snap, junos-snapshot) instead of recalling the actual jsnapy CLI syntax with --snap and --check.

13
MCQhard

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?

A.cu.validate()
B.cu.test_syntax()
C.cu.verify()
D.cu.check()
AnswerA

Within a PyEZ `Config` context, `cu.validate()` runs the candidate configuration through Junos's own commit-time syntax and semantic checks without committing, satisfying the requirement to detect errors beforehand. It returns detailed error output, letting your script abort or correct the candidate before `commit()` applies it.

Why this answer

The PyEZ Config utility provides the `cu.validate()` method to check the candidate configuration for syntax errors before committing. It performs a commit check on the device, returning any errors without actually committing the configuration, allowing the script to verify correctness inside a Config context.

Exam trap

JNCIA-DevOps often tests the exact method names on the PyEZ Config object, so candidates who guess plausible-sounding names like `test_syntax()` or `check()` instead of the correct `validate()` pick the wrong answer.

How to eliminate wrong answers

Option B is wrong because `test_syntax()` is not a method on the PyEZ Config object — the correct method is `validate()`. Option C is wrong because `verify()` is not a PyEZ Config method; verification of configuration is done via `validate()` or by comparing rollback diffs. Option D is wrong because `check()` is not a PyEZ Config method — the correct method for syntax validation is `validate()`.

14
Multi-Selectmedium

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

Select 2 answers
A.Capturing operational state snapshots of devices defined in configuration files
B.Provisioning zero-touch deployment (ZTP) DHCP server scopes on core switches
C.Comparing pre- and post-change snapshots to verify test assertions
D.Directly compiling Junos Source routing daemon binaries
E.Translating PyEZ Python scripts into native Junos SLAX op scripts
AnswersA, C

JSNAPy's CLI captures operational state snapshots by running its snapshot command against devices listed in the YAML configuration files, satisfying the requirement to record live device state during verification workflows. This snapshot mechanism underpins later comparison and diff operations, letting engineers detect configuration drift across Junos devices.

Why this answer

JSNAPy (Junos Snapshot Administrator in Python) is a CLI tool designed for network verification workflows, and option A is correct because its core function is to capture operational state snapshots from devices listed in the jsnapy.cfg configuration file using commands like 'jsnapy --snapcheck' or 'jsnapy --snap'. Option C is also correct because JSNAPy's primary purpose is to compare pre-change and post-change snapshots against test assertions defined in YAML test files, executed via 'jsnapy --check' or 'jsnapy --diff', to validate that network state matches expected values. The unmarked options do not belong: ZTP DHCP server scope provisioning (B) is a configuration task unrelated to JSNAPy's snapshot/verification role, compiling Junos routing daemon binaries (D) is an internal Juniper build process not exposed through JSNAPy, and translating PyEZ scripts into SLAX op scripts (E) is not a JSNAPy capability since JSNAPy consumes PyEZ but does not perform such translation.

15
MCQmedium

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?

A.`ConfigTable`
B.`InterfaceTable`
C.`PhyPortTable`
D.`EthPortTable`
AnswerB

`InterfaceTable` is a predefined PyEZ Table that retrieves operational information about interfaces, including status, statistics, and configuration details. It is specifically designed for this purpose and returns a dictionary-like structure keyed by interface name. Using it avoids the need to write custom XML parsing code.

Why this answer

PyEZ includes predefined Tables that simplify retrieving operational data. `InterfaceTable` is the standard Table for interface information, providing operational status, statistics, and configuration attributes for all interfaces. It abstracts the underlying XML RPCs and returns a structured dictionary, making it ideal for scripts that need interface statistics without custom parsing.

Exam trap

The trap here is choosing a platform-specific Table like `EthPortTable` or `PhyPortTable` instead of the general-purpose `InterfaceTable` that works across all Junos devices.

16
MCQeasy

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?

A.from jnpr.junos.rpcs import RPC
B.from jnpr.junos.facts import Facts
C.from jnpr.junos.device import Device
D.from jnpr.junos.utils.sw import SW
AnswerC

Importing `Device` from `jnpr.junos.device` provides the class that models a Junos target, holding connection parameters and transport settings. Instantiating it satisfies the stem's requirement to create a device object for the PyEZ script, since this class exposes the `open()`, `close()` and RPC methods the automation relies on.

Why this answer

Junos PyEZ provides the Device class in the jnpr.junos.device module, which is used to instantiate a device object representing a Junos target. Importing 'from jnpr.junos.device import Device' is the correct way to create a Device instance and connect to a Junos device. This is the foundational import for any PyEZ automation script.

Exam trap

JNCIA-DevOps often tests the confusion between the Device class (for connection/instantiation) and utility classes like RPC, Facts, or SW, so candidates who pick A, B, or D miss the core object needed to represent the target device.

How to eliminate wrong answers

Option A is wrong because jnpr.junos.rpcs.RPC is used for executing RPCs, not for instantiating a device object. Option B is wrong because jnpr.junos.facts.Facts is used to retrieve facts from a device, not to create the device object. Option D is wrong because jnpr.junos.utils.sw.SW is a utility class for software management (upgrades, installs), not for device instantiation.

17
MCQmedium

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?

A.jsnapy --test
B.jsnapy --check
C.jsnapy --verify
D.jsnapy --compare
AnswerB

The jsnapy --check action compares a freshly captured snapshot against the stored baseline and reports differences, which is exactly the comparison the scenario requires. Other actions such as --snap take snapshots rather than performing the check.

Why this answer

JSNAPy's --check action compares a freshly captured snapshot against the stored baseline snapshot and reports any differences. It is the standard command for post-change verification, typically run after a configuration commit to detect drift from the known-good baseline. The --snap action captures the snapshot, while --check performs the comparison.

Exam trap

The trap here is confusing JSNAPy's --check with generic verbs like --verify or --compare — candidates who haven't run JSNAPy may pick the most 'intuitive' word rather than the actual CLI flag.

How to eliminate wrong answers

Option A is wrong because jsnapy --test is not a valid JSNAPy CLI action — the tool uses --snap, --check, and --diff, not --test. Option C is wrong because jsnapy --verify does not exist as a JSNAPy action; verification is performed via --check. Option D is wrong because jsnapy --compare is not a JSNAPy action — the comparison is invoked with --check, not --compare.

18
MCQeasy

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

A.Ansible Engine
B.Mako
C.ERB
D.Jinja2
AnswerD

Jinja2 is the templating engine used alongside Python to generate structured Junos configuration text, supporting variables, loops and conditionals. This satisfies the scenario's requirement for producing device-ready configuration snippets within network automation workflows, rather than ad-hoc string concatenation.

Why this answer

Jinja2 is the de facto templating engine used with Python for generating Junos configuration text in network automation. It is bundled or easily installed alongside Python, integrates natively with Ansible, and supports loops, conditionals, and variable substitution that map cleanly to Junos configuration hierarchies. Its syntax ({{ }} for variables, {% %} for logic) is widely used in Junos automation examples and Juniper's own tooling.

Exam trap

JNCIA-DevOps often tests whether candidates confuse the orchestration tool (Ansible) with the templating engine (Jinja2), or mistake a templating engine from another language ecosystem (ERB/Ruby, Mako) for the Python-standard choice.

How to eliminate wrong answers

Option A is wrong because Ansible Engine is a configuration management and orchestration platform, not a templating engine — it uses Jinja2 internally for templating. Option B is wrong because Mako is a Python templating library, but it is not the primary engine used in Junos automation workflows and lacks the ecosystem integration Jinja2 has with Ansible and Junos tooling. Option C is wrong because ERB (Embedded Ruby) is a Ruby templating system, not a Python one, and is irrelevant to Python-based Junos automation.

19
MCQmedium

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?

A.cu.load(path='interfaces.conf', format='text')
B.dev.load_configuration(file='interfaces.conf')
C.cu.load_file('interfaces.conf')
D.cu.read_config('interfaces.conf')
AnswerA

The PyEZ Config utility's load() method accepts a path argument pointing to an external file plus a format argument, so text format parses 'interfaces.conf' as Junos configuration text. This satisfies the stem's requirement to load from an external text file.

Why this answer

The Config object's load() method is the standard PyEZ API for loading configuration data into a candidate configuration, and it accepts a path argument pointing to an external file plus a format argument specifying the data format. Since the file is a plain text Junos configuration file, format='text' is the correct specification. This combination loads the file contents into the candidate config so it can later be committed.

Exam trap

JNCIA-DevOps often tests whether candidates confuse the PyEZ Config class methods (load, commit, rollback) with non-existent or Device-level methods, so candidates who have not actually written PyEZ code often pick plausible-sounding but invalid method names.

How to eliminate wrong answers

Option B is wrong because load_configuration() is not a valid PyEZ Device method — configuration loading is performed via the Config utility class, not directly on the Device object. Option C is wrong because load_file() is not a PyEZ Config method; the correct method name is load() with a path parameter. Option D is wrong because read_config() does not exist in the PyEZ Config API — reading and loading are distinct operations, and there is no such method for importing a config file.

20
Multi-Selecthard

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

Select 3 answers
A.RpcError
B.DatabaseLockedError
C.ConfigError
D.ConnectError
E.TemplateRenderError
AnswersA, C, D

RpcError is raised by PyEZ when the Junos device returns an RPC error reply, such as an invalid command or permission failure. It surfaces device-side execution faults encountered while a script interacts with the Junos device, making it one of the valid PyEZ exceptions.

Why this answer

PyEZ raises RpcError (option A) when an RPC sent to the Junos device returns an error response, such as a failed <rpc-error> element from the NETCONF/RPC layer. ConfigError (option C) is raised when a configuration load, commit, or related config operation fails on the device. ConnectError (option D) is raised when PyEZ cannot establish or maintain the connection to the Junos device, for example due to authentication or transport failures.

DatabaseLockedError (option B) and TemplateRenderError (option E) are not PyEZ exceptions: DatabaseLockedError is not a standard PyEZ exception class, and TemplateRenderError belongs to Jinja2 templating, not PyEZ's exception hierarchy.

Exam trap

JNCIA-DevOps often tests whether candidates can distinguish genuine PyEZ exception classes from plausible-sounding but fabricated names like DatabaseLockedError or TemplateRenderError.

21
MCQmedium

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?

A.Set `auto_probe=30` in the `Device` constructor to periodically verify the session and reconnect if needed.
B.Pass `auto_probe=0` to the `Device` constructor to disable session probing.
C.Set `port=22` in the `Device` constructor to use SSH instead of NETCONF.
D.Use the `Device` context manager (`with Device(...) as dev:`) to ensure the session is closed properly.
AnswerA

`auto_probe` specifies the interval in seconds at which PyEZ probes the connection to verify it is still alive. If the session has dropped, PyEZ will attempt to reconnect automatically. Setting `auto_probe=30` means the library checks every 30 seconds, providing resilience during long-running tasks without manual intervention.

Why this answer

The `auto_probe` parameter in the PyEZ `Device` constructor enables automatic session health checks at a specified interval. When set to a non-zero value, PyEZ periodically probes the NETCONF session and reconnects if it has dropped, which is essential for long-running automation tasks that must survive transient network issues. Other parameters like `port` or context managers do not provide this recovery capability.

Exam trap

The trap here is confusing the context manager's cleanup behavior with automatic session recovery, or thinking that specifying a port enables reconnection.

22
Multi-Selecthard

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

Select 3 answers
A.Automatic translation of Jinja2 syntax into NETCONF XML filters without evaluation
B.Direct execution of arbitrary host-level Bash shell scripts inside template bodies
C.Variable substitution using double curly braces (e.g., {{ interface_name }})
D.Control structures such as loops and conditional blocks (e.g., {% for item in list %})
E.Template inheritance and block overriding (e.g., {% block content %})
AnswersC, D, E

Double curly braces are Jinja2's native expression delimiters, rendering the referenced variable into the generated Junos configuration text at render time. This satisfies the stem's requirement for a natively supported syntax construct, since {{ }} is core engine behaviour requiring no extension.

Why this answer

Jinja2 natively supports variable substitution through double curly braces, so option C ({{ interface_name }}) is correct because the engine evaluates the expression and renders its value into the output. Option D is correct because Jinja2 provides control structures such as {% for item in list %} loops and {% if %} conditional blocks that are evaluated during rendering. Option E is correct because Jinja2 supports template inheritance via {% extends %} and overridable {% block content %} sections, allowing a base template to be reused and customized.

Option A is not a Jinja2 feature; Jinja2 renders text and does not automatically translate its syntax into NETCONF XML filters, which is handled by Junos-specific tooling such as PyEZ or Jinja2 filters written for that purpose. Option B is also not native Jinja2 behavior; arbitrary host-level Bash execution is not part of the template engine and would require custom extensions or filters, not standard Jinja2 syntax.

23
Multi-Selectmedium

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

Select 2 answers
A.It compiles Jinja2 configuration templates directly into Junos CLI commands.
B.It replaces PyEZ as the primary library for executing NETCONF RPC calls.
C.It saves captured operational data into snapshot files for later comparison.
D.It modifies the active configuration database automatically upon finding errors.
E.It can compare a post-change snapshot against a baseline pre-change snapshot.
AnswersC, E

JSNAPy captures operational state—such as configuration and interface data—and writes it to snapshot files, enabling later comparison against fresh captures to detect drift. This directly satisfies the stem's requirement for snapshot operations, since persistent storage of captured data is what makes subsequent diff-based validation possible.

Why this answer

Option C is correct because JSNAPy's core function is to capture operational state (for example, via 'show' commands defined in a YAML file) and store that output into snapshot files, which serve as the reference data for later checks. Option E is correct because JSNAPy's primary use case is comparing snapshots — typically a post-change snapshot against a baseline pre-change snapshot — to detect configuration or operational drift, using commands like 'jsnapy --check' or 'jsnapy --snapcheck'. Options A, B, and D are incorrect: JSNAPy does not compile Jinja2 templates into CLI commands (that is the role of tools like Jinja2 templating with PyEZ or Junos PyEZ config utilities), it does not replace PyEZ as the NETCONF RPC library (JSNAPy actually relies on PyEZ under the hood), and it does not modify the active configuration database automatically — it only reports differences and never commits changes.

24
MCQmedium

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

A.Template(open('template.j2').read())
B.template.open('template.j2')
C.import_template('template.j2')
D.jinja2.load_file('template.j2')
AnswerA

Passing the file contents to `Template()` constructs the template object directly from the string read off disk, satisfying the requirement to load before rendering. Jinja2's `Template` class accepts a source string, so `open('template.j2').read()` supplies it; rendering with variables then follows via `.render()`. For repeated use, `Environment` with a `FileSystemLoader` is preferred.

Why this answer

The Jinja2 `Template` class accepts a template source string, so reading the file contents with `open('template.j2').read()` and passing that string to `Template()` is a valid way to load a template from disk. This is the standard minimal pattern when you don't need Jinja2's file-system loader features. The other options reference methods or modules that do not exist in the Jinja2 API.

Exam trap

The trap here is that candidates assume Jinja2 has a dedicated file-loading helper like `load_file()` or a method on the template object, when in fact the simplest correct pattern is just reading the file and passing the string to `Template()`.

How to eliminate wrong answers

Option B is wrong because `template.open()` is not a Jinja2 method — the `Template` object has no `open` attribute; file loading is done via `Environment`/`FileSystemLoader`, not a method on the template instance. Option C is wrong because `import_template()` is not a Jinja2 function; templates are loaded via `Template()`, `Environment.from_string()`, or `Environment.get_template()`. Option D is wrong because `jinja2.load_file()` does not exist — the correct file-based API is `jinja2.Environment(loader=jinja2.FileSystemLoader('path'))` followed by `env.get_template('template.j2')`.

25
MCQhard

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?

A.It locks the global database and forces all other users into maintenance mode.
B.It requires an explicit cu.lock() call before any load operation can take place.
C.It automatically locks the candidate configuration upon entry and unlocks it upon exit.
D.It locks the running configuration and restarts the mgd daemon.
AnswerC

Using the context manager form `with Config(dev) as cu:` acquires an exclusive lock on the candidate configuration automatically, then releases it on exit. This satisfies the stem's requirement for default locking behaviour, preventing concurrent commits during the edit session without any explicit `cu.lock()` call.

Why this answer

When entering the Config context manager in PyEZ, it automatically locks the candidate configuration database to prevent concurrent edits and unlocks it upon exiting the context.

26
MCQmedium

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?

A.jnpr.junos.rpchandler.RPC
B.jnpr.junos.device.Device
C.jnpr.junos.factory.Table
D.jnpr.junos.utils.config.Config
AnswerC

Custom Table classes must inherit from jnpr.junos.factory.Table, which provides the parsing machinery that maps Junos XML output into structured rows via the associated View. Inheriting from this base class satisfies the requirement to map to Junos XML output.

Why this answer

To leverage PyEZ Table/View mapping for operational commands, your custom table class must inherit from 'jnpr.junos.factory.Table'.

27
MCQhard

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?

A.from jnpr.jsnapy.verify import VerifyEngine
B.from jnpr.junos.utils.jsnapy import JSNAPy
C.from jnpr.jsnapy.runner import JSNAPyRunner
D.from jnpr.jsnapy import SnapAdmin
AnswerD

SnapAdmin is the JSNAPy class that programmatically runs snapshot comparisons, exposing methods to generate snapshots and check them against stored references. Importing it from jnpr.jsnapy satisfies the stem's requirement to execute verification tests via Python code.

Why this answer

The SnapAdmin class from the jnpr.jsnapy module is the main entry point for programmatically running JSNAPy operations, including taking snapshots and comparing them. You import it with 'from jnpr.jsnapy import SnapAdmin' and instantiate it to call methods like snap() and check(). This is the documented Python API for JSNAPy.

Exam trap

JNCIA-DevOps often tests the exact import path and class name for JSNAPy; candidates confuse the CLI runner with the Python API and pick a non-existent class like JSNAPyRunner or VerifyEngine.

How to eliminate wrong answers

Option A is wrong because jnpr.jsnapy.verify does not contain a VerifyEngine class; the verification logic is handled through SnapAdmin. Option B is wrong because jnpr.junos.utils.jsnapy is not the correct module path for the JSNAPy Python API; JSNAPy is a separate package from PyEZ. Option C is wrong because jnpr.jsnapy.runner does not expose a JSNAPyRunner class for programmatic use; the runner is an internal component invoked by the CLI.

28
MCQeasy

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

A.INI
B.YAML
C.XML
D.JSON
AnswerB

JSNAPy test cases and expected operational states are defined in YAML files, which its parser reads to build assertions. This satisfies the stem's constraint by using YAML's structured key-value syntax rather than JSON or XML for test definitions.

Why this answer

JSNAPy uses YAML configuration files for defining tests and expected values.

29
MCQeasy

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?

A.Instantiate a `Table` and `View` for the system configuration and extract the hostname field.
B.Access `dev.facts['hostname']` after opening the device connection.
C.Use `dev.rpc.get_software_information()` and extract the hostname from the response.
D.Call `dev.rpc.get_config()` and parse the XML response for the hostname element.
AnswerB

PyEZ automatically gathers a set of basic facts when the device connection is opened, including the hostname. Accessing `dev.facts['hostname']` returns the configured hostname as a string without any manual XML parsing. This is the simplest and most efficient method for this specific requirement.

Why this answer

PyEZ automatically populates a dictionary of facts when the device connection is established. The `dev.facts` dictionary includes common values such as `hostname`, `model`, `version`, and `serialnumber`. Accessing `dev.facts['hostname']` is the simplest and most direct way to obtain the configured hostname as a string, avoiding manual XML parsing or additional RPC calls.

Exam trap

The trap here is overlooking the built-in facts and instead opting for manual RPC calls or custom Table/View definitions, which are unnecessary for basic information.

30
MCQmedium

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?

A.`dev.connected`
B.`dev.is_open()`
C.`dev.status()`
D.`dev.session`
AnswerA

The `connected` property returns `True` if the NETCONF session is currently established, and `False` otherwise. It is a read-only Boolean attribute available on the Device object. Checking this property after `open()` ensures the session is active before sending RPCs, preventing errors from operations on a closed or failed connection.

Why this answer

The `connected` property is a read-only Boolean that reflects whether the NETCONF session is currently open. After calling `open()`, checking `dev.connected` confirms the session is active before sending operational commands. Other options are not valid PyEZ attributes or methods for this check.

Exam trap

The trap here is confusing the `connected` property with a method like `is_open()` or `status()`, which do not exist in the PyEZ API.

31
MCQhard

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?

A.The rescue configuration database
B.The candidate configuration database
C.A private configuration database instance
D.The global active configuration database
AnswerB

PyEZ's Config utility defaults to locking and loading into the candidate configuration, which satisfies the partial merge requirement without committing to the active database. Changes remain staged until an explicit commit, allowing validation before affecting running device state.

Why this answer

By default, PyEZ loads configuration changes into the candidate configuration database.

32
MCQmedium

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?

A.jnpr.junos.parallel
B.multiprocessing.device
C.asyncio.netconf
D.concurrent.futures
AnswerD

`concurrent.futures` provides the `ThreadPoolExecutor` class, which manages a pool of worker threads and dispatches tasks across them, satisfying the stem's requirement for concurrent connections to multiple Junos devices. PyEZ device sessions are I/O-bound, so threading suits this well, and the executor's `map` or `submit` methods collect results cleanly.

Why this answer

The concurrent.futures module is the standard Python library for managing thread pools and parallel execution. It provides ThreadPoolExecutor and ProcessPoolExecutor, which are commonly used with PyEZ to connect to multiple Junos devices concurrently. This is the recommended approach for parallel device operations in Python scripts.

Exam trap

JNCIA-DevOps often tests the standard Python library for concurrency; candidates pick asyncio or multiprocessing because they sound more modern, but concurrent.futures is the correct and commonly used module for thread pooling with PyEZ.

How to eliminate wrong answers

Option A is wrong because jnpr.junos.parallel is not a real module in PyEZ; PyEZ does not provide a built-in parallel execution module. Option B is wrong because multiprocessing.device is not a valid module; multiprocessing is a standard library for process-based parallelism, but it does not have a 'device' submodule. Option C is wrong because asyncio.netconf is not a standard module; asyncio is for asynchronous I/O, but PyEZ does not use asyncio for NETCONF, and there is no asyncio.netconf module.

33
MCQeasy

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?

A.dev = Device(host="192.168.1.1"); dev.start_session()
B.with Device(host="192.168.1.1", user="admin", passwd="secret") as dev:
C.dev = Device(host="192.168.1.1"); dev.open(autoclose=True)
D.dev = Device(host="192.168.1.1").connect()
AnswerB

Using `with Device(...) as dev:` invokes PyEZ's context-manager protocol, guaranteeing `dev.close()` runs during `__exit__` even when an exception propagates. This satisfies the stem's requirement that the Junos session closes reliably on error, unlike manual `open()`/`close()` calls that leak sessions if an exception interrupts the script.

Why this answer

Using the context manager 'with Device(...) as dev:' is best practice because it ensures the NETCONF session is automatically closed when the block exits, even if an exception occurs. The Device class implements the context manager protocol (__enter__ and __exit__), which calls open() on entry and close() on exit. This prevents session leaks and is the recommended pattern in Juniper's PyEZ documentation.

Exam trap

JNCIA-DevOps often tests the difference between valid PyEZ methods (open, close, start_session) and invalid ones (connect, autoclose) — candidates pick plausible-sounding but non-existent methods.

How to eliminate wrong answers

Option A is wrong because manually calling start_session() does not guarantee session closure on exception — the developer must explicitly call close() in a finally block. Option C is wrong because autoclose=True is not a valid parameter for the open() method in PyEZ; the correct approach is the context manager. Option D is wrong because connect() is not a standard PyEZ Device method — the correct method is open(), and without a context manager or explicit close, the session may leak.

34
MCQmedium

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

A.{% block block_name %} ... {% endblock %}
B.{{ super() }}
C.{% insert block_name %}
D.{% child_content %}
AnswerA

The {% block block_name %} ... {% endblock %} tag defines an overridable region in a base template; child templates using {% extends %} replace its contents. This satisfies the stem's requirement for marking where child templates insert custom content.

Why this answer

In Jinja2 template inheritance, the base (parent) template defines placeholders using the '{% block block_name %} ... {% endblock %}' syntax. Child templates then use '{% extends "base.html" %}' and override those named blocks with their own content. This is the standard mechanism for defining replaceable sections in a parent template.

Exam trap

JNCIA-DevOps often tests the distinction between defining a block in the parent ('{% block %}') versus calling the parent's content from the child ('{{ super() }}'), so candidates confuse the two roles.

How to eliminate wrong answers

Option B is wrong because '{{ super() }}' is used inside a child template's block to render the parent block's content in addition to the child's content — it is not the tag that defines the placeholder in the base template. Option C is wrong because '{% insert block_name %}' is not valid Jinja2 syntax; there is no 'insert' tag in Jinja2. Option D is wrong because '{% child_content %}' is not a Jinja2 tag; child content is provided by overriding blocks, not by a dedicated tag.

35
MCQeasy

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?

A.`dev.facts`
B.`dev.rpc.get_interface_information()`
C.`dev.cli('show interfaces')`
D.`dev.rpc.get_interface_information(normalize=True)`
AnswerD

The `normalize=True` parameter in PyEZ RPC calls converts the XML response into a Python dictionary, making it easier to work with in scripts. Calling `dev.rpc.get_interface_information(normalize=True)` returns the interface operational status as a dictionary, allowing direct access to fields without XML parsing.

Why this answer

To get structured dictionary output from an RPC in PyEZ, use the `normalize=True` parameter. This converts the XML response into a Python dictionary. Other methods either return XML, facts, or raw text, and do not provide the interface status as a dictionary.

Exam trap

The trap here is assuming that any RPC method returns a dictionary by default, when in fact you must explicitly set `normalize=True`.

36
Multi-Selectmedium

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

Select 2 answers
A.Direct packet capture inspection at Layer 1 physical media levels
B.Writing device firmware assembly code
C.Automated pushing of validated Jinja2-generated configurations to candidate databases
D.Automated pre-check and post-check operational verification during maintenance windows
E.Compiling Junos kernel device drivers in C++
AnswersC, D

PyEZ's Config class loads Jinja2-rendered configuration snippets and commits them to the candidate database, enabling programmatic, validated pushes. This satisfies the pipeline requirement for automated configuration deployment rather than manual CLI entry, keeping changes version-controlled and repeatable.

Why this answer

Option C is correct because PyEZ (junos-eznc) provides modules such as Config and the load() method with merge/override/replace actions that push Jinja2-rendered configuration text into the candidate database, then commit it — a core use case in network DevOps pipelines for templated, validated config deployment. Option D is correct because PyEZ exposes operational RPCs via the RPC class and facts/table retrieval (e.g., get_interface_information, get_route_information), enabling scripts to run pre-checks before a change and post-checks after a maintenance window to verify state and automatically roll back on failure. Option A is not correct because PyEZ operates at the Junos management/RPC layer over NETCONF or the Junos XML API, not at Layer 1 physical media, where packet capture requires tools like tcpdump or dedicated analyzers.

Option B is not correct because firmware assembly is a low-level hardware/vendor engineering task, not something PyEZ automates. Option E is not correct because compiling Junos kernel device drivers in C++ is part of Juniper's internal OS build process, not a PyEZ automation task.

37
MCQhard

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?

A.`exception.errs`
B.`exception.detail`
C.`exception.message`
D.`exception.response`
AnswerA

The `CommitError` exception in PyEZ includes an `errs` attribute, which is a list of error dictionaries or objects containing the detailed error messages from the Junos device. Accessing `exception.errs` allows you to iterate over each error and extract the specific text, such as syntax errors or commit check failures.

Why this answer

When a commit fails, PyEZ raises `CommitError` with an `errs` attribute containing a list of error details from the device. Iterating over `exception.errs` provides the specific commit error messages. Other attributes like `message`, `detail`, or `response` are not the correct way to retrieve these details.

Exam trap

The trap here is assuming that `exception.message` or `exception.response` contains the commit error text, when in fact PyEZ stores them in `errs`.

38
MCQeasy

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?

A.from jnpr.junos.cfg import ConfigTemplate
B.from jinja2 import Environment, FileSystemLoader
C.from jnpr.junos.template import TemplateRenderer
D.import jnpr.junos.utils.jinja as jinja
AnswerB

FileSystemLoader resolves template paths from local disk, and Environment compiles and renders them with the supplied variable dictionary. This pairing satisfies the filesystem-loading constraint, since a plain Template object cannot locate external files without a configured loader.

Why this answer

The standard Jinja2 API for loading templates from disk is to create an Environment with a FileSystemLoader pointed at the template directory, then call get_template() and render() with a variable dictionary. This is the canonical Python Jinja2 pattern and works directly with Junos config templates. PyEZ does not provide its own Jinja2 wrapper module for this purpose.

Exam trap

The trap is that candidates assume PyEZ provides its own Jinja2 wrapper (like ConfigTemplate or TemplateRenderer) when in fact you import Jinja2 directly from the jinja2 package and use Environment + FileSystemLoader.

How to eliminate wrong answers

Option A is wrong because jnpr.junos.cfg.ConfigTemplate is not a real module/class in PyEZ — PyEZ uses jinja2 directly for templating, not a ConfigTemplate class. Option C is wrong because jnpr.junos.template.TemplateRenderer does not exist in the PyEZ library. Option D is wrong because jnpr.junos.utils.jinja is not a real PyEZ module — while PyEZ has jnpr.junos.utils.* submodules (config, sw, fs, etc.), there is no jinja utility module; Jinja2 is imported directly from the jinja2 package.

39
MCQmedium

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?

A.auto_reboot=1
B.reboot=True
C.reload_after_install=True
D.action='reboot'
AnswerB

The reboot=True parameter instructs the PyEZ SW utility to reboot the device automatically once the new Junos image installs successfully. This satisfies the scenario's constraint of unattended installation, removing the need for a separate manual reboot step after the image is written.

Why this answer

The PyEZ SW utility's install() method accepts a reboot=True parameter that instructs the utility to reboot the device automatically after the Junos image is successfully installed. This is the documented keyword argument in the jnpr.junos.utils.sw.SW class, and it triggers the device reboot as part of the install workflow.

Exam trap

JNCIA-DevOps often tests whether candidates can distinguish real PyEZ method parameters from plausible-sounding fabrications like auto_reboot or reload_after_install.

How to eliminate wrong answers

Option A is wrong because auto_reboot=1 is not a recognized parameter of the PyEZ SW.install() method — it is a fabricated name that sounds plausible but does not exist in the API. Option C is wrong because reload_after_install=True is not a PyEZ parameter; the actual method uses reboot, and inventing a longer name is a common distractor pattern. Option D is wrong because action='reboot' is not a valid keyword for SW.install(); the install method does not take an action parameter for rebooting.

40
MCQmedium

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?

A.Use `cu.load(path='config.conf', overwrite=True, check=False)`
B.Use `cu.load(path='config.conf', merge=True, check=False)`
C.Use `cu.load(path='config.conf', merge=True, commit_check=True)`
D.Use `cu.load(path='config.conf', action='merge', verify=False)`
AnswerB

The `load` method of the `Config` object accepts parameters `merge` and `check`. Setting `merge=True` merges the configuration with the candidate, and `check=False` disables the automatic commit check. This matches the requirement to merge and avoid an automatic check. This is the correct method and parameter combination.

Why this answer

The `load` method of the PyEZ `Config` object supports `merge` and `check` parameters. To merge without a commit check, use `merge=True` and `check=False`. The other options either use incorrect parameter names, perform an overwrite, or enable the check.

Only the combination of merge and check=False achieves the desired behavior.

Exam trap

The trap here is confusing the `check` parameter with `commit_check` or using `overwrite` when merge is needed.

41
Multi-Selectmedium

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

Select 2 answers
A.dev = Device(host='192.168.1.1', user='admin', password='secret')
B.dev = Device.connect('192.168.1.1')
C.dev = Device.from_cli('192.168.1.1')
D.dev = Device(database='candidate')
E.dev = Device('192.168.1.1', user='admin', ssh_private_key='/path/to/key')
AnswersA, E

Device() accepts connection parameters as keyword arguments, so host, user and password passed directly instantiate the object and populate the connection details. This is a valid PyEZ instantiation method, satisfying the requirement to provide connection parameters at creation.

Why this answer

Option A is correct because the PyEZ Device constructor accepts connection parameters as keyword arguments, so Device(host='192.168.1.1', user='admin', password='secret') is a valid instantiation that supplies the host, username, and password directly. Option E is also correct because the Device constructor accepts the host as the first positional argument along with keyword parameters such as user and ssh_private_key, so Device('192.168.1.1', user='admin', ssh_private_key='/path/to/key') properly creates a Device object using key-based authentication. Option B is not valid because Device.connect() is not a classmethod for instantiation; connection is performed via the open() method on an already-created Device instance.

Option C is not valid because PyEZ does not provide a Device.from_cli() constructor. Option D is not valid because database='candidate' is not a connection parameter for instantiating a Device; the candidate configuration is selected later via the Config or cu.load() mechanisms, not at object creation.

42
MCQeasy

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?

A.dev.close()
B.dev.terminate()
C.dev.end_session()
D.dev.disconnect()
AnswerA

Calling dev.close() tears down the NETCONF session and releases the underlying SSH transport, satisfying the requirement to terminate cleanly after all configuration and operational tasks finish. Without it, the persistent session lingers, exhausting device resources and blocking other management connections.

Why this answer

In PyEZ, the Device object maintains an active NETCONF session over SSH (port 830) that must be explicitly torn down. The dev.close() method cleanly closes the NETCONF session, releases the underlying SSH transport, and frees associated resources. Without calling close(), the session may linger until timeout, consuming VTY/session slots on the Junos device.

Exam trap

JNCIA-DevOps often tests whether candidates confuse PyEZ's close() with generic connection-termination method names like disconnect(), terminate(), or end_session() — only close() is the actual PyEZ API.

How to eliminate wrong answers

Option B is wrong because dev.terminate() is not a valid PyEZ Device method — there is no such API for ending sessions. Option C is wrong because dev.end_session() does not exist in the PyEZ Device class; NETCONF session teardown is not exposed under that name. Option D is wrong because dev.disconnect() is not a PyEZ method — while 'disconnect' sounds plausible, PyEZ uses close() to release the NETCONF/SSH connection.

43
MCQeasy

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

A.They eliminate the need to establish a Device connection object
B.They automatically convert XML into structured Python data structures like dictionaries and lists
C.They allow direct execution of Junos CLI operational commands without NETCONF
D.They automatically commit configurations to the active database
AnswerB

PyEZ Table and View map returned XML elements into native Python dictionaries and lists, removing manual XPath and element traversal. This satisfies the scenario's need to avoid raw RPC XML parsing and work with structured data directly.

Why this answer

PyEZ Table and View abstractions map Junos XML output to Python dictionaries and lists, eliminating the need for manual XML parsing. Tables define the structure and XPath, while Views map XML elements to Python attributes. This provides a clean, programmatic interface to operational data, making scripts more readable and maintainable.

Exam trap

JNCIA-DevOps often tests whether candidates understand that Table/View still rely on NETCONF and a Device object — the trap is thinking they bypass the connection or use CLI directly.

How to eliminate wrong answers

Option A is wrong because Table and View still require a Device connection object to execute RPCs — they do not eliminate it. Option C is wrong because Table and View use NETCONF RPCs under the hood, not direct CLI execution; they do not bypass NETCONF. Option D is wrong because Table and View are for reading operational data, not for committing configurations.

44
MCQhard

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?

A.dev.rpc.get-ethernet-switching-table-information()
B.dev.get_ethernet_switching_table_information()
C.dev.execute_rpc('get-ethernet-switching-table-information')
D.dev.rpc.get_ethernet_switching_table_information()
AnswerD

PyEZ maps XML tags to Python methods by converting hyphens to underscores, so get-ethernet-switching-table-information becomes get_ethernet_switching_table_information. Calling it on the dev.rpc object executes the custom RPC and returns the Ethernet switching table, satisfying the stem's naming constraint.

Why this answer

PyEZ maps XML RPC hyphens to Python underscores, allowing you to call rpc methods directly as attributes on dev.rpc.

45
Multi-Selectmedium

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

Select 2 answers
A.`ConnectTimeoutError`
B.`ConnectAuthError`
C.`RpcError`
D.`PermissionError`
E.`ConfigError`
AnswersA, B

`ConnectTimeoutError` is raised when PyEZ cannot establish a connection to the device within the specified timeout period. This typically occurs when the device is unreachable, the management interface is down, or there is a network issue. It indicates that the connection attempt timed out.

Why this answer

PyEZ defines a set of exceptions for connection-related failures. `ConnectAuthError` is raised when authentication fails, and `ConnectTimeoutError` is raised when the connection attempt times out due to an unreachable device or network issue. These two exceptions directly address the scenarios of authentication failure and unreachability, making them the correct choices.

Exam trap

The trap here is confusing RPC or configuration exceptions with connection exceptions, or selecting a generic Python exception like `PermissionError` instead of PyEZ-specific ones.

46
Multi-Selectmedium

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

Select 2 answers
A.They automatically compile Python scripts into binary executable files for Junos.
B.They allow installing specific versions of PyEZ, lxml, and Jinja2 independently of system Python.
C.They remove the need to install SSH clients on the local machine.
D.They enable direct root-level execution of Junos CLI commands on physical routers.
E.They isolate Python package dependencies for specific projects, preventing version conflicts.
AnswersB, E

Virtual environments create an isolated directory with its own interpreter and site-packages, so pip installs PyEZ, lxml, and Jinja2 there rather than into system Python. This satisfies the constraint of dependency isolation, letting each project pin distinct library versions without conflicting with OS-managed packages or other automation projects.

Why this answer

Option B is correct because a Python virtual environment creates an isolated site-packages directory with its own pip, so you can install pinned versions of PyEZ, lxml, and Jinja2 (e.g., pip install junos-eznc==2.6.3) without touching or conflicting with the system Python's packages. Option E is correct because that same isolation means each project's dependency set is self-contained, so upgrading a library for one automation project cannot break another project that depends on a different version. The unmarked options do not belong: virtual environments do not compile scripts into Junos binaries (A), do not replace SSH clients since PyEZ still uses NETCONF over SSH (C), and do not grant root-level CLI execution on routers (D).

47
Multi-Selecthard

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

Select 3 answers
A.Using the PyEZ Config context manager to ensure locks are released and rollbacks occur on error
B.Hardcoding administrative passwords inside template files for easy rendering
C.Using try-except blocks to catch specific PyEZ exceptions like ConnectError and ConfigError
D.Avoiding device.close() calls to keep network sessions open permanently
E.Separating Jinja2 template files from core Python execution scripts
AnswersA, C, E

The PyEZ Config context manager acquires the configuration lock and automatically releases it, rolling back on error. This guarantees clean lock handling during Jinja2-driven configuration loads, satisfying the stem's requirement for robust, maintainable automation code that avoids orphaned locks.

Why this answer

Option A is correct because the PyEZ Config context manager (with Config(dev) as cu:) automatically acquires the configuration lock, and on an exception it discards the candidate configuration and releases the lock, preventing stale locks and partial commits. Option C is correct because catching specific PyEZ exceptions such as ConnectError, ConfigError, LockError, and CommitError lets scripts handle connection and configuration failures precisely rather than masking all errors with a bare except. Option E is correct because keeping Jinja2 templates in separate .j2 files (loaded via Environment with FileSystemLoader) separates presentation from logic, improving readability, reuse, and maintainability.

Option B is wrong because hardcoding administrative passwords in template files exposes credentials and violates secure secret-handling practices. Option D is wrong because omitting device.close() leaks NETCONF/SSH sessions and consumes device and client resources; sessions should be closed when work is complete.

Exam trap

JNCIA-DevOps often tests PyEZ best practices, and candidates may be tempted by options that seem convenient (like hardcoding passwords or keeping sessions open) but are actually poor practices, leading them to select incorrect answers.

48
MCQeasy

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

A.A JSON dictionary
B.An XML Element (lxml.etree)
C.A raw plain text string
D.A Python list of strings
AnswerB

PyEZ RPC replies default to raw lxml.etree XML elements rather than dictionaries or JSON. The response is only converted when you explicitly request another structure, such as calling the RPC with a different return format or parsing it yourself.

Why this answer

PyEZ RPC calls return an ElementTree object (XML Element) representing the response from the Junos device.

49
Multi-Selecthard

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

Select 2 answers
A.Views must be defined in a separate YAML file and cannot be coded in Python.
B.Tables automatically convert all XML responses into JSON format.
C.Tables can only retrieve configuration data, not operational data.
D.A View defines how to extract specific fields from the XML response of an RPC.
E.A Table uses a View to parse the RPC output and returns a list of dictionaries.
AnswersD, E

A View in PyEZ is a class that maps XML elements to Python attributes. It specifies XPath expressions to extract desired fields from the RPC response. This allows structured access to data without manual XML parsing. The View is used by a Table to transform the raw XML into a list of dictionaries or objects.

Why this answer

A View defines the extraction of fields from XML, and a Table uses that View to parse RPC output into a list of dictionaries. The other statements are incorrect: Tables do not auto-convert to JSON, Views can be in Python, and Tables are for operational data.

Exam trap

The trap here is thinking that Tables automatically convert XML to JSON, or that Views must be in YAML, when in fact they are flexible and produce dictionaries.

50
MCQmedium

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?

A.Disabling authentication in the script
B.Storing credentials in plaintext in a public GitHub repository
C.Hardcoding credentials in base64 encoding
D.Using SSH key-based authentication or environment variables/config files (.junodes)
AnswerD

SSH key-based authentication removes passwords from source entirely, while the `.junodes` configuration file and environment variables let PyEZ retrieve credentials at runtime. Both satisfy the stem's constraint that credentials must not be hardcoded, keeping secrets outside version-controlled scripts.

Why this answer

PyEZ natively supports configuration files like ~/.junodes or passing parameters dynamically, but also respects environment variables or SSH keys.

51
MCQmedium

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?

A.Remove the `terse=True` argument from the RPC call to retrieve the full interface information.
B.Use the `get_config` method with `config_format='set'` to retrieve the interface configuration and infer the operational status.
C.Set the `normalize=True` parameter in the `Device` object to ensure all fields are returned.
D.Call `get_interface_information` with `interface_name='all'` to retrieve details for every interface including all status fields.
AnswerA

The `terse=True` argument instructs the Junos device to return a condensed version of the interface information, omitting fields such as admin-status and oper-status. By removing this argument, the RPC returns the complete output, including all operational status fields. This is the correct approach to get the full data without altering the RPC itself.

Why this answer

The `terse` argument is a common RPC option that reduces output size by omitting detailed fields. For complete operational status, it must be omitted. The other options either retrieve the wrong type of data or do not affect the output completeness.

Removing `terse=True` directly addresses the missing fields.

Exam trap

The trap here is assuming that adding other parameters or using a different method will automatically include all fields, while the `terse` flag is the specific cause of the missing data.

52
MCQmedium

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?

A.dev.facts
B.dev.rpc.get_system_inventory()
C.dev.gather_facts()
D.dev.get_facts()
AnswerA

Accessing `dev.facts` triggers PyEZ to run the built-in facts gathering routine, returning a dictionary of hardware and OS inventory such as model, serial number, hostname and Junos version. This satisfies the stem's requirement for standard inventory facts from an open Device instance without manual RPC calls.

Why this answer

The dev.facts property on a PyEZ Device instance returns a dictionary of standard hardware and OS inventory facts, such as hostname, model, serial number, Junos version, and uptime. It is populated automatically when the Device connects and is accessed as a property, not called as a method. This is the canonical way to retrieve inventory facts in PyEZ scripts.

Exam trap

JNCIA-DevOps often tests whether candidates know dev.facts is a property (no parentheses) rather than a method, and candidates frequently add parentheses or invent method names like get_facts() or gather_facts().

How to eliminate wrong answers

Option B is wrong because dev.rpc.get_system_inventory() is a lower-level RPC call that returns raw XML inventory data, not a parsed dictionary of standard facts, and it is not the idiomatic PyEZ facts mechanism. Option C is wrong because gather_facts() is not a PyEZ Device method — that naming resembles Ansible's setup module, not PyEZ. Option D is wrong because get_facts() is not a PyEZ Device method; facts are exposed as the dev.facts property, not via a getter method.

53
MCQmedium

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?

A.dev.get_version()
B.dev.version
C.dev.os_version
D.dev.facts['version']
AnswerD

The `facts` dictionary exposes device state gathered at connection time, and its `version` key returns the Junos OS release string loaded on the device. Checking `dev.facts['version']` therefore satisfies the stem's requirement to inspect software version before deciding whether an RPC is supported.

Why this answer

The PyEZ Device object exposes device facts through the `dev.facts` dictionary, and the loaded Junos software version is stored under the key `'version'`. Accessing `dev.facts['version']` returns the string reported by the device (for example, '21.4R3-S2.6'), which a script can parse to decide whether a feature RPC is supported. This is the canonical PyEZ pattern for version inspection.

Exam trap

JNCIA-DevOps often tests the distinction between PyEZ's facts dictionary and non-existent convenience attributes, so candidates who assume a `dev.version` or `dev.os_version` property exists pick the wrong answer.

How to eliminate wrong answers

Option A is wrong because `get_version()` is not a method on the PyEZ Device object — version data is exposed via the facts dictionary, not a dedicated getter. Option B is wrong because `dev.version` is not a defined attribute; PyEZ does not expose version as a top-level property. Option C is wrong because `dev.os_version` does not exist in PyEZ; the OS version lives inside `dev.facts`, not as a standalone attribute.

Ready to test yourself?

Try a timed practice session using only Python And PyEZ questions.