本文整理汇总了Python中charms.reactive.hook方法的典型用法代码示例。如果您正苦于以下问题:Python reactive.hook方法的具体用法?Python reactive.hook怎么用?Python reactive.hook使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charms.reactive
的用法示例。
在下文中一共展示了reactive.hook方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: default_upgrade_charm
# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import hook [as 别名]
def default_upgrade_charm():
"""Default handler for the 'upgrade-charm' hook.
This calls the charm.singleton.upgrade_charm() function as a default.
"""
reactive.set_state('run-default-upgrade-charm')
示例2: changed
# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import hook [as 别名]
def changed(self):
"""This hook is used to indicate that something has changed on the
interface and that interested parties should recheck the properties
exposed to see if they need to do anything.
The handler should clear the state after it has been consumed so that
the next change gets registered too.
"""
self.update_status()
示例3: check_dns_slaves
# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import hook [as 别名]
def check_dns_slaves():
"""verify if the config('dns-slaves') is valid and set or remove the state
accordingly. Note, that hooks run BEFORE the reactive handlers so this
should happen first during a hook.
"""
if hookenv.config('dns-slaves'):
with provide_charm_instance() as instance:
if not instance.options.invalid_pool_config():
reactive.set_state('dns-slaves-config-valid')
return
reactive.remove_state('dns-slaves-config-valid')
示例4: update_peers
# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import hook [as 别名]
def update_peers(cluster):
"""Inform designate peers about this unit"""
with provide_charm_instance() as instance:
# This function ONLY updates the peers if the data has changed. Thus
# it's okay to call it on every hook invocation.
instance.update_peers(cluster)
示例5: run_assess_status_on_every_hook
# 需要导入模块: from charms import reactive [as 别名]
# 或者: from charms.reactive import hook [as 别名]
def run_assess_status_on_every_hook():
"""The call to charm instance.assess_status() sets up the assess status
functionality to be called atexit() of the charm. i.e. as the last thing
it does. Thus, this handle gets called for EVERY hook invocation, which
means that no other handlers need to call the assess_status function.
"""
with provide_charm_instance() as instance:
instance.assess_status()