pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
+The crussial element in an image location is the container (e.g. `pithos`) and
+the image object path (e.g. `debian_base3.diskdump`).
Register an image
-----------------
.. code-block:: console
- [kamaki]: image register 'Debian Base Alpha' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump
+ [kamaki]: image register 'Debian Base Alpha' pithos:debian_base3.diskdump
checksum: 3cb03556ec971f...e8dd6190443b560cb7
container-format: bare
created-at: 2013-06-19 08:00:22
Metadata file uploaded as pithos:debian_base3.diskdump.meta (version 1352)
[kamaki]:
-.. note:: The `image register` command automatically create a meta file and
+.. note:: The `image register` command automatically creates a meta file and
uploads it to the same location as the image. The meta file can be
downloaded and reused for more image registrations.
.. code-block:: console
- [kamaki]: image register 'Debian Base Gama' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump -p OS=Linux -p user=someuser
+ [kamaki]: image register 'Debian Base Gama' pithos:debian_base3.diskdump -p OS=Linux -p user=someuser
Metadata file pithos:debian_base3.diskdump.meta already exists
[kamaki]:
.. code-block:: console
- [kamaki]: image register -f 'Debian Base Gama' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump -p OS=Linux -p user=someuser
+ [kamaki]: image register -f 'Debian Base Gama' pithos:debian_base3.diskdump -p OS=Linux -p user=someuser
[kamaki]:
Register with a meta file
.. code-block:: console
- [kamaki]: image register -f 'Debian Base Delta' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump --metafile=debian_base3.diskdump.meta
+ [kamaki]: image register -f 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta
checksum: 3cb03556ec971f...e8dd6190443b560cb7
container-format: bare
created-at: 2013-06-19 08:00:22
.. code-block:: console
- [kamaki]: image register -f 'Debian Base Delta' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump --metafile=debian_base3.diskdump.meta
+ [kamaki]: image register -f 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta
checksum: 3cb03556ec971f...e8dd6190443b560cb7
container-format: bare
created-at: 2013-06-19 08:00:22
.. code-block:: console
- [kamaki]: image register 'Debian Base Delta' pithos://s0m3-u53r-1d/pithos/debian_base3.diskdump --metafile=debian_base3.diskdump.meta --no-metafile-upload
+ [kamaki]: image register 'Debian Base Delta' pithos:debian_base3.diskdump --metafile=debian_base3.diskdump.meta --no-metafile-upload
checksum: 3cb03556ec971f...e8dd6190443b560cb7
container-format: bare
created-at: 2013-06-19 08:00:22
container=... # e.g. pithos
for path in images/*.diskdump; do
- location=pithos://$userid/$container/${path}
+ location=$container:${path}
kamaki image register $path $location
done
.. code-block:: console
$ for path in images/*.diskdump; do
- location=pithos://s0m3-u53r-1d/pithos/${path}
+ location=pithos:${path}
echo "- - - Register ${path} - - -"
kamaki image register $path $location --public
done
def _validate_image_location(location):
"""
- :param location: (str) pithos://<user-id>/<container>/<img-file-path>
+ :param location: (str) pithos://<user-id>/<container>/<image-path>
- :returns: (<user-id>, <container>, <img-file-path>)
+ :returns: (<user-id>, <container>, <image-path>)
:raises AssertionError: if location is invalid
"""
no_metafile_upload=FlagArgument(
'Do not store metadata in remote meta file',
('--no-metafile-upload')),
-
+ container=ValueArgument(
+ 'Pithos+ container containing the image file',
+ ('-C', '--container')),
+ uuid=ValueArgument('Custom user uuid', '--uuid')
)
def _get_user_id(self):
importance=2, details=[
'An image location is needed. Image location format:',
' pithos://<user-id>/<container>/<path>',
- ' an image file at the above location must exist.'
+ ' where an image file at the above location must exist.'
] + howto_image_file)
try:
return _validate_image_location(location)
' pithos://<user-id>/<container>/<img-file-path>'
] + howto_image_file)
+ def _mine_location(self, container_path):
+ uuid = self['uuid'] or self._get_user_id()
+ if self['container']:
+ return uuid, self['container'], container_path
+ container, sep, path = container_path.partition(':')
+ if not (bool(container) and bool(path)):
+ raiseCLIError(
+ 'Incorrect container-path format', importance=1, details=[
+ 'Use : to seperate container form path',
+ ' <container>:<image-path>',
+ 'OR',
+ 'Use -C to specifiy a container',
+ ' -C <container> <image-path>'] + howto_image_file)
+
+ return uuid, container, path
+
@errors.generic.all
@errors.plankton.connection
- def _run(self, name, location):
- (params, properties, location) = self._load_params_from_file(location)
- uuid, container, img_path = self._validate_location(location)
+ def _run(self, name, uuid, container, img_path):
+ location = 'pithos://%s/%s/%s' % (uuid, container, img_path)
+ (params, properties, new_loc) = self._load_params_from_file(location)
+ if location != new_loc:
+ uuid, container, img_path = self._validate_location(new_loc)
self._load_params_from_args(params, properties)
pclient = self._get_pithos_client(container)
print('Metadata file uploaded as %s:%s (version %s)' % (
container, meta_path, meta_headers['x-object-version']))
- def main(self, name, location):
+ def main(self, name, container___image_path):
super(self.__class__, self)._run()
- self._run(name, location)
+ self._run(name, *self._mine_location(container___image_path))
@command(image_cmds)