From e40e6eb81e6400903cb2dd2af3838ec4948555d5 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 14 Sep 2015 20:58:54 +0000 Subject: [PATCH] Action managed openstack upgrade support --- actions.yaml | 4 ++++ actions/openstack-upgrade | 1 + actions/openstack_upgrade.py | 38 ++++++++++++++++++++++++++++++++++++ config.yaml | 10 ++++++++++ hooks/ceilometer_hooks.py | 5 +++-- 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 actions.yaml create mode 120000 actions/openstack-upgrade create mode 100755 actions/openstack_upgrade.py diff --git a/actions.yaml b/actions.yaml new file mode 100644 index 0000000..48e1374 --- /dev/null +++ b/actions.yaml @@ -0,0 +1,4 @@ +openstack-upgrade: + description: | + Perform openstack upgrades. Config option action-managed-upgrade must be + set to True. diff --git a/actions/openstack-upgrade b/actions/openstack-upgrade new file mode 120000 index 0000000..6179301 --- /dev/null +++ b/actions/openstack-upgrade @@ -0,0 +1 @@ +openstack_upgrade.py \ No newline at end of file diff --git a/actions/openstack_upgrade.py b/actions/openstack_upgrade.py new file mode 100755 index 0000000..9f5e967 --- /dev/null +++ b/actions/openstack_upgrade.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +import sys +import uuid + +sys.path.append('hooks/') + +from charmhelpers.contrib.openstack.utils import ( + do_action_openstack_upgrade, +) + +from ceilometer_hooks import config_changed + +from ceilometer_utils import ( + do_openstack_upgrade, + register_configs +) + + +CONFIGS = register_configs() + + +def openstack_upgrade(): + """Perform action-managed OpenStack upgrade. + + Upgrades packages to the configured openstack-origin version and sets + the corresponding action status as a result. + + If the charm was installed from source we cannot upgrade it. + For backwards compatibility a config flag (action-managed-upgrade) must + be set for this code to run, otherwise a full service level upgrade will + fire on config-changed.""" + + if (do_action_openstack_upgrade(do_openstack_upgrade, + CONFIGS, package='ceilometer-common')): + config_changed() + +if __name__ == '__main__': + openstack_upgrade() diff --git a/config.yaml b/config.yaml index 7759f85..f3e514c 100644 --- a/config.yaml +++ b/config.yaml @@ -146,3 +146,13 @@ options: description: | Default multicast port number that will be used to communicate between HA Cluster nodes. + action-managed-upgrade: + type: boolean + default: False + description: | + If True enables openstack upgrades for this charm via juju actions. + You will still need to set openstack-origin to the new repository but + instead of an upgrade running automatically across all units, it will + wait for you to execute the openstack-upgrade action for this charm on + each unit. If False it will revert to existing behavior of upgrading + all units on config change. diff --git a/hooks/ceilometer_hooks.py b/hooks/ceilometer_hooks.py index 381d80c..ef006da 100755 --- a/hooks/ceilometer_hooks.py +++ b/hooks/ceilometer_hooks.py @@ -137,8 +137,9 @@ def configure_https(): @hooks.hook('config-changed') @restart_on_change(restart_map()) def config_changed(): - if openstack_upgrade_available('ceilometer-common'): - do_openstack_upgrade(CONFIGS) + if not config('action-managed-upgrade'): + if openstack_upgrade_available('ceilometer-common'): + do_openstack_upgrade(CONFIGS) update_nrpe_config() CONFIGS.write_all() ceilometer_joined()