Wednesday, November 30, 2016

The Self-Healing Data Center Part 2: Installing the Translation Shims for Automating vR Ops Alerts

In the previous post, I explained some of the capabilities and limitations with vR Ops alert notifications for automation of alert notifications via the REST Notification Plugin.  I also introduced the Translation Shims for Log Insight and/or vRealize Operations Manager Webhooks as a solution to these current limitations.  By the way, as the name indicates, this solution works great with Log Insight webhooks as well!  In fact, it was originally created for that purpose and later vR Ops support was added.



In this post, I will walk you through installing the Translation Shims in your environment and setting up a simple use case to test things out.

For example, you probably know that vR Ops can monitor services on a supported OS through Endpoint Operations.  If that service becomes unavailable, vR Ops can alert you.  But wouldn't it be nice if vR Ops attempted to restart the service first?  Why bother an administrator for such a simple task?  If it still doesn't respond after an automated restart attempt, then you may want a human to take a look.

Let's begin with installation of the Translation Shims.  For this you will need an environment capable of running Python 2.7 (the language used to build the shim).  If you already have a Python 2.7 environment with virtualenv installed, you can skip over the next section.

Also, there are some modules in the shim that don't play well with Windows, so I strongly recommend a Linux OS here.


Installing Prerequisites on Photon OS

To keep things simple, I'll use a virtual machine created with the Photon OS OVA (as it already comes pre-loaded with Python 2.7).  Once you have the Photon OVA deployed, you can open an SSH session and log in with root and the password changeme (which will prompt you for a password change).

The first thing we need to do is install wget.  Enter the command

tdnf install wget -y


Now we can use wget for the next step, installing pip and virtualenv for Python.  First, grab the pip installation script with wget

wget https://bootstrap.pypa.io/get-pip.py


Now you can install pip using the script we just downloaded.  What is pip?  It is a package manager for Python, sort of like how yum is for Linux (or in the case of our little Photon OS, tdnf).

python get-pip.py


Finally, you are ready to install virtualenv using pip.  By the way, virtualenv is not a requirement, it just is a good practice to avoid contaminating your nice clean Python install with modules that are unique to a given environment or may require different module versions.  Anyway, install virtualenv

pip install virtualenv


Congratulations!  Prerequisites are complete and we can get busy installing the shim.

Installing the Translator Shim

Now that we have our environment ready, let's begin the Translation Shims install.  For this, we'll use git to pull the repository down, so we will need to install that first.

tdnf install git -y


Great.  Now we can clone the Translation Shims repository from github.

git clone https://github.com/vmw-loginsight/webhook-shims.git


Using a git repository allows you to update the Translation Shims easily whenever a change is made (i.e. fixes or enhancements) to the main branch.

At this point, we can create the virtual environment for Python, using virtualenv.  As the readme on the Translation Shims repository github page suggests, we will use venv-webhookshims.  We will create this environment in the repository directory.

cd webhook-shims
virtualenv venv-webhookshims


Now you will see why we are using a Python virtual environment.  The Translation Shims has some modules that are required that are not included in the default Python library.  We will need to install those into the virtual environment we just created.  First, we will activate the virtual environment and then install the prerequisites.  This is easier than you might think, because the repository contains a file with a list of the prerequisites so we just have to reference that file with pip.

First, activate the virtual environment.

source venv-webhookshims/bin/activate


Notice the prompt changes to let us know we are in a virtual environment.  The OS will function as it normally does, the only difference is that the Python library will include any modules we add while in the virtual environment.  By the way, to exit the virtual environment, simply enter deactivate at any time.

Installing the prerequisites, as I mentioned, is easy.  There is a file in the repo named requirements.txt that contains all the modules needed to run the Translation Shims.  Using pip we can simply reference that file to install them.

pip install -r requirements.txt


Now that was easy!  At this point you have installed the translator and are ready for the next step - configuring and running the Translation Shims.  I will cover that in the next blog post.

No comments:

Post a Comment