Task #6900

Updated by Nico Schottelius about 2 years ago

h2. Objective

Users can upload files. Files can be used as images for VMs, if they are in the qcow2 format.

h2. How it works

* Files are uploaded to a specific VM (likely
* Users can use the ucloud-cli to convert a file to an image

h2. CLI

* ucloud image-create-from-file --uuid $UUID --name <name-of-the-image> --image-store <name> [--desc "optional description"] [--public]
** if --public is passed, the image is public
** do not implement --public before v2
** for --public we need to clarify how is paying for the storage
** Need to specify the name of the image store; OR we use the UUID (persisten!) of the image store

* ucloud image-set-permission [--public|--private]
** makes image public or private
** do not implement before v2

h3. API

The API modifies entries in etcd as follows:

* Finds the file in etcd
** if it does not exist -> error out
** Only accept "sane" filenames (i.e. no .. and funky stuff)
* Creates an image entry below /v1/image/$UUID
** maybe the same UUID as the file OR a random UUID - to be discussed in ucloud channel
** JSON: set status on create to "TO_BE_CREATED", needs to include "owner" field

h3. Cron job on

* Scans all entries in /v1/image
* If there is a json with TO_BE_CREATED
** Look for the filename below basepath/$owner/$filename
** If it is not there, error out
* If image is found
** Verify that it is qcow2 format (file or qemu-img)
** Convert it to raw and import it into ceph
*** qemu-img convert ... | rbd import ...

-> ping @llnu for a test ceph cluster to try this out