Copying OpenStack Glance images

Use these instructions to copy OpenStack Glance images from one region to another.

About this task

If you have access to the image files and you already know information such as the container format and disk format, you can create those images in region two. If the file is accessibly using HTTP, you can use the OpenStack dashboard to create a new image. Otherwise, you can use the glance image-create command to create the image. The following example assumes that you are logged on to the region two controller and that you have copied the image file, test_image.img, to that system:
# . openrc
# glance image-create --name='test image' --is-public=true --container-format=bare --disk-format=qcow2 < test_image.img

If the image files are stored in the region one glance repository or you are not sure of the image properties, use the following procedure to copy OpenStack cloud images from region r1 to region r2. The examples assume that the files openrc.r1 and openrc.r2 contain credentials for authenticating to regions r1 and r2 respectively.

Procedure

  1. Access the environment file for the first region by using the following command.
    # . openrc.r1
  2. List the images in the first region and identify those that you want to copy.
    # openstack image list
    
    +--------------------------------------+------------+
    | ID                                   | Name       |
    +--------------------------------------+------------+
    | f3b35877-f182-4cb5-a69c-bc3b40a4feb3 | test image |
    +--------------------------------------+------------+
  3. Display the properties for the image:
    # openstack image show -f shell "test image"
    checksum="d972013792949d0d3ba628fbe8685bce"
    container_format="bare"
    created_at="2014-12-08T20:51:26.066496"
    deleted="False"
    deleted_at="None"
    disk_format="qcow2"
    id="f3b35877-f182-4cb5-a69c-bc3b40a4feb3"
    is_public="True"
    min_disk="0"
    min_ram="0"
    name="test image"
    owner="e17e12ef8219460abeaf1075cbaabbd5"
    properties="{}"
    protected="False"
    size="13147648"
    status="active"
    updated_at="2014-12-08T20:54:24.441587"
    virtual_size="None"
  4. Note the highlighted items in the previous step. The highlighted parameters are used in the openstack image create command. If the properties field has a value, it must be split into sets of key value pairs. For example:
    properties="{u'key2': u'value2', u'key1': u'value1'}"
    The preceding values correspond to the following key value pairs:
    
    "key2" "value2"
    "key1" "value1"
  5. Save the image file on the region two controller:
    # openstack image save --file test_image.img "test image"
  6. Access the environment file for the second region by using the following command.
    # . openrc.r2
  7. Create the image in region r2:
    # openstack image create  --container-format bare --disk-format=qcow2 --public --file test_image.img "test image"
    If the image has properties set, use the --property key=value option to set each option. For example:
    --property key1=value1 --property key2=value2
    Note: You can use glance help or openstack help to get more information about OpenStack CLI commands for working with images in the OpenStack image repository.

Results

The glance repository in region r2 should now contain copies of the images from region r1 including their metadata.