Skip to content

Commit 8df31a1

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Assign admin role for admin user on default domain"
2 parents a3ab686 + 59c6377 commit 8df31a1

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

functions-common

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,38 @@ function get_or_add_user_domain_role {
896896
echo $user_role_id
897897
}
898898

899+
# Gets or adds user role to domain
900+
# Usage: get_or_add_user_domain_role <role> <user> <domain>
901+
function get_or_add_user_domain_role {
902+
local user_role_id
903+
# Gets user role id
904+
user_role_id=$(openstack role list \
905+
--user $2 \
906+
--os-url=$KEYSTONE_SERVICE_URI_V3 \
907+
--os-identity-api-version=3 \
908+
--column "ID" \
909+
--domain $3 \
910+
--column "Name" \
911+
| grep " $1 " | get_field 1)
912+
if [[ -z "$user_role_id" ]]; then
913+
# Adds role to user and get it
914+
openstack role add $1 \
915+
--user $2 \
916+
--domain $3 \
917+
--os-url=$KEYSTONE_SERVICE_URI_V3 \
918+
--os-identity-api-version=3
919+
user_role_id=$(openstack role list \
920+
--user $2 \
921+
--os-url=$KEYSTONE_SERVICE_URI_V3 \
922+
--os-identity-api-version=3 \
923+
--column "ID" \
924+
--domain $3 \
925+
--column "Name" \
926+
| grep " $1 " | get_field 1)
927+
fi
928+
echo $user_role_id
929+
}
930+
899931
# Gets or adds group role to project
900932
# Usage: get_or_add_group_project_role <role> <group> <project>
901933
function get_or_add_group_project_role {

lib/keystone

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ function create_keystone_accounts {
332332
local admin_role
333333
admin_role=$(get_or_create_role "admin")
334334
get_or_add_user_project_role $admin_role $admin_user $admin_tenant
335+
get_or_add_user_domain_role $admin_role $admin_user default
335336

336337
# Create service project/role
337338
get_or_create_project "$SERVICE_TENANT_NAME" default

0 commit comments

Comments
 (0)