Browse code

Merge "Use keystone v3 API for projects"

Jenkins authored on 2015/07/01 02:15:54
Showing 5 changed files
... ...
@@ -740,18 +740,15 @@ function get_or_create_user {
740 740
 }
741 741
 
742 742
 # Gets or creates project
743
-# Usage: get_or_create_project <name> [<domain>]
743
+# Usage: get_or_create_project <name> <domain>
744 744
 function get_or_create_project {
745
-    # Gets project id
746
-    local os_cmd="openstack"
747
-    local domain=""
748
-    if [[ ! -z "$2" ]]; then
749
-        domain="--domain=$2"
750
-        os_cmd="$os_cmd --os-url=$KEYSTONE_SERVICE_URI_V3 --os-identity-api-version=3"
751
-    fi
752 745
     local project_id=$(
753 746
         # Creates new project with --or-show
754
-        $os_cmd project create $1 $domain --or-show -f value -c id
747
+        openstack --os-url=$KEYSTONE_SERVICE_URI_V3 \
748
+            --os-identity-api-version=3 \
749
+            project create $1 \
750
+            --domain=$2 \
751
+            --or-show -f value -c id
755 752
     )
756 753
     echo $project_id
757 754
 }
... ...
@@ -366,7 +366,7 @@ function configure_ironic_conductor {
366 366
         fi
367 367
         iniset $IRONIC_CONF_FILE glance swift_endpoint_url http://${HOST_IP}:${SWIFT_DEFAULT_BIND_PORT:-8080}
368 368
         iniset $IRONIC_CONF_FILE glance swift_api_version v1
369
-        local tenant_id=$(get_or_create_project $SERVICE_TENANT_NAME)
369
+        local tenant_id=$(get_or_create_project $SERVICE_TENANT_NAME default)
370 370
         iniset $IRONIC_CONF_FILE glance swift_account AUTH_${tenant_id}
371 371
         iniset $IRONIC_CONF_FILE glance swift_container glance
372 372
         iniset $IRONIC_CONF_FILE glance swift_temp_url_duration 3600
... ...
@@ -357,13 +357,13 @@ function configure_keystone_extensions {
357 357
 function create_keystone_accounts {
358 358
 
359 359
     # admin
360
-    local admin_tenant=$(get_or_create_project "admin")
360
+    local admin_tenant=$(get_or_create_project "admin" default)
361 361
     local admin_user=$(get_or_create_user "admin" "$ADMIN_PASSWORD")
362 362
     local admin_role=$(get_or_create_role "admin")
363 363
     get_or_add_user_project_role $admin_role $admin_user $admin_tenant
364 364
 
365 365
     # Create service project/role
366
-    get_or_create_project "$SERVICE_TENANT_NAME"
366
+    get_or_create_project "$SERVICE_TENANT_NAME" default
367 367
 
368 368
     # Service role, so service users do not have to be admins
369 369
     get_or_create_role service
... ...
@@ -382,10 +382,10 @@ function create_keystone_accounts {
382 382
     local another_role=$(get_or_create_role "anotherrole")
383 383
 
384 384
     # invisible tenant - admin can't see this one
385
-    local invis_tenant=$(get_or_create_project "invisible_to_admin")
385
+    local invis_tenant=$(get_or_create_project "invisible_to_admin" default)
386 386
 
387 387
     # demo
388
-    local demo_tenant=$(get_or_create_project "demo")
388
+    local demo_tenant=$(get_or_create_project "demo" default)
389 389
     local demo_user=$(get_or_create_user "demo" \
390 390
         "$ADMIN_PASSWORD" "demo@example.com")
391 391
 
... ...
@@ -616,7 +616,7 @@ function create_swift_accounts {
616 616
             "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s"
617 617
     fi
618 618
 
619
-    local swift_tenant_test1=$(get_or_create_project swifttenanttest1)
619
+    local swift_tenant_test1=$(get_or_create_project swifttenanttest1 default)
620 620
     die_if_not_set $LINENO swift_tenant_test1 "Failure creating swift_tenant_test1"
621 621
     SWIFT_USER_TEST1=$(get_or_create_user swiftusertest1 $swiftusertest1_password "test@example.com")
622 622
     die_if_not_set $LINENO SWIFT_USER_TEST1 "Failure creating SWIFT_USER_TEST1"
... ...
@@ -626,7 +626,7 @@ function create_swift_accounts {
626 626
     die_if_not_set $LINENO swift_user_test3 "Failure creating swift_user_test3"
627 627
     get_or_add_user_project_role $another_role $swift_user_test3 $swift_tenant_test1
628 628
 
629
-    local swift_tenant_test2=$(get_or_create_project swifttenanttest2)
629
+    local swift_tenant_test2=$(get_or_create_project swifttenanttest2 default)
630 630
     die_if_not_set $LINENO swift_tenant_test2 "Failure creating swift_tenant_test2"
631 631
 
632 632
     local swift_user_test2=$(get_or_create_user swiftusertest2 $swiftusertest2_password "test2@example.com")
... ...
@@ -550,7 +550,7 @@ function create_tempest_accounts {
550 550
     if is_service_enabled tempest; then
551 551
         # Tempest has some tests that validate various authorization checks
552 552
         # between two regular users in separate tenants
553
-        get_or_create_project alt_demo
553
+        get_or_create_project alt_demo default
554 554
         get_or_create_user alt_demo "$ADMIN_PASSWORD" "alt_demo@example.com"
555 555
         get_or_add_user_project_role Member alt_demo alt_demo
556 556
     fi