initial commit

This commit is contained in:
Adam Gandelman 2011-07-05 17:32:33 -07:00
commit d234c53698
8 changed files with 139 additions and 0 deletions

52
hooks/glance-common Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
SERVICES="glance-api glance-registry"
GLANCE_REGISTRY_CONF="/etc/glance/glance-registry.conf"
GLANCE_API_CONF="/etc/glance/glance-api.conf"
DEFAULT_ETH=$(ip route | grep default | awk '{ print $5 }')
IP=$(ifconfig $DEFAULT_ETH | grep 'inet addr' | awk '{ print $2 }' | cut -d: -f2)
DB_USER="glance"
NOVA_DB="nova"
function glance_ctl {
if [[ $1 == "all" ]] ; then
CTL=$SERVICES
else
CTL=$1
fi
ACTION=$2
if [[ -z $CTL ]] || [[ -z $ACTION ]] ; then
ensemble-log "ERROR glance_ctl: Not enough arguments"
exit 1
fi
for i in $CTL ; do
service $i $ACTION
if [[ $? != 0 ]] ; then
ensemble-log "ERROR glance_ctl: Service $i failed to $ACTION"
fi
done
}
function set_or_update {
# This handles configuration of both api and registry server
# until LP #806241 is resolved. Until then, $3 is either
# 'api' or 'registry' to specify which
# set or update a key=value config option in nova.conf
KEY=$1
VALUE=$2
[[ $3 == "api" ]] && CONF=$GLANCE_API_CONF
[[ $3 == "registry" ]] && CONF=$GLANCE_REGISTRY_CONF
[[ -z $KEY ]] && exit 1
[[ -z $VALUE ]] && exit 1
cat $CONF | grep "$KEY = $VALUE" >/dev/null \
&& ensemble-log "glance: $KEY = $VALUE already set" exit 0
if cat $CONF | grep "$KEY =" >/dev/null ; then
echo "updatei $3 $KEY $VALUE"
sed -i "s|\($KEY = \).*|\1$VALUE|" $CONF
else
echo "set $3 $KEY $VALUE"
echo "$KEY = $VALUE" >>$CONF
fi
}

67
hooks/glance-relations Executable file
View File

@ -0,0 +1,67 @@
#!/bin/bash
FORMULA_DIR=$(dirname $0)
ARG0=${0##*/}
if [[ -e $FORMULA_DIR/glance-common ]] ; then
. $FORMULA_DIR/glance-common
else
echo "ERROR: Could nto load glance-common from $FORMULA_DIR"
fi
function install_hook {
ensemble-log "Installing nova packages"
apt-get -y install python-software-properties || exit 1
add-apt-repository ppa:nova-core/trunk || exit 1
apt-get update || exit 1
apt-get -y install glance || exit 1
glance_ctl all stop
# work around LP #784837 until its fixed.
[[ ! -d /var/log/glance ]] && mkdir /var/log/glance
chown glance /var/log/glance
[[ ! -e /var/log/glance/api.log ]] && touch /var/log/glance/api.log
[[ ! -e /var/log/glance/registry.log ]] && touch /var/log/glance/registry.log
chown glance /var/log/glance/*.log
# XXX turn up the logging for now.
set_or_update verbose True api
set_or_update debug True api
set_or_update verbose True registry
set_or_update debug True registry
}
function db_joined {
ensemble-log "glance: db_joined: requesting access to $NOVA_DB for $DB_USER@$IP"
echo "DB JOINED $NOVA_DB $DB_USER $HOSTNAME $IP" >>/tmp/log
relation-set database=$NOVA_DB
relation-set username=$DB_USER
relation-set hostname=`uname -n`
relation-set ip=$IP
echo "###### DB JOINED $NOVA_DB $DB_USER $HOSTNAME $IP" >>/tmp/log
}
function db_changed {
DB_HOST=`relation-get db_host`
DB_PASSWORD=`relation-get password`
echo "OUT: $DB_HOST $DB_PASSWORD" >>/tmp/log
if [[ -z $DB_HOST ]] || [[ -z $DB_PASSWORD ]] ; then
echo "db_changed: DB_HOST || DB_PASSWORD not yet set. Exit 0 and retry"
exit 0
else
echo "db_chan ged: Received password from $DB_HOST"
fi
ensemble-log "glance: db_changed: Configuring registry for access to $NOVA_DB@$DB_HOST"
set_or_update sql_connection "mysql://$DB_USER:$DB_PASSWORD@$DB_HOST/$NOVA_DB" registry
echo "####### DB CHANGED $DB_HOST $DB_PASSWORD" >>/tmp/log
}
case $ARG0 in
"start"|"stop") exit 0 ;;
"install") install_hook ;;
"shared-db-realtion-joined") db_joined ;;
"shared-db-relation-changed") db_changed;;
esac

1
hooks/install Symbolic link
View File

@ -0,0 +1 @@
glance-relations

View File

@ -0,0 +1 @@
glance-relations

View File

@ -0,0 +1 @@
glance-relations

1
hooks/start Symbolic link
View File

@ -0,0 +1 @@
glance-relations

1
hooks/stop Symbolic link
View File

@ -0,0 +1 @@
glance-relations

15
metadata.yaml Normal file
View File

@ -0,0 +1,15 @@
ensemble: formula
name: glance
revision: 11
summary: "OpenStack Image Registry and Delivery Service"
description: |
The Glance project provides an image registration and discovery service
(Parallax) and an image delivery service (Teller). These services are used
in conjunction by Nova to deliver images from object stores, such as
OpenStack's Swift service, to Nova's compute nodes.
provides:
image-service:
interface: glance
requires:
shared-db:
interface: mysql