This patch adds an admin role assignment for the admin user on
the default domain as part of the Keystone configuration stage.
(Cherry-picked from 59c6377ae51c024c28a6fba72de567bc97edda10)
Closes-Bug: #1494081
Change-Id: I91c88917bd51be4572e4970c94e65d866798df26
| ... | ... |
@@ -856,6 +856,38 @@ function get_or_add_user_project_role {
|
| 856 | 856 |
echo $user_role_id |
| 857 | 857 |
} |
| 858 | 858 |
|
| 859 |
+# Gets or adds user role to domain |
|
| 860 |
+# Usage: get_or_add_user_domain_role <role> <user> <domain> |
|
| 861 |
+function get_or_add_user_domain_role {
|
|
| 862 |
+ local user_role_id |
|
| 863 |
+ # Gets user role id |
|
| 864 |
+ user_role_id=$(openstack role list \ |
|
| 865 |
+ --user $2 \ |
|
| 866 |
+ --os-url=$KEYSTONE_SERVICE_URI_V3 \ |
|
| 867 |
+ --os-identity-api-version=3 \ |
|
| 868 |
+ --column "ID" \ |
|
| 869 |
+ --domain $3 \ |
|
| 870 |
+ --column "Name" \ |
|
| 871 |
+ | grep " $1 " | get_field 1) |
|
| 872 |
+ if [[ -z "$user_role_id" ]]; then |
|
| 873 |
+ # Adds role to user and get it |
|
| 874 |
+ openstack role add $1 \ |
|
| 875 |
+ --user $2 \ |
|
| 876 |
+ --domain $3 \ |
|
| 877 |
+ --os-url=$KEYSTONE_SERVICE_URI_V3 \ |
|
| 878 |
+ --os-identity-api-version=3 |
|
| 879 |
+ user_role_id=$(openstack role list \ |
|
| 880 |
+ --user $2 \ |
|
| 881 |
+ --os-url=$KEYSTONE_SERVICE_URI_V3 \ |
|
| 882 |
+ --os-identity-api-version=3 \ |
|
| 883 |
+ --column "ID" \ |
|
| 884 |
+ --domain $3 \ |
|
| 885 |
+ --column "Name" \ |
|
| 886 |
+ | grep " $1 " | get_field 1) |
|
| 887 |
+ fi |
|
| 888 |
+ echo $user_role_id |
|
| 889 |
+} |
|
| 890 |
+ |
|
| 859 | 891 |
# Gets or adds group role to project |
| 860 | 892 |
# Usage: get_or_add_group_project_role <role> <group> <project> |
| 861 | 893 |
function get_or_add_group_project_role {
|
| ... | ... |
@@ -351,6 +351,7 @@ function create_keystone_accounts {
|
| 351 | 351 |
local admin_user=$(get_or_create_user "admin" "$ADMIN_PASSWORD" default) |
| 352 | 352 |
local admin_role=$(get_or_create_role "admin") |
| 353 | 353 |
get_or_add_user_project_role $admin_role $admin_user $admin_tenant |
| 354 |
+ get_or_add_user_domain_role $admin_role $admin_user default |
|
| 354 | 355 |
|
| 355 | 356 |
# Create service project/role |
| 356 | 357 |
get_or_create_project "$SERVICE_TENANT_NAME" default |