Python Network Automation

23 Comments



This is some of what I have been learning with Python and guess what??? YOU CAN DO IT TOO!!!

You can see all of the files that were used here on my #github page – https://github.com/ospfpacket/python_ospf_lab

Get your lab up and running by checking out my video on Eve-NG on VMWare Workstation https://www.youtube.com/watch?v=prqnFjJ5stg&t=433s

source

23 Comments
    • blank
      Daniel Barron
      Jun 01, 2022 18:09 pm Reply

      Great content and encouragement!

    • blank
      Carlos Nyambo
      Jun 01, 2022 18:09 pm Reply

      hie please how can l contact l need assistance on my python project

    • blank
      KomradWide
      Jun 01, 2022 18:09 pm Reply

      What level of knowledge in programming do you exactly need to be able to do network automation? Basic? Intermediate? Expert level?

    • blank
      ZimCanIT
      Jun 01, 2022 18:09 pm Reply

      Great video! What is the function of _pycache_ ?

    • blank
      Alex Popa
      Jun 01, 2022 18:09 pm Reply

      Good stuff man. You should look into Threads and execute all configs concurently.

    • blank
      Network Automator
      Jun 01, 2022 18:09 pm Reply

      Thanks for this encouragement!

      I would like to think I’m fairly new to networking but then again…been in IT game for years lol.

      I am fortunate enough to be running several catalysts L3 switches with 15.9 IOS. I am designing L3 spine/leaf architecture as my lab with 5 leafs and 2 spine fortunate enough to have 10gig etherchannel uplinks between spine and leafs. One of the most repetitive thing was on-boarding out of the box each spine and leaf. Luckily. I was able to use python serial module to automate the entire on boarding process (setting up ssh, management vlan those two where the main ones).

      Then came the next actually on-boarding the spine or leaf into the fabric!

      I managed to use netMiko module but my code was so inefficient! Similar issue you had where you was ssh into each devices separately, send separate config for each router etc.

      I never used the zip function but you encouraged me to use serialisation YAML, so that I was able to feed the YML config into my Python code for loop. Learning YAML was the deal breaker! I created a single YAML file with all the devices (the entities and atttributes)(key:Value). Once I learned how to use nested for loops it was game time. All I needed to change was YML file e.g OSPF advertised networks and all else such as ECMP for each leaf etc. was the same! All leafs are trunking VLANs from ESXi host(that portion of the fabric is L2)

      Here’s my surprise the actual python code was like 10 lines. LoL it was just looping for each device and getting the config from YAML. You could use Json or even xml! I don’ t need to change the python code just the YAML config!

      My point is for efficiency you need to learn how to dump and load config a from a serialisation language(json, yml or xml)

      I will post all codes on GitHub, I’m considering writing a module specifically for python Cisco console serial automation for cli/iOS.

      iOS-xe has a awesome zero-touch on boarding functionality!

      Please may I remind everyone I am just a help desk guy. Studying for CCNA. Learned all this in about 3-5months

    • blank
      Jamil Haussmann
      Jun 01, 2022 18:09 pm Reply

      Great job man

    • blank
      Matthew Smith
      Jun 01, 2022 18:09 pm Reply

      Awesome and stay humble

    • blank
      e0b1ff
      Jun 01, 2022 18:09 pm Reply

      Great work!

    • blank
      Mr Fister
      Jun 01, 2022 18:09 pm Reply

      I may be missing something, as I'm quite the noob when it comes to networking, but if you have to configure ip addresses etc at the device, why not just copy and paste the full config?

    • blank
      J Rockford
      Jun 01, 2022 18:09 pm Reply

      Load GENIE AND NAPALM

    • blank
      George Smith
      Jun 01, 2022 18:09 pm Reply

      Hello friend. You should look into threads and thread pool. This way instead of configuring each router serially, you can configure them all together. I always use threads because I have to configure 600-700 routers.

    • blank
      gussta1
      Jun 01, 2022 18:09 pm Reply

      Great vid….thanks for sharing. What python resources did you use?

    • blank
      Subham Singh ray
      Jun 01, 2022 18:09 pm Reply

      Hii I just want to automate my login into server that I have automated with the help of python pexpect module….
      But I want if I am login into my server and for long time I am not doing anything on my server then it should automatically logout from the server…
      How this automatically logout from the server,if for long time I am not doing any work on server could be coded in python???

    • blank
      Angel A
      Jun 01, 2022 18:09 pm Reply

      hell yea brotha, keep it up

    • blank
      head inthekloudz
      Jun 01, 2022 18:09 pm Reply

      How long did it take you to learn python? And do you pay for vmware?

    • blank
      head inthekloudz
      Jun 01, 2022 18:09 pm Reply

      Nashty

    • blank
      Hobbyist Shooter
      Jun 01, 2022 18:09 pm Reply

      Great work! You might want to checkout Nornir, a great framework to push configuration to your network devices much faster.

    • blank
      Guy H
      Jun 01, 2022 18:09 pm Reply

      Thanks heaps sir!

    • blank
      William Humphrey
      Jun 01, 2022 18:09 pm Reply

      Keep up the good work !

    • blank
      Brent Harrison
      Jun 01, 2022 18:09 pm Reply

      Zip function saved the day!!

    • blank
      Steven
      Jun 01, 2022 18:09 pm Reply

      Nice Video!

    • blank
      William Humphrey
      Jun 01, 2022 18:09 pm Reply

      Great job !

Leave us a comment