Network Automation with Python – The Language

Getting started with Network Automation is arguably the most difficult part of the process, what tools should I use, what processes should I automate, what resources can I tap into. These are all very good questions and in this article I aim to make them a little easier for you to solve.


The Language

This can be a source of debate on what technologies to use to take automate parts of your network. Based on the information I have been exposed to Python is the leading language across platforms that is being used by network administrators. This is great because not only is there a huge community with a wealth of knowledge Stack Overflow at the time of writing this article has 1,533,616 questions on Python alone at the time of writing this article, but Python is a language that is extremely easy for beginners to catch onto. If you have written a Powershell or Bash script in the past and felt comfortable you will have no problem catching on I have personally taught several network admins in this boat before and they had no issues. If you come from a developer background I think it goes without saying it will be very easy to catch onto Python.

The last reason I will advocate for Python is because of the ecosystem there will most likely be a package already written out there that will allow you to interface with almost any API or CLI scrape almost any network device, and if there isn’t already a package out there Python gives you the tools to write your own wrapper for an API or some CLI scraping.


While there are other proprietary tools out there like Solarwinds scripting engine, or other programming languages I will not be going into them much because in my research I can not find anything that comes close to Python in terms of user experience, flexibility, and power. However I do encourage you to take the time and research the options available to you and your company, just because using Python as my primary automation tool has been very helpful does not mean that it will always be the right choice for you in your situation. With that in mind lets take a quick look at some of the things you should consider when deciding on your main automation language.


Choosing A Language

What this comes down to is what language are we going to chose, If you go with Solarwinds scripting engine you will be using a language that is proprietary to Solarwinds if you go with a major programming language like Java, Python, C, etc. so its something to consider. In my experience the most important features you need in whatever language you chose are the following.

  1. Ability to integrate with external systems
  2. Small learning curve
  3. Ability to quickly develop scripts
  4. Community Adoption

I would say number 1 by far is the ability to integrate with external systems, while I have the luxury of working at a business that has 100% of our routing and switching infrastructure from a single vendor, I still have to integrate my scripts with other systems like our ticketing system, our monitoring system, or existing excel spreadsheets and you need a language that will be able to facilitate this. This right hear for me eliminates any company proprietary “system” like Solarwinds scripting engine because they simply are not able to integrate with a wide variety of external systems.

A side note about the ability to integrate with external systems is the ability to stand alone without the need for external systems, whatever language you use to automate your network the programs and scripts you write should be able to outlast with minor changes if you replace your network monitoring tool, ticketing system, etc. This will allow the core business logic you build inside your automation programs to stay relatively unchanged.


The second most important factor for choosing the language to automate with is to have the smallest learning curve possible. The main reason for this is because most network administrators are not always rock star programmers nor should they need to be. It is important that members of the team are able to fairly quickly be able to write automation scripts that actually help them save time in the tasks they are trying to complete, which is exactly why we are trying to automate things in the first place.


The third most important factor in my opinion is slightly related to the second, which is to be able to quickly develop scripts. A network admin should not need to spend 2 days setting up an environment, installing dependencies, and troubleshooting the environment, this whole task should be very close to a non event and in my opinion should not take more than a half hour.


Points 2 and 3 together pretty much rule out the majority of other languages, for instance C and Java, while you can use them to do almost anything, it is not easy to get up and running and typically takes a long time to build a script or program especially if you are not familiar with programming because you have to go through the compilation process etc.


Lastly community adoption is another major factor in my opinion. This is specifically because if other network administrators are out there writing automation scripts in the same language as you, more often than not the problem you are trying to solve has already been solved by someone else, or a very similar problem has already been solved. This will allow you to integrate someone else’s script into your network without having to start completely from scratch.


When taking all of these points into account I easily decided upon Python to be the language I write automation programs in. It has afforded me the flexibility to make quick 1 line scripts, all the way up to fully fledged web apps that integrate various other systems on our network. While I know it is not always the right choice for everyone, I highly recommend looking into it for your situation.

Be the first to comment

Leave a Reply

Your email address will not be published.