An engineer is automating an NTP change across 40 IOS XE switches with Netmiko. The connection opens and the prompt is detected, but send_command('ntp server 10.10.10.1') returns an IOS error and the running config never gains the NTP line. Which Netmiko method should the script use to apply this change?
Select an answer to reveal the explanation.
Short Explanation
You’re sending the line at the privileged exec prompt, where configuration commands are rejected. send_config_set() enters global configuration mode, applies the line, and returns you to the prompt, so the NTP setting reaches the running configuration. Think of it as moving from reading a form to filling it in.
Full Explanation
Netmiko tracks the prompt in an interactive session, and the method you call determines the mode in which it sends your text. send_command() sends text at the privileged exec prompt and waits for the next prompt; that works for show commands, but exec mode has no configuration context, so the switch rejects the NTP line and the running configuration stays unchanged. send_config_set() enters global configuration mode, sends the configuration line, and returns to exec, allowing the setting to reach the running configuration. A higher delay_factor on send_command() only makes Netmiko wait longer for output; it does not change the prompt or enter configuration mode. Passing expect_string='#' to send_command() changes when the method stops reading output, not where it sends the line, so the command is still issued at the exec prompt. send_command_timing() also sends at that same prompt; timing-based interaction does not automatically enter configuration mode, so the line remains invalid there. Exam caveat: prompt detection and configuration mode are separate concerns; recognizing a prompt does not mean the session is ready for configuration commands. Practical check: test against a lab switch and verify that the prompt enters configuration mode before the NTP line is sent.