From a98d369a39a4818f68333065f669d827e8216382 Mon Sep 17 00:00:00 2001 From: Rodrigo Duarte Sousa Date: Mon, 20 Feb 2017 09:47:18 -0300 Subject: [PATCH] Use *_as_ids instead *_as_list The parents_as_list and subtree_as_list query parameters limit the result to only parents and subtree where the user making the call has role assignments in. Since OSC only displays the IDs, the call would be the same as the similar *_as_ids queries, the difference is that the later doesn't enforce the role assignments (making it more useful). Output example by using this patch: $ openstack project show --children root +-------------+------------------------------+ | Field | Value | +-------------+------------------------------+ | description | | | domain_id | default | | enabled | True | | id | 123 | | is_domain | False | | name | root | | parent_id | default | | subtree | {u'456': None, u'789': None} | +-------------+------------------------------+ Change-Id: Ib7b37ae8f55190a7efcc375d5be4a2823d02d1a4 --- openstackclient/identity/v3/project.py | 11 ++-------- .../tests/unit/identity/v3/test_project.py | 20 +++++++++---------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py index 43eca2b525..da6aa7345d 100644 --- a/openstackclient/identity/v3/project.py +++ b/openstackclient/identity/v3/project.py @@ -348,15 +348,8 @@ class ShowProject(command.ShowOne): # identity manager.get() with kwargs directly. project = identity_client.projects.get( project.id, - parents_as_list=parsed_args.parents, - subtree_as_list=parsed_args.children) - - if project._info.get('parents'): - project._info['parents'] = [str(p['project']['id']) - for p in project._info['parents']] - if project._info.get('subtree'): - project._info['subtree'] = [str(p['project']['id']) - for p in project._info['subtree']] + parents_as_ids=parsed_args.parents, + subtree_as_ids=parsed_args.children) project._info.pop('links') return zip(*sorted(six.iteritems(project._info))) diff --git a/openstackclient/tests/unit/identity/v3/test_project.py b/openstackclient/tests/unit/identity/v3/test_project.py index b99eaf8506..3a035922ce 100644 --- a/openstackclient/tests/unit/identity/v3/test_project.py +++ b/openstackclient/tests/unit/identity/v3/test_project.py @@ -845,8 +845,8 @@ class TestProjectShow(TestProject): self.projects_mock.get.assert_has_calls([call(self.project.id), call(self.project.id, - parents_as_list=True, - subtree_as_list=False, + parents_as_ids=True, + subtree_as_ids=False, )]) collist = ( @@ -868,7 +868,7 @@ class TestProjectShow(TestProject): self.project.is_domain, self.project.name, self.project.parent_id, - [self.project.parent_id], + [{'project': {'id': self.project.parent_id}}] ) self.assertEqual(data, datalist) @@ -904,8 +904,8 @@ class TestProjectShow(TestProject): columns, data = self.cmd.take_action(parsed_args) self.projects_mock.get.assert_has_calls([call(self.project.id), call(self.project.id, - parents_as_list=False, - subtree_as_list=True, + parents_as_ids=False, + subtree_as_ids=True, )]) collist = ( @@ -927,7 +927,7 @@ class TestProjectShow(TestProject): self.project.is_domain, self.project.name, self.project.parent_id, - ['children-id'], + [{'project': {'id': 'children-id'}}] ) self.assertEqual(data, datalist) @@ -965,8 +965,8 @@ class TestProjectShow(TestProject): columns, data = self.cmd.take_action(parsed_args) self.projects_mock.get.assert_has_calls([call(self.project.id), call(self.project.id, - parents_as_list=True, - subtree_as_list=True, + parents_as_ids=True, + subtree_as_ids=True, )]) collist = ( @@ -989,7 +989,7 @@ class TestProjectShow(TestProject): self.project.is_domain, self.project.name, self.project.parent_id, - [self.project.parent_id], - ['children-id'], + [{'project': {'id': self.project.parent_id}}], + [{'project': {'id': 'children-id'}}] ) self.assertEqual(data, datalist)