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


Python Action.inherits_from方法代码示例

本文整理汇总了Python中MilkCheck.Engine.Action.Action.inherits_from方法的典型用法代码示例。如果您正苦于以下问题:Python Action.inherits_from方法的具体用法?Python Action.inherits_from怎么用?Python Action.inherits_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MilkCheck.Engine.Action.Action的用法示例。


在下文中一共展示了Action.inherits_from方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_command_output_warning

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def test_command_output_warning(self):
        '''Test command line output with warning'''
        svc_warn = Service('service_failled')
        svc_warn.desc = 'I am the failled service'
        svc_ok = Service('service_ok')
        svc_ok.desc = 'I am the ok service'
        # Actions
        action = Action('warning', command='/bin/false')
        action.inherits_from(svc_warn)
        svc_warn.add_action(action)
        action = Action('warning', command='/bin/true')
        action.inherits_from(svc_ok)
        svc_ok.add_action(action)

        # Register services within the manager
        svc_ok.add_dep(target=svc_warn, sgth=REQUIRE_WEAK)
        self.manager.add_service(svc_warn)
        self.manager.add_service(svc_ok)

        self._output_check(['service_ok', 'warning'], RC_OK,
"""warning service_failled ran in 0.00 s
 > localhost exited with 1
service_failled - I am the failled service                        [  ERROR  ]
service_ok - I am the ok service                                  [    OK   ]
""")
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:27,代码来源:CliTest.py

示例2: setUp

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                                _ start
                   -- service1 /
                 -'             _ start
                  '-- service2 /
        '''

        CLICommon.setUp(self)

        # Service
        service1 = Service('service1')
        service1.desc = 'I am the service 1'
        service2 = Service('service2')
        service2.desc = 'I am the service 2'
        # Actions
        action = Action('start', command='/bin/true')
        action.inherits_from(service1)
        service1.add_action(action)

        service2.add_dep(target=service1)

        action = Action('start', command='/bin/true')
        action.inherits_from(service2)
        service2.add_action(action)

        # Register services within the manager
        self.manager.register_services(service1, service2)
开发者ID:mdlx,项目名称:milkcheck,代码行数:33,代码来源:CliTest.py

示例3: test_desc

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def test_desc(self):
        """Test action inherits 'desc'"""
        # No service description, no action description
        action1 = Action('status', command='/bin/true')
        service = Service('TEST')
        service.add_actions(action1)
        self.assertEqual(action1.desc, None)

        # Service description, actions inherits the description
        action2 = Action('status', command='/bin/true')
        service2 = Service('TEST2')
        service2.desc = "Service TEST"
        service2.add_actions(action2)
        action2.inherits_from(service2)
        self.assertEqual(action2.desc, "Service TEST")
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:17,代码来源:ActionTest.py

示例4: test_command_output_interactive_delayed

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def test_command_output_interactive_delayed(self):
        '''Test command line output in interactive mode with delayed actions'''
        action = Action('start', command='/bin/sleep 0.1', delay=0.3)
        srv = Service('service')
        srv.desc = 'I am the service'
        action.inherits_from(srv)
        srv.add_action(action)
        self.manager.register_services(srv)
        self._output_check(['service', 'start'], RC_OK,
'''
Actions in progress
 > service.start (delayed for 0.3s) on localhost

service - I am the service                                        [    OK   ]
''')
开发者ID:mdlx,项目名称:milkcheck,代码行数:17,代码来源:CliTest.py

示例5: test_run_skipped_with_error_deps

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def test_run_skipped_with_error_deps(self):
        """Test run with ERROR dependencies for a SKIPPED service"""

        # Distant service with empty target: should be skipped
        svc = Service('test_service', target="tempnode[1-2]")
        action = Action('start', command='/bin/true')
        action.inherits_from(svc)
        svc.add_action(action)
        svc.update_target("tempnode[1-2]", 'DIF')

        # A simple dep
        dep = Service('DEP_A')
        dep.add_action(Action('start', command='/bin/false'))

        svc.add_dep(dep)
        svc.run('start')

        self.assertEqual(svc.eval_deps_status(), DEP_ERROR)
        self.assertEqual(dep.status, ERROR)
        self.assertEqual(svc.status, SKIPPED)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:22,代码来源:ServiceTest.py

示例6: setUp

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                                _ start
                   -- service1 /
                 -'             _ start
                  '-- service2 /
        '''

        self.backup_terminal = MilkCheck.UI.Cli.Terminal
        self.backup_interactivethr = MilkCheck.UI.Cli.InteractiveThread
        self.backup_confirm_actions = \
            ConfigParser.DEFAULT_FIELDS['confirm_actions']['value']
        MilkCheck.UI.Cli.Terminal = MockInterTerminal
        MilkCheck.UI.Cli.InteractiveThread = MockInteractiveThread
        MockInterTerminal.called = False
        CLICommon.setUp(self)

        # Service
        service1 = Service('service1')
        service1.desc = 'I am the service 1'
        self.service1 = service1
        service2 = Service('service2')
        service2.desc = 'I am the service 2'
        self.service2 = service2
        # Actions
        action = Action('start', command='/bin/sleep 0.1')
        action.inherits_from(service1)
        service1.add_action(action)

        service2.add_dep(target=service1)

        action = Action('start', command='/bin/sleep 0.8')
        action.inherits_from(service2)
        service2.add_action(action)

        # Register services within the manager
        self.manager.add_service(service1)
        self.manager.add_service(service2)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:43,代码来源:CliTest.py

