A team wants an automation script that is straightforward to test and maintain as its device inventory grows. Which design best separates the script's data, logic, and device access?
4 Network Automation with Python Online Quiz Questions
Use this free practice quiz with 20 questions to review 4 Network Automation with Python, test your knowledge, and prepare for your next test or exam.
True or false: In the inventory-validation example, an invalid management address can raise ValueError, which the script catches to report the affected device.
- A
True
- B
False
To decide whether a device needs a configuration change, compare its current state with the .
What term describes an automation run that can be repeated without making further changes once the device has reached the desired state?
In the NAPALM example, what happens when the candidate differs from the device's current configuration but the APPLY environment variable is not set to "1"?
- A
It commits the candidate configuration and verifies the hostname.
- B
It displays the proposed diff, then discards the candidate without applying the change.
- C
It replaces the device configuration with the candidate and closes the session.
- D
It skips the diff and marks the device compliant.
Select all actions that belong in the automation workflow before a consequential device change is applied.
- A
Validate the device list and required inputs.
- B
Read the current device state needed for the task.
- C
Compare current and desired state to calculate the change.
- D
Produce a diff or plan for review before applying the change.
- E
Apply the change before reading the current state, then decide whether it was necessary.
True or false: In the NAPALM example, the finally block is used to clean up a pending candidate and close the device session, including when an error occurs.
- A
True
- B
False
How many numbered stages are in the reliable automation pattern, from loading and validating inputs through recording the outcome and cleaning up?
In the NAPALM example, credentials are read from rather than embedded in the source code.
A configuration commit succeeds, but the team needs to know whether the device actually reached the intended state. Which check best provides that evidence?
- A
Confirm that the script printed the proposed diff.
- B
Confirm that the candidate was loaded without an exception.
- C
After committing, retrieve live device facts and check that the hostname matches the intended name.
- D
Confirm that the device session closed without an exception.
A device may temporarily stop responding during an automation run. Select all practices that help handle this safely.
- A
Set timeouts and limit retries to errors likely to be temporary.
- B
Retry every failed operation indefinitely until the device responds.
- C
Avoid blindly repeating operations that are not idempotent.
- D
Remove timeouts so a slow device can never cause the script to fail.
Before applying a candidate configuration, an engineer is unsure whether the target platform replaces or merges configuration. What is the safest next step?
- A
Assume every configuration operation merges changes and apply the entire candidate.
- B
Determine whether the device or library merges or replaces configuration, then choose the smallest suitable change.
- C
Prefer replacing configuration because it guarantees unrelated settings will be preserved.
- D
Skip reviewing the candidate if the requested setting appears in the inventory.
A script commits a risky production change, but its post-change check shows that the device is not operating as intended. What should the automation team do next, and what recovery safeguards should it have planned for such a change?
A device inventory may contain malformed management addresses. Which approach helps detect those errors before the script attempts device connections?
- A
Attempt to connect to every device and handle malformed addresses only after authentication fails.
- B
Parse each management address with the ipaddress module before attempting connections.
- C
Replace every invalid address with a default address so the script can continue.
- D
Skip address checks because the network library will always report invalid input consistently.
A network automation script needs a username and password to connect to devices. Which approach best protects those credentials?
- A
Store the password in a comment so operators can find it easily.
- B
Commit the password in a configuration file alongside the script.
- C
Retrieve credentials from a secrets manager or protected environment injection.
- D
Print the password to the log before connecting so failures are easier to diagnose.
What property should an automation script have if rerunning it after the desired device state is reached makes no further changes?
In the NAPALM workflow, which method displays the difference for a staged configuration candidate before it is committed or discarded?
True or false: If a device accepts a configuration command, that alone proves the intended operational result was achieved.
- A
True
- B
False
A change script should default to a dry run and require an explicit opt-in before applying a staged change. Which behavior matches that requirement?
- A
Commit every candidate as soon as it is loaded, then display the diff.
- B
Display the proposed diff and discard the candidate unless APPLY=1 is set.
- C
Discard every candidate before comparing it with the current configuration.
- D
Apply the candidate only when the diff is empty.
A script may fail after loading a candidate configuration. Which cleanup strategy best ensures that the candidate is discarded when needed and the device session is closed?
- A
Use a finally block to discard any still-loaded candidate and close the session.
- B
Close the session only after every operation succeeds.
- C
Retry the commit indefinitely before closing the session.
- D
Leave the candidate loaded so a later run can reuse the session.