本文整理汇总了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