Add config-changed openstack upgrade support.

This commit is contained in:
Adam Gandelman 2013-05-22 13:50:39 -07:00
parent 1982f05141
commit afe8a69ea9
3 changed files with 34 additions and 0 deletions

1
hooks/config-changed Symbolic link
View File

@ -0,0 +1 @@
swift-storage-node-relations

View File

@ -129,3 +129,22 @@ function setup_storage {
done
chown -R swift:swift /srv/node
}
function do_openstack_upgrade {
# update openstack components to those provided by a new installation source
# it is assumed the calling hook has confirmed that the upgrade is sane.
local rel="$1"
shift
local packages=$@
# Backup the config directory.
local stamp=$(date +"%Y%m%d%M%S")
tar -pcf /var/lib/juju/$CHARM-backup-$stamp.tar $CONF_DIR
configure_install_source "$rel"
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get \
--option Dpkg::Options::=--force-confnew -y \
install --no-install-recommends $packages
swift-init all restart || true
}

View File

@ -67,9 +67,23 @@ function storage_changed {
swift-init all start || true
}
function config_changed {
local install_src=$(config-get openstack-origin)
local cur=$(get_os_codename_package "glance-common")
local available=$(get_os_codename_install_source "$install_src")
if [[ "$available" != "unknown" ]] ; then
if dpkg --compare-versions $(get_os_version_codename "$cur") lt \
$(get_os_version_codename "$available") ; then
juju-log "$CHARM: Upgrading OpenStack release: $cur -> $available."
do_openstack_upgrade "$install_src" $PACKAGES
fi
fi
}
case $ARG0 in
"install") install_hook ;;
"start"|"stop") exit 0 ;;
"swift-storage-relation-joined") storage_joined ;;
"swift-storage-relation-changed") storage_changed ;;
"config-changed") config_changed ;;
esac