4 In Synnefo, an image is loaded as a file to the storage service (Pithos+), and
5 then is registered to the image service (Plankton). The image location at the
6 storage server is unique through out a deployment and also necessary for the
9 The image location format::
11 pithos://<user id>/<container>/<object path>
15 pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
17 The crussial element in an image location is the container (e.g. `pithos`) and
18 the image object path (e.g. `debian_base3.diskdump`).
23 Let the image file `debian_base3.diskdump` be a debian image located at the
26 Upload the image to container `pithos`
28 .. code-block:: console
30 [kamaki]: file upload debian_base3.diskdump pithos
31 Uploading /home/someuser/debian_base3.diskdump --> pithos:debian_base3.diskdump
35 Register the image object with the name 'Debian Base Alpha'
37 .. code-block:: console
39 [kamaki]: image register 'Debian Base Alpha' pithos:debian_base3.diskdump
40 checksum: 3cb03556ec971f...e8dd6190443b560cb7
41 container-format: bare
42 created-at: 2013-06-19 08:00:22
47 location: pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
48 name: Debian Base Alpha
53 updated-at: 2013-06-19 08:01:00
54 Metadata file uploaded as pithos:debian_base3.diskdump.meta (version 1352)
57 .. note:: The `image register` command automatically creates a meta file and
58 uploads it to the same location as the image. The meta file can be
59 downloaded and reused for more image registrations.
63 .. code-block:: console
65 [kamaki]: file cat pithos:debian_base3.diskdump
67 "status": "available",
68 "name": "Debian Base Gama",
69 "checksum": "3cb03556ec971f...e8dd6190443b560cb7",
70 "id": "7h1rd-1m4g3-1d2",
71 "updated-at": "2013-06-19 08:01:00",
72 "created-at": "2013-06-19 08:00:22",
74 "location": "pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump",
76 "owner": "s0m3-u53r-1d",
77 "disk-format": "diskdump",
80 "container-format": "bare"
84 Images registered by me
85 -----------------------
87 List all images, then list only images owned by the user with id s0m3-u53r-1d
89 .. code-block:: console
92 f1r57-1m4g3-1d Debian Base Alpha
93 container_format: bare
97 53c0nd-1m4g3-1d Beta Debian Base
98 container_format: bare
102 7h1rd-1m4g3-1d Debian Base Gama
103 container_format: bare
104 disk_format: diskdump
107 [kamaki]: image list --owner=s0m3-u53r-1d
108 7h1rd-1m4g3-1d Debian Base Gama
109 container_format: bare
110 disk_format: diskdump
115 .. note:: To get the current user id, use `user authenticate` in kamaki
120 An image can be unregistered by its image id, but only if the current user is
121 also the image owner. In this example, there is only one image owned by current
124 Unregister image owned by current user
126 .. code-block:: console
128 [kamaki]: image unregister 7h1rd-1m4g3-1d
131 Check if the image is deleted
133 .. code-block:: console
135 [kamaki]: image list --owner=s0m3-u53r-1d
138 Attempt to unregister an image of another user
140 .. code-block:: console
142 [kamaki]: image unregister f1r57-1m4g3-1d
143 (403) FORBIDDEN forbidden ()
146 Register with properties
147 ------------------------
149 The image will be registered again, but with some custom properties::
154 These properties can be added freely by the user, and they have no significance
155 for the image server, but they could be used to help using the image more
158 Attempt to register with properties
160 .. code-block:: console
162 [kamaki]: image register 'Debian Base Gama' pithos:debian_base3.diskdump -p OS=Linux -p user=someuser
163 Metadata file pithos:debian_base3.diskdump.meta already exists
166 It's true that the metafile is already there, but we can override it (**-f**)
168 .. code-block:: console
170 [kamaki]: image register -f 'Debian Base Gama' pithos:debian_base3.diskdump -p OS=Linux -p user=someuser
173 Register with a meta file
174 -------------------------
176 Download the meta file of the image (it was uploaded recently)
178 .. code-block:: console
180 [kamaki]: file download pithos:debian_base3.diskdump.meta
181 Downloading pithos:debian_base3.diskdump.meta --> /home/someuser/debian_base3.diskdump.meta
185 The metadata file can be edited. Let's edit the file, by adding properties::
190 The resulting file will look like this:
192 .. code-block:: javascript
195 "status": "available",
196 "name": "Debian Base Gama",
197 "checksum": "3cb03556ec971f...e8dd6190443b560cb7",
198 "id": "7h1rd-1m4g3-1d2",
199 "updated-at": "2013-06-19 08:01:00",
200 "created-at": "2013-06-19 08:00:22",
205 "location": "pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump",
206 "is-public": "False",
207 "owner": "s0m3-u53r-1d",
208 "disk-format": "diskdump",
211 "container-format": "bare"
214 .. warning:: make sure the file is in a valid json format, otherwise image
217 In the following registration, a different name will be used for the image.
219 Register the image (don't forget the -f parameter, to override the metafile).
221 .. code-block:: console
223 [kamaki]: image register -f 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta
224 checksum: 3cb03556ec971f...e8dd6190443b560cb7
225 container-format: bare
226 created-at: 2013-06-19 08:00:22
228 disk-format: diskdump
231 location: pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
232 name: Debian Base Delta
239 updated-at: 2013-06-19 08:01:00
240 Metadata file uploaded as pithos:debian_base3.diskdump.meta (version 1359)
243 Reregistration: priorities and overrides
244 ----------------------------------------
246 Let's review the examples presented above::
248 - Register an image with name `Debian Base Gama`
249 - Unregister the image
250 - Register a new image of the uploaded image object, with custom properties
251 - Reregister the image with a meta file and modified properties and name
253 **The image id is related to the image object**
255 Although the image was unregistered and reregistered, the image id, that is
256 produced automatically at the server side, was the same. This is due to the
257 fact that image ids are 1 to 1 related to image objects uploaded to Pithos+
259 **An explicit name overrides the metafile**
261 Each image needs a name and this is given as the first argument of the
262 `register` command. This name overrides the name in the metafile.
264 **Reregistration is not update, but an override**
266 The property `user: root` won over `user: someuser`, because it was set last.
267 Actually, all properties were replaced by the new ones, when the image was
268 reregistered, and the same holds with all customizable attributes of the image.
270 Command line wins the metafile
271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
273 Let's compine the metafile with a command line attribute `user: admin`
275 .. code-block:: console
277 [kamaki]: image register -f 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta
278 checksum: 3cb03556ec971f...e8dd6190443b560cb7
279 container-format: bare
280 created-at: 2013-06-19 08:00:22
282 disk-format: diskdump
285 location: pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
286 name: Debian Base Delta
293 updated-at: 2013-06-19 08:01:00
294 Metadata file uploaded as pithos:debian_base3.diskdump.meta (version 1377)
297 Although the property `OS` was read from the metafile, the property `USER` was
298 set by the command line property to `admin`.
300 .. note:: This feature allows the use of a metafile as a template for uploading
301 multiple images with many common attributes but slight modifications per
304 Multiple metafile versions
305 --------------------------
307 .. warning:: Make sure your container is set to auto, otherwise, there will be
310 .. code-block:: console
312 [kamaki]: file versioning get pithos
313 x-container-policy-versioning: auto
316 To set versioning to auto
318 .. code-block:: console
320 [kamaki]: file versioning set auto pithos
323 In the above examples, the image was registered many times by overriding the
324 metafile. It is possible to avoid writing a metafile, as well as accessing
325 older versions of the file.
327 Register the image without uploading a metafile
329 .. code-block:: console
331 [kamaki]: image register 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta --no-metafile-upload
332 checksum: 3cb03556ec971f...e8dd6190443b560cb7
333 container-format: bare
334 created-at: 2013-06-19 08:00:22
336 disk-format: diskdump
339 location: pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
340 name: Debian Base Delta
347 updated-at: 2013-06-19 08:01:00
350 Uploaded metafiles are kept in versions, thanks to Pithos+ versioning support
352 .. code-block:: console
354 [kamaki]: file versions pithos:debian_base3.diskdump.meta
356 created: 19-06-2013 11:00:22
358 created: 19-06-2013 11:01:00
360 created: 19-06-2013 11:34:37
363 Consult the first version of the metafile
365 .. code-block:: console
367 [kamaki]: file cat --object-version=1352 pithos:debian_base3.diskdump.meta
369 "status": "available",
370 "name": "Debian Base Gama",
371 "checksum": "3cb03556ec971f...e8dd6190443b560cb7",
372 "id": "7h1rd-1m4g3-1d2",
373 "updated-at": "2013-06-19 08:01:00",
374 "created-at": "2013-06-19 08:00:22",
376 "location": "pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump",
377 "is-public": "False",
378 "owner": "s0m3-u53r-1d",
379 "disk-format": "diskdump",
382 "container-format": "bare"
386 Download the second version
388 .. code-block:: console
390 [kamaki]: file download --object-version=1359 pithos:debian_base3.diskdump.meta debian_base3.diskdump.meta.v1359
391 Downloading pithos:debian_base3.diskdump.meta --> /home/someuser/debian_base3.diskdump.meta.v1359
398 Let a directory at /home/someuser/images with a variety of images needed to be
399 uploaded and registered.
401 Batch-upload the images
403 .. code-block:: console
405 [kamaki]: file upload -R images pithos
407 Uploading /home/someuser/images/debian.diskdump --> pithos:images/debian.diskdump
408 Uploading /home/someuser/images/win8.diskdump --> pithos:images/win8.diskdump
413 Make sure the images are uploaded to pithos:images/ remote directory object
415 .. code-block:: console
417 [kamaki]: file list pithos:images/
419 983MB images/debian.diskdump
420 2.2GB images/win8.diskdump
424 Use the host shell capabilities to streamline the registration, so exit kamaki
426 .. code-block:: console
430 The following is a bash script that attempts to register the already uploaded
437 userid=... # e.g. s0m3-u53r-1d
438 container=... # e.g. pithos
440 for path in images/*.diskdump; do
441 location=$container:${path}
442 kamaki image register $path $location
445 Let's use the script (enriched with a separator message) to batch-register the
446 images (all images will be named after their relative paths).
448 Also, let the registered images be public (accessible to all users for creating
449 VMs) by adding the **--public** flag argument when calling `image register`.
451 .. code-block:: console
453 $ for path in images/*.diskdump; do
454 location=pithos:${path}
455 echo "- - - Register ${path} - - -"
456 kamaki image register $path $location --public
458 - - - Register images/debian.diskdump ---
459 checksum: 3cb03556ec971f...e8dd6190443b560cb7
460 container-format: bare
461 created-at: 2013-06-19 08:00:22
463 disk-format: diskdump
466 location: pithos://s0m3-u53r-1d/pithos/images/debian.diskdump
467 name: images/debian.diskdump
472 updated-at: 2013-06-19 08:01:00
473 Metadata file uploaded as pithos:images/debian.diskdump.meta (version 4201)
474 - - - Register images/win8.diskdump ---
475 checksum: 4cb03556ec971f...e8dd6190443b560cb6
476 container-format: bare
477 created-at: 2013-06-19 08:00:22
479 disk-format: diskdump
482 location: pithos://s0m3-u53r-1d/pithos/images/win8.diskdump
483 name: images/win8.diskdump
488 updated-at: 2013-06-19 08:01:00
489 Metadata file uploaded as pithos:images/debian.diskdump.meta (version 4301)
493 .. note:: All images can be re-registered, either individually or with a batch