3
# Common utility functions used across all nova charms.
5
# Load the common OpenStack helper library.
6
if [[ -e $CHARM_DIR/lib/openstack-common ]] ; then
7
. $CHARM_DIR/lib/openstack-common
9
juju-log "Couldn't load $CHARM_DIR/lib/opentack-common." && exit 1
13
# Update config flags in nova.conf or api-paste.ini.
14
# Config layout changed in Folsom, so this is now OpenStack release specific.
15
local rel=$(get_os_codename_package "nova-common")
16
. $CHARM_DIR/lib/nova/$rel
20
function set_config_flags() {
21
# Set user-defined nova.conf flags from deployment config
22
juju-log "$CHARM: Processing config-flags."
23
flags=$(config-get config-flags)
24
if [[ "$flags" != "None" && -n "$flags" ]] ; then
25
for f in $(echo $flags | sed -e 's/,/ /g') ; do
26
k=$(echo $f | cut -d= -f1)
27
v=$(echo $f | cut -d= -f2)
28
set_or_update "$k" "$v"
33
configure_volume_service() {
36
"cinder") set_or_update "volume_api_class" "nova.volume.cinder.API" ;;
37
"nova-volume") set_or_update "volume_api_class" "nova.volume.api.API" ;;
38
*) juju-log "$CHARM ERROR - configure_volume_service: Invalid service $svc"
43
function configure_network_manager {
45
echo "$CHARM: configuring $manager network manager"
48
set_or_update "network_manager" "nova.network.manager.FlatManager"
51
set_or_update "network_manager" "nova.network.manager.FlatDHCPManager"
53
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
57
function trigger_remote_service_restarts() {
58
# Trigger a service restart on all other nova nodes that have a relation
59
# via the cloud-controller interface.
61
# possible relations to other nova services.
62
local relations="cloud-compute nova-volume-service"
64
for rel in $relations; do
65
local r_ids=$(relation-ids $rel)
66
for r_id in $r_ids ; do
67
juju-log "$CHARM: Triggering a service restart on relation $r_id."
68
relation-set -r $r_id restart-trigger=$(uuid)
73
do_openstack_upgrade() {
74
# update openstack components to those provided by a new installation source
75
# it is assumed the calling hook has confirmed that the upgrade is sane.
80
orig_os_rel=$(get_os_codename_package "nova-common")
81
new_rel=$(get_os_codename_install_source "$rel")
83
# Backup the config directory.
84
local stamp=$(date +"%Y%m%d%M%S")
85
tar -pcf /var/lib/juju/$CHARM-backup-$stamp.tar $CONF_DIR
87
# load the release helper library for pre/post upgrade hooks specific to the
88
# release we are upgrading to.
89
. $CHARM_DIR/lib/nova/$new_rel
91
# new release specific pre-upgrade hook
92
nova_pre_upgrade "$orig_os_rel"
94
# Setup apt repository access and kick off the actual package upgrade.
95
configure_install_source "$rel"
97
DEBIAN_FRONTEND=noninteractive apt-get --option Dpkg::Options::=--force-confold -y \
98
install --no-install-recommends $packages
100
# new release sepcific post-upgrade hook
101
nova_post_upgrade "$orig_os_rel"