Tuesday, January 16, 2018

How to download images from Openstack

Use following command to download images from OpenStack glance.

source  overcloudrc 
openstack image save --file file-name.qcow2 image-name-or-id  

if you would like to download and compress at the same time use

source overcloudrc 
openstack image save image-name-or-id | gzip -c > image-name.raw.gz  

For example:

[stack@ospdir ~]$ source overcloudrc 
(admin@overcloud) [stack@ospdir ~]$ openstack image list -c ID -c Name -c "Disk Format" -c Size -f table --long 
+--------------------------------------+----------+-------------+-------------+ 
| ID                                   | Name     | Disk Format |        Size | 
+--------------------------------------+----------+-------------+-------------+ 
| 6c5384f6-cf86-4a41-b9d4-8cafbb9c08fc | CentOS74 | qcow2       |   854851584 | 
| 4d43fb6d-16a3-4c85-8eab-f0088a9f5aaa | Win2k16  | raw         | 42954915840 | 
| 3bcdeb04-9170-4f2c-8468-8797477b6c02 | cirros   | qcow2       |    13267968 | 
+--------------------------------------+----------+-------------+-------------+ 
(admin@overcloud) [stack@ospdir ~]$ openstack image save Win2K16 | gzip -c > Win2K16.raw.gz 
(admin@overcloud) [stack@ospdir ~]$ du -b Win2k16.raw.gz  9151990788    Win2k16.raw.gz 
(admin@overcloud) [stack@ospdir ~]$ openstack image save --file  cirros.qcow2 cirros 
(admin@overcloud) [stack@ospdir ~]$ du -b cirros.qcow2  13267968    Win2k16.raw.gz  

No comments:

Post a Comment