Revision cf115aed kamaki/cli/commands/image.py

b/kamaki/cli/commands/image.py
482 482
                    details=[
483 483
                        'Make sure the image file exists'] + howto_image_file)
484 484
            raise
485
        r['owner'] += '( %s)' % self._uuid2username(r['owner'])
485 486
        self._print(r, print_dict)
486 487

  
487 488
        #upload the metadata file
......
528 529
    @errors.generic.all
529 530
    @errors.plankton.connection
530 531
    def _run(self, member):
531
        self._print(self.client.list_shared(member), title=('image_id',))
532
        r = self.client.list_shared(member)
533
        if r:
534
            uuid = self._username2uuid(member)
535
            r = self.client.list_shared(uuid) if uuid else []
536
        self._print(r, title=('image_id',))
532 537

  
533
    def main(self, member):
538
    def main(self, member_id_or_username):
534 539
        super(self.__class__, self)._run()
535
        self._run(member)
540
        self._run(member_id_or_username)
536 541

  
537 542

  
538 543
@command(image_cmds)
......
548 553
    @errors.plankton.connection
549 554
    @errors.plankton.id
550 555
    def _run(self, image_id):
551
        self._print(self.client.list_members(image_id), title=('member_id',))
556
        members = self.client.list_members(image_id)
557
        if not self['json_output']:
558
            uuids = [member['member_id'] for member in members]
559
            usernames = self._uuids2usernames(uuids)
560
            for member in members:
561
                member['member_id'] += ' (%s)' % usernames[member['member_id']]
562
        self._print(members, title=('member_id',))
552 563

  
553 564
    def main(self, image_id):
554 565
        super(self.__class__, self)._run()
......
565 576
    def _run(self, image_id=None, member=None):
566 577
            self._optional_output(self.client.add_member(image_id, member))
567 578

  
568
    def main(self, image_id, member):
579
    def main(self, image_id, member_id):
569 580
        super(self.__class__, self)._run()
570
        self._run(image_id=image_id, member=member)
581
        self._run(image_id=image_id, member=member_id)
571 582

  
572 583

  
573 584
@command(image_cmds)
......
595 606
    def _run(self, image_id, members):
596 607
            self._optional_output(self.client.set_members(image_id, members))
597 608

  
598
    def main(self, image_id, *members):
609
    def main(self, image_id, *member_ids):
599 610
        super(self.__class__, self)._run()
600
        self._run(image_id=image_id, members=members)
611
        self._run(image_id=image_id, members=member_ids)
601 612

  
602 613

  
603 614
# Compute Image Commands
......
695 706
    @errors.plankton.id
696 707
    def _run(self, image_id):
697 708
        image = self.client.get_image_details(image_id)
709
        uuids = [image['user_id'], image['tenant_id']]
710
        usernames = self._uuids2usernames(uuids)
711
        image['user_id'] += ' (%s)' % usernames[image['user_id']]
712
        image['tenant_id'] += ' (%s)' % usernames[image['tenant_id']]
698 713
        self._print(image, print_dict)
699 714

  
700 715
    def main(self, image_id):

Also available in: Unified diff