Openstack Queens\Rocky - Glance: Create an image from an existing RBD volume
Seems like something that should be simple!
Step1 – Create the empty image
1glance image-create --container-format=bare --disk-format=raw --min-ram 2048 --name="Windows Server test"
1+------------------+--------------------------------------+
2| Property | Value |
3+------------------+--------------------------------------+
4| checksum | None |
5| container_format | bare |
6| created_at | 2020-07-14T03:37:29Z |
7| disk_format | raw |
8| id | ca9bf831-df20-4c7c-884e-08e355e5a012 |
9| locations | [] |
10| min_disk | 0 |
11| min_ram | 2048 |
12| name | 3CX - July 2020 |
13| os_hash_algo | None |
14| os_hash_value | None |
15| os_hidden | False |
16| owner | ccd547784c804de99a63dd17dfb7ff15 |
17| protected | False |
18| size | None |
19| status | queued |
20| tags | [] |
21| updated_at | 2020-07-14T03:37:29Z |
22| virtual_size | None |
23| visibility | shared |
24+------------------+--------------------------------------+
Step 2 - If you haven't already done so, upload the image into ceph - Note the image must be in RAW format. Use qemu-img convert to convert the image from QCOW2 to RAW if required
To convert and import in one pass
1qemu-img convert -f qcow2 -O raw inputfile.cqow2 rbd:images/outputfile.raw
To import an existing RAW image file
1rbp import -p images myimg.raw
Step 2 – Update the ‘location’ attribute
1glance location-add --url "rbd://b42a82f3-f493-49f4-98e0-2d355bbe8ee3/saspool/image-Windows2016v1/snap" 763a2ca2-e8f8-4bf9-974f-98d7020e200b
You’ll obviously need to ensure you have a protected snapshot of your image like so
1:~# rbd snap create saspool/image-Windows2016v1@snap
2
3:~# rbd snap protect saspool/image-Windows2016v1@snap
4
5:~# rbd snap ls saspool/image-Windows2016v1
1SNAPID NAME SIZE TIMESTAMP
2
318 snap 150 GB Thu Apr 26 13:24:30 2018
You’ll also need to ensure that show_multiple_locations = true
is set in glance-api.conf or you'll see something like this
403 Forbidden: It's not allowed to add locations if locations are invisible. (HTTP 403)