本文整理汇总了Python中MilkCheck.Engine.Action.Action.fromdict方法的典型用法代码示例。如果您正苦于以下问题:Python Action.fromdict方法的具体用法?Python Action.fromdict怎么用?Python Action.fromdict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.Action.Action
的用法示例。
在下文中一共展示了Action.fromdict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_action1
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import fromdict [as 别名]
def test_create_action1(self):
'''Test instanciation of an Action through a dictionnary'''
act = Action('start')
act.fromdict(
{
'target': 'localhost',
'fanout': 4,
'retry': 5,
'delay': 2,
'errors': 3,
'timeout': 4,
'cmd': '/bin/True',
'desc': 'my desc',
'mode': 'delegate',
}
)
self.assertTrue(act)
self.assertEqual(act.name, 'start')
self.assertEqual(act.target, NodeSet('localhost'))
self.assertEqual(act.fanout, 4)
self.assertEqual(act.maxretry, 5)
self.assertEqual(act.errors, 3)
self.assertEqual(act.delay, 2)
self.assertEqual(act.timeout, 4)
self.assertEqual(act.command, '/bin/True')
self.assertEqual(act.desc, 'my desc')
self.assertEqual(act.mode, 'delegate')
示例2: test_create_action1
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import fromdict [as 别名]
def test_create_action1(self):
"""Test instanciation of an Action through a dictionnary"""
act = Action("start")
act.fromdict(
{
"target": "localhost",
"fanout": 4,
"retry": 5,
"delay": 2,
"errors": 3,
"timeout": 4,
"cmd": "/bin/True",
"desc": "my desc",
"mode": "delegate",
}
)
self.assertTrue(act)
self.assertEqual(act.name, "start")
self.assertEqual(act.target, NodeSet("localhost"))
self.assertEqual(act.fanout, 4)
self.assertEqual(act.maxretry, 5)
self.assertEqual(act.errors, 3)
self.assertEqual(act.delay, 2)
self.assertEqual(act.timeout, 4)
self.assertEqual(act.command, "/bin/True")
self.assertEqual(act.desc, "my desc")
self.assertEqual(act.mode, "delegate")
示例3: test_resolve_all
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import fromdict [as 别名]
def test_resolve_all(self):
"""resolve_all() resolves in all Action properties"""
act = Action('start')
act.fromdict({
'variables': {
'label': 'Start action',
},
'desc': "%label",
'cmd': 'service foo %ACTION'
})
act.resolve_all()
self.assertEqual(act.desc, "Start action")
self.assertEqual(act.command, "service foo start")
示例4: test_create_action2
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import fromdict [as 别名]
def test_create_action2(self):
"""Test instanciation of an action with variables"""
act = Action("start")
act.fromdict(
{
"target": "localhost",
"variables": {"var1": "toto", "var2": "titi"},
"fanout": 4,
"retry": 5,
"delay": 2,
"timeout": 4,
"cmd": "/bin/True",
}
)
self.assertTrue(act)
self.assertTrue(len(act.variables) == 2)
self.assertTrue("var1" in act.variables)
self.assertTrue("var2" in act.variables)
示例5: test_create_action2
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import fromdict [as 别名]
def test_create_action2(self):
'''Test instanciation of an action with variables'''
act = Action('start')
act.fromdict(
{
'target': 'localhost',
'variables': {
'var1': 'toto',
'var2': 'titi'
},
'fanout': 4,
'retry': 5,
'delay': 2,
'timeout': 4,
'cmd': '/bin/True'
}
)
self.assertTrue(act)
self.assertTrue(len(act.variables) == 2)
self.assertTrue('var1' in act.variables)
self.assertTrue('var2' in act.variables)
示例6: fromdict
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import fromdict [as 别名]
def fromdict(self, svcdict):
"""Populate service attributes from dict."""
BaseEntity.fromdict(self, svcdict)
if "actions" in svcdict:
dependencies = {}
actions = {}
for names, props in svcdict["actions"].items():
for name in NodeSet(names):
action = Action(name)
action.fromdict(props)
actions[name] = action
dependencies[name] = props.get("check", [])
for action in actions.values():
for dep in dependencies[action.name]:
action.add_dep(actions[dep])
self.add_action(action)
# Inherits properies between service and actions
for action in self.iter_actions():
action.inherits_from(self)