DevNet Associate (DEVASC) v1.0Infrastructure and AutomationMedium
A network automation engineer is developing a Python script to interact with a Cisco device using NETCONF. After establishing an SSH connection, the script needs to send an RPC request to retrieve the device's running configuration. Which Python library is commonly used for NETCONF client operations, simplifying the XML handling and session management?
- Arequests
- Bparamiko
- Cncclient
- Dnetmiko
Show answer & explanationAnswer & explanation
Correct answer: C. ncclient
ncclient is a popular Python library specifically designed for NETCONF client operations. It abstracts away the complexities of XML parsing, session establishment, and RPC handling, allowing developers to interact with NETCONF-enabled devices more easily. requests is for HTTP, paramiko for general SSH, and netmiko for CLI automation.
Why the other options are wrong
- A. requests is for making HTTP requests, not NETCONF.
- B. paramiko is a general-purpose SSH client library, but lacks NETCONF-specific XML parsing and RPC handling.
- D. netmiko is primarily for screen-scraping CLI output over SSH, not for structured NETCONF interactions.
ncclient
ncclient is an open-source Python library that implements a client for the NETCONF protocol, simplifying programmatic interaction with NETCONF-enabled network devices.
- Python library for NETCONF client.
- Handles XML parsing and serialization.
- Manages NETCONF sessions (SSH).
- Provides methods for RPC operations (get, get-config, edit-config).
Memory trick: ncclient connects Python to NETCONF's XML.