This is a blog about how to:
- Snapshot an OpenStack nova instance as a glance image
- Boot an instance from the snapshot (glance image)
- Download the snapshot (glance image) as a file onto disk
- Validate the downloaded snapshot file (image) using qemu-img
- Upload this file (image) on disk into OpenStack glance
1. Snapshot an OpenStack nova instance as a glance image:
Make sure that this snapshot is seen as an glance image.
2. Boot an instance from the snapshot (glance image):
Make sure that the flavor of the instance booted is at least equal to or bigger than the flavor of the instance that was snapshotted in step 1.
Make sure to allow ICMP and SSH (TCP port 22) in nova security groups. Once the above instance is up, make sure you can ping and SSH into the instance.
3. Download the snapshot (glance image) as a file onto disk:
# glance image-list
+--------------------------------------+--------------------------------+
| ID | Name |
+--------------------------------------+--------------------------------+
| 56c4028c-57ab-4d12-8cf4-d96d874e90c3 | test-vm-snapshot |
+--------------------------------------+--------------------------------+
# glance image-download 56c4028c-57ab-4d12-8cf4-d96d874e90c3 --file test-vm-snapshot
#
# ls -l test-vm-snapshot
-rw-r--r--. 1 root root 960692224 Jul 18 20:26 test-vm-snapshot
This downloaded image can now be backed up or transferred over the network.
4. Validate the downloaded snapshot file (image) using qemu-img
The downloaded snapshot file (image) can be validated using:
qemu-image check test-vm-snapshot
qemu-image info test-vm-snapshot
Sorry, unfortunately I do not have the output of the qemu-image commands above.
qemu-img(1): QEMU disk image utility - Linux man page
5. Upload this file (image) on disk into OpenStack glance
# glance image-create --name 'image-from-downloaded-snapshot' --disk-format qcow2 --container-format bare --file test-vm-snapshot --visibility public --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 6c323b8eb0406d7f6097bfb821e9d68a |
| container_format | bare |
| created_at | 2016-07-18T20:28:25Z |
| disk_format | qcow2 |
| id | 44734abf-60c1-42ee-ac2a-c3018f43f003 |
| min_disk | 0 |
| min_ram | 0 |
| name | image-from-downloaded-snapshot |
| owner | 3f61ded7cb7b46d594cbff5899e54ead |
| protected | False |
| size | 960692224 |
| status | active |
| tags | [] |
| updated_at | 2016-07-18T20:28:37Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------+
# glance image-list
+--------------------------------------+--------------------------------+
| ID | Name |
+--------------------------------------+--------------------------------+
| 44734abf-60c1-42ee-ac2a-c3018f43f003 | image-from-downloaded-snapshot |
+--------------------------------------+--------------------------------+
This uploaded image will be seen in Horizon as well under "Images". This image can now be used to boot a nova instance!