Enable swift by default.

- Set by default SWIFT_REPLICAS to 1 since this is the most common use
  case when using it in devstack.
- If we have swift_replicas to 1 launch the object container account and
  proxy servers in foreground in screen.
- Allow any s- services if we have just 'swift' in service enabled
  instead of having to specify all s- services to enable swift. This will be
  removed in the future.
- Set object server starting at 6013 instead of 6010 to not conflict
  with remote ssh x11 forwarding.

Change-Id: I890b6953b70283bfa0927fff0cf5e92f3c08455b
This commit is contained in:
Chmouel Boudjnah 2013-03-06 10:58:33 +01:00
parent 0d71d1ec56
commit 0c3a5584c6
11 changed files with 64 additions and 35 deletions

View File

@ -85,19 +85,21 @@ Example (Qpid):
# Swift # Swift
Swift is not installed by default, you can enable easily by adding this to your `localrc`: Swift is enabled by default configured with only one replica to avoid being IO/memory intensive on a small vm. When running with only one replica the account, container and object services will run directly in screen. The others services like replicator, updaters or auditor runs in background.
enable_service swift If you would like to disable Swift you can add this to your `localrc` :
disable_service s-proxy s-object s-container s-account
If you want a minimal Swift install with only Swift and Keystone you can have this instead in your `localrc`: If you want a minimal Swift install with only Swift and Keystone you can have this instead in your `localrc`:
disable_all_services disable_all_services
enable_service key mysql swift enable_service key mysql s-proxy s-object s-container s-account
If you use Swift with Keystone, Swift will authenticate against it. You will need to make sure to use the Keystone URL to auth against. If you only want to do some testing of a real normal swift cluster with multiple replicas you can do so by customizing the variable `SWIFT_REPLICAS` in your `localrc` (usually to 3).
# Swift S3
If you are enabling `swift3` in `ENABLED_SERVICES` devstack will install the swift3 middleware emulation. Swift will be configured to act as a S3 endpoint for Keystone so effectively replacing the `nova-objectstore`. If you are enabling `swift3` in `ENABLED_SERVICES` devstack will install the swift3 middleware emulation. Swift will be configured to act as a S3 endpoint for Keystone so effectively replacing the `nova-objectstore`.
Only Swift proxy server is launched in the screen session all other services are started in background and managed by `swift-init` tool. Only Swift proxy server is launched in the screen session all other services are started in background and managed by `swift-init` tool.
By default Swift will configure 3 replicas (and one spare) which could be IO intensive on a small vm, if you only want to do some quick testing of the API you can choose to only have one replica by customizing the variable `SWIFT_REPLICAS` in your `localrc`.

View File

@ -136,7 +136,7 @@ fi
# Swift client # Swift client
# ------------ # ------------
if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
STATUS_SWIFT="Skipped" STATUS_SWIFT="Skipped"
else else

View File

@ -144,7 +144,8 @@ fi
# Swift client # Swift client
# ------------ # ------------
if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
STATUS_SWIFT="Skipped" STATUS_SWIFT="Skipped"
else else

View File

@ -35,7 +35,7 @@ source $TOP_DIR/exerciserc
# If swift is not enabled we exit with exitcode 55 which mean # If swift is not enabled we exit with exitcode 55 which mean
# exercise is skipped. # exercise is skipped.
is_service_enabled swift || exit 55 is_service_enabled s-proxy || exit 55
# Container name # Container name
CONTAINER=ex-swift CONTAINER=ex-swift

View File

@ -52,7 +52,7 @@ RESELLER_ROLE=$(get_id keystone role-create --name=ResellerAdmin)
# Services # Services
# -------- # --------
if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "swift" ]]; then if [[ "$ENABLED_SERVICES" =~ "n-api" ]] && [[ "$ENABLED_SERVICES" =~ "s-proxy" || "$ENABLED_SERVICES" =~ "swift" ]]; then
NOVA_USER=$(keystone user-list | awk "/ nova / { print \$2 }") NOVA_USER=$(keystone user-list | awk "/ nova / { print \$2 }")
# Nova needs ResellerAdmin role to download images when accessing # Nova needs ResellerAdmin role to download images when accessing
# swift through the s3 api. # swift through the s3 api.
@ -123,7 +123,8 @@ if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
fi fi
# Swift # Swift
if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
SWIFT_USER=$(get_id keystone user-create \ SWIFT_USER=$(get_id keystone user-create \
--name=swift \ --name=swift \
--pass="$SERVICE_PASSWORD" \ --pass="$SERVICE_PASSWORD" \
@ -190,7 +191,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
fi fi
# S3 # S3
if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift" ]]; then if [[ "$ENABLED_SERVICES" =~ "n-obj" || "$ENABLED_SERVICES" =~ "swift3" ]]; then
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
S3_SERVICE=$(get_id keystone service-create \ S3_SERVICE=$(get_id keystone service-create \
--name=s3 \ --name=s3 \

View File

@ -181,6 +181,10 @@ function get_packages() {
if [[ ! $file_to_parse =~ ceilometer ]]; then if [[ ! $file_to_parse =~ ceilometer ]]; then
file_to_parse="${file_to_parse} ceilometer" file_to_parse="${file_to_parse} ceilometer"
fi fi
elif [[ $service == s-* ]]; then
if [[ ! $file_to_parse =~ swift ]]; then
file_to_parse="${file_to_parse} swift"
fi
elif [[ $service == n-* ]]; then elif [[ $service == n-* ]]; then
if [[ ! $file_to_parse =~ nova ]]; then if [[ ! $file_to_parse =~ nova ]]; then
file_to_parse="${file_to_parse} nova" file_to_parse="${file_to_parse} nova"
@ -566,6 +570,9 @@ $option = $value
# **ceilometer** returns true if any service enabled start with **ceilometer** # **ceilometer** returns true if any service enabled start with **ceilometer**
# **glance** returns true if any service enabled start with **g-** # **glance** returns true if any service enabled start with **g-**
# **quantum** returns true if any service enabled start with **q-** # **quantum** returns true if any service enabled start with **q-**
# **swift** returns true if any service enabled start with **s-**
# For backward compatibility if we have **swift** in ENABLED_SERVICES all the
# **s-** services will be enabled. This will be deprecated in the future.
# #
# Uses global ``ENABLED_SERVICES`` # Uses global ``ENABLED_SERVICES``
# is_service_enabled service [service ...] # is_service_enabled service [service ...]
@ -578,6 +585,8 @@ function is_service_enabled() {
[[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0 [[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0
[[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0 [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
[[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0 [[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
[[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && return 0
[[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && return 0
done done
return 1 return 1
} }

View File

@ -146,7 +146,7 @@ function configure_keystone() {
cp -p $FILES/default_catalog.templates $KEYSTONE_CATALOG cp -p $FILES/default_catalog.templates $KEYSTONE_CATALOG
# Add swift endpoints to service catalog if swift is enabled # Add swift endpoints to service catalog if swift is enabled
if is_service_enabled swift; then if is_service_enabled s-proxy; then
echo "catalog.RegionOne.object_store.publicURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG echo "catalog.RegionOne.object_store.publicURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG
echo "catalog.RegionOne.object_store.adminURL = http://%SERVICE_HOST%:8080/" >> $KEYSTONE_CATALOG echo "catalog.RegionOne.object_store.adminURL = http://%SERVICE_HOST%:8080/" >> $KEYSTONE_CATALOG
echo "catalog.RegionOne.object_store.internalURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG echo "catalog.RegionOne.object_store.internalURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG

View File

@ -56,17 +56,18 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}
SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}
# Set ``SWIFT_REPLICAS`` to configure how many replicas are to be # Set ``SWIFT_REPLICAS`` to configure how many replicas are to be
# configured for your Swift cluster. By default the three replicas would need a # configured for your Swift cluster. By default we are configuring
# bit of IO and Memory on a VM you may want to lower that to 1 if you want to do # only one replica since this is way less CPU and memory intensive. If
# only some quick testing. # you are planning to test swift replication you may want to set this
SWIFT_REPLICAS=${SWIFT_REPLICAS:-3} # up to 3.
SWIFT_REPLICAS=${SWIFT_REPLICAS:-1}
SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS}) SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS})
# Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE`` # Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE``
# Port bases used in port number calclution for the service "nodes" # Port bases used in port number calclution for the service "nodes"
# The specified port number will be used, the additinal ports calculated by # The specified port number will be used, the additinal ports calculated by
# base_port + node_num * 10 # base_port + node_num * 10
OBJECT_PORT_BASE=6010 OBJECT_PORT_BASE=6013
CONTAINER_PORT_BASE=6011 CONTAINER_PORT_BASE=6011
ACCOUNT_PORT_BASE=6012 ACCOUNT_PORT_BASE=6012
@ -359,19 +360,34 @@ function start_swift() {
sudo systemctl start xinetd.service sudo systemctl start xinetd.service
fi fi
# First spawn all the swift services then kill the # By default with only one replica we are launching the proxy,
# proxy service so we can run it in foreground in screen. # container, account and object server in screen in foreground and
# ``swift-init ... {stop|restart}`` exits with '1' if no servers are running, # other services in background. If we have SWIFT_REPLICAS set to something
# ignore it just in case # greater than one we first spawn all the swift services then kill the proxy
# service so we can run it in foreground in screen. ``swift-init ...
# {stop|restart}`` exits with '1' if no servers are running, ignore it just
# in case
swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
swift-init --run-dir=${SWIFT_DATA_DIR}/run proxy stop || true if [[ ${SWIFT_REPLICAS} == 1 ]];then
screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v" todo="object container account"
fi
for type in proxy ${todo};do
swift-init --run-dir=${SWIFT_DATA_DIR}/run ${type} stop || true
done
screen_it s-proxy "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"
if [[ ${SWIFT_REPLICAS} == 1 ]];then
for type in object container account;do
screen_it s-${type} "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-${type}-server ${SWIFT_CONFIG_DIR}/${type}-server/1.conf -v"
done
fi
} }
# stop_swift() - Stop running processes (non-screen) # stop_swift() - Stop running processes (non-screen)
function stop_swift() { function stop_swift() {
# screen normally killed by unstack.sh # screen normally killed by unstack.sh
if type -p swift-init >/dev/null;then
swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
fi
} }
# Restore xtrace # Restore xtrace

View File

@ -425,7 +425,7 @@ if is_service_enabled rabbit; then
read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT." read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT."
fi fi
if is_service_enabled swift; then if is_service_enabled s-proxy; then
# If we are using swift3, we can default the s3 port to swift instead # If we are using swift3, we can default the s3 port to swift instead
# of nova-objectstore # of nova-objectstore
if is_service_enabled swift3;then if is_service_enabled swift3;then
@ -662,12 +662,12 @@ install_novaclient
git_clone $OPENSTACKCLIENT_REPO $OPENSTACKCLIENT_DIR $OPENSTACKCLIENT_BRANCH git_clone $OPENSTACKCLIENT_REPO $OPENSTACKCLIENT_DIR $OPENSTACKCLIENT_BRANCH
# glance, swift middleware and nova api needs keystone middleware # glance, swift middleware and nova api needs keystone middleware
if is_service_enabled key g-api n-api swift; then if is_service_enabled key g-api n-api s-proxy; then
# unified auth system (manages accounts/tokens) # unified auth system (manages accounts/tokens)
install_keystone install_keystone
fi fi
if is_service_enabled swift; then if is_service_enabled s-proxy; then
install_swiftclient install_swiftclient
install_swift install_swift
if is_service_enabled swift3; then if is_service_enabled swift3; then
@ -724,10 +724,10 @@ echo_summary "Configuring OpenStack projects"
configure_keystoneclient configure_keystoneclient
configure_novaclient configure_novaclient
setup_develop $OPENSTACKCLIENT_DIR setup_develop $OPENSTACKCLIENT_DIR
if is_service_enabled key g-api n-api swift; then if is_service_enabled key g-api n-api s-proxy; then
configure_keystone configure_keystone
fi fi
if is_service_enabled swift; then if is_service_enabled s-proxy; then
configure_swift configure_swift
configure_swiftclient configure_swiftclient
if is_service_enabled swift3; then if is_service_enabled swift3; then
@ -911,7 +911,7 @@ if is_service_enabled g-reg; then
init_glance init_glance
# Store the images in swift if enabled. # Store the images in swift if enabled.
if is_service_enabled swift; then if is_service_enabled s-proxy; then
iniset $GLANCE_API_CONF DEFAULT default_store swift iniset $GLANCE_API_CONF DEFAULT default_store swift
iniset $GLANCE_API_CONF DEFAULT swift_store_auth_address $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ iniset $GLANCE_API_CONF DEFAULT swift_store_auth_address $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/
iniset $GLANCE_API_CONF DEFAULT swift_store_user $SERVICE_TENANT_NAME:glance iniset $GLANCE_API_CONF DEFAULT swift_store_user $SERVICE_TENANT_NAME:glance
@ -970,7 +970,7 @@ fi
# Storage Service # Storage Service
# --------------- # ---------------
if is_service_enabled swift; then if is_service_enabled s-proxy; then
echo_summary "Configuring Swift" echo_summary "Configuring Swift"
init_swift init_swift
fi fi
@ -1117,7 +1117,7 @@ fi
# Only run the services specified in ``ENABLED_SERVICES`` # Only run the services specified in ``ENABLED_SERVICES``
# Launch Swift Services # Launch Swift Services
if is_service_enabled swift; then if is_service_enabled s-proxy; then
echo_summary "Starting Swift" echo_summary "Starting Swift"
start_swift start_swift
fi fi

View File

@ -21,7 +21,7 @@ fi
# ``disable_service`` functions in ``localrc``. # ``disable_service`` functions in ``localrc``.
# For example, to enable Swift add this to ``localrc``: # For example, to enable Swift add this to ``localrc``:
# enable_service swift # enable_service swift
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,mysql ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,s-proxy,s-account,s-object,s-container,horizon,rabbit,tempest,mysql
# Set the default Nova APIs to enable # Set the default Nova APIs to enable
NOVA_ENABLED_APIS=ec2,osapi_compute,metadata NOVA_ENABLED_APIS=ec2,osapi_compute,metadata

View File

@ -63,7 +63,7 @@ if [[ -n "$SCREEN" ]]; then
fi fi
# Swift runs daemons # Swift runs daemons
if is_service_enabled swift; then if is_service_enabled s-proxy; then
stop_swift stop_swift
cleanup_swift cleanup_swift
fi fi