Browse code

Converts bundle exercise to use swift/s3

- Fix keystone s3token configuration (in admin api not public api).
- Set s3 service in keystone to swift if installed.
- Fixes a bug in bundle.sh
- Adds config options for nova to use swift as s3 store

Change-Id: Ic2fca5aba06a25c0b3a74f1e97d062390a8e2ab1

Chmouel Boudjnah authored on 2012/03/01 01:55:43
Showing 5 changed files
... ...
@@ -57,7 +57,7 @@ AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2`
57 57
 die_if_not_set AMI "Failure registering $BUCKET/$IMAGE"
58 58
 
59 59
 # Wait for the image to become available
60
-if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep '$AMI' | grep 'available'; do sleep 1; done"; then
60
+if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep $AMI | grep -q available; do sleep 1; done"; then
61 61
     echo "Image $AMI not available within $REGISTER_TIMEOUT seconds"
62 62
     exit 1
63 63
 fi
... ...
@@ -24,9 +24,9 @@ catalog.RegionOne.ec2.internalURL = http://%SERVICE_HOST%:8773/services/Cloud
24 24
 catalog.RegionOne.ec2.name = EC2 Service
25 25
 
26 26
 
27
-catalog.RegionOne.s3.publicURL = http://%SERVICE_HOST%:3333
28
-catalog.RegionOne.s3.adminURL = http://%SERVICE_HOST%:3333
29
-catalog.RegionOne.s3.internalURL = http://%SERVICE_HOST%:3333
27
+catalog.RegionOne.s3.publicURL = http://%SERVICE_HOST%:%S3_SERVICE_PORT%
28
+catalog.RegionOne.s3.adminURL = http://%SERVICE_HOST%:%S3_SERVICE_PORT%
29
+catalog.RegionOne.s3.internalURL = http://%SERVICE_HOST%:%S3_SERVICE_PORT%
30 30
 catalog.RegionOne.s3.name = S3 Service
31 31
 
32 32
 
... ...
@@ -71,10 +71,10 @@ paste.app_factory = keystone.service:public_app_factory
71 71
 paste.app_factory = keystone.service:admin_app_factory
72 72
 
73 73
 [pipeline:public_api]
74
-pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension s3_extension public_service
74
+pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension public_service
75 75
 
76 76
 [pipeline:admin_api]
77
-pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension crud_extension admin_service
77
+pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension s3_extension crud_extension admin_service
78 78
 
79 79
 [app:public_version_service]
80 80
 paste.app_factory = keystone.service:public_version_app_factory
... ...
@@ -3,14 +3,14 @@
3 3
 # Initial data for Keystone using python-keystoneclient
4 4
 #
5 5
 # Tenant               User      Roles
6
-# -------------------------------------------------------
6
+# ------------------------------------------------------------------
7 7
 # admin                admin     admin
8 8
 # service              glance    admin
9
-# service              nova      admin
9
+# service              nova      admin, [ResellerAdmin (swift only)]
10 10
 # service              quantum   admin        # if enabled
11 11
 # service              swift     admin        # if enabled
12 12
 # demo                 admin     admin
13
-# demo                 demo      Member,anotherrole
13
+# demo                 demo      Member, anotherrole
14 14
 # invisible_to_admin   demo      Member
15 15
 #
16 16
 # Variables set before calling this script:
... ...
@@ -96,6 +96,15 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
96 96
     keystone user-role-add --tenant_id $SERVICE_TENANT \
97 97
                            --user $SWIFT_USER \
98 98
                            --role $ADMIN_ROLE
99
+    # Nova needs ResellerAdmin role to download images when accessing
100
+    # swift through the s3 api. The admin role in swift allows a user
101
+    # to act as an admin for their tenant, but ResellerAdmin is needed
102
+    # for a user to act as any tenant. The name of this role is also
103
+    # configurable in swift-proxy.conf
104
+    RESELLER_ROLE=$(get_id keystone role-create --name=ResellerAdmin)
105
+    keystone user-role-add --tenant_id $SERVICE_TENANT \
106
+                           --user $NOVA_USER \
107
+                           --role $RESELLER_ROLE
99 108
 fi
100 109
 
101 110
 if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then
... ...
@@ -430,13 +430,18 @@ SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}
430 430
 # only some quick testing.
431 431
 SWIFT_REPLICAS=${SWIFT_REPLICAS:-3}
432 432
 
433
-# We only ask for Swift Hash if we have enabled swift service.
434 433
 if is_service_enabled swift; then
434
+    # If we are using swift, we can default the s3 port to swift instead
435
+    # of nova-objectstore
436
+    S3_SERVICE_PORT=${S3_SERVICE_PORT:-8080}
437
+    # We only ask for Swift Hash if we have enabled swift service.
435 438
     # SWIFT_HASH is a random unique string for a swift cluster that
436 439
     # can never change.
437 440
     read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
438 441
 fi
439 442
 
443
+# Set default port for nova-objectstore
444
+S3_SERVICE_PORT=${S3_SERVICE_PORT:-3333}
440 445
 
441 446
 # Keystone
442 447
 # --------
... ...
@@ -1017,6 +1022,9 @@ fi
1017 1017
 
1018 1018
 # Storage Service
1019 1019
 if is_service_enabled swift; then
1020
+    # Install memcached for swift.
1021
+    apt_get install memcached
1022
+
1020 1023
     # We first do a bit of setup by creating the directories and
1021 1024
     # changing the permissions so we can run it as our user.
1022 1025
 
... ...
@@ -1176,7 +1184,7 @@ if is_service_enabled swift; then
1176 1176
 
1177 1177
    # TODO: Bring some services in foreground.
1178 1178
    # Launch all services.
1179
-   swift-init all start
1179
+   swift-init all restart
1180 1180
 
1181 1181
    unset s swift_hash swift_auth_server
1182 1182
 fi
... ...
@@ -1243,9 +1251,8 @@ add_nova_opt "root_helper=sudo /usr/local/bin/nova-rootwrap"
1243 1243
 add_nova_opt "compute_scheduler_driver=$SCHEDULER"
1244 1244
 add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF_DIR/$NOVA_CONF"
1245 1245
 add_nova_opt "fixed_range=$FIXED_RANGE"
1246
-if is_service_enabled n-obj; then
1247
-    add_nova_opt "s3_host=$SERVICE_HOST"
1248
-fi
1246
+add_nova_opt "s3_host=$SERVICE_HOST"
1247
+add_nova_opt "s3_port=$S3_SERVICE_PORT"
1249 1248
 if is_service_enabled quantum; then
1250 1249
     add_nova_opt "network_manager=nova.network.quantum.manager.QuantumManager"
1251 1250
     add_nova_opt "quantum_connection_host=$Q_HOST"
... ...
@@ -1471,6 +1478,7 @@ if is_service_enabled key; then
1471 1471
 
1472 1472
     sudo sed -e "s,%SERVICE_HOST%,$SERVICE_HOST,g" -i $KEYSTONE_CATALOG
1473 1473
 
1474
+    sudo sed -e "s,%S3_SERVICE_PORT%,$S3_SERVICE_PORT,g" -i $KEYSTONE_CATALOG
1474 1475
 
1475 1476
     if [ "$SYSLOG" != "False" ]; then
1476 1477
         cp $KEYSTONE_DIR/etc/logging.conf.sample $KEYSTONE_DIR/etc/logging.conf
... ...
@@ -1500,6 +1508,16 @@ if is_service_enabled key; then
1500 1500
     SERVICE_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0
1501 1501
     ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD SERVICE_TOKEN=$SERVICE_TOKEN SERVICE_ENDPOINT=$SERVICE_ENDPOINT DEVSTACK_DIR=$TOP_DIR ENABLED_SERVICES=$ENABLED_SERVICES \
1502 1502
         bash $FILES/keystone_data.sh
1503
+
1504
+    # create an access key and secret key for nova ec2 register image
1505
+    if is_service_enabled swift && is_service_enabled nova; then
1506
+        CREDS=$(keystone --os_auth_url=$SERVICE_ENDPOINT --os_username=nova --os_password=$SERVICE_PASSWORD --os_tenant_name=$SERVICE_TENANT_NAME ec2-credentials-create)
1507
+        ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }')
1508
+        SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }')
1509
+        add_nova_opt "s3_access_key=$ACCESS_KEY"
1510
+        add_nova_opt "s3_secret_key=$SECRET_KEY"
1511
+        add_nova_opt "s3_affix_tenant=True"
1512
+    fi
1503 1513
 fi
1504 1514
 
1505 1515
 # launch the nova-api and wait for it to answer before continuing