Add update-trilio action
Add update-trilio action which can be run after a Trilio upgrade. Trilio sometimes updates packages in package repositiories that require DB migrations or config file changes. Since these package updates are not applied by the charm as they would be by changing the openstack-origin or triliovault-pkg-source the charm has no event to react to to automatically perform the post package upgrade actions. This change adds an action `update-trilio` which can be run to apply the changes. Change-Id: I4c12bc9ff9b8b20a5ddc16a040f70b87f4cac30b
This commit is contained in:
parent
d3a9cd4668
commit
e6c0e146e8
@ -6,3 +6,7 @@ ghost-share:
|
||||
description: Comma separated nfs-shares configuration option from secondary deployment. NFS shares must be provided in the same order as the nfs-shares configuration option for the local deployment.
|
||||
required:
|
||||
- nfs-shares
|
||||
update-trilio:
|
||||
description: |
|
||||
Update the trilio packages and run post-update steps such as rerender
|
||||
configuration files and run any upgrade tasks such as database migrations.
|
||||
|
@ -26,6 +26,8 @@ basic.init_config_states()
|
||||
|
||||
import charmhelpers.core.hookenv as hookenv
|
||||
|
||||
import charms.reactive as reactive
|
||||
|
||||
import charms_openstack.charm
|
||||
|
||||
# import the trilio_wlm module to get the charm definitions created.
|
||||
@ -40,12 +42,33 @@ def ghost_share(*args):
|
||||
trilio_dm_charm.ghost_nfs_share(secondary_nfs_share)
|
||||
|
||||
|
||||
def update_trilio(*args):
|
||||
"""Run setup after Trilio upgrade.
|
||||
"""
|
||||
with charms_openstack.charm.provide_charm_instance() as trilio_charm:
|
||||
interfaces = ["shared-db", "amqp"]
|
||||
endpoints = [
|
||||
reactive.relations.endpoint_from_flag("{}.available".format(i))
|
||||
for i in interfaces]
|
||||
ceph = reactive.endpoint_from_flag("ceph.available")
|
||||
if ceph:
|
||||
endpoints.append(ceph)
|
||||
trilio_charm.run_trilio_upgrade(endpoints)
|
||||
trilio_charm._assess_status()
|
||||
|
||||
|
||||
# Actions to function mapping, to allow for illegal python action names that
|
||||
# can map to a python function.
|
||||
ACTIONS = {"ghost-share": ghost_share}
|
||||
ACTIONS = {
|
||||
"ghost-share": ghost_share,
|
||||
"update-trilio": update_trilio
|
||||
}
|
||||
|
||||
|
||||
def main(args):
|
||||
# Manually trigger any register atstart events to ensure all endpoints
|
||||
# are correctly setup.
|
||||
hookenv._run_atstart()
|
||||
action_name = os.path.basename(args[0])
|
||||
try:
|
||||
action = ACTIONS[action_name]
|
||||
@ -56,6 +79,7 @@ def main(args):
|
||||
action(args)
|
||||
except Exception as e:
|
||||
hookenv.function_fail(str(e))
|
||||
hookenv._run_atexit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
1
src/actions/update-trilio
Symbolic link
1
src/actions/update-trilio
Symbolic link
@ -0,0 +1 @@
|
||||
actions.py
|
Loading…
Reference in New Issue
Block a user