Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example reactive charm to test register_trigger
from charms.reactive import when, when_not, set_flag
from charmhelpers.core.hookenv import log, config
from charms.reactive.flags import register_trigger
# Register a trigger so that we can respond to config.changed, even if
# it's being cleared by another handler
register_trigger(when='config.changed',
set_flag='trigger.config')
@when_not('test-config-changed.installed')
def install_test_config_changed():
set_flag('test-config-changed.installed')
@when('config.changed')
def log_config_changed():
cfg = config()
log("#### config-changed state handled: {}".format(cfg))
@when('trigger.config')
def trigger_config_changed():
cfg = config()
log("#### trigger_config_changed called: {}".format(cfg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.