In this lesson, we will cover:

  • What is Scrapli Cfg?
  • Scrapli Cfg connections.
  • Scrapli Cfg getters.
  • Scrapli Cfg config operations (load, replace, merge, abort).
  • Scrapli Cfg diff.

What is Scrapli Cfg?

Scrapli Cfg is a Scrapli extension that provides a set of common (vendor-agnostic) methods for merging, replacing and diff`ing device configuration via Telnet or SSH. It abstracts and removes much of the heavy lifting and complexities required when performing config operations in a multi-vendor environment.

Installation

To install Scrapli Cfg, simply run the following:

$ pip3 install scrapli-cfg

Note: You may find that this is already installed if you completed the Scrapli AsyncIO lesson.

Scrapli Cfg Connections

Before we can perform any configuration operations on our devices with Scrapli Cfg we must first create a `ScrapliCfg` connection by:
  • Performing the required imports.
  • Instantiating ScrapliCfg using the Scrapli connection object.
  • Preparing the connection via prepare.

For example:

from scrapli_cfg import ScrapliCfg

with Scrapli(**device) as conn:
    # Instantiate Scrapli Cfg
    cfg_conn = ScrapliCfg(conn=conn)

    # Prepare Scrapli connection, call prepare_on() etc
    cfg_conn.prepare()

Note: The on_prepare method (which is called during prepare) allows you to perform additional actions on the device before performing your configuration operations.

If we now perform this against one of our lab devices, we can see the available properties and methods available to us, which we will be exploring in the upcoming sections!

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.