In this post, I would like to cover, how to prepare an image (a virtual hard disk), that could be launched in OpenStack. I will use a cirros image to demonstrate the steps.
-
Download an image. For this example a QCOW2 image will be used:
wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
- Now convert the image to XenServer VHD format. Converting a raw file to VHD, using a patched vhd-util, is covered in this blog entry.
- Make sure, that the produced vhd file is called 0.vhd. The OpenStack XAPI plugin looks for the file 0.vhd, so the filename is important.
-
Create a .tgz:
tar -czf tarred.tgz 0.vhd
-
Upload the file to glance.
glance image-create --name="cirros" --is-public=true \ --container-format=ovf --disk-format=vhd < tarred.tgz
It would be really good to combine this step with the above one, using a pipe, but at the moment this is not supported by the glance CLI. (Bug report:can’t pipe bytes to image-create)
- Start the new instance. After the image is uploaded to glance, you are free to boot an instance with the uploaded image:
nova boot --image cirros --flavor m1.small somevmname