Managing images with OpenStack Image Service

Uploading and managing images within OpenStack Storage is achieved using the glance command-line tool. This tool allows us to upload, remove, and change information about the stored images for use within our OpenStack environment.

Getting ready

To begin with, ensure that you are either logged in to an Ubuntu client where we can run the glance tool, or on our OpenStack Controller where OpenStack Image Service is running directly. If the Glance client isn't installed, this can be installed using the following commands:

sudo apt-get update
sudo apt-get install python-glanceclient

Ensure that you have your environment variables set up correctly with our admin user and password, as created in the previous chapter:

export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/
export OS_NO_CACHE=1
export OS_KEY=/vagrant/cakey.pem
export OS_CACERT=/vagrant/ca.pem

How to do it...

We can upload and view images in our OpenStack Image Service in a number of ways. Carry out the following steps to upload and show details of our uploaded images.

Uploading Ubuntu images

Ubuntu provides images that can easily be added to our OpenStack environment, as follows:

  1. We download an Ubuntu cloud image from http://uec-images.ubuntu.com, as follows:
    wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
    
  2. We then upload our cloud image:
    glance image-create 
        --name='Ubuntu 14.04 x86_64 Server' 
        --disk-format=qcow2 
        --container-format=bare 
        --is-public True < 	rusty-server-cloudimg-amd64-disk1.img
    

    You will see an output like this:

    Uploading Ubuntu images

Listing images

To list the images in our OpenStack Image Service repository, we use the Glance client to interrogate the Image Service directly, or use the Nova client that is used to manage our OpenStack environment. This is covered in Chapter 4, Nova – OpenStack Compute.

To list the images available to our user using the Glance client, we issue the following command:

glance image-list

The preceding command produces a result like this:

Listing images

Viewing image details

We can view further details of our images in the repository. To show further details of any image, issue the following command:

glance image-show IMAGE_ID

Consider the following example:

glance image-show 18584bff-2c12-4c2d-85f6-59771073c936

This returns the same details as when we uploaded our image (shown on the previous page).

Deleting images

There will be times when you will need to remove images from being able to be called within your OpenStack cloud environment. You can delete images where you have permission to do so:

  1. To delete an image, issue the following command:
    glance image-delete IMAGE_ID
    
  2. Consider the following example:
    glance image-delete 794dca52-5fcd-4216-ac8e-7655cdc88852
    
  3. OpenStack Image Service will not produce any output when you successfully delete an image. You can verify this with the glance image-list command.

Making private images public

When you upload an image, they get entered into OpenStack Image Service as private, by default. If an image is uploaded this way but you want to make it public, you perform the following steps in OpenStack Image Service:

  1. First, list and view the image(s) that you want to make public. In this case, we will choose our first uploaded image:
    glance image-show IMAGE_ID
    

    Consider the following example:

    glance image-show 18584bff-2c12-4c2d-85f6-59771073c936
    

    This produces results somewhat similar to what is shown here:

    Making private images public
  2. We can now convert this to a public image that is available to all the users of our cloud environment with the following command:
    glance image-update 18584bff-2c12-4c2d-85f6-59771073c936 
        --is-public True
    
  3. List the available public images as follows:
    glance image-show 18584bff-2c12-4c2d-85f6-59771073c936 
    

    We will now see the following output:

    Making private images public

How it works

OpenStack Image Service is a very flexible system for managing images in our private cloud environment. It allows us to modify many aspects of our OpenStack Image Service registry—adding new images, deleting them, updating information, such as the name that is used so that end users can easily identify them, and making private images public or vice-versa.

To do all this, we use the glance tool from any connected client.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset