Add a group create function, and a sample group
Slowly trying to introduce more v3 concepts into a generic
devstack installation.
Work with description of none and description with spaces
Change-Id: I7d2fde58363698ff020f92f129f1ff7378f945a8
diff --git a/functions-common b/functions-common
index 3b4309a..c3c8486 100644
--- a/functions-common
+++ b/functions-common
@@ -815,7 +815,7 @@
# Gets or creates a domain
# Usage: get_or_create_domain <name> <description>
function get_or_create_domain {
- local os_url="$KEYSTONE_SERVICE_URI/v3"
+ local os_url="$KEYSTONE_SERVICE_URI_V3"
# Gets domain id
local domain_id=$(
# Gets domain id
@@ -831,6 +831,23 @@
echo $domain_id
}
+# Gets or creates group
+# 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
+ local group_id=$(
+ # 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 \
+ -f value -c id
+ )
+ echo $group_id
+}
+
# Gets or creates user
# Usage: get_or_create_user <username> <password> <project> [<email> [<domain>]]
function get_or_create_user {
@@ -843,7 +860,7 @@
local domain=""
if [[ ! -z "$5" ]]; then
domain="--domain=$5"
- os_cmd="$os_cmd --os-url=$KEYSTONE_SERVICE_URI/v3 --os-identity-api-version=3"
+ os_cmd="$os_cmd --os-url=$KEYSTONE_SERVICE_URI_V3 --os-identity-api-version=3"
fi
# Gets user id
local user_id=$(
@@ -868,7 +885,7 @@
local domain=""
if [[ ! -z "$2" ]]; then
domain="--domain=$2"
- os_cmd="$os_cmd --os-url=$KEYSTONE_SERVICE_URI/v3 --os-identity-api-version=3"
+ os_cmd="$os_cmd --os-url=$KEYSTONE_SERVICE_URI_V3 --os-identity-api-version=3"
fi
local project_id=$(
# Creates new project with --or-show
diff --git a/lib/heat b/lib/heat
index 544ec45..d98b096 100644
--- a/lib/heat
+++ b/lib/heat
@@ -265,23 +265,21 @@
if [[ "$HEAT_STACK_DOMAIN" == "True" ]]; then
# Note we have to pass token/endpoint here because the current endpoint and
# version negotiation in OSC means just --os-identity-api-version=3 won't work
- local ks_endpoint_v3="$KEYSTONE_SERVICE_URI/v3"
-
- D_ID=$(openstack --os-token $OS_TOKEN --os-url=$ks_endpoint_v3 \
+ D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
--os-identity-api-version=3 domain list | grep ' heat ' | get_field 1)
if [[ -z "$D_ID" ]]; then
- D_ID=$(openstack --os-token $OS_TOKEN --os-url=$ks_endpoint_v3 \
+ D_ID=$(openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
--os-identity-api-version=3 domain create heat \
--description "Owns users and projects created by heat" \
| grep ' id ' | get_field 2)
iniset $HEAT_CONF DEFAULT stack_user_domain_id ${D_ID}
- openstack --os-token $OS_TOKEN --os-url=$ks_endpoint_v3 \
+ openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
--os-identity-api-version=3 user create --password $SERVICE_PASSWORD \
--domain $D_ID heat_domain_admin \
--description "Manages users and projects created by heat"
- openstack --os-token $OS_TOKEN --os-url=$ks_endpoint_v3 \
+ openstack --os-token $OS_TOKEN --os-url=$KEYSTONE_SERVICE_URI_V3 \
--os-identity-api-version=3 role add \
--user heat_domain_admin --domain ${D_ID} admin
iniset $HEAT_CONF DEFAULT stack_domain_admin heat_domain_admin
diff --git a/lib/keystone b/lib/keystone
index 1599fa5..219034b 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -106,6 +106,10 @@
KEYSTONE_AUTH_URI=${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_AUTH_HOST}:${KEYSTONE_AUTH_PORT}
KEYSTONE_SERVICE_URI=${KEYSTONE_SERVICE_PROTOCOL}://${KEYSTONE_SERVICE_HOST}:${KEYSTONE_SERVICE_PORT}
+# V3 URIs
+KEYSTONE_AUTH_URI_V3=$KEYSTONE_AUTH_URI/v3
+KEYSTONE_SERVICE_URI_V3=$KEYSTONE_SERVICE_URI/v3
+
# Functions
# ---------
# cleanup_keystone() - Remove residual data files, anything left over from previous
@@ -394,6 +398,9 @@
get_or_add_user_role $another_role $demo_user $demo_tenant
get_or_add_user_role $member_role $demo_user $invis_tenant
+ get_or_create_group "developers" "default" "openstack developers"
+ get_or_create_group "testers" "default"
+
# Keystone
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
diff --git a/lib/tempest b/lib/tempest
index d31119b..aea913d 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -278,7 +278,7 @@
# Identity
iniset $TEMPEST_CONFIG identity uri "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v2.0/"
- iniset $TEMPEST_CONFIG identity uri_v3 "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v3/"
+ iniset $TEMPEST_CONFIG identity uri_v3 "$KEYSTONE_SERVICE_URI_V3"
iniset $TEMPEST_CONFIG identity username $TEMPEST_USERNAME
iniset $TEMPEST_CONFIG identity password "$password"
iniset $TEMPEST_CONFIG identity tenant_name $TEMPEST_TENANT_NAME