Merge lp:~gandelman-a/charm/precise/glance/trunk
This commit is contained in:
commit
e10649b105
|
@ -2,7 +2,7 @@ options:
|
|||
glance-release:
|
||||
default: distro
|
||||
type: string
|
||||
description: Glance PPA from which to install. (distro, trunk, milestone, milestone-proposed)
|
||||
description: Glance PPA from which to install. (distro, trunk, milestone, milestone-proposed or ppa:somewhere/else)
|
||||
api-config:
|
||||
default: /etc/glance/glance-api.conf
|
||||
type: string
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
SERVICES="glance-api glance-registry"
|
||||
PACKAGES="glance python-mysqldb python-swift python-keystone"
|
||||
|
||||
GLANCE_REGISTRY_CONF=$(config-get registry-config)
|
||||
GLANCE_API_CONF=$(config-get api-config)
|
||||
|
||||
|
@ -47,6 +49,27 @@ function glance_ctl {
|
|||
done
|
||||
}
|
||||
|
||||
function update_pipeline {
|
||||
# updates pipeline middleware definitions in api-paste.ini
|
||||
local pipeline="$1"
|
||||
local new="$2"
|
||||
local config="$3"
|
||||
|
||||
case $config in
|
||||
"api") local api_conf=$GLANCE_API_CONF ;;
|
||||
"registry") local api_conf=$GLANCE_REGISTRY_CONF ;;
|
||||
*) juju-log "ERROR: update_pipeline: invalid config=$config" && exit 1 ;;
|
||||
esac
|
||||
|
||||
local tag="\[pipeline:$pipeline\]"
|
||||
if ! grep -q "$tag" $api_conf ; then
|
||||
juju-log "ERROR: update_pipeline: pipeline not found: $pipeline"
|
||||
return 1
|
||||
fi
|
||||
juju-log "Updating pipeline:$pipeline in $api_conf"
|
||||
sed -i "/$tag/, +1 s/\(pipeline = \).*/\1$new/g" $api_conf
|
||||
}
|
||||
|
||||
function set_or_update {
|
||||
# This handles configuration of both api and registry server
|
||||
# until LP #806241 is resolved. Until then, $3 is either
|
||||
|
@ -56,6 +79,8 @@ function set_or_update {
|
|||
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
|
||||
[[ -z $KEY ]] && exit 1
|
||||
[[ -z $VALUE ]] && exit 1
|
||||
cat $CONF | grep "$KEY = $VALUE" >/dev/null \
|
||||
|
@ -71,8 +96,20 @@ function add_ppa {
|
|||
# Install from archive instead of PPA.
|
||||
[[ $PPA == "distro" ]] && return 0
|
||||
. /etc/lsb-release
|
||||
juju-log "glance: Setting up PPA for $PPA"
|
||||
[[ -z $PPA ]] && return 0
|
||||
PPA_URL="deb http://ppa.launchpad.net/nova-core/$PPA/ubuntu $DISTRIB_CODENAME main"
|
||||
add-apt-repository "$PPA_URL" || exit 1
|
||||
# if referenced by name, setup ppa to upstream PPAs
|
||||
if [[ "$PPA" == "trunk" ]] ||
|
||||
[[ "$PPA" == "milestone" ]] ||
|
||||
[[ "$PPA" == "milestone-proposed" ]] ; then
|
||||
juju-log "glance: Configuring installation from upstream PPA ($PPA)"
|
||||
PPA_URL="deb http://ppa.launchpad.net/glance-core/$PPA/ubuntu $DISTRIB_CODENAME main"
|
||||
add-apt-repository "$PPA_URL" || exit 1
|
||||
return
|
||||
fi
|
||||
if [[ "${PPA:0:4}" == "ppa:" ]] ; then
|
||||
juju-log "glance: Configuring installation from custom PPA ($PPA)"
|
||||
add-apt-repository -y "$PPA" || exit 1
|
||||
return
|
||||
fi
|
||||
juju-log "glance: No PPA specified. Falling back to installation from Ubuntu archive."
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ else
|
|||
fi
|
||||
|
||||
function install_hook {
|
||||
juju-log "Installing nova packages"
|
||||
juju-log "Installing glance packages"
|
||||
apt-get -y install python-software-properties || exit 1
|
||||
|
||||
add_ppa
|
||||
|
||||
apt-get update || exit 1
|
||||
apt-get -y install glance python-mysqldb python-swift || exit 1
|
||||
apt-get -y install $PACKAGES || exit 1
|
||||
|
||||
glance_ctl all stop
|
||||
|
||||
|
@ -77,6 +77,42 @@ function object-store_changed {
|
|||
glance_ctl glance-api restart
|
||||
}
|
||||
|
||||
function keystone_joined {
|
||||
# advertise our API endpoint to keystone
|
||||
url="http://$(unit-get private-address):9292/v1.1/"
|
||||
relation-set service="glance" \
|
||||
region="RegionOne" public_url=$url admin_url=$url internal_url=$url
|
||||
}
|
||||
|
||||
function keystone_changed {
|
||||
# we hopefully get a token in return. configure middleware accordingly
|
||||
token=$(relation-get admin_token)
|
||||
service_port=$(relation-get service_port)
|
||||
auth_port=$(relation-get auth_port)
|
||||
[[ -z "$token" ]] || [[ -z "$service_port" ]] || [[ -z "$auth_port" ]] &&
|
||||
juju-log "keystone_changed: Peer not ready" && exit 0
|
||||
[[ "$token" == "-1" ]] &&
|
||||
juju-log "keystone_changed: admin token error" && exit 1
|
||||
juju-log "keystone_changed: Acquired admin. token"
|
||||
keystone_host=`dig +short +search $(relation-get private-address)`
|
||||
|
||||
# update the pipeline settings in both configs
|
||||
update_pipeline "glance-api" \
|
||||
"versionnegotiation authtoken auth-context apiv1app" "api"
|
||||
update_pipeline "glance-registry" \
|
||||
"authtoken auth-context registryapp" "registry"
|
||||
|
||||
for i in api registry ; 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
|
||||
set_or_update "auth_port" "$auth_port" $i
|
||||
set_or_update "auth_uri" "http://$keystone_host:$service_port/" $i
|
||||
set_or_update "admin_token" "$token" $i
|
||||
done
|
||||
glance_ctl all restart
|
||||
}
|
||||
|
||||
case $ARG0 in
|
||||
"start"|"stop") glance_ctl all $ARG0 ;;
|
||||
"install") install_hook ;;
|
||||
|
@ -86,5 +122,7 @@ case $ARG0 in
|
|||
"image-service-relation-changed") exit 0 ;;
|
||||
"object-store-relation-joined") exit 0 ;;
|
||||
"object-store-relation-changed") object-store_changed ;;
|
||||
"identity-service-relation-joined") keystone_joined ;;
|
||||
"identity-service-relation-changed") keystone_changed ;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
glance-relations
|
|
@ -0,0 +1 @@
|
|||
glance-relations
|
|
@ -14,3 +14,5 @@ requires:
|
|||
interface: mysql-shared
|
||||
object-store:
|
||||
interface: swift
|
||||
identity-service:
|
||||
interface: keystone
|
||||
|
|
Loading…
Reference in New Issue