A team scripts NETCONF reads across 200 IOS XE routers, must leave every device's state untouched, and needs only the running configuration for the interfaces subtree kept small enough to log. The library already opens SSH to port 830 and returns an ncclient Manager. Which ncclient call retrieves exactly that subtree from the running datastore?
Select an answer to reveal the explanation.
Short Explanation
You ask for exactly what you need with get_config, which wraps the NETCONF get-config RPC and lets a subtree filter trim the reply on the router. It's like ordering a side dish instead of the whole menu — same kitchen, smaller plate. The source argument decides which datastore answers.
Full Explanation
ncclient maps each NETCONF operation to a Python method, and get_config wraps the get-config RPC, so it requests configuration data and stages no change. Passing source='running' names the datastore you actually need, while the subtree filter tuple puts an XML snippet into a NETCONF subtree filter and lets the router trim the reply, so you receive just the container you asked for. The generic get method issues the get RPC, which can return operational state as well as running configuration, so it does not guarantee a configuration-only reply. Asking for the whole datastore and dropping nodes in Python works, but it pushes the entire configuration across the wire on every router, defeating the goal of a small log. The candidate datastore may differ from running if edits are pending, so it is not a reliable substitute for reading live configuration. Caveat: filter behaviour and returned shapes differ between native and OpenConfig models on IOS XE, and the XML filter may need the appropriate namespace for the model. Practical check: print reply.data after the first call and confirm only the interfaces container came back before you loop.