diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 40984fc43..9cb88feb0 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -722,6 +722,12 @@ class OpenStackCloud( # We don't need to track validity here, just get_token() each time. return self.keystone_session.get_token() + @property + def current_user_id(self): + """Get the id of the currently logged-in user from the token.""" + return self.keystone_session.auth.get_access( + self.keystone_session).user_id + @property def current_project_id(self): """Get the current project ID. diff --git a/shade/tests/functional/test_project.py b/shade/tests/functional/test_project.py index 5a0437be2..e4c999e69 100644 --- a/shade/tests/functional/test_project.py +++ b/shade/tests/functional/test_project.py @@ -63,8 +63,7 @@ class TestProject(base.KeystoneBaseFunctionalTestCase): self.assertEqual(project_name, project['name']) self.assertEqual('test_create_project', project['description']) - user_id = self.operator_cloud.keystone_session.auth.get_access( - self.operator_cloud.keystone_session).user_id + user_id = self.operator_cloud.current_user_id # Grant the current user access to the project self.assertTrue(self.operator_cloud.grant_role(