Merge "Add update-trilio action"

This commit is contained in:
Zuul 2021-08-19 12:07:54 +00:00 committed by Gerrit Code Review
commit c6a5fdaa95
3 changed files with 69 additions and 0 deletions

4
src/actions.yaml Normal file
View File

@ -0,0 +1,4 @@
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.

64
src/actions/actions.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/local/sbin/charm-env python3
# Copyright 2018,2020 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
# Load modules from $CHARM_DIR/lib
sys.path.append("lib")
from charms.layer import basic
basic.bootstrap_charm_deps()
basic.init_config_states()
import charmhelpers.core.hookenv as hookenv
import charms_openstack.charm
# import the trilio module to get the charm definitions created.
import charm.openstack.trilio_horizon_plugin # noqa
def update_trilio(*args):
"""Run setup after Trilio upgrade.
"""
with charms_openstack.charm.provide_charm_instance() as trilio_charm:
trilio_charm.run_trilio_upgrade([])
trilio_charm._assess_status()
# Actions to function mapping, to allow for illegal python action names that
# can map to a python function.
ACTIONS = {
"update-trilio": update_trilio,
}
def main(args):
action_name = os.path.basename(args[0])
try:
action = ACTIONS[action_name]
except KeyError:
return "Action %s undefined" % action_name
else:
try:
action(args)
except Exception as e:
hookenv.function_fail(str(e))
if __name__ == "__main__":
sys.exit(main(sys.argv))

1
src/actions/update-trilio Symbolic link
View File

@ -0,0 +1 @@
actions.py