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 b63fb33..e3b5e5d 100644 --- a/config.yaml +++ b/config.yaml @@ -40,3 +40,13 @@ options: description: | A comma-separated list of nagios servicegroups. If left empty, the nagios_context will be used as the servicegroup + 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 1f8ee31..62b30f5 100755 --- a/hooks/ceilometer_hooks.py +++ b/hooks/ceilometer_hooks.py @@ -61,8 +61,9 @@ def ceilometer_changed(): @hooks.hook('config-changed') @restart_on_change(restart_map(), stopstart=True) 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) if is_relation_made('nrpe-external-master'): update_nrpe_config() CONFIGS.write_all()