Downloading Images
Introduction, how to download an image in stand-alone and multi-node cluster environments.
In stand-alone environment, images are stored in file. While in a multi-node cluster environment, images can be stored in a file and swift.
If stored in file, the following configuration can be found in /etc/glance/glance-api.conf. Users can get the image file directly from the directory specified in filesystem_store_datadir.
[glance_store] default_backend = file filesystem_store_datadir = /var/lib/glance/images/
If stored in a swift, the following configuration can be found in /etc/glance/glance-api.conf. Users cannot get the image directly from swift. They need to download the image to a local file, then can use it.
enabled_backends = swift:swift ... [glance_store] default_backend = swift
No matter if in a stand-alone or multi-node environment, users can download an image two ways as follows.
Two ways to download an image to a local file in stand-alone and multi-node cluster environments
Use openstack cli.
openstack image save --file <filename> <image name or id>
The example is as follows. Download the image named rh79_dasd to a file named rh79_dasd_download.
openstack image save --file rh79_dasd_download rh79_dasd
Use openstack API. Refer to OpenStack link.
- API URL: GET /v2/images/{image_id}/file
You can use API tool to send the api request. Usually, it says that File is too large to show in response. Please download it! in response. You can download response body to get the image file.
You can use curl command as follows to send the api request:
curl -i -X GET -H "X-Auth-Token: $token" $image_url/v2/images/{image_id}/file --output <filename>
The example is as follows. Download the image with ID equals 2ecb3c5f-9936-4810-b52a-54b8bdf0303b to a file named rh79_dasd_download.
curl -X GET -k -H "X-Auth-Token: <openstack_token>" https://<management-node-ip-address>/icic/openstack/image/v2/images/2ecb3c5f-9936-4810-b52a-54b8bdf0303b/file --output rh79_dasd_download