示例7: fromdict

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [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

示例8: test_command_output_dist_report_full_error_and_ok

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
    def test_command_output_dist_report_full_error_and_ok(self):
        """
        Test command line output with full report, FAILED actions and OK
        actions on distant nodes.
        """
        # Service
        svc = Service('service_ok')
        svc.desc = 'I am the ok service'
        svc2 = Service('service_fail')
        svc2.desc = 'I am the fail service'
        svc.add_dep(svc2, sgth=REQUIRE_WEAK)
        # Actions
        false_action = Action('stop', command='/bin/false', target=NodeSet(HOSTNAME))
        false_action.inherits_from(svc)
        svc.add_action(false_action)

        true_action = Action('stop', command='/bin/true', target=NodeSet(HOSTNAME))
        true_action.inherits_from(svc2)
        svc2.add_action(true_action)

        # Register services within the manager
        self.manager.add_service(svc)
        self.manager.add_service(svc2)

        # FIXME: must return RC_OK
        self._output_check(['service_fail', 'stop', '--report=full'], RC_OK,
"""stop service_ok ran in 0.00 s
 > HOSTNAME exited with 1
service_ok - I am the ok service                                  [  ERROR  ]
service_fail - I am the fail service                              [    OK   ]

 SUMMARY - 2 actions (1 failed)
 + service_ok.stop - I am the ok service
    Target: HOSTNAME
    Command: /bin/false
""")
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:38,代码来源:CliTest.py

示例9: CommandLineOutputTests

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import inherits_from [as 别名]
class CommandLineOutputTests(CLICommon):
    '''Tests cases of the command line output'''

    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                              _ start
           group --> service /
                             `- stop
        '''
        CLICommon.setUp(self)

        # ServiceGroup
        group = ServiceGroup('ServiceGroup')
        # Service
        self.service = service = Service('service')
        service.desc = 'I am the service'
        # Actions
        self.start_action = Action('start', command='/bin/true')
        self.stop_action = Action('stop', command='/bin/false')
        self.timeout_action = Action('timeout', command='sleep 1', timeout=0.1)
        self.start_action.inherits_from(service)
        self.stop_action.inherits_from(service)
        service.add_action(self.start_action)
        service.add_action(self.stop_action)
        service.add_action(self.timeout_action)

        # Build graph
        group.add_inter_dep(target=service)

        # Register services within the manager
        self.manager.add_service(group)

    def test_command_output_help(self):
        '''Test command line help output'''
        self._output_check([], RC_OK,
"""Usage: nosetests [options] [SERVICE...] ACTION

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -v, --verbose         Increase or decrease verbosity
  -d, --debug           Set debug mode and maximum verbosity
  -g, --graph           Output dependencies graph
  -s, --summary         --summary is an alias for --report=default
  -r REPORT, --report=REPORT
                        Display a report of executed actions
  -c CONFIG_DIR, --config-dir=CONFIG_DIR
                        Change configuration files directory
  -q, --quiet           Enable quiet mode
  -y, --assumeyes       Answer yes to any requested confirmation

  Engine parameters:
    Those options allow you to configure the behaviour of the engine

    -n ONLY_NODES, --only-nodes=ONLY_NODES
                        Use only the specified nodes
    -x EXCLUDED_NODES, --exclude-nodes=EXCLUDED_NODES
                        Exclude the cluster's nodes specified
    -X EXCLUDED_SVC, --exclude-service=EXCLUDED_SVC
                        Skip the specified services
    --dry-run           Only simulate command execution
    -D DEFINES, --define=DEFINES, --var=DEFINES
                        Define custom variables
    --nodeps            Do not run dependencies
    -t TAGS, --tags=TAGS
                        Run services matching these tags
""")

    def test_command_output_checkconfig(self):
        '''Test command line output checking config'''
        self._output_check(['-c', '../conf/samples'], RC_OK,
"""No actions specified, checking configuration...
../conf/samples seems good                     
""" )

    def test_command_line_variables(self):
        '''Test automatic variables from command line.'''
        self._output_check(['ServiceGroup', 'start', '-n', 'fo1', '-x', 'fo2'],
                           RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""", "[service]\r")
        self.assertEqual(self.manager.variables['SELECTED_NODES'], 'fo1')
        self.assertEqual(self.manager.variables['EXCLUDED_NODES'], 'fo2')

    def test_command_line_default_variables(self):
        '''Test default values of automatic variables from command line.'''
        self._output_check(['ServiceGroup', 'start'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""", "[service]\r")
        self.assertEqual(self.manager.variables['SELECTED_NODES'], '')
        self.assertEqual(self.manager.variables['EXCLUDED_NODES'], '')

    def test_command_output_ok(self):
        '''Test command line output with all actions OK'''
        self._output_check(['ServiceGroup', 'start'], RC_OK,
#.........这里部分代码省略.........
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:103,代码来源:CliTest.py


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