Browse code

Move swift stuff out of keystone-data.sh

- Fixes bug 1199918.

Change-Id: I808bdd74a94c8e0ca126b9bee1bfd53eafa189a9

Chmouel Boudjnah authored on 2013/07/11 04:03:43
Showing 2 changed files
... ...
@@ -5,7 +5,6 @@
5 5
 # Tenant               User       Roles
6 6
 # ------------------------------------------------------------------
7 7
 # service              glance     admin
8
-# service              swift      service        # if enabled
9 8
 # service              heat       service        # if enabled
10 9
 # service              ceilometer admin          # if enabled
11 10
 # Tempest Only:
... ...
@@ -124,32 +123,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
124 124
     fi
125 125
 fi
126 126
 
127
-# Swift
128
-
129
-if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
130
-    SWIFT_USER=$(get_id keystone user-create \
131
-        --name=swift \
132
-        --pass="$SERVICE_PASSWORD" \
133
-        --tenant_id $SERVICE_TENANT \
134
-        --email=swift@example.com)
135
-    keystone user-role-add \
136
-        --tenant_id $SERVICE_TENANT \
137
-        --user_id $SWIFT_USER \
138
-        --role_id $SERVICE_ROLE
139
-    if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
140
-        SWIFT_SERVICE=$(get_id keystone service-create \
141
-            --name=swift \
142
-            --type="object-store" \
143
-            --description="Swift Service")
144
-        keystone endpoint-create \
145
-            --region RegionOne \
146
-            --service_id $SWIFT_SERVICE \
147
-            --publicurl "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s" \
148
-            --adminurl "http://$SERVICE_HOST:8080" \
149
-            --internalurl "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s"
150
-    fi
151
-fi
152
-
127
+# Ceilometer
153 128
 if [[ "$ENABLED_SERVICES" =~ "ceilometer" ]]; then
154 129
     CEILOMETER_USER=$(get_id keystone user-create --name=ceilometer \
155 130
                                               --pass="$SERVICE_PASSWORD" \
... ...
@@ -357,18 +357,39 @@ function create_swift_disk() {
357 357
         sudo chown -R $USER: ${node}
358 358
     done
359 359
 }
360
-# create_swift_accounts() - Set up common required swift accounts for tests we
361
-# are all attach names since we want to make it compatible with tempauth which
362
-# use underscores for separators.
360
+# create_swift_accounts() - Set up standard swift accounts and extra
361
+# one for tests we do this by attaching all words in the account name
362
+# since we want to make it compatible with tempauth which use
363
+# underscores for separators.
363 364
 
364 365
 # Tenant               User       Roles
365 366
 # ------------------------------------------------------------------
367
+# service            swift              service
366 368
 # swifttenanttest1   swiftusertest1     admin
367 369
 # swifttenanttest1   swiftusertest3     anotherrole
368 370
 # swifttenanttest2   swiftusertest2     admin
369 371
 
370
-# Migrated from keystone_data.sh
371 372
 function create_swift_accounts() {
373
+    KEYSTONE_CATALOG_BACKEND=${KEYSTONE_CATALOG_BACKEND:-sql}
374
+
375
+    SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
376
+    ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
377
+
378
+    SWIFT_USER=$(keystone user-create --name=swift --pass="$SERVICE_PASSWORD" \
379
+        --tenant_id $SERVICE_TENANT --email=swift@example.com | grep " id " | get_field 2)
380
+    keystone user-role-add --tenant_id $SERVICE_TENANT --user_id $SWIFT_USER --role_id $ADMIN_ROLE
381
+
382
+    if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
383
+        SWIFT_SERVICE=$(keystone service-create --name=swift --type="object-store" \
384
+            --description="Swift Service" | grep " id " | get_field 2)
385
+        keystone endpoint-create \
386
+            --region RegionOne \
387
+            --service_id $SWIFT_SERVICE \
388
+            --publicurl "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s" \
389
+            --adminurl "http://$SERVICE_HOST:8080" \
390
+            --internalurl "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s"
391
+    fi
392
+
372 393
     SWIFT_TENANT_TEST1=$(keystone tenant-create --name=swifttenanttest1 | grep " id " | get_field 2)
373 394
     SWIFT_USER_TEST1=$(keystone user-create --name=swiftusertest1 --pass=testing --email=test@example.com | grep " id " | get_field 2)
374 395
     keystone user-role-add --user_id $SWIFT_USER_TEST1 --role_id $ADMIN_ROLE --tenant_id $SWIFT_TENANT_TEST1