本文整理匯總了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