Implementing Automation for Cisco Service Provider Solutions (SPAUTO) — Question 21
How does using the Python with statement in conjunction with ncclient manager improve an existing NETCONF automation script?
Answer options
- A. It allows the NETCONF connection to the device to be gracefully closed without having to explicitly code this action.
- B. It manages the running configuration of the device by comparing it to the new configuration applied using NETCONF.
- C. The with statement tries to connect to the device using TCP port 830 first but also tries to connect via TCP port 22.
- D. Use of the with statement catches any exceptions when trying to connect to a device using NETCONF.
Correct answer: D
Explanation
The correct answer is D because the with statement handles exceptions that may occur during the connection process, providing a cleaner and safer way to manage connections. Option A is incorrect as it refers to closing connections, which is not the primary function of the with statement. Option B discusses configuration management, which is not related to the with statement's role. Option C incorrectly describes the connection process, as the with statement does not specifically attempt connections through multiple ports.