Over the the next several weeks I will be posting a new series of articles focused around the Python programming language. The simple goal of the series will be to enable you to take advantage of Python to make your life easier in some form or another.
I am by no stretch of the imagination a ‘developer’ but I am a firm believer in automating anything that you have to do more than twice. This is where Python shines. It’s simple syntax and active community allows anyone to easily and quickly create any manor of scripts and utilities for their tool chest. There are also a plethora of SDKs, APIs, and DevOps tools written in Python that can be taken advantage of once the basics of Python are understood.
In my experience the easiest way to learn a new programming language is by actually coding something relevant. For the purpose of this series we will be taking a request from the VMware vExpert community.
Somebody write a tool that checks all the vsphere ports, shows which ones are blocked and whats dead. Firewalls are driving me nuts #vexpert
— Chris Nickl (@ck_nic) April 8, 2015
When I initially saw the tweet from Chris I thought to myself ‘it should be easy enough to accomplish that in Python’ and sure enough within an hour I had a basic prototype up and running. Since then I have been slowly adding features and in its current state the script will report blocked ports and the services that are being affected.
If you are already familiar with Python but would like more practice take a look at the vphere-port-scan repo hosted on the newly created DatacenterDudes organization on GitHub. See what code you can improve on or review the ‘Features in Development’ section of the README and see what progress you can make on adding features.
For those of you just getting started in Python (or programming in general) I will be walking through the code step by step and overviewing the process I took to get the script to its current form in subsequent articles. By working through the step-by-step process we will have the opportunity to review:
- external libraries
- conditional statements
- gathering user input
- and more
Stay tuned for our first walkthrough of the code!