Installing and using Python Shade in your Red Hat OpenStack environment

Installing and using Python Shade in your Red Hat OpenStack environment

So you want to install python Shade in your Red Hat OpenStack environment without destroying your undercloud director node? If you do this without following these instructions, you’ll very likely destroy the usability of your director. I’ll walk you through the steps necessary, as of the writing of this post (2017-08-30),  to not only get shade workin on your director — but to deploy an instance in your cloud with it.

What is Shade?

From the OpenStack documentation for Shade:

“shade is a simple client library for interacting with OpenStack clouds.”

Using shade, you can perform tasks like:

  • creating instances
  • deleting instances

and much more…

You can think of shade as a high-level python library for OpenStack clouds. An analogous library for ruby, for instance, would be something like FOG.

The Problem

Looking at the requirements for shade:

You can see that there are a number of packages that you already have installed as part of the Red Hat OpenStack Platform. Changing the versions of these libraries, which is what will happen if you directly install shade via pip,  will put you into the dangerzone and destroy your working undercloud. Just don’t do it.

Virtualenv to the rescue

One way to get around this potential danger is to just use virtualenv. Virtualenv allows you to create an environment with a self-contained python installation. This allows you to use pip to install shade without touching your known-good installation on the director.

Let’s get started

First, let’s install virtualenv on the director node:

Next, lets create a virtualenv called “shade” in our home directory. Note that I use the –system-site-packages argument, as this allows you to use your current python libraries as dependencies, thereby not touching them and only installing what you need in this virtualenv.

Next up, we’ll activate this virutalenv and install the shade library with pip:

Note that your prompt will change to (shade) when you’re active in the virtualenv environment. To get out of the virutal environment, simply type ‘deactivate’.

Code it up

Ok, now we’re ready to write some code to create a server in our new cloud. These examples are based on the documentation for shade, with a few minor differences.

First – let’s create a file called clouds.yml in our home directory. We’re going to do all of this in the same directory for now, I suggest you do the same for testing. Shade will look for this file in:

  • ~/.config/openstack
  • /etc/openstack
  • the current working directory (our method here)

These settings will vary per your overcloud. I’ve used mine here, and am just using the default admin project for simplicity’s sake. You could create your own project, and reference it via these values as well.

Here’s a line by line explanation of these values

  • clouds: this is whatever you’d like to call this cloud – refer to it consistently.
  • region: you need to use the correct region here – get it by looking at openstack endpoint list once you’ve sourced your overcloudrc. The default is ‘regionOne’ in Red Hat OpenStack.
  • auth: all of the auth parameters can be found by looking at your overcloudrc. Just fill these out as they are and you should be good.

Next, we’ll create a python script to upload an image into glance, and start a server for us with that image:


This is the ca certificate I used to sign my self-signed certs for the overcloud. Because I’m using self-signed certs, the SSL handshake will fail unless I specify the cert here, and thus, so will shade.

You know this, I’m sure of it.

Here’s our cloud, referenced from our clouds.yml we created earlier.

This is the image we’re uploading into glance, present in the current working directory here. You could use anything you like here – the first value ‘rhel7’ is what it’ll be named in glance.

We want a flavor with at least 4096MB of memory. Shade will use the first flavor it finds that is > than 4096 here.

Finally, we create the server and tell shade to auto_ip it in our cloud.

The Final Blow

All that’s left is to run this with python:

You’ll see some debug output and finally be left with your server:


I hope this helps you to get started with python shade in Red Hat OpenStack 11. While I haven’t tested this with version 10, I’m pretty sure it’ll work mostly the same way.

If you’d like to read more about Shade, go here:

If you’re coding an application in python that uses this library, you’ll want to get familiar with some of the usage documentation here:

2 responses

Leave a Reply

%d bloggers like this: