Scrapli is a widely used library in Python for network related work. In this post let's see how it can be used to do very simple taks. Following link gives more information on Scrapli as it is the official site.
Output:-
When this code is run, configured commands will be shown as the output as per the last line also.
https://carlmontanari.github.io/scrapli/
First of all installing Scrapli..
python3 -m pip install scrapli
I had to change the ssh_config file of Ubuntu to match the older Ciphers like the following and auth_secondary which is the enable password needed to be configured in order to access the devices in EVE-NG.
Following white colored text were the text I needed to add.
This can be using one of the following solutions.
1. Text fsm
2. Genie
I will perform the following example by Textfsm. For that we need to install Textfsm templates to Scrapli library.
use following command in cli;
python3 -m pip install scrapli[textfsm]
Following code will get the "show version" output to the "JSON" structured format.
Output:-
Configuring Devices with Scrapli
Following example will configure ospf process and ospf router id using Scrapli.
Note that the commands are sent as a list and will be configured as line by line and no need to send "configure terminal" command as it will be taken care by the library.