From b632c9ef81090e210fee27346c6e1f2b4f3bedec Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Thu, 28 May 2015 23:36:15 +0000 Subject: [PATCH] Use keystone v3 API for projects Always use the keystone v3 API for project creation. Make domain a required argument. Whilst we could simply default this value within the function I think it's better to make this explicit as these are things deployers and services need to consider. In future we will want to figure out how we want devstack to organize domains however I don't believe that it belongs in this patch. Change-Id: Ib9587193c5c8419dc4b5a608246709baaddd2a52 Implements: bp keystonev3 --- functions-common | 15 ++++++--------- lib/ironic | 2 +- lib/keystone | 8 ++++---- lib/swift | 4 ++-- lib/tempest | 2 +- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/functions-common b/functions-common index 3a2f5f7f41..33245fbc3d 100644 --- a/functions-common +++ b/functions-common @@ -720,18 +720,15 @@ function get_or_create_user { } # Gets or creates project -# Usage: get_or_create_project [] +# Usage: get_or_create_project function get_or_create_project { - # Gets project id - local os_cmd="openstack" - local domain="" - if [[ ! -z "$2" ]]; then - domain="--domain=$2" - 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 - $os_cmd project create $1 $domain --or-show -f value -c id + openstack --os-url=$KEYSTONE_SERVICE_URI_V3 \ + --os-identity-api-version=3 \ + project create $1 \ + --domain=$2 \ + --or-show -f value -c id ) echo $project_id } diff --git a/lib/ironic b/lib/ironic index 4984be1861..40a3460f1f 100644 --- a/lib/ironic +++ b/lib/ironic @@ -366,7 +366,7 @@ function configure_ironic_conductor { fi iniset $IRONIC_CONF_FILE glance swift_endpoint_url http://${HOST_IP}:${SWIFT_DEFAULT_BIND_PORT:-8080} iniset $IRONIC_CONF_FILE glance swift_api_version v1 - local tenant_id=$(get_or_create_project $SERVICE_TENANT_NAME) + local tenant_id=$(get_or_create_project $SERVICE_TENANT_NAME default) iniset $IRONIC_CONF_FILE glance swift_account AUTH_${tenant_id} iniset $IRONIC_CONF_FILE glance swift_container glance iniset $IRONIC_CONF_FILE glance swift_temp_url_duration 3600 diff --git a/lib/keystone b/lib/keystone index 7a949cf96f..90ff31a54c 100644 --- a/lib/keystone +++ b/lib/keystone @@ -357,13 +357,13 @@ function configure_keystone_extensions { function create_keystone_accounts { # admin - local admin_tenant=$(get_or_create_project "admin") + local admin_tenant=$(get_or_create_project "admin" default) local admin_user=$(get_or_create_user "admin" "$ADMIN_PASSWORD") local admin_role=$(get_or_create_role "admin") get_or_add_user_project_role $admin_role $admin_user $admin_tenant # Create service project/role - get_or_create_project "$SERVICE_TENANT_NAME" + get_or_create_project "$SERVICE_TENANT_NAME" default # Service role, so service users do not have to be admins get_or_create_role service @@ -382,10 +382,10 @@ function create_keystone_accounts { local another_role=$(get_or_create_role "anotherrole") # invisible tenant - admin can't see this one - local invis_tenant=$(get_or_create_project "invisible_to_admin") + local invis_tenant=$(get_or_create_project "invisible_to_admin" default) # demo - local demo_tenant=$(get_or_create_project "demo") + local demo_tenant=$(get_or_create_project "demo" default) local demo_user=$(get_or_create_user "demo" \ "$ADMIN_PASSWORD" "demo@example.com") diff --git a/lib/swift b/lib/swift index 820042d972..420350b95e 100644 --- a/lib/swift +++ b/lib/swift @@ -616,7 +616,7 @@ function create_swift_accounts { "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s" fi - local swift_tenant_test1=$(get_or_create_project swifttenanttest1) + local swift_tenant_test1=$(get_or_create_project swifttenanttest1 default) die_if_not_set $LINENO swift_tenant_test1 "Failure creating swift_tenant_test1" SWIFT_USER_TEST1=$(get_or_create_user swiftusertest1 $swiftusertest1_password "test@example.com") die_if_not_set $LINENO SWIFT_USER_TEST1 "Failure creating SWIFT_USER_TEST1" @@ -626,7 +626,7 @@ function create_swift_accounts { die_if_not_set $LINENO swift_user_test3 "Failure creating swift_user_test3" get_or_add_user_project_role $another_role $swift_user_test3 $swift_tenant_test1 - local swift_tenant_test2=$(get_or_create_project swifttenanttest2) + local swift_tenant_test2=$(get_or_create_project swifttenanttest2 default) die_if_not_set $LINENO swift_tenant_test2 "Failure creating swift_tenant_test2" local swift_user_test2=$(get_or_create_user swiftusertest2 $swiftusertest2_password "test2@example.com") diff --git a/lib/tempest b/lib/tempest index c4ae05f534..4e7133a0db 100644 --- a/lib/tempest +++ b/lib/tempest @@ -546,7 +546,7 @@ function create_tempest_accounts { if is_service_enabled tempest; then # Tempest has some tests that validate various authorization checks # between two regular users in separate tenants - get_or_create_project alt_demo + get_or_create_project alt_demo default get_or_create_user alt_demo "$ADMIN_PASSWORD" "alt_demo@example.com" get_or_add_user_project_role Member alt_demo alt_demo fi