Python for Network Engineers

Recently, the Python Language has become one of the most popular Programming Language. Today almost all network engineers irrespective of their technologies will be required to learn Python or some other form of automation skills using programming language. Recently I got a use-case on network automation & delivering that manually was a nightmare and almost impossible. Therefore, I started leaning Python. Hence in our next few blogs – we shall be decoding the individual beans which are must required for a Network Automation.

This is exactly the same methodology which i followed :-

At the first place – we will start this with leaning different modules in Python. You may ask – why so many? (or probably so less for python experts :P?)
Answer is “Simple” – There are tons of articles available on Learning Python. Hence, we will not cover any of the topics such as Data types, looping in Python. Our methodology will be different like “delivering python code as per the usecase”. This objective is simple & “get practical”. I won’t talk about programming in abstract terms and make us wait before one can start automating networks. I will demonstrate how we can quickly and easily start network programming by using GNS3, Cisco IOS and Python. Because a network engineer would spend 90% of their Python time to work in one of these mentioned module. Hence, It would a good idea to understand each one of them at once.

  1. Python module – “getpass”
  2. Python module – “argparse:
  3. Python module – “netmiko”
  4. Python module – “telnetlib”
  5. Python module – “ipaddress”
  6. Python module – “paramiko”
  7. Python module – “jinja”
  8. Python module – “os”
  9. Python module – “sys”
  10. Python module – “ConfigParser”
  11. Python module – “logging”
  12. Python module – “queue”
  13. Python module – “threading”
  14. Python module – “collection”
  15. Python module – “re”

Once, we got a sufficient understanding of above module’s our 50% of the Job is already completed.

The next step would be connecting the dots. To accomplish this we will demonstrate a real world use-case – with a production level Python code & we will see how each module fits and connect with other’s.

Trust me, In one python code – we will be using all of these module and get things going to deliver our defined objectives.

Disclaimer: – I am not an expert in Python. I have been spending some good time to understand it primarily focused on Network Automation use-cases. This arcticle was written by me (Gaurav Agrawal) in my personal capacity. The opinions expressed in this article are solely my own and do not reflect the view of my employer or my preference towards any of the OEMs.