當前位置: 首頁>>代碼示例>>Python>>正文


Python unitdata.HookData方法代碼示例

本文整理匯總了Python中charmhelpers.core.unitdata.HookData方法的典型用法代碼示例。如果您正苦於以下問題:Python unitdata.HookData方法的具體用法?Python unitdata.HookData怎麽用?Python unitdata.HookData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在charmhelpers.core.unitdata的用法示例。


在下文中一共展示了unitdata.HookData方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: resume

# 需要導入模塊: from charmhelpers.core import unitdata [as 別名]
# 或者: from charmhelpers.core.unitdata import HookData [as 別名]
def resume(args):
    """Resume all the swift services.

    @raises Exception if any services fail to start
    """
    for service in args.services:
        started = service_resume(service)
        if not started:
            raise Exception("{} didn't start cleanly.".format(service))
    with HookData()():
        kv().set('unit-paused', False)
    set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
                           charm_func=assess_status)


# A dictionary of all the defined actions to callables (which take
# parsed arguments). 
開發者ID:openstack,項目名稱:charm-swift-storage,代碼行數:19,代碼來源:actions.py

示例2: config_value_changed

# 需要導入模塊: from charmhelpers.core import unitdata [as 別名]
# 或者: from charmhelpers.core.unitdata import HookData [as 別名]
def config_value_changed(option):
    """
    Determine if config value changed since last call to this function.
    """
    hook_data = unitdata.HookData()
    with hook_data():
        db = unitdata.kv()
        current = config(option)
        saved = db.get(option)
        db.set(option, current)
        if saved is None:
            return False
        return current != saved 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:15,代碼來源:utils.py

示例3: set_unit_paused

# 需要導入模塊: from charmhelpers.core import unitdata [as 別名]
# 或者: from charmhelpers.core.unitdata import HookData [as 別名]
def set_unit_paused():
    """Set the unit to a paused state in the local kv() store.
    This does NOT actually pause the unit
    """
    with unitdata.HookData()() as t:
        kv = t[0]
        kv.set('unit-paused', True) 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:9,代碼來源:utils.py

示例4: clear_unit_paused

# 需要導入模塊: from charmhelpers.core import unitdata [as 別名]
# 或者: from charmhelpers.core.unitdata import HookData [as 別名]
def clear_unit_paused():
    """Clear the unit from a paused state in the local kv() store
    This does NOT actually restart any services - it only clears the
    local state.
    """
    with unitdata.HookData()() as t:
        kv = t[0]
        kv.set('unit-paused', False) 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:10,代碼來源:utils.py

示例5: is_unit_paused_set

# 需要導入模塊: from charmhelpers.core import unitdata [as 別名]
# 或者: from charmhelpers.core.unitdata import HookData [as 別名]
def is_unit_paused_set():
    """Return the state of the kv().get('unit-paused').
    This does NOT verify that the unit really is paused.

    To help with units that don't have HookData() (testing)
    if it excepts, return False
    """
    try:
        with unitdata.HookData()() as t:
            kv = t[0]
            # transform something truth-y into a Boolean.
            return not(not(kv.get('unit-paused')))
    except Exception:
        return False 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:16,代碼來源:utils.py

示例6: is_unit_paused_set

# 需要導入模塊: from charmhelpers.core import unitdata [as 別名]
# 或者: from charmhelpers.core.unitdata import HookData [as 別名]
def is_unit_paused_set():
    """Return the state of the kv().get('unit-paused').
    This does NOT verify that the unit really is paused.

    To help with units that don't have HookData() (testing)
    if it excepts, return False
    """
    try:
        with unitdata.HookData()() as t:
            kv = t[0]
            # transform something truth-y into a Boolean.
            return not(not(kv.get('unit-paused')))
    except:
        return False 
開發者ID:openstack,項目名稱:charm-ceph-osd,代碼行數:16,代碼來源:utils.py


注:本文中的charmhelpers.core.unitdata.HookData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。