Update to match new Glance paste deploy configuration.

This commit is contained in:
Adam Gandelman 2012-01-20 13:38:00 -08:00
parent aa024b3387
commit ced2514f62
3 changed files with 35 additions and 12 deletions

View File

@ -1,10 +1,12 @@
#!/bin/bash
#$!/bin/bash
SERVICES="glance-api glance-registry"
PACKAGES="glance python-mysqldb python-swift python-keystone"
GLANCE_REGISTRY_CONF=$(config-get registry-config)
GLANCE_REGISTRY_PASTE_INI="/etc/glance/glance-registry-paste.ini"
GLANCE_API_CONF=$(config-get api-config)
GLANCE_API_PASTE_INI="/etc/glance/glance-api-paste.ini"
DB_USER=$(config-get db-user)
NOVA_DB=$(config-get nova-db)
@ -49,6 +51,25 @@ function glance_ctl {
done
}
function set_paste_deploy_flavor {
local flavor="$1"
local config="$2"
case $config in
"api") local conf=$GLANCE_API_CONF ;;
"registry") local conf=$GLANCE_REGISTRY_CONF ;;
*) juju-log "ERROR: set_paste_deploy: invalid config=$config" && exit 1 ;;
esac
if ! grep -q "\[paste_deploy\]" "$conf" ; then
juju-log "Updating $conf: Setting new paste_deploy flavor = $flavor"
echo -e "\n[paste_deploy]\nflavor = keystone\n" >>$conf && return 0
juju-log "ERROR: Could not update paste_deploy flavor in $conf" && return 1
fi
juju-log "Updating $conf: Setting paste_deploy flavor = $flavor"
local tag="[paste_deploy]"
sed -i "/$tag/, +1 s/\(flavor = \).*/\1$flavor/g" $conf && return 0
juju-log "ERROR: Could not update paste_deploy flavor in $conf" && return 1
}
function update_pipeline {
# updates pipeline middleware definitions in api-paste.ini
local pipeline="$1"
@ -77,10 +98,14 @@ function set_or_update {
# set or update a key=value config option in glance.conf
KEY=$1
VALUE=$2
[[ $3 == "api" ]] && CONF=$GLANCE_API_CONF
[[ $3 == "registry" ]] && CONF=$GLANCE_REGISTRY_CONF
[[ -z $CONF ]] && juju-log "ERROR: set_or_update: No config file specified" &&
exit 1
case "$3" in
"api") CONF=$GLANCE_API_CONF ;;
"api-paste") CONF=$GLANCE_API_PASTE_INI ;;
"registry") CONF=$GLANCE_REGISTRY_CONF ;;
"registry-paste") CONF=$GLANCE_REGISTRY_PASTE_INI ;;
*) juju-log "ERROR: set_or_update(): Invalid or no config file specified." \
&& exit 1 ;;
esac
[[ -z $KEY ]] && exit 1
[[ -z $VALUE ]] && exit 1
cat $CONF | grep "$KEY = $VALUE" >/dev/null \

View File

@ -95,13 +95,11 @@ function keystone_changed {
juju-log "keystone_changed: admin token error" && exit 1
juju-log "keystone_changed: Acquired admin. token"
keystone_host=$(relation-get private-address)
# update the pipeline settings in both configs
update_pipeline "glance-api" \
"versionnegotiation authtoken auth-context apiv1app" "api" || exit 1
update_pipeline "glance-registry" \
"authtoken auth-context registryapp" "registry" || exit 1
for i in api registry ; do
set_paste_deploy_flavor "keystone" "api" || exit 1
set_paste_deploy_flavor "keystone" "registry" || exit 1
for i in api-paste registry-paste ; do
set_or_update "service_host" "$keystone_host" $i
set_or_update "service_port" "$service_port" $i
set_or_update "auth_host" "$keystone_host" $i

View File

@ -1 +1 @@
53
60