networkautomation |


Network Automation Example - Finditer With Defaultdict

Submitted by zeroslash on Sat, 04/27/2019 - 01:40

In this example, I explored another approach to using Finditer to count network interfaces in my last post. I recommend you check that out first before going through this one.

Here I combined re.finditer() with defaultdict() instead, keeping the matched patterns associated with the keyword we are looking for.

Network Automation Example - Finditer With Counter

Submitted by zeroslash on Thu, 12/27/2018 - 11:10

Still using the same example data that I've been using in my previous Network Automation examples, this time around I try out a counting scenario.

In this example, I wanted a quick and easy way to just zip through the text and count how many interfaces of a certain type I will find.

I'm using the re.finditer() function to give me an iterable of all matches (line 16).

Copying Files Through SCP With Junos PyEZ

Submitted by zeroslash on Wed, 08/29/2018 - 15:52

Copying a file is one of the simplest tasks you can do with Junos PyEZ or with Junos in general. You typically do this for example when you are copying the text file for request support information before you submit it to support. Having said that, let's get right into an example of this using Junos PyEZ.

Network Automation Example - Generators With Filtering

Submitted by zeroslash on Tue, 05/15/2018 - 12:58

Following on from my last post, I made a variation of it. In this instance I wanted to filter the interfaces based on a certain amount of errors.

One thing I changed is I switched it up with a generator function instead (lines 11-14) and used that to provide the iterable sequence in the generator comprehension following that. The generator comprehension (lines 16-18) is where the filtering happens.

Network Automation Example - Namedtuple

Submitted by zeroslash on Wed, 05/09/2018 - 01:08

Let's say we just grabbed the list of interfaces from a router along with its error count. As you can see here I used namedtuples with a list comprehension (lines 13-14). Then I moved on to sort the data by error field and then provide some order with the name field as well, for errors with the same value (line 15). The output looks good. This type of approach seems enough for now but may change or improve given new scenarios to cover in the future. 

Testing SSH Key-based Authentication for Network Automation

Submitted by zeroslash on Fri, 03/23/2018 - 10:05

In my last post How To Configure SSH Key-based Authentication on Linux, I gave a walkthrough on how to set up SSH keys with an SSH agent so you get the benefits of passwordless logins while still maintaining the increased security that key-based authentication is supposed to provide. The reason why I reiterate this is because using SSH keys without passphrases pretty much defeats the purpose of using keys at all.

The Easiest Way to Build a Network Automation Lab

Submitted by zeroslash on Mon, 02/26/2018 - 13:59

For some time I have been trying different things on how to build a good Network Automation Lab. You would think that this can be as trivial as just your typical GNS3 lab hooked up with some VMs where you can launch your scripts, but in my mind, I wanted something very simple and straightforward, pretty much painless approach to building one. I had a good idea of how this kind of lab should be. Below are the points which guided me in my search for the right kind of setup.

My Network Automation Journey

Submitted by zeroslash on Sat, 01/06/2018 - 16:01

Before I get into my story I just want to give an overview of what Network Automation is as I understand not everybody who might read this will be familiar with it. If you are new to networking or has plans to jump on board, this is probably the most important thing that you need to know. The whole networking industry has been undergoing a shift for the last couple of years now.