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.

2 thoughts on “Python for Network Engineers

  1. Hi Gaurav,

    Are you going to start your Python journey with learning all these commands? Could you please share your plan to learn Python here, so that I can sync it with mine too.


  2. Partially yes. I am not exactly learning the commands. Actually, I am just learning a mindset of writing a Production level code for Network Automation. To do that, these modules are important. Hence, I will be going through these one by one. At the end, in one program i will use all of these modules to connect all dots. If you would like to get anything added from your experience. Please feel free to share. I will go through it and amend it to my post. But, use case focus must be with the Network Automation.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.