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 theScrapli
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!