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.

  1. Download an image. For this example a QCOW2 image will be used:
  2. 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.
  3. 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.
  4. Create a .tgz:
    tar -czf tarred.tgz 0.vhd
  5. 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)
  6. 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