Revision cf115aed

b/kamaki/cli/commands/cyclades.py
292 292
    @errors.cyclades.connection
293 293
    @errors.cyclades.server_id
294 294
    def _run(self, server_id):
295
        self._print(self.client.get_server_details(server_id), print_dict)
295
        vm = self.client.get_server_details(server_id)
296
        uuids = self._uuids2usernames([vm['user_id'], vm['tenant_id']])
297
        vm['user_id'] += ' (%s)' % uuids[vm['user_id']]
298
        vm['tenant_id'] += ' (%s)' % uuids[vm['tenant_id']]
299
        self._print(vm, print_dict)
296 300

  
297 301
    def main(self, server_id):
298 302
        super(self.__class__, self)._run()
......
355 359
    def _run(self, name, flavor_id, image_id):
356 360
        r = self.client.create_server(
357 361
            name, int(flavor_id), image_id, self['personality'])
362
        usernames = self._uuids2usernames([r['user_id'], r['tenant_id']])
363
        r['user_id'] += ' (%s)' % usernames[r['user_id']]
364
        r['tenant_id'] += ' (%s)' % usernames[r['tenant_id']]
358 365
        self._print(r, print_dict)
359 366
        if self['wait']:
360 367
            self._wait(r['id'], r['status'])
......
781 788
        self._run(flavor_id=flavor_id)
782 789

  
783 790

  
791
def _add_name(self, net):
792
        user_id, tenant_id, uuids = net['user_id'], net['tenant_id'], []
793
        if user_id:
794
            uuids.append(user_id)
795
        if tenant_id:
796
            uuids.append(tenant_id)
797
        if uuids:
798
            usernames = self._uuids2usernames(uuids)
799
            if user_id:
800
                net['user_id'] += ' (%s)' % usernames[user_id]
801
            if tenant_id:
802
                net['tenant_id'] += ' (%s)' % usernames[tenant_id]
803

  
804

  
784 805
@command(network_cmds)
785 806
class network_info(_init_cyclades, _optional_json):
786 807
    """Detailed information on a network
......
792 813
    @errors.cyclades.network_id
793 814
    def _run(self, network_id):
794 815
        network = self.client.get_network_details(int(network_id))
816
        _add_name(self, network)
795 817
        self._print(network, print_dict, exclude=('id'))
796 818

  
797 819
    def main(self, network_id):
......
920 942
            gateway=self['gateway'],
921 943
            dhcp=self['dhcp'],
922 944
            type=self['type'])
945
        _add_name(self, r)
923 946
        self._print(r, print_dict)
924

  
925 947
        if self['wait']:
926 948
            self._wait(r['id'], 'PENDING')
927 949

  
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):
b/kamaki/cli/commands/pithos.py
1509 1509
                    until=self['until'], delimiter=self['delimiter']))
1510 1510
            else:
1511 1511
                print('Aborted')
1512
        else:
1512
        elif self.container:
1513 1513
            if self['recursive']:
1514 1514
                ask_msg = 'Delete container contents'
1515 1515
            else:
......
1519 1519
                    until=self['until'], delimiter=self['delimiter']))
1520 1520
            else:
1521 1521
                print('Aborted')
1522
        else:
1523
            raiseCLIError('Nothing to delete, please provide container[:path]')
1522 1524

  
1523 1525
    def main(self, container____path__=None):
1524 1526
        super(self.__class__, self)._run(container____path__)
......
2054 2056
    @errors.pithos.connection
2055 2057
    def _run(self):
2056 2058
        accounts = self.client.get_sharing_accounts(marker=self['marker'])
2057
        uuids = [acc['name'] for acc in accounts]
2058
        try:
2059
            astakos_responce = self.auth_base.post_user_catalogs(uuids)
2060
            usernames = astakos_responce.json
2061
            r = usernames['uuid_catalog']
2062
        except Exception as e:
2063
            print 'WARNING: failed to call user_catalogs, %s' % e
2064
            r = dict(sharer_uuid=uuids)
2065
            usernames = accounts
2066
        if self['json_output'] or self['detail']:
2067
            self._print(usernames)
2068
        else:
2069
            self._print(r, print_dict)
2059
        if not self['json_output']:
2060
            usernames = self._uuids2usernames(
2061
                [acc['name'] for acc in accounts])
2062
            for item in accounts:
2063
                uuid = item['name']
2064
                item['id'], item['name'] = uuid, usernames[uuid]
2065
                if not self['detail']:
2066
                    item.pop('last_modified')
2067
        self._print(accounts)
2070 2068

  
2071 2069
    def main(self):
2072 2070
        super(self.__class__, self)._run()

Also available in: Unified diff