Archives For BuildVRFIndex

Yesterday I discovered an error in my DownloadRouterConfig application where it would terminate abnormally if a variable (a path name) in the settings.cfg file was left blank.  Should no path name be specified, the application should have used it’s current working directory.  Instead, it just crashed.

In fixing the code, I realized that all my other applications used this same function — so I corrected all of them as well.  (I also took care of a few other miscellaneous things while I was in there.  See the CHANGELOG, if interested.)  If you happen to be using any of these applications to help manage your own Cisco routers, you’ll want to pull the latest code down to prevent any possible errors in the future.

BuildVRFIndex v0.0.9-alpha (2014-03-17) v2.2.3 (2014-03-17) v1.2.0 (2014-03-17)
VRFBackupTool v0.0.9-alpha (2014-03-17)
VRFSearchAndBackup v1.0.1 (2014-03-17)
VRFSearchTool v0.0.18-beta (2014-03-17)

The primary reason I decided to revive my rusty programming skills was to automate tedious or time-consuming functions at work.  I’m a big proponent of automation whenever possible and in an age of employment where we’re all asked to do more with less, I’ll gladly invest the time required to “automate all the things”.

However, automation is only useful if embraced by everyone that can benefit from it.  Despite frequent lip service from colleagues who expressed excitement over the creation of a few of my applications, I had reservations about who may actually be using what within the team.

So I decided to have a look…

Several weeks ago I placed a small bit of code in all of my applications to capture their usage data:

import getpass # Required to read username from the command line
def trackUsage():
# This function appends a line to a file with the timestamp, user name
# and name of the application so I can see who is using what
with open("X:\path\to\file.log", "a") as appUsage:
appUsage.write(str(","+getpass.getuser()+","+__title__+" "+__version__+"\n")
except IOError:

Of course, it could be that some of my teammates are using antiquated versions of some of my applications despite corrected bugs or limited functionality — and there certainly isn’t any way for me to determine that.  Given the frequency in which I have communicated that each person obtain the newest version AND the results I’ve outlined above — I must conclude that either my enthusiasm for improving our work flow and time management isn’t shared among my team or I hold my applications in higher regard than they’re actually worth.

My VRF Search Tool is proving to be quite useful on the job and I was looking for a way to automate some of the functionality of the tool so that it can be extended for use in other applications.  As it stands now, the index of VRF Names is only updated once a day by the first person to run the tool each day.  Since the tool is being used in a 24/7 environment, engineers working late may be working with old information.

Therefore, I’ve sought to automate the buildIndex() function of the VRF Search Tool and created  Just like the VRF Search Tool, BuildVRFIndex builds a CSV file of the VRF Name, Remote Peer IP and Local Peer IP of each VPN tunnel — but it lacks the functionality to search the index.

Unlike my other Python applications, this is the first time I’ve ventured into the use of a configuration file.  The configuration file will allow the user to pre-set the path and name of the files the application needs to run.  You can also set the username and password that will be used to log in to each of the routers.  NOTE: The password must be base64-encoded.  You can use a website like to translate your password into a base64-encoded string.

Continue Reading…