Skip to main content

Raymii.org Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Openstack Glance Image Download, download Openstack images

Published: 25-02-2015 | Author: Remy van Elst | Text only version of this article


Table of Contents


This guide shows you how download Openstack Images to your local machine usingthe command line Glance client. You can use this, for example, to download acopy of an image created from a VM, or to download the images your Openstackprovider provides and adapt those.

You can see all my Openstack related articles here. For example, how to useDuplicity to create Encrypted backups to the Openstack Swift Object Store

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

Command Line tools

Make sure you have the Openstack command line tools installed. Follow theofficial openstack guide here. If you have pip installed you can use thatto install the tools:

pip install python-novaclientpip install python-cinderclientpip install python-glanceclientpip install python-keystoneclientpip install python-neutronclientpip install python-swiftclient

Save yourself some time and create a file named computerc with the belowcontents:

export OS_AUTH_URL="https://identity.stack.cloudvps.com/v2.0"export OS_TENANT_NAME="<tenant name>"export OS_USERNAME="<username>"export OS_PASSWORD="<password>"export OS_TENANT_ID="<tenant id>"

When you are going to do stuff with the Openstack command line clients, loadthis file:

source computerc

That way, your authentication data are loaded and you don't have to giveparameters like --os-username and such.

Openstack Overview

Openstack is a datacenter virtualization plaform consisting out of manydifferent tools and services. Here is a short overview of the different servicesyou might encounter.

Compute (Nova)

This is the virtualization service. It works with a hypervisor to create andmanage virtual machines. You can create a VM based on a specific "Flavour",which is just a definition of specs like disk, cpu and ram.

Block Storage (Cinder)

This is the service which makes block devices (volumes) available to services. Aflavour can not be changed, just resized. If you want extra storage you need tocreate a volume, attach it to the VM and mount it there for use.

Images (Glance)

This is the service which holds all the images. Images can be used to boot a VMfrom. Images can be prepared with tools like cloud-init to make them behavebetter in a cloud environment, for example, setting an SSH key or password atboot.

Listing images

When you've created a computerc file and loaded it up in your shell you canstart the process. You need the UUID of the image you want to download. Get alist of all images using the glance image-list command:

$ glance image-list

Output:

+------------+---------------------+--------+-----------+------------+--------+| ID         | Name                | Disk   | Container | Size       | Status |+------------+---------------------+--------+-----------+------------+--------+| 0a[...]5dd | example-test        | raw    | bare      | 4843700224 | active || 13[...]b30 | example-2           | qcow2  | bare      | 4762632192 | active || 22[...]eeb | FreeBSD-10.1        | qcow2  | bare      | 736981504  | active || d2[...]625 | pfSense 2.1.5       | iso    | bare      | 403243008  | active |+------------+---------------------+--------+-----------+------------+--------+

The ID part is what you need. In this example it is trimmed.

Download Image

Use the glance image-download command to download the image. By default itwill go to STDOUT, use the --file parameter to place the output in a file.

$ glance image-download --file ./example-test.img 0a[...]5dd

The command syntax is:

$ glance image-download --file $FILENAME $UUID

If you get the following error:

object of type 'generator' has no len()

Try executing the command without the --progress option.

Tags: cloud, compute, download, glance, image, images, nova, openstack, tutorials