當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。