Use Keystone v3 API for user creation
This includes requiring a domain when creating a user. This will allow us to
control where users are created in a later patch.
Adding the token to the user creation call is required because of a bad
interaction between OpenStackClient, os-client-config and keystoneclient
when dealing with v2 authentication but v3 API calls. It will be cleaned
up when we switch to v3 credentials.
Change-Id: I6ef50fd384d423bc0f13ee1016a8bdbb0650ecd9
Implements: bp keystonev3
diff --git a/functions-common b/functions-common
index 33245fb..48c0c75 100644
--- a/functions-common
+++ b/functions-common
@@ -675,9 +675,8 @@
}
# Gets or creates group
-# Usage: get_or_create_group <groupname> [<domain> <description>]
+# Usage: get_or_create_group <groupname> <domain> [<description>]
function get_or_create_group {
- local domain=${2:+--domain ${2}}
local desc="${3:-}"
local os_url="$KEYSTONE_SERVICE_URI_V3"
# Gets group id
@@ -685,34 +684,30 @@
# Creates new group with --or-show
openstack --os-token=$OS_TOKEN --os-url=$os_url \
--os-identity-api-version=3 group create $1 \
- $domain --description "$desc" --or-show \
+ --domain $2 --description "$desc" --or-show \
-f value -c id
)
echo $group_id
}
# Gets or creates user
-# Usage: get_or_create_user <username> <password> [<email> [<domain>]]
+# Usage: get_or_create_user <username> <password> <domain> [<email>]
function get_or_create_user {
- if [[ ! -z "$3" ]]; then
- local email="--email=$3"
+ if [[ ! -z "$4" ]]; then
+ local email="--email=$4"
else
local email=""
fi
- local os_cmd="openstack"
- local domain=""
- if [[ ! -z "$4" ]]; then
- domain="--domain=$4"
- os_cmd="$os_cmd --os-url=$KEYSTONE_SERVICE_URI_V3 --os-identity-api-version=3"
- fi
# Gets user id
local user_id=$(
# Creates new user with --or-show
- $os_cmd user create \
+ openstack user create \
$1 \
--password "$2" \
+ --os-url=$KEYSTONE_SERVICE_URI_V3 \
+ --os-identity-api-version=3 \
+ --domain=$3 \
$email \
- $domain \
--or-show \
-f value -c id
)