In a Python script utilizing PyEZ, what method must be called on the Device instance after all configuration and operational tasks are complete to properly terminate the NETCONF session?
Calling dev.close() tears down the NETCONF session and releases the underlying SSH transport, satisfying the requirement to terminate cleanly after all configuration and operational tasks finish. Without it, the persistent session lingers, exhausting device resources and blocking other management connections.
Why this answer
In PyEZ, the Device object maintains an active NETCONF session over SSH (port 830) that must be explicitly torn down. The dev.close() method cleanly closes the NETCONF session, releases the underlying SSH transport, and frees associated resources. Without calling close(), the session may linger until timeout, consuming VTY/session slots on the Junos device.
Exam trap
JNCIA-DevOps often tests whether candidates confuse PyEZ's close() with generic connection-termination method names like disconnect(), terminate(), or end_session() — only close() is the actual PyEZ API.
How to eliminate wrong answers
Option B is wrong because dev.terminate() is not a valid PyEZ Device method — there is no such API for ending sessions. Option C is wrong because dev.end_session() does not exist in the PyEZ Device class; NETCONF session teardown is not exposed under that name. Option D is wrong because dev.disconnect() is not a PyEZ method — while 'disconnect' sounds plausible, PyEZ uses close() to release the NETCONF/SSH connection.