本文整理匯總了Python中charmhelpers.core.hookenv.execution_environment方法的典型用法代碼示例。如果您正苦於以下問題:Python hookenv.execution_environment方法的具體用法?Python hookenv.execution_environment怎麽用?Python hookenv.execution_environment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類charmhelpers.core.hookenv
的用法示例。
在下文中一共展示了hookenv.execution_environment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_gets_execution_environment
# 需要導入模塊: from charmhelpers.core import hookenv [as 別名]
# 或者: from charmhelpers.core.hookenv import execution_environment [as 別名]
def test_gets_execution_environment(self, os_, relations_get,
relations, relation_id, local_unit,
relation_type, config):
config.return_value = 'some-config'
relation_type.return_value = 'some-type'
local_unit.return_value = 'some-unit'
relation_id.return_value = 'some-id'
relations.return_value = 'all-relations'
relations_get.return_value = 'some-relations'
os_.environ = 'some-environment'
result = hookenv.execution_environment()
self.assertEqual(result, {
'conf': 'some-config',
'reltype': 'some-type',
'unit': 'some-unit',
'relid': 'some-id',
'rel': 'some-relations',
'rels': 'all-relations',
'env': 'some-environment',
})
示例2: test_gets_execution_environment_no_relation
# 需要導入模塊: from charmhelpers.core import hookenv [as 別名]
# 或者: from charmhelpers.core.hookenv import execution_environment [as 別名]
def test_gets_execution_environment_no_relation(
self, os_, relations_get, relations, relation_id,
local_unit, relation_type, config):
config.return_value = 'some-config'
relation_type.return_value = 'some-type'
local_unit.return_value = 'some-unit'
relation_id.return_value = None
relations.return_value = 'all-relations'
relations_get.return_value = 'some-relations'
os_.environ = 'some-environment'
result = hookenv.execution_environment()
self.assertEqual(result, {
'conf': 'some-config',
'unit': 'some-unit',
'rels': 'all-relations',
'env': 'some-environment',
})
示例3: _record_hook
# 需要導入模塊: from charmhelpers.core import hookenv [as 別名]
# 或者: from charmhelpers.core.hookenv import execution_environment [as 別名]
def _record_hook(self, hookenv):
data = hookenv.execution_environment()
self.conf = conf_delta = self.kv.delta(data['conf'], 'config')
self.rels = rels_delta = self.kv.delta(data['rels'], 'rels')
self.kv.set('env', dict(data['env']))
self.kv.set('unit', data['unit'])
self.kv.set('relid', data.get('relid'))
return conf_delta, rels_delta