In this lesson, we will cover:

  • What is Scrapli Netconf?
  • What is NETCONF?
  • How to create a NETCONF session.
  • How to obtain NETCONF capabilities.
  • How to use Scrapli Netconf to get the running config.
  • How to use Scrapli Netconf to configure an interface.

What is Scrapli Netconf?

Scrapli Netconf is a Scrapli extension that gives you the ability to communicate with devices via NETCONF. By using Scrapli Netconf instead of traditionally used tools such as ncclient, you get the same benefits seen throughout Scrapli, such as:

  • Customizable transport types such as system, SSH2, paramiko and asyncssh.
  • Sync and async support.
  • A single set of common interfaces/APIs whether you are working with devices over Telnet, SSH or Netconf.

What is NETCONF?

For those of you new to NETCONF, it is a:

protocol defined by the IETF to install, manipulate, and delete the configuration of network devices. NETCONF operations are performed via a Remote Procedure Call (RPC) layer using eXtensible Markup Language (XML) based encoding.

NETCONF is typically used alongside YANG. Whereas NETCONF is the protocol that applies the changes to the relevant datastore (i.e running, saved etc) upon the device, YANG is the modelling language that describes the network configuration.

Installing Scrapli Netconf

To install Scrapli Netconf run the following:

$ pip3 install scrapli-netconf

Creating a Session

The first step in using Scrapli Netconf is to create a session. We need to import the NetconfDriver and then call open() from our instance of NetconfDriver.

from scrapli_netconf.driver import NetconfDriver
# Create device dict()
device = {
    "host": "nebula.packetflow.co.uk",
    "auth_username": os.getenv("LAB_USERNAME"),
    "auth_password": os.getenv("LAB_PASSWORD"),
    "auth_strict_key": False,
    "port": 9837,
}

# Instantiate Scrapli Netconf driver with device dict()
conn = NetconfDriver(**device)
 
# Open connection
conn.open()

At this point we will have an open NETCONF connection to the device. To close the session, we would perform the following:

# Close connection
conn.close()
Members Only Content
Join today and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 Multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Monthly online meetups

100% Satisfaction Guaranteed!
Cancel your membership at any time.


Join Today
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.