当前位置: 首页>>代码示例>>Python>>正文


Python Action.fromdict方法代码示例

本文整理汇总了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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:29,代码来源:ActionTest.py

示例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")
开发者ID:mdlx,项目名称:milkcheck,代码行数:29,代码来源:ActionTest.py

示例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")
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:15,代码来源:ActionTest.py

示例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)
开发者ID:mdlx,项目名称:milkcheck,代码行数:20,代码来源:ActionTest.py

示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:23,代码来源:ActionTest.py

示例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)
开发者ID:pombredanne,项目名称:milkcheck,代码行数:25,代码来源:Service.py


注:本文中的MilkCheck.Engine.Action.Action.fromdict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。