Use existing RBD images and put it into Glance
The title of the article is not that explicit, actually I had trouble to find a proper one. Thus let me clarify a bit. Here is the context I was wondering if Glance was capable of converting images within its store. The quick answer is no, but I think such feature is worth to be implemented. Glance could be able to convert a QCOW2 image to a RAW format. Usually if you already have an image within let’s say a Ceph cluster (RBD), you have to download the image (since you probably don’t have the source image file anymore), then manually convert it with qemu-img (QCOW2 –> RAW) and eventually import it into Glance. Enough talk about this, I’ll address this in a future article. For now let’s stick to the first matter. Imagine that you have a KVM cluster backed by a Ceph Cluster and your CTO wants you to migrate the whole environment to OpenStack because it’s trendy (joking, OpenStack just rocks!). You’re not going to backup all your images and then build a new cluster or something like that, you might want OpenStack (Glance) to be aware of your Ceph cluster. Generally speaking you just have to connect Glance to one of your image pool. After this, the only thing to do is to create (it’s more registering the images ID and metadata than creating a new image) into Glance. No worries here’s the explanation. Longest introduction ever.
In this article, I’m assuming that Glance is already connected to Ceph and to the proper RBD pool. Before starting anything, please understand that within the current Grizzly stable branch, the RBD backend is not implemented. That’s funny because we don’t need that much to implement it. The bug report is on launchpad and the proposed feature is under review on Gerrit.
However if you want to enable the fix now:
- Go to the line 278 of
- Then simply edit the line like so:
Let’s test this! ¶
Get the image size from the rbd client:
1 2 3 4 5 6
Eventually create/register the new image:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
R Note about the URI from the
--location option, there are 2 way to build it, it can be:
rbd://<image-name>; Glance will figured out the pool since you put it into the Glance configuration.
It either 1 or 4 field(s).
Of course the example was only with one image but the method will definitely work for a whole Ceph cluster with tons of images!