A campus engineer automates nightly show version collection and VLAN updates on 40 IOS XE switches using Python. The script must log in reliably, run both read and write tasks, and close cleanly. Which Netmiko approach establishes the session and sends show and config commands?
Select an answer to reveal the explanation.
Short Explanation
You are wiring the right tool to the right box and using each call for its job. Your session works like a labelled key that opens both read and write doors.
Full Explanation
Netmiko uses ConnectHandler with a platform device_type such as cisco_xe to handle IOS XE login, prompt detection and paging, send_command or send_command variants for operational show commands, and send_config_set to enter configuration mode, apply a list of commands and exit cleanly with disconnect, which matches the need for both read and write tasks. Using cisco_xr targets a different OS prompt and command set, so session handling and parsing can fail against IOS XE even though the method names look similar. Using send_command for configuration changes misses config-mode handling and commit behavior, so changes may be rejected or left unapplied. Raw SSHClient loops abandon Netmiko prompt handling entirely and add fragile sleeps and parsing, violating the task to use Netmiko. Exam caveat: match device_type to the actual platform and use send_config_set only for config. Practical check: test on one lab switch and confirm show output plus running-config diff.