Sunday, November 6, 2016

Auditing Cisco Switches with python, paramiko and SSH part 1

Auditing Cisco Switches with python, paramiko and SSH

When your datacenters and HCI offerings are top cakes in
the market it can’t just happen by doing it right but also by making sure you
have done it right. In VCE (now EMC DELL HCI) we have at the least 9+ quality
checks before the client gets it and more onsite once we do the plug and play
of the datacenter. Powershell is and was a great thing to achieve some of these
but powershell doesn’t have native ssh support and you might get away with
plink or other custom ssh modules but then again it is not as snappy and as
convenient as python with paramiko module. Python is great at configuring
stuff, validating, auditing and for many other things due to its compatibility.
Powershell is now stepping into linux but python is still a bit way ahead of
powershell when it comes to practicality and usability. I find powershell to be
easy to use due to it’s very small learning curve and how easy it is to read or
write code but python nonetheless is the top dog for now so you go with what
works the most, most of the times and at most of the places.

Thanks to stackoverflow, the custom function
get_script_dir is going to act as an equivalent of $psscriptroot in powershell.
If you run the whole thing with #print filepath uncommented
then you will know that it will print out the exact path to the root directory
from which you are running the script from. Now let us append the filename to
this path to get the full path to the filename and the filename itself so that
it would be easy for us to create a file to which we are going to append the
outputs of the cisco switch.

About Me

A passionate IT Professional with an endless fetish for innovative Science & Technology.I am a lot of things and a few among them areAn avid gamer,loves photography(not anymore),love a lot of variety of music, movies (foreign),like a lot of manga, anime series and most importantly love life.