Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Standard action entry point template and action state #69
Closed
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,28 @@ | ||
| +#!/usr/bin/env python3 | ||
| + | ||
| +# Load modules from $CHARM_DIR/lib | ||
| +import sys | ||
| +sys.path.append('lib') # noqa | ||
| + | ||
| +import traceback | ||
| + | ||
| +from charms.reactive import main | ||
| +from charmhelpers.core import hookenv | ||
| + | ||
| +if __name__ == '__main__': | ||
| + try: | ||
| + action_name = hookenv.action_name() | ||
| + hookenv.log('Running action {} ({})'.format(action_name, | ||
| + hookenv.action_uuid())) | ||
| + | ||
| + # This will load and run the appropriate @action and other decorated | ||
| + # handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, | ||
| + # and $CHARM_DIR/hooks/relations. | ||
| + # | ||
| + # See https://jujucharms.com/docs/stable/authors-charm-building | ||
| + # for more information on this pattern. | ||
| + main() | ||
| + except Exception: | ||
| + hookenv.action_fail('Unhandled exception') | ||
| + hookenv.action_set(dict(traceback=traceback.format_exc())) | ||
| + raise |