3
# Folsom-specific functions
6
# TODO: This needs to be shared among folsom, grizzly and beyond.
7
# Set a config option in nova.conf or api-paste.ini, depending
8
# Defaults to updating nova.conf
12
local section="${4:-DEFAULT}"
14
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
15
local api_conf=${API_CONF:-/etc/nova/api-paste.ini}
16
local quantum_conf=${QUANTUM_CONF:-/etc/quantum/quantum.conf}
17
local quantum_api_conf=${QUANTUM_API_CONF:-/etc/quantum/api-paste.ini}
18
local quantum_plugin_conf=${QUANTUM_PLUGIN_CONF:-/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini}
19
local libvirtd_conf=${LIBVIRTD_CONF:-/etc/libvirt/libvirtd.conf}
21
[[ -z $key ]] && juju-log "$CHARM: set_or_update: value $value missing key" && exit 1
22
[[ -z $value ]] && juju-log "$CHARM: set_or_update: key $key missing value" && exit 1
24
[[ -z "$conf_file" ]] && conf_file=$nova_conf
28
"$nova_conf") match="^$key="
32
"$api_conf"|"$quantum_conf"|"$quantum_api_conf"|"$quantum_plugin_conf"| \
38
*) juju-log "$CHARM ERROR: set_or_update: Invalid conf_file ($conf_file)"
41
cat $conf_file | grep "$match$value" >/dev/null &&
42
juju-log "$CHARM: $key=$value already in set in $conf_file" \
46
"$quantum_conf"|"$quantum_api_conf"|"$quantum_plugin_conf")
49
config = ConfigParser.RawConfigParser()
50
config.read('$conf_file')
51
config.set('$section','$key','$value')
52
with open('$conf_file', 'wb') as configfile:
53
config.write(configfile)
57
if cat $conf_file | grep "$match" >/dev/null ; then
58
juju-log "$CHARM: Updating $conf_file, $key=$value"
59
sed -i "s|\($pattern\).*|\1$value|" $conf_file
61
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
62
echo "$out$value" >>$conf_file
71
# Pre-upgrade helper. Caller should pass the version of OpenStack we are
73
return 0 # Nothing to do here, yet.
77
# Post-upgrade helper. Caller should pass the version of OpenStack we are
79
local upgrade_from="$1"
80
juju-log "$CHARM: Running post-upgrade hook: $upgrade_from -> grizzly."
81
# We only support folsom -> grizzly, currently.
82
[[ "$upgrade_from" != "folsom" ]] &&
83
error_out "Unsupported upgrade: $upgrade_from -> grizzly"
85
# This may be dangerous, if we are upgrading a number of units at once
86
# and they all begin the same migration concurrently. Migrate only from
87
# the cloud controller(s).
88
if [[ "$CHARM" == "nova-cloud-controller" ]] ; then
89
juju-log "$CHARM: Migrating nova database."
90
/usr/bin/nova-manage db sync
92
# Trigger a service restart on all other nova nodes.
93
trigger_remote_service_restarts
96
juju-log "$CHARM: Post-upgrade hook complete: $upgrade_from -> grizzly."