4 VSCode Extensions Network Engineers Can’t Live Without
It is fair to say that professionals are only as good as their tools. Even the best sculptor will produce sub-part statues with a blunt chisel. The same logic can be applied to Python network engineers. You may know exactly how to configure routers, open firewall ports, and analyze MAC addresses. But it's kind of hard to do that using nothing but VSCode and your own memory.
VSCode in and of itself is great. It's free, easy to use, and best of all it provides hundreds of VSCode extensions to increase productivity. In this post, we will discuss four networking engineering-focused VSCode extensions that will greatly enhance your Python experience.
A large portion of this post will describe Remote SSH and how to configure it. However, the next three VSCode Extensions will not be nearly as time-consuming to verify. First however, let's walk through how to add a VSCode Extensions to your integrated development environment (IDE).
How to Add VSCode Extensions
To Add VSCode Extensions, open up VSCode and click "file" in the top left corner. Then, open up "preferences" toward the bottom. This will enable a new pane on the right. Click on "extensions". It will look like the image below:
After that, click on "Extensions" and a search bar will appear in the top left. Below it will be a list of extensions. Use the search bar to find any and all VSCode Extensions.
With that being said, let's start with arguably the most useful of the four extensions: Remote SSH Extension.
Remote SSH Extension
Remote SSH (Secure Shell) is an incredibly powerful extension for Windows users. One caveat before we begin: it is assumed you have VS Code and you have some Linux-based virtual machine or server. If that is not currently available, do not fret. Follow this video and you'll be set.
Why is SSH Extension Needed?
The basic gist is that it allows a Linux environment to be used under the hood of your Windows OS. It is generally agreed upon that it is not optimal to perform network engineering tasks on a Windows machine. The brunt of engineering duties ought to be accomplished on a Linux-type OS such as Ubuntu or Red Hat.
The sad reality is that most of us are on Windows. So how do we use Windows OS for our day-to-day operations while still taking full advantage of what Linux has to offer? That is where Remote SSH comes into play. Here is what it looks like when you have successfully found it from the list of VSCode Extensions:
As the description says, Remote SSH allows a user to open any folder on a remote machine using SSH and take advantage of VS Code's full feature set. Let's walk through how to set it up.
How to Set Up a Virtual Machine for Remote SSH
First, log into the virtual machine (VM) or server. Ensure it is running as an SSH server. In order to do that, open a terminal and type sudo apt openssh-server. It will look something like the image below:
There will be a point where you will be prompted. Type Y and hit enter. This will complete the process, and now SSH is enabled on the VM.
Next, obtain the IP address of the VM and write it down somewhere. The IP can be found by typing ip addr into the console. Now you have everything you need from the VM.
How to Set Up SSH in VSCode
Open up VSCode and click on "Remote Explorer" on the left-hand side of VSCode. Click on the drop-down in the top left labeled remote explorer and click SSH Targets. Next, click the "plus sign" (+) near the top of the pane. So far, your screen should look something like this:
As shown above, enter your Linux login name and IP address in the following format: ssh <username>@<IP Address>. Hit enter and VSCode will prompt you to choose a configuration file. Choose the first one available. Now the IP address of your VM should be on the left pane. Right click it, then click "connect" and you're all set up.
Remote SSH is Set Up… Now What?
Now it is time to see the fruits of your labor. Open a terminal in the bottom pane of VSCode and it should be a terminal on your VM. So for instance, if you create a directory in VSCode, that directory will appear on the Ubuntu server. Not only can you create directories, but software can be run, installed, and executed all from your Windows OS directly onto the Ubuntu server. If the power of this concept is not registering yet, it will once you use it more and more in practice.
Cisco IOS Syntax
Cisco IOS Syntax is exactly what a network engineer needs to parse and understand complex networking files. Oftentimes when a network engineer needs to configure a list of routers, they will do so in an IOS image file. These files contain the system code that your router uses to execute operations. In other words, it is the "image" of the router.
The point of Cisco IOS Syntax is to color code the syntax of your Cisco code. While this may not seem very important at first, it makes a world of difference when editing complex Cisco files. For example:
In the same vein as Cisco IOS syntax, Better Jinja highlights the syntax so the user can discern different keywords easier. Jinja is a web template engine for the Python programming language. By the way, it is completely understandable if you have no idea what that means or what "Jinja" even is. You will become very familiar with it later as you become a professional network automator. However Better Jinja will provide an excellent foundation to make the process far easier to understand.
One thing that is nice about Better Jinja is it also provides syntax highlighting for other programming languages and frameworks, such as Python, Ruby, HTML, and more. The last of the VSCode Extensions to discuss is arguably one of the most important: Python Code Extension. So let's dive in!
In the world of network engineering, Python is pretty much king. Yes, you could technically execute networking operations in Java, C#, or Ruby. However, Python has become dominant through its easy-to-read syntax and plethora of networking libraries and APIs. However, with all of those different libraries, APIs, and keywords, it is virtually impossible to memorize all the jargon required to run a network. This is where Python Extension comes into play.
The Python Extension provides Intellisense, Linting, Jupyter Notebooks, and more to the network engineer. Let's briefly go over each of these features.
Software developers and engineers need to memorize hundreds of keywords. With Intellisense, that's made easier because the IDE "guesses" what you are trying to type by providing a dropdown of available keywords.
Linting means that the Python Extension will analyze your code and catch bad practices. For example, it will let you know if there are unused imports in the file, overcomplicated flow control statements, and numerous other benefits.
A Jupyter Notebook is a separate server that runs and allows you to execute containerized code snippets. This is great for testing small pieces of code or going through tutorials. An entire article could be written about Jupyter Notebooks, so rest assured that this is a very useful item.
Lastly, the Python Extension provides excellent testing modules. With the Python Extension, you can debug your Python scripts, web apps, and other multi-threaded processes.
In this post, we discussed four different VSCode Extensions. First, we went in-depth on Remote SSH, and why it is a critical tool in any network engineer's toolbox. Remote SSH allows you to utilize all the best parts of a Linux Operating system while still leveraging an existing Windows machine.
Next, we walked through the benefits of IOS syntax highlighting. Creating router images is a critical aspect of network engineering, and syntax highlighting will greatly improve productivity. After that, we discussed Better Jinja. Better Jinja provides syntax highlighting and Intellisense to the Jinja Python framework.
Last, but certainly not least, we talked about Python Extension. This is simply a must-have for anyone planning to write Python Code. It provides Intellisense, debugging, linting, and more.
Remember, an engineer is only as good as their tools, so hopefully, these four VSCode Extensions will serve as starting points for bigger and better things to come.
delivered to your inbox.