Skip to content

Commit d2ace93

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Converts bundle exercise to use swift/s3"
2 parents 504f871 + 77b0e1d commit d2ace93

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed

exercises/bundle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2`
5757
die_if_not_set AMI "Failure registering $BUCKET/$IMAGE"
5858

5959
# 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
6161
echo "Image $AMI not available within $REGISTER_TIMEOUT seconds"
6262
exit 1
6363
fi

files/default_catalog.templates

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ catalog.RegionOne.ec2.internalURL = http://%SERVICE_HOST%:8773/services/Cloud
2424
catalog.RegionOne.ec2.name = EC2 Service
2525

2626

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%
3030
catalog.RegionOne.s3.name = S3 Service
3131

3232

files/keystone.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ paste.app_factory = keystone.service:public_app_factory
7171
paste.app_factory = keystone.service:admin_app_factory
7272

7373
[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
7575

7676
[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
7878

7979
[app:public_version_service]
8080
paste.app_factory = keystone.service:public_version_app_factory

files/keystone_data.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# Initial data for Keystone using python-keystoneclient
44
#
55
# Tenant User Roles
6-
# -------------------------------------------------------
6+
# ------------------------------------------------------------------
77
# admin admin admin
88
# service glance admin
9-
# service nova admin
9+
# service nova admin, [ResellerAdmin (swift only)]
1010
# service quantum admin # if enabled
1111
# service swift admin # if enabled
1212
# demo admin admin
13-
# demo demo Member,anotherrole
13+
# demo demo Member, anotherrole
1414
# invisible_to_admin demo Member
1515
#
1616
# Variables set before calling this script:
@@ -96,6 +96,15 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
9696
keystone user-role-add --tenant_id $SERVICE_TENANT \
9797
--user $SWIFT_USER \
9898
--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
99108
fi
100109

101110
if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then

stack.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,18 @@ SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}
430430
# only some quick testing.
431431
SWIFT_REPLICAS=${SWIFT_REPLICAS:-3}
432432

433-
# We only ask for Swift Hash if we have enabled swift service.
434433
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.
435438
# SWIFT_HASH is a random unique string for a swift cluster that
436439
# can never change.
437440
read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
438441
fi
439442

443+
# Set default port for nova-objectstore
444+
S3_SERVICE_PORT=${S3_SERVICE_PORT:-3333}
440445

441446
# Keystone
442447
# --------
@@ -1017,6 +1022,9 @@ fi
10171022

10181023
# Storage Service
10191024
if is_service_enabled swift; then
1025+
# Install memcached for swift.
1026+
apt_get install memcached
1027+
10201028
# We first do a bit of setup by creating the directories and
10211029
# changing the permissions so we can run it as our user.
10221030

@@ -1176,7 +1184,7 @@ if is_service_enabled swift; then
11761184

11771185
# TODO: Bring some services in foreground.
11781186
# Launch all services.
1179-
swift-init all start
1187+
swift-init all restart
11801188

11811189
unset s swift_hash swift_auth_server
11821190
fi
@@ -1243,9 +1251,8 @@ add_nova_opt "root_helper=sudo /usr/local/bin/nova-rootwrap"
12431251
add_nova_opt "compute_scheduler_driver=$SCHEDULER"
12441252
add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF_DIR/$NOVA_CONF"
12451253
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
1254+
add_nova_opt "s3_host=$SERVICE_HOST"
1255+
add_nova_opt "s3_port=$S3_SERVICE_PORT"
12491256
if is_service_enabled quantum; then
12501257
add_nova_opt "network_manager=nova.network.quantum.manager.QuantumManager"
12511258
add_nova_opt "quantum_connection_host=$Q_HOST"
@@ -1471,6 +1478,7 @@ if is_service_enabled key; then
14711478

14721479
sudo sed -e "s,%SERVICE_HOST%,$SERVICE_HOST,g" -i $KEYSTONE_CATALOG
14731480

1481+
sudo sed -e "s,%S3_SERVICE_PORT%,$S3_SERVICE_PORT,g" -i $KEYSTONE_CATALOG
14741482

14751483
if [ "$SYSLOG" != "False" ]; then
14761484
cp $KEYSTONE_DIR/etc/logging.conf.sample $KEYSTONE_DIR/etc/logging.conf
@@ -1500,6 +1508,16 @@ if is_service_enabled key; then
15001508
SERVICE_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0
15011509
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 \
15021510
bash $FILES/keystone_data.sh
1511+
1512+
# create an access key and secret key for nova ec2 register image
1513+
if is_service_enabled swift && is_service_enabled nova; then
1514+
CREDS=$(keystone --os_auth_url=$SERVICE_ENDPOINT --os_username=nova --os_password=$SERVICE_PASSWORD --os_tenant_name=$SERVICE_TENANT_NAME ec2-credentials-create)
1515+
ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }')
1516+
SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }')
1517+
add_nova_opt "s3_access_key=$ACCESS_KEY"
1518+
add_nova_opt "s3_secret_key=$SECRET_KEY"
1519+
add_nova_opt "s3_affix_tenant=True"
1520+
fi
15031521
fi
15041522

15051523
# launch the nova-api and wait for it to answer before continuing

0 commit comments

Comments
 (0)