Scrapli and Flask – Part 3: Scrapli Integrated into Flask

This is where we start to integrate Scrapli with Flask.

Here I have created a very quick website that is mostly reused from my F5 Dashboard project. This is a very simple web app with the single purpose of adding data to a database and then displaying that to a user.

How it Works

The user first goes to the website. They navigate to the Device Info page.
Here they are presented with a form that is asking for an IP address of a device. This IP is the management IP of the device.
The user enters the device IP and clicks submit, this is then when we begin the Scrapli process.

The full web app is available to view in my GitHub.
I will be adding different versions as I go. This current version is just to test that everything mostly works, this is not found on GitHub. Part 4 will be more complete and will be version 1.

The Scrapli script will;

  • Take that IP address
  • SSH into the device
  • Perform a “show version”
  • Return the output and parse with Genie
  • Pick out the; hostname, software version, model, OS type, chassis serial and the uptime
  • These variables are then added to an SQLite database
  • The page is then redirected to an inventory page (which is not a clickable link from the website) where they can see the full table.
    • This table is using jQuery to make it neater.
    • It’s done on the client side, so has some down sides. Such as; if the table is large it is noticeable to the user that a default HTML table loads, and is then corrected into the format you see in the screenshot, split up and all neat.
    • The way the table loads and looks at this current testing stage are not my concern.

Scrapli

Leave a Comment

Your email address will not be published. Required fields are marked *