3
# Folsom-specific functions
6
# Set a config option in nova.conf or api-paste.ini, depending
7
# Defaults to updating nova.conf
12
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
13
local api_conf=${API_CONF:-/etc/nova/api-paste.ini}
15
[[ -z $key ]] && juju-log "$CHARM: set_or_update: value $value missing key" && exit 1
16
[[ -z $value ]] && juju-log "$CHARM: set_or_update: key $key missing value" && exit 1
18
[[ -z "$conf_file" ]] && conf_file=$nova_conf
22
"$nova_conf") match="^$key="
26
"$api_conf") match="^$key = "
30
*) juju-log "$CHARM ERROR: set_or_update: Invalid conf_file ($conf_file)"
33
cat $conf_file | grep "$match$value" >/dev/null &&
34
juju-log "$CHARM: $key=$value already in set in $conf_file" \
36
if cat $conf_file | grep "$match" >/dev/null ; then
37
juju-log "$CHARM: Updating $conf_file, $key=$value"
38
sed -i "s|\($pattern\).*|\1$value|" $conf_file
40
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
41
echo "$out$value" >>$conf_file
47
# Pre-upgrade helper. Caller should pass the version of OpenStack we are
49
return 0 # Nothing to do here, yet.
53
# Post-upgrade helper. Caller should pass the version of OpenStack we are
55
local upgrade_from="$1"
56
juju-log "$CHARM: Running post-upgrade hook: $upgrade_from -> folsom."
57
# We only support essex -> folsom, currently.
58
[[ "$upgrade_from" != "essex" ]] &&
59
error_out "Unsupported upgrade: $upgrade_from -> folsom"
61
# This may be dangerous, if we are upgrading a number of units at once
62
# and they all begin the same migration concurrently. Migrate only from
63
# the cloud controller(s).
64
if [[ "$CHARM" == "nova-cloud-controller" ]] ; then
65
juju-log "$CHARM: Migrating nova database."
66
/usr/bin/nova-manage db sync
68
# Trigger a service restart on all other nova nodes.
69
trigger_remote_service_restarts
72
# Packaging currently takes care of converting the Essex gflags format
73
# to .ini, but we need to update the api-paste.ini manually. It can be
74
# updated directly from keystone, via the identity-service relation,
75
# if it exists. Only services that require keystone credentials will
76
# have modified api-paste.ini, and only those services will have a .dpkg-dist
78
local r_id=$(relation-ids identity-service)
79
if [[ -n "$r_id" ]] && [[ -e "$CONF_DIR/api-paste.ini.dpkg-dist" ]] ; then
80
# Backup the last api config, update the stock packaged version
81
# with our current Keystone info.
82
mv $API_CONF $CONF_DIR/api-paste.ini.juju-last
83
mv $CONF_DIR/api-paste.ini.dpkg-dist $CONF_DIR/api-paste.ini
85
unit=$(relation-list -r $r_id | head -n1)
86
# Note, this should never be called from an relation hook, only config-changed.
87
export JUJU_REMOTE_UNIT=$unit
88
service_port=$(relation-get -r $r_id service_port)
89
auth_port=$(relation-get -r $r_id auth_port)
90
service_username=$(relation-get -r $r_id service_username)
91
service_password=$(relation-get -r $r_id service_password)
92
service_tenant=$(relation-get -r $r_id service_tenant)
93
keystone_host=$(relation-get -r $r_id private-address)
94
unset JUJU_REMOTE_UNIT
96
juju-log "$CHARM: Updating new api-paste.ini with keystone data from $unit:$r_id"
97
set_or_update "service_host" "$keystone_host" "$API_CONF"
98
set_or_update "service_port" "$service_port" "$API_CONF"
99
set_or_update "auth_host" "$keystone_host" "$API_CONF"
100
set_or_update "auth_port" "$auth_port" "$API_CONF"
101
set_or_update "auth_uri" "http://$keystone_host:$service_port/" "$API_CONF"
102
set_or_update "admin_tenant_name" "$service_tenant" "$API_CONF"
103
set_or_update "admin_user" "$service_username" "$API_CONF"
104
set_or_update "admin_password" "$service_password" "$API_CONF"
108
# RC3 packaging in cloud archive doesn't have this in postinst. Do it here
109
sed -e "s,^root_helper=.\+,rootwrap_config=/etc/nova/rootwrap.conf," -i /etc/nova/nova.conf
111
juju-log "$CHARM: Post-upgrade hook complete: $upgrade_from -> folsom."