From 50821bed081e94dfd4b75cf02121a42a56cdbaac Mon Sep 17 00:00:00 2001 From: Roxana Gherle Date: Tue, 22 Sep 2015 10:52:46 -0700 Subject: [PATCH] Fix return value of get_or_add_user_project_role get_or_add_user_project_role function was always returning an empty user_role_id because the role assignment command does not return any output. Added a command to get the user_role_id after the assignment happens. Closes-Bug: #1498599 Change-Id: If1b77eef0d4f0ebdcdf761ecb5e2011484f73871 --- functions-common | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/functions-common b/functions-common index cf140072fd..d230a29891 100644 --- a/functions-common +++ b/functions-common @@ -830,14 +830,20 @@ function get_or_add_user_project_role { --column "Name" \ | grep " $1 " | get_field 1) if [[ -z "$user_role_id" ]]; then - # Adds role to user - user_role_id=$(openstack role add \ - $1 \ + # Adds role to user and get it + openstack role add $1 \ --user $2 \ --project $3 \ --os-url=$KEYSTONE_SERVICE_URI_V3 \ + --os-identity-api-version=3 + user_role_id=$(openstack role list \ + --user $2 \ + --os-url=$KEYSTONE_SERVICE_URI_V3 \ --os-identity-api-version=3 \ - | grep " id " | get_field 2) + --column "ID" \ + --project $3 \ + --column "Name" \ + | grep " $1 " | get_field 1) fi echo $user_role_id }