Browse code

Move Nova account creation out of keystone_data.sh

Supports the coming HA/proxy configuration for Nova

Change-Id: I2baf1f51486537a1489f1376d38f5710bd96c314

Dean Troyer authored on 2012/12/12 07:52:37
Showing 3 changed files
... ...
@@ -5,7 +5,6 @@
5 5
 # Tenant               User       Roles
6 6
 # ------------------------------------------------------------------
7 7
 # service              glance     admin
8
-# service              nova       admin, [ResellerAdmin (swift only)]
9 8
 # service              quantum    admin        # if enabled
10 9
 # service              swift      admin        # if enabled
11 10
 # service              cinder     admin        # if enabled
... ...
@@ -53,29 +52,8 @@ RESELLER_ROLE=$(get_id keystone role-create --name=ResellerAdmin)
53 53
 # Services
54 54
 # --------
55 55
 
56
-# Nova
57
-if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
58
-    NOVA_USER=$(get_id keystone user-create \
59
-        --name=nova \
60
-        --pass="$SERVICE_PASSWORD" \
61
-        --tenant_id $SERVICE_TENANT \
62
-        --email=nova@example.com)
63
-    keystone user-role-add \
64
-        --tenant_id $SERVICE_TENANT \
65
-        --user_id $NOVA_USER \
66
-        --role_id $ADMIN_ROLE
67
-    if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
68
-        NOVA_SERVICE=$(get_id keystone service-create \
69
-            --name=nova \
70
-            --type=compute \
71
-            --description="Nova Compute Service")
72
-        keystone endpoint-create \
73
-            --region RegionOne \
74
-            --service_id $NOVA_SERVICE \
75
-            --publicurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s" \
76
-            --adminurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s" \
77
-            --internalurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s"
78
-    fi
56
+if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
57
+    NOVA_USER=$(keystone user-list | awk "/ nova / { print \$2 }")
79 58
     # Nova needs ResellerAdmin role to download images when accessing
80 59
     # swift through the s3 api.
81 60
     keystone user-role-add \
... ...
@@ -277,6 +277,46 @@ EOF'
277 277
     fi
278 278
 }
279 279
 
280
+# create_nova_accounts() - Set up common required nova accounts
281
+
282
+# Tenant               User       Roles
283
+# ------------------------------------------------------------------
284
+# service              nova       admin, [ResellerAdmin (swift only)]
285
+
286
+# Migrated from keystone_data.sh
287
+create_nova_accounts() {
288
+
289
+    SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
290
+    ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
291
+
292
+    # Nova
293
+    if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
294
+        NOVA_USER=$(keystone user-create \
295
+            --name=nova \
296
+            --pass="$SERVICE_PASSWORD" \
297
+            --tenant_id $SERVICE_TENANT \
298
+            --email=nova@example.com \
299
+            | grep " id " | get_field 2)
300
+        keystone user-role-add \
301
+            --tenant_id $SERVICE_TENANT \
302
+            --user_id $NOVA_USER \
303
+            --role_id $ADMIN_ROLE
304
+        if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
305
+            NOVA_SERVICE=$(keystone service-create \
306
+                --name=nova \
307
+                --type=compute \
308
+                --description="Nova Compute Service" \
309
+                | grep " id " | get_field 2)
310
+            keystone endpoint-create \
311
+                --region RegionOne \
312
+                --service_id $NOVA_SERVICE \
313
+                --publicurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s" \
314
+                --adminurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s" \
315
+                --internalurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s"
316
+        fi
317
+    fi
318
+}
319
+
280 320
 # create_nova_conf() - Create a new nova.conf file
281 321
 function create_nova_conf() {
282 322
     # Remove legacy ``nova.conf``
... ...
@@ -934,6 +934,7 @@ if is_service_enabled key; then
934 934
     export OS_SERVICE_TOKEN=$SERVICE_TOKEN
935 935
     export OS_SERVICE_ENDPOINT=$SERVICE_ENDPOINT
936 936
     create_keystone_accounts
937
+    create_nova_accounts
937 938
 
938 939
     # ``keystone_data.sh`` creates services, admin and demo users, and roles.
939 940
     ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD \