Standard action entry point template and action state #69

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+28 −0
Split
View
@@ -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