summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Duarte Sousa <rduartes@redhat.com>2017-02-20 09:47:18 -0300
committerRodrigo Duarte Sousa <rduartes@redhat.com>2017-03-01 23:24:11 -0300
commita98d369a39a4818f68333065f669d827e8216382 (patch)
treea000125b43dd72810772d2a2eecc98a64fe7fa89
parent98d5641ac5b99dc47cd72941b71303547f9e6054 (diff)
downloadpython-openstackclient-a98d369a39a4818f68333065f669d827e8216382.tar.gz
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
-rw-r--r--openstackclient/identity/v3/project.py11
-rw-r--r--openstackclient/tests/unit/identity/v3/test_project.py20
2 files changed, 12 insertions, 19 deletions
diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py
index 43eca2b5..da6aa734 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 b99eaf85..3a035922 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)