当前位置: 首页>>代码示例>>Python>>正文


Python reactive.hook方法代码示例

本文整理汇总了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') 
开发者ID:openstack,项目名称:charm-layer-openstack,代码行数:7,代码来源:layer_openstack.py

示例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() 
开发者ID:openstack,项目名称:charm-interface-manila-plugin,代码行数:11,代码来源:provides.py

示例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') 
开发者ID:openstack,项目名称:charm-designate,代码行数:13,代码来源:designate_handlers.py

示例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) 
开发者ID:openstack,项目名称:charm-designate,代码行数:8,代码来源:designate_handlers.py

示例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() 
开发者ID:openstack,项目名称:charm-designate,代码行数:10,代码来源:designate_handlers.py


注:本文中的charms.reactive.hook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。