Commit 1144594b authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-image-register-help' into develop

parents 3d6a513a b98ad4ba
......@@ -6,17 +6,18 @@ then is registered to the image service (Plankton). The image location at the
storage server is unique through out a deployment and also necessary for the
image to exist.
The image location format::
The image location format at user level::
pithos://<user id>/<container>/<object path>
<container>:<object path>
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
......@@ -58,6 +59,22 @@ Register the image object with the name 'Debian Base Alpha'
uploads it to the same location as the image. The meta file can be
downloaded and reused for more image registrations.
Another way to perform the two operations above is to call **/image register**
with the **\- -upload-image-file** argument. This single operation will upload
the image file and then register it as an image, and is equivalent to manually
calling **/file upload** and **/image register**.
In other words, the example that follows is equivalent to calling the two
operations above.
.. code-block:: console
[kamaki]: image register 'Debian Base Alpha'
Read the metafile
.. code-block:: console
......@@ -65,7 +65,8 @@ howto_image_file = [
' check available containers: /file list',
' create a new container: /file create <container>',
' check container contents: /file list <container>',
' upload files: /file upload <image file> <container>']
' upload files: /file upload <image file> <container>',
' register an image: /image register <image name> <container>:<path>']
about_image_id = ['To see a list of available image ids: /image list']
......@@ -541,10 +542,11 @@ class image_register(_init_image, _optional_json):
def _run(self, name, uuid, container, img_path):
def _run(self, name, uuid, dst_cont, img_path):
if self['local_image_path']:
with open(self['local_image_path']) as f:
pithos = self._get_pithos_client(container)
pithos = self._get_pithos_client(dst_cont)
(pbar, upload_cb) = self._safe_progress_bar('Uploading')
if pbar:
hash_bar = pbar.clone()
......@@ -555,12 +557,12 @@ class image_register(_init_image, _optional_json):
location = 'pithos://%s/%s/%s' % (uuid, container, img_path)
location = 'pithos://%s/%s/%s' % (uuid, dst_cont, 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)
uuid, dst_cont, img_path = self._validate_location(new_loc)
self._load_params_from_args(params, properties)
pclient = self._get_pithos_client(container)
pclient = self._get_pithos_client(dst_cont)
#check if metafile exists
meta_path = '%s.meta' % img_path
......@@ -569,7 +571,7 @@ class image_register(_init_image, _optional_json):
'Metadata file %s:%s already exists, abort' % (
container, meta_path),
dst_cont, meta_path),
details=['Registration ABORTED', 'Try -f to overwrite'])
except ClientError as ce:
if ce.status != 404:
......@@ -579,11 +581,12 @@ class image_register(_init_image, _optional_json):
r = self.client.register(name, location, params, properties)
except ClientError as ce:
if ce.status in (400, ):
if ce.status in (400, 404):
ce, 'Nonexistent image file location %s' % location,
ce, 'Nonexistent image file location\n\t%s' % location,
'Make sure the image file exists'] + howto_image_file)
'Does the image file %s exist at container %s ?' % (
img_path, dst_cont)] + howto_image_file)
r['owner'] += '( %s)' % self._uuid2username(r['owner'])
self._print(r, print_dict)
......@@ -595,15 +598,15 @@ class image_register(_init_image, _optional_json):
meta_path, dumps(r, indent=2),
except TypeError:
print('Failed to dump metafile %s:%s' % (container, meta_path))
print('Failed to dump metafile %s:%s' % (dst_cont, meta_path))
if self['json_output']:
metafile_location='%s:%s' % (container, meta_path),
metafile_location='%s:%s' % (dst_cont, meta_path),
print('Metadata file uploaded as %s:%s (version %s)' % (
container, meta_path, meta_headers['x-object-version']))
dst_cont, meta_path, meta_headers['x-object-version']))
def main(self, name, container___image_path):
super(self.__class__, self)._run()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment