Move get_user_by_username to common part
get_user_by_username of keystone service client is just wrapper method
and it should be moved from the client for implementing it as library.
Partially implements blueprint consistent-service-method-names
Change-Id: Ib44c0b2d085ef2b8f488d804c1c57e078323ce78
diff --git a/tempest/common/identity.py b/tempest/common/identity.py
index 303f620..2179363 100644
--- a/tempest/common/identity.py
+++ b/tempest/common/identity.py
@@ -22,3 +22,11 @@
if tenant['name'] == tenant_name:
return tenant
raise lib_exc.NotFound('No such tenant(%s) in %s' % (tenant_name, tenants))
+
+
+def get_user_by_username(client, tenant_id, username):
+ users = client.list_tenant_users(tenant_id)['users']
+ for user in users:
+ if user['name'] == username:
+ return user
+ raise lib_exc.NotFound('No such user(%s) in %s' % (username, users))