Revision c4aefeaf

b/kamaki/cli/commands/errors.py
358 358
        '* get a list of image ids: /image list',
359 359
        '* details of image: /flavor info <image id>']
360 360

  
361
    remote_image_file = [
362
        'Suggested usage:',
363
        '  /image register <image container>:<uploaded image file path>',
364
        'To set "image" as image container and "my_dir/img.diskdump" as',
365
        'the remote image file path, try one of the following:',
366
        '- <image container>:<remote path>',
367
        '    e.g. image:/my_dir/img.diskdump',
368
        '- <remote path> -C <image container>',
369
        '    e.g. /my_dir/img.diskdump -C image',
370
        'To check if the image file is accessible to current user:',
371
        '  /file list <image container>',
372
        'If the file is located under a different user id "us3r1d"',
373
        ' use the --fileowner=us3r1d  argument e.g.:',
374
        '  /image register "my" image:my_dir/img.diskdump --fileowner=us3r1d',
375
        'Note: The form pithos://<userid>/<container>/<path> is deprecated']
376

  
361 377
    @classmethod
362 378
    def connection(this, foo):
363 379
        return generic._connection(foo, 'image.url')
......
386 402
        def _raise(self, *args, **kwargs):
387 403
            key = kwargs.get('key', None)
388 404
            try:
389
                foo(self, *args, **kwargs)
405
                return foo(self, *args, **kwargs)
390 406
            except ClientError as ce:
391 407
                ce_msg = ('%s' % ce).lower()
392 408
                if ce.status == 404 or (
......
396 412
                raise
397 413
        return _raise
398 414

  
415
    @classmethod
416
    def image_file(this, foo):
417
        def _raise(self, name, container_path):
418
            try:
419
                return foo(self, name, container_path)
420
            except ClientError as ce:
421
                if ce.status in (400,):
422
                    raiseCLIError(
423
                        ce,
424
                        'Nonexistent location for %s' % container_path,
425
                        importance=2, details=this.remote_image_file)
426
                raise
427
        return _raise
428

  
399 429

  
400 430
class pithos(object):
401 431
    container_howto = [
b/kamaki/cli/commands/image.py
319 319
        return container, path
320 320

  
321 321
    @errors.generic.all
322
    @errors.plankton.image_file
322 323
    @errors.plankton.connection
323 324
    def _run(self, name, container_path):
324 325
        container, path = self._get_container_path(container_path)
......
351 352

  
352 353
        #load properties
353 354
        properties = dict()
354
        if self['property_file']:
355
            for k, v in _load_image_props(self['property_file']).items():
356
                properties[k.lower()] = v
355
        pfile = self['property_file']
356
        if pfile:
357
            try:
358
                for k, v in _load_image_props(pfile).items():
359
                    properties[k.lower()] = v
360
            except Exception as e:
361
                raiseCLIError(
362
                    e, 'Format error in property file %s' % pfile,
363
                    details=[
364
                        'Expected content format:',
365
                        '  {',
366
                        '    "key1": "value1",',
367
                        '    "key2": "value2",',
368
                        '    ...',
369
                        '  }',
370
                        '',
371
                        'Parser:'
372
                    ])
357 373
        for k, v in self['properties'].items():
358 374
            properties[k.lower()] = v
359 375

  
......
368 384
                    property_file_location='%s:%s' % (container, prop_path),
369 385
                    headers=prop_headers))
370 386
            else:
371
                print('Property file location is %s:%s with version %s' % (
387
                print('Property file uploaded as %s:%s (version %s)' % (
372 388
                    container, prop_path, prop_headers['x-object-version']))
373 389

  
374 390
    def main(self, name, container___path):

Also available in: Unified diff