Revision f2ea1314
b/docs/collection_of_examples/imageregister.rst | ||
---|---|---|
14 | 14 |
|
15 | 15 |
pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump |
16 | 16 |
|
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`). |
|
17 | 19 |
|
18 | 20 |
Register an image |
19 | 21 |
----------------- |
... | ... | |
34 | 36 |
|
35 | 37 |
.. code-block:: console |
36 | 38 |
|
37 |
[kamaki]: image register 'Debian Base Alpha' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
|
|
39 |
[kamaki]: image register 'Debian Base Alpha' pithos:debian_base3.diskdump |
|
38 | 40 |
checksum: 3cb03556ec971f...e8dd6190443b560cb7 |
39 | 41 |
container-format: bare |
40 | 42 |
created-at: 2013-06-19 08:00:22 |
... | ... | |
52 | 54 |
Metadata file uploaded as pithos:debian_base3.diskdump.meta (version 1352) |
53 | 55 |
[kamaki]: |
54 | 56 |
|
55 |
.. note:: The `image register` command automatically create a meta file and |
|
57 |
.. note:: The `image register` command automatically creates a meta file and
|
|
56 | 58 |
uploads it to the same location as the image. The meta file can be |
57 | 59 |
downloaded and reused for more image registrations. |
58 | 60 |
|
... | ... | |
157 | 159 |
|
158 | 160 |
.. code-block:: console |
159 | 161 |
|
160 |
[kamaki]: image register 'Debian Base Gama' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump -p OS=Linux -p user=someuser
|
|
162 |
[kamaki]: image register 'Debian Base Gama' pithos:debian_base3.diskdump -p OS=Linux -p user=someuser |
|
161 | 163 |
Metadata file pithos:debian_base3.diskdump.meta already exists |
162 | 164 |
[kamaki]: |
163 | 165 |
|
... | ... | |
165 | 167 |
|
166 | 168 |
.. code-block:: console |
167 | 169 |
|
168 |
[kamaki]: image register -f 'Debian Base Gama' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump -p OS=Linux -p user=someuser
|
|
170 |
[kamaki]: image register -f 'Debian Base Gama' pithos:debian_base3.diskdump -p OS=Linux -p user=someuser |
|
169 | 171 |
[kamaki]: |
170 | 172 |
|
171 | 173 |
Register with a meta file |
... | ... | |
218 | 220 |
|
219 | 221 |
.. code-block:: console |
220 | 222 |
|
221 |
[kamaki]: image register -f 'Debian Base Delta' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump --metafile=debian_base3.diskdump.meta
|
|
223 |
[kamaki]: image register -f 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta |
|
222 | 224 |
checksum: 3cb03556ec971f...e8dd6190443b560cb7 |
223 | 225 |
container-format: bare |
224 | 226 |
created-at: 2013-06-19 08:00:22 |
... | ... | |
272 | 274 |
|
273 | 275 |
.. code-block:: console |
274 | 276 |
|
275 |
[kamaki]: image register -f 'Debian Base Delta' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump --metafile=debian_base3.diskdump.meta
|
|
277 |
[kamaki]: image register -f 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta |
|
276 | 278 |
checksum: 3cb03556ec971f...e8dd6190443b560cb7 |
277 | 279 |
container-format: bare |
278 | 280 |
created-at: 2013-06-19 08:00:22 |
... | ... | |
326 | 328 |
|
327 | 329 |
.. code-block:: console |
328 | 330 |
|
329 |
[kamaki]: image register 'Debian Base Delta' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump --metafile=debian_base3.diskdump.meta --no-metafile-upload
|
|
331 |
[kamaki]: image register 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta --no-metafile-upload |
|
330 | 332 |
checksum: 3cb03556ec971f...e8dd6190443b560cb7 |
331 | 333 |
container-format: bare |
332 | 334 |
created-at: 2013-06-19 08:00:22 |
... | ... | |
436 | 438 |
container=... # e.g. pithos |
437 | 439 |
|
438 | 440 |
for path in images/*.diskdump; do |
439 |
location=pithos://$userid/$container/${path}
|
|
441 |
location=$container:${path}
|
|
440 | 442 |
kamaki image register $path $location |
441 | 443 |
done |
442 | 444 |
|
... | ... | |
449 | 451 |
.. code-block:: console |
450 | 452 |
|
451 | 453 |
$ for path in images/*.diskdump; do |
452 |
location=pithos://s0m3-u53r-1d/pithos/${path}
|
|
454 |
location=pithos:${path} |
|
453 | 455 |
echo "- - - Register ${path} - - -" |
454 | 456 |
kamaki image register $path $location --public |
455 | 457 |
done |
b/kamaki/cli/commands/image.py | ||
---|---|---|
153 | 153 |
|
154 | 154 |
def _validate_image_location(location): |
155 | 155 |
""" |
156 |
:param location: (str) pithos://<user-id>/<container>/<img-file-path>
|
|
156 |
:param location: (str) pithos://<user-id>/<container>/<image-path>
|
|
157 | 157 |
|
158 |
:returns: (<user-id>, <container>, <img-file-path>)
|
|
158 |
:returns: (<user-id>, <container>, <image-path>)
|
|
159 | 159 |
|
160 | 160 |
:raises AssertionError: if location is invalid |
161 | 161 |
""" |
... | ... | |
305 | 305 |
no_metafile_upload=FlagArgument( |
306 | 306 |
'Do not store metadata in remote meta file', |
307 | 307 |
('--no-metafile-upload')), |
308 |
|
|
308 |
container=ValueArgument( |
|
309 |
'Pithos+ container containing the image file', |
|
310 |
('-C', '--container')), |
|
311 |
uuid=ValueArgument('Custom user uuid', '--uuid') |
|
309 | 312 |
) |
310 | 313 |
|
311 | 314 |
def _get_user_id(self): |
... | ... | |
379 | 382 |
importance=2, details=[ |
380 | 383 |
'An image location is needed. Image location format:', |
381 | 384 |
' pithos://<user-id>/<container>/<path>', |
382 |
' an image file at the above location must exist.' |
|
385 |
' where an image file at the above location must exist.'
|
|
383 | 386 |
] + howto_image_file) |
384 | 387 |
try: |
385 | 388 |
return _validate_image_location(location) |
... | ... | |
391 | 394 |
' pithos://<user-id>/<container>/<img-file-path>' |
392 | 395 |
] + howto_image_file) |
393 | 396 |
|
397 |
def _mine_location(self, container_path): |
|
398 |
uuid = self['uuid'] or self._get_user_id() |
|
399 |
if self['container']: |
|
400 |
return uuid, self['container'], container_path |
|
401 |
container, sep, path = container_path.partition(':') |
|
402 |
if not (bool(container) and bool(path)): |
|
403 |
raiseCLIError( |
|
404 |
'Incorrect container-path format', importance=1, details=[ |
|
405 |
'Use : to seperate container form path', |
|
406 |
' <container>:<image-path>', |
|
407 |
'OR', |
|
408 |
'Use -C to specifiy a container', |
|
409 |
' -C <container> <image-path>'] + howto_image_file) |
|
410 |
|
|
411 |
return uuid, container, path |
|
412 |
|
|
394 | 413 |
@errors.generic.all |
395 | 414 |
@errors.plankton.connection |
396 |
def _run(self, name, location): |
|
397 |
(params, properties, location) = self._load_params_from_file(location) |
|
398 |
uuid, container, img_path = self._validate_location(location) |
|
415 |
def _run(self, name, uuid, container, img_path): |
|
416 |
location = 'pithos://%s/%s/%s' % (uuid, container, img_path) |
|
417 |
(params, properties, new_loc) = self._load_params_from_file(location) |
|
418 |
if location != new_loc: |
|
419 |
uuid, container, img_path = self._validate_location(new_loc) |
|
399 | 420 |
self._load_params_from_args(params, properties) |
400 | 421 |
pclient = self._get_pithos_client(container) |
401 | 422 |
|
... | ... | |
440 | 461 |
print('Metadata file uploaded as %s:%s (version %s)' % ( |
441 | 462 |
container, meta_path, meta_headers['x-object-version'])) |
442 | 463 |
|
443 |
def main(self, name, location):
|
|
464 |
def main(self, name, container___image_path):
|
|
444 | 465 |
super(self.__class__, self)._run() |
445 |
self._run(name, location)
|
|
466 |
self._run(name, *self._mine_location(container___image_path))
|
|
446 | 467 |
|
447 | 468 |
|
448 | 469 |
@command(image_cmds) |
Also available in: Unified diff