use lowercase name to check for user/tenant existence

keystone client's getuser/gettenant is case sensitive while create
is not, which will cause failure to create user or tenant with
letter case difference due to duplicate entry, so format user
name and tenant name to lowercase as the filter string and the
keystone ***-list output to lowercase as well,so that any case
of duplication could be avoided.
This is a work-around for keystoneclient bug: 1392035
Partial-bug: #1392035

Change-Id: I793fbef43d4321c6a991f89b6cfe0088fc24b58b
This commit is contained in:
Jerry Zhao 2014-11-21 11:55:17 -08:00
parent 1ddbdacdc5
commit 0cf3bd0de4
1 changed files with 4 additions and 2 deletions

View File

@ -65,7 +65,8 @@ if [ -z "$EMAIL" -o -z "$NAME" -o -z "$TENANT" -o -z "$USERCODE" -o -n "$EXTRA_A
fi
echo "Checking for user $USERCODE"
USER_ID=$(keystone user-get $USERCODE | awk '$2=="id" { print $4 }')
#TODO: fix after bug 1392035 in keystone client
USER_ID=$(keystone user-list | awk '{print tolower($0)}' |grep " ${USER_CODE,,} " |awk '{print$2}')
if [ -z "$USER_ID" ]; then
PASSWORD=''
if [ -e os-asserted-users ]; then
@ -79,7 +80,8 @@ if [ -z "$USER_ID" ]; then
--pass="$PASSWORD" \
--email="$EMAIL" | awk '$2=="id" {print $4}')
fi
TENANT_ID=$(keystone tenant-get $TENANT | awk '$2=="id" { print $4 }')
#TODO: fix after bug 1392035 in keystone client
TENANT_ID=$(keystone tenant-list | awk '{print tolower($0)}' |grep " ${TENANT,,} " |awk '{print$2}')
if [ -z "$TENANT_ID" ]; then
TENANT_ID=$(keystone tenant-create --name=$TENANT | awk '$2=="id" {print $4}')
fi