本文整理汇总了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).
示例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
示例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)
示例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)
示例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
示例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