Skip to content

Commit a98d369

Browse files
author
Rodrigo Duarte Sousa
committed
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
1 parent 98d5641 commit a98d369

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

openstackclient/identity/v3/project.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,8 @@ def take_action(self, parsed_args):
348348
# identity manager.get() with kwargs directly.
349349
project = identity_client.projects.get(
350350
project.id,
351-
parents_as_list=parsed_args.parents,
352-
subtree_as_list=parsed_args.children)
353-
354-
if project._info.get('parents'):
355-
project._info['parents'] = [str(p['project']['id'])
356-
for p in project._info['parents']]
357-
if project._info.get('subtree'):
358-
project._info['subtree'] = [str(p['project']['id'])
359-
for p in project._info['subtree']]
351+
parents_as_ids=parsed_args.parents,
352+
subtree_as_ids=parsed_args.children)
360353

361354
project._info.pop('links')
362355
return zip(*sorted(six.iteritems(project._info)))

openstackclient/tests/unit/identity/v3/test_project.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,8 @@ def test_project_show_parents(self):
845845

846846
self.projects_mock.get.assert_has_calls([call(self.project.id),
847847
call(self.project.id,
848-
parents_as_list=True,
849-
subtree_as_list=False,
848+
parents_as_ids=True,
849+
subtree_as_ids=False,
850850
)])
851851

852852
collist = (
@@ -868,7 +868,7 @@ def test_project_show_parents(self):
868868
self.project.is_domain,
869869
self.project.name,
870870
self.project.parent_id,
871-
[self.project.parent_id],
871+
[{'project': {'id': self.project.parent_id}}]
872872
)
873873
self.assertEqual(data, datalist)
874874

@@ -904,8 +904,8 @@ def test_project_show_subtree(self):
904904
columns, data = self.cmd.take_action(parsed_args)
905905
self.projects_mock.get.assert_has_calls([call(self.project.id),
906906
call(self.project.id,
907-
parents_as_list=False,
908-
subtree_as_list=True,
907+
parents_as_ids=False,
908+
subtree_as_ids=True,
909909
)])
910910

911911
collist = (
@@ -927,7 +927,7 @@ def test_project_show_subtree(self):
927927
self.project.is_domain,
928928
self.project.name,
929929
self.project.parent_id,
930-
['children-id'],
930+
[{'project': {'id': 'children-id'}}]
931931
)
932932
self.assertEqual(data, datalist)
933933

@@ -965,8 +965,8 @@ def test_project_show_parents_and_children(self):
965965
columns, data = self.cmd.take_action(parsed_args)
966966
self.projects_mock.get.assert_has_calls([call(self.project.id),
967967
call(self.project.id,
968-
parents_as_list=True,
969-
subtree_as_list=True,
968+
parents_as_ids=True,
969+
subtree_as_ids=True,
970970
)])
971971

972972
collist = (
@@ -989,7 +989,7 @@ def test_project_show_parents_and_children(self):
989989
self.project.is_domain,
990990
self.project.name,
991991
self.project.parent_id,
992-
[self.project.parent_id],
993-
['children-id'],
992+
[{'project': {'id': self.project.parent_id}}],
993+
[{'project': {'id': 'children-id'}}]
994994
)
995995
self.assertEqual(data, datalist)

0 commit comments

Comments
 (0)