Revision 1d0f1ffa kamaki/cli/commands/image.py

b/kamaki/cli/commands/image.py
83 83
        if getattr(self, 'cloud', None):
84 84
            img_url = self._custom_url('image') or self._custom_url('plankton')
85 85
            if img_url:
86
                token = self._custom_token('image')\
87
                    or self._custom_token('plankton')\
88
                    or self.config.get_cloud(self.cloud, 'token')
86
                token = self._custom_token('image') or self._custom_token(
87
                    'plankton') or self.config.get_cloud(self.cloud, 'token')
89 88
                self.client = ImageClient(base_url=img_url, token=token)
90 89
                return
91 90
        if getattr(self, 'auth_base', False):
......
378 377
    )
379 378

  
380 379
    def _check_empty(self):
381
        for term in (
382
                'disk_format', 'container_format', 'status', 'properties'):
383
            if self[term]:
380
        for t in ('disk_format', 'container_format', 'status', 'properties'):
381
            if self[t]:
384 382
                return
385 383
        raiseCLIError(
386 384
            'Nothing to update, please use arguments (-h for a list)')
......
425 423
    arguments = dict(
426 424
        checksum=ValueArgument('Set image checksum', '--checksum'),
427 425
        container_format=ValueArgument(
428
            'Set container format',
429
            '--container-format'),
426
            'Set container format', '--container-format'),
430 427
        disk_format=ValueArgument('Set disk format', '--disk-format'),
431 428
        owner_name=ValueArgument('Set user uuid by user name', '--owner-name'),
432 429
        properties=KeyValueArgument(
......
461 458
        if getattr(self, 'auth_base', False):
462 459
            return self.auth_base.term('id', atoken)
463 460
        else:
464
            astakos_url = self.config.get('user', 'url')\
465
                or self.config.get('astakos', 'url')
461
            astakos_url = self.config.get('user', 'url') or self.config.get(
462
                'astakos', 'url')
466 463
            if not astakos_url:
467 464
                raise CLIBaseUrlError(service='astakos')
468 465
            user = AstakosClient(astakos_url, atoken)
......
494 491
            try:
495 492
                for k, v in _load_image_meta(pfile).items():
496 493
                    key = k.lower().replace('-', '_')
497
                    if k == 'properties':
494
                    if key == 'properties':
498 495
                        for pk, pv in v.items():
499 496
                            properties[pk.upper().replace('-', '_')] = pv
500 497
                    elif key == 'name':
......
639 636
                    meta_path, dumps(r, indent=2),
640 637
                    container_info_cache=self.container_info_cache)
641 638
            except TypeError:
642
                print('Failed to dump metafile %s:%s' % (dst_cont, meta_path))
639
                self.error(
640
                    'Failed to dump metafile %s:%s' % (dst_cont, meta_path))
643 641
                return
644 642
            if self['json_output']:
645 643
                print_json(dict(
646 644
                    metafile_location='%s:%s' % (dst_cont, meta_path),
647 645
                    headers=meta_headers))
648 646
            else:
649
                print('Metadata file uploaded as %s:%s (version %s)' % (
647
                self.error('Metadata file uploaded as %s:%s (version %s)' % (
650 648
                    dst_cont, meta_path, meta_headers['x-object-version']))
651 649

  
652 650
    def main(self, name, container___image_path):
......
775 773
    arguments = dict(
776 774
        detail=FlagArgument('show detailed output', ('-l', '--details')),
777 775
        limit=IntArgument('limit number listed images', ('-n', '--number')),
778
        more=FlagArgument(
779
            'output results in pages (-n to set items per page, default 10)',
780
            '--more'),
776
        more=FlagArgument('handle long lists of results', '--more'),
781 777
        enum=FlagArgument('Enumerate results', '--enumerate'),
782 778
        user_id=ValueArgument('filter by user_id', '--user-id'),
783 779
        user_name=ValueArgument('filter by username', '--user-name'),
......
917 913
        self._run(image_id=image_id, key=key)
918 914

  
919 915

  
920
#@command(image_cmds)
921
#class image_compute_properties_add(_init_cyclades, _optional_json):
922
#    """Add a property to an image"""
923
#
924
#    @errors.generic.all
925
#    @errors.cyclades.connection
926
#    @errors.plankton.id
927
#    @errors.plankton.metadata
928
#    def _run(self, image_id, key, val):
929
#        self._print(
930
#            self.client.create_image_metadata(image_id, key, val), print_dict)
931
#
932
#    def main(self, image_id, key, val):
933
#        super(self.__class__, self)._run()
934
#        self._run(image_id=image_id, key=key, val=val)
935

  
936

  
937 916
@command(image_cmds)
938 917
class image_compute_properties_set(_init_cyclades, _optional_json):
939 918
    """Add / update a set of properties for an image

Also available in: Unified diff