A network engineer is developing a Python script using PyEZ to apply a new BGP configuration to a Junos device. The script must ensure that the configuration is syntactically correct before attempting to merge it into the candidate configuration. Which sequence of PyEZ Config methods provides the most efficient and safe way to achieve this?
Answer and explanation
Correct answer: B
The most efficient and safe method is load(check=True). The check=True argument performs a syntax check on the configuration before loading it into the candidate datastore. This prevents a malformed configuration from being loaded, which could cause issues later. After a successful load, the commit() method can be called to apply the changes. The other options are less efficient or perform checks at the wrong stage.
Question 2
While troubleshooting a failing NETCONF session, an automation engineer captures the following RPC reply from a Junos device:
protocol
operation-failed
error
bgp
Configuration is locked
Based on this output, what is the root cause of the failure?
Answer and explanation
Correct answer: C
The tag clearly states 'Configuration is locked'. The operation-failed indicates that the requested operation could not be completed. This combination means that the script's attempt to modify the configuration failed because another session (either a user via CLI or another script) has an exclusive lock on the candidate datastore, preventing changes.
Question 3
When defining infrastructure variables for configuration management tools like Ansible, what is the primary advantage of using YAML over JSON?
Answer and explanation
Correct answer: B
YAML's primary advantage, especially in the context of tools like Ansible, is its focus on human readability. It uses indentation and minimal syntax (no brackets or braces for structure), making variable files and playbooks easier to read, write, and maintain. Additionally, YAML natively supports comments, which is a crucial feature for documenting configuration intent, something JSON lacks.
Question 4
A network automation team is integrating JSNAPy into their CI/CD pipeline to validate network changes. At which stage of the pipeline would the execution of JSNAPy tests provide the most value?
Answer and explanation
Correct answer: C
JSNAPy is a state validation tool designed to capture and compare snapshots of a device's operational state. Its greatest value is realized immediately before a change is deployed (pre-check) and immediately after (post-check). This happens during the 'Test' (on a staging device) and 'Deploy' (on a production device) stages of a CI/CD pipeline to ensure the change had the intended effect and no unintended side effects.
Question 5
Which cURL command correctly uses the Junos REST API to replace the entire configuration for the ge-0/0/1 interface with content from a local file named interface.json?
Answer and explanation
Correct answer: C
The correct method to replace a resource via the REST API is the HTTP PUT method. The -X PUT flag specifies this. The URL correctly points to the specific interface resource (/configuration/interfaces/interface/ge-0_0_1). The -H 'Content-Type: application/json' header tells the server the format of the payload, and --data @interface.json sends the content of the specified file as the request body.
Question 6
A Python script using PyEZ needs to retrieve the BGP summary information and then process only the neighbors that are in the 'Established' state. Given that dev.rpc.get_bgp_summary_information() returns a complex XML object, what is the most effective way to access the desired data?
Answer and explanation
Correct answer: C
The PyEZ RPC reply is an lxml object, which is ideal for parsing with XPath. Using an XPath expression like .//bgp-peer[peer-state='Established'] with the .findall() method is the most direct, efficient, and reliable way to select only the specific XML elements that match the criteria. This avoids fragile string manipulation and inefficient manual iteration.
Question 7
What is the function of the operation="merge" attribute within a NETCONF RPC sent to a Junos device?
Answer and explanation
Correct answer: B
The operation="merge" attribute instructs the NETCONF server to merge the configuration data from the RPC with the configuration in the target datastore. New elements in the RPC are added, and existing elements are updated. It does not delete elements that are absent from the RPC, which is the key difference from the replace operation.
Question 8
Company Background: Global Financial Services Inc. operates a large-scale network with strict compliance and uptime requirements. Network changes are only permitted during scheduled weekly maintenance windows and must be rigorously validated to prevent service disruptions. The network operations team is small and needs to automate as much of the change validation process as possible to reduce human error and meet tight deadlines.
Current Situation: The team currently relies on manual CLI commands to check the state of core routers before and after applying configuration changes. This process is slow, error-prone, and generates inconsistent reports. They have decided to build an automated solution using Python, leveraging the PyEZ library for device interaction and JSNAPy for state validation.
Technical Requirements:
The solution must be a single Python script that can be executed from a central automation server.
Before applying any changes, the script must capture a 'pre-change' snapshot of the device state. This must include the full IPv4 routing table, the status of all BGP sessions, and the operational status of all physical interfaces.
After changes are applied (manually or by another script), the script must capture a 'post-change' snapshot of the same data points.
The script must compare the two snapshots and generate a simple, clear report indicating a PASS or FAIL status. A FAIL status should be triggered if any BGP sessions have dropped, any critical interfaces have gone down, or if specific critical routes are missing from the routing table.
Constraint: The solution must not require any custom daemons or agents to be installed on the Junos devices themselves.
Which approach best satisfies all the requirements for this automated validation solution?
Answer and explanation
Correct answer: B
This approach directly addresses all requirements using the intended tools. JSNAPy is specifically designed for this use case. A JSNAPy configuration file allows the declarative definition of what data to snapshot (routing table, BGP summary, interfaces) and the conditions for a PASS/FAIL result. The Python script can then orchestrate the JSNAPy operations (--snap, --check), providing a robust, maintainable, and scalable solution without requiring screen scraping or complex manual comparisons.
Question 9
Multiple answers
An engineer is creating a YAML file to store a list of NTP servers. Which of the following snippets are syntactically correct representations of a list in YAML? (Select TWO)
Answer and explanation
Correct answers: A, C
Question 10
True or False: In a mature DevOps workflow, the principle of Infrastructure as Code (IaC) encourages defining network configurations in version-controlled files, which are then used to automate deployments, ensuring consistency and repeatability.
Answer and explanation
Correct answer: A
This statement is true. A core tenet of Infrastructure as Code (IaC) is to manage and provision infrastructure through machine-readable definition files (e.g., YAML, JSON) rather than manual configuration. These files are stored in a version control system (like Git), becoming the single source of truth. Automation tools then use these files to apply configurations, which makes the process repeatable, consistent, and auditable.