Creating the image

We will start by downloading a cirros image to the automation server. cirros is a lightweight, Linux-based image, used by many OpenStack developers and testers around the world to validate the functionality of OpenStack services:

#cd /root/ ; wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

Then, we will upload the image to the OpenStack image repository using glanceclient. Notice that we need to have the keystone token and the session parameter first, in order to communicate with glance, otherwise, glance won't accept any API requests from us.

The script will be as follows:

from keystoneauth1.identity import v3from keystoneauth1 import sessionfrom glanceclient import client as gclientfrom pprint ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.