5
SERVICES="glance-api glance-registry"
6
PACKAGES="glance python-mysqldb python-swift python-keystone uuid haproxy"
8
GLANCE_REGISTRY_CONF="/etc/glance/glance-registry.conf"
9
GLANCE_REGISTRY_PASTE_INI="/etc/glance/glance-registry-paste.ini"
10
GLANCE_API_CONF="/etc/glance/glance-api.conf"
11
GLANCE_API_PASTE_INI="/etc/glance/glance-api-paste.ini"
12
CONF_DIR="/etc/glance"
13
HOOKS_DIR="$CHARM_DIR/hooks"
15
# Flag used to track config changes.
16
CONFIG_CHANGED="False"
17
if [[ -e "$HOOKS_DIR/lib/openstack-common" ]] ; then
18
. $HOOKS_DIR/lib/openstack-common
20
juju-log "ERROR: Couldn't load $HOOKS_DIR/lib/openstack-common." && exit 1
23
function set_or_update {
29
[[ -z $key ]] && juju-log "ERROR: set_or_update(): value $value missing key" \
31
[[ -z $value ]] && juju-log "ERROR: set_or_update(): key $key missing value" \
35
"api") conf=$GLANCE_API_CONF ;;
36
"api-paste") conf=$GLANCE_API_PASTE_INI ;;
37
"registry") conf=$GLANCE_REGISTRY_CONF ;;
38
"registry-paste") conf=$GLANCE_REGISTRY_PASTE_INI ;;
39
*) juju-log "ERROR: set_or_update(): Invalid or no config file specified." \
43
[[ ! -e $conf ]] && juju-log "ERROR: set_or_update(): File not found $conf" \
46
if [[ "$(local_config_get "$conf" "$key" "$section")" == "$value" ]] ; then
47
juju-log "$CHARM: set_or_update(): $key=$value already set in $conf."
51
cfg_set_or_update "$key" "$value" "$conf" "$section"
55
do_openstack_upgrade() {
56
# update openstack components to those provided by a new installation source
57
# it is assumed the calling hook has confirmed that the upgrade is sane.
61
orig_os_rel=$(get_os_codename_package "glance-common")
62
new_rel=$(get_os_codename_install_source "$rel")
64
# Backup the config directory.
65
local stamp=$(date +"%Y%m%d%M%S")
66
tar -pcf /var/lib/juju/$CHARM-backup-$stamp.tar $CONF_DIR
68
# Setup apt repository access and kick off the actual package upgrade.
69
configure_install_source "$rel"
71
DEBIAN_FRONTEND=noninteractive apt-get --option Dpkg::Options::=--force-confnew -y \
72
install --no-install-recommends $packages
74
# Update the new config files for existing relations.
77
r_id=$(relation-ids shared-db)
78
if [[ -n "$r_id" ]] ; then
79
juju-log "$CHARM: Configuring database after upgrade to $rel."
83
r_id=$(relation-ids identity-service)
84
if [[ -n "$r_id" ]] ; then
85
juju-log "$CHARM: Configuring identity service after upgrade to $rel."
86
keystone_changed $r_id
89
local ceph_ids="$(relation-ids ceph)"
90
[[ -n "$ceph_ids" ]] && apt-get -y install ceph-common python-ceph
91
for r_id in $ceph_ids ; do
92
for unit in $(relation-list -r $r_id) ; do
93
ceph_changed "$r_id" "$unit"
97
[[ -n "$(relation-ids object-store)" ]] && object-store_joined
101
# request openstack-common setup reverse proxy mapping for API and registry
103
service_ctl glance-api stop
104
if [[ -n "$(peer_units)" ]] || is_clustered ; then
105
# haproxy may already be configured. need to push it back in the request
106
# pipeline in preparation for a change from:
107
# from: haproxy (9292) -> glance_api (9282)
108
# to: ssl (9292) -> haproxy (9291) -> glance_api (9272)
109
local next_server=$(determine_haproxy_port 9292)
110
local api_port=$(determine_api_port 9292)
111
configure_haproxy "glance_api:$next_server:$api_port"
113
# if not clustered, the glance-api is next in the pipeline.
114
local api_port=$(determine_api_port 9292)
115
local next_server=$api_port
118
# setup https to point to either haproxy or directly to api server, depending.
119
setup_https 9292:$next_server
121
# configure servers to listen on new ports accordingly.
122
set_or_update bind_port "$api_port" "api"
123
service_ctl all start
126
# (re)configure ks endpoint accordingly in ks and nova.
127
for r_id in $(relation-ids identity-service) ; do
128
keystone_joined "$r_id"
130
for r_id in $(relation-ids image-service) ; do
131
image-service_joined "$r_id"