Select Page

Python For Network Engineer 3

by | 9-Jan-2021 | DevOps, Programming

Python For Network Engineers 3

(1) Backup switch configurations

Ubuntu-1

  • Create and modify “getconfigs.py” script (Figure 1)
    • Add comments
    • Use “strip()” to removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove)
    • Use “read_all” to get all the written output
    • Use “w” to enable read write
      • > open(“switch” + HOST, “w”)
      • > “write” and “close”
  • Run the script (Figure 2)
    • Use “ls” to see the just now created files
  • Read the running config files (Figure 3)
    • Use “less” for easy navigation

(2) Jupyter Python Clients (3.0 and 2.7)

Lab Overview

  • Jupyter: an open-source web application that allows you to create and shares codes, and etc.
    • Jupyter 2.7 (Figure 1)
    • Jupyter 3.0 (Figure 2)
  • Network Topology (Figure 3)
    • Initialize the Router and Jupyter clients (IP addressing, and Router telnet access)

 

Jupyter Client

  • Create new notebook name “Telnet1” (Figure 4)
    • Paste the python script
    • Run the script in the section “In [1]”
    • It will print the result (Figure 5)
  • Navigate in Jupyter
    • New notebook (Figure 6)
    • Open saved notebook (Figure 7)
    • Saved noteboks (Figure 8)

0 Comments

Submit a Comment

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