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


Python constants.COLOR_OK属性代码示例

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


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

示例1: v2_runner_item_on_ok

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_runner_item_on_ok(self, result):
        """Print out task results for items you're iterating over"""
        delegated_vars = result._result.get('_ansible_delegated_vars', None)
        if result._task.action in ('include', 'include_role'):
            return
        elif result._result.get('changed', False):
            msg = 'changed'
            color = C.COLOR_CHANGED
        else:
            msg = 'ok'
            color = C.COLOR_OK

        if delegated_vars:
            msg += ": [%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
        else:
            msg += ": [%s]" % result._host.get_name()

        msg += " => (item=%s)" % (self._get_item(result._result),)

        if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
            msg += " => %s" % self._dump_results(result._result)
        self._display.display(msg, color=color, log_only=True) 
开发者ID:openshift,项目名称:origin-ci-tool,代码行数:24,代码来源:openshift_quick_installer.py

示例2: v2_playbook_on_stats

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_playbook_on_stats(self, stats):
        if os.path.isfile(FAIL_LOGFILE):
            count = -1
            with open(FAIL_LOGFILE, 'r') as f:
                for count, line in enumerate(f):
                    pass
                count += 1

            if count > 0:
                self._display.banner("ERROR MESSAGE SUMMARY")
                with io.open(FAIL_LOGFILE, 'r', encoding="utf-8") as f:
                    for _, line in enumerate(f):
                        self._display.display(line.strip('\n'), color=C.COLOR_ERROR)
                    self.print_help_message()
            else:
                self._display.display("Congrats! All goes well. :-)", color=C.COLOR_OK) 
开发者ID:pingcap,项目名称:tidb-ansible,代码行数:18,代码来源:help.py

示例3: _get_item_line

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def _get_item_line(self, result, item=False):
        line = [
            self._get_uuid(result)
        ]
        host_str = self._get_host(result=result)

        if (getattr(result, '_result', False)
                and result._result.get('changed', False)):
            line.append(self._get_state('CHANGED')),
            line.append(self._get_task_name(result))
            line.append(host_str)
            color = C.COLOR_CHANGED
        else:
            if not self.display_ok_hosts:
                return (None, None)
            line.append(self._get_state('OK'))
            line.append(self._get_task_name(result))
            line.append(host_str)
            color = C.COLOR_OK
        if item:
            item_result = self._get_item_label(result._result)
            # don't display if None
            if item_result:
                line.append('item=%s' % item_result)
        return (line, color) 
开发者ID:openstack,项目名称:tripleo-ansible,代码行数:27,代码来源:tripleo_dense.py

示例4: phase_color

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def phase_color(self, status):
        """ Return color code for installer phase"""
        valid_status = [
            'In Progress',
            'Complete',
        ]

        if status not in valid_status:
            self._display.warning('Invalid phase status defined: {}'.format(status))

        if status == 'Complete':
            phase_color = C.COLOR_OK
        elif status == 'In Progress':
            phase_color = C.COLOR_ERROR
        else:
            phase_color = C.COLOR_WARN

        return phase_color 
开发者ID:ceph,项目名称:ceph-ansible,代码行数:20,代码来源:installer_checkpoint.py

示例5: _changed_or_not

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def _changed_or_not(result, host_string):
        if result.get('changed', False):
            msg = "%s | CHANGED" % host_string
            color = C.COLOR_CHANGED
        else:
            msg = "%s | SUCCESS" % host_string
            color = C.COLOR_OK

        return [msg, color] 
开发者ID:octplane,项目名称:ansible_stdout_compact_logger,代码行数:11,代码来源:anstomlog.py

示例6: _emit_line

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def _emit_line(self, lines, color=C.COLOR_OK):

        if self.task_start_preamble is None:
            self._open_section("system")

        if self.task_start_preamble.endswith(" ..."):
            sys.stdout.write("\b\b\b\b | ")
            self.task_start_preamble = " "

        for line in lines.splitlines():
            self._display.display(line, color=color) 
开发者ID:octplane,项目名称:ansible_stdout_compact_logger,代码行数:13,代码来源:anstomlog.py

示例7: v2_playbook_on_stats

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_playbook_on_stats(self, stats):
        self._open_section("system")
        self._emit_line("-- Play recap --")

        hosts = sorted(stats.processed.keys())
        for h in hosts:
            t = stats.summarize(h)

            self._emit_line(u"%s : %s %s %s %s" % (
                hostcolor(h, t),
                colorize(u'ok', t['ok'], C.COLOR_OK),
                colorize(u'changed', t['changed'], C.COLOR_CHANGED),
                colorize(u'unreachable', t['unreachable'], C.COLOR_UNREACHABLE),
                colorize(u'failed', t['failures'], C.COLOR_ERROR))) 
开发者ID:octplane,项目名称:ansible_stdout_compact_logger,代码行数:16,代码来源:anstomlog.py

示例8: v2_runner_on_ok

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_runner_on_ok(self, result):
        """This prints out task results in a fancy format

The only thing we change here is adding `log_only=True` to the
.display() call
        """
        delegated_vars = result._result.get('_ansible_delegated_vars', None)
        self._clean_results(result._result, result._task.action)
        if result._task.action in ('include', 'include_role'):
            return
        elif result._result.get('changed', False):
            if delegated_vars:
                msg = "changed: [%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
            else:
                msg = "changed: [%s]" % result._host.get_name()
            color = C.COLOR_CHANGED
        else:
            if delegated_vars:
                msg = "ok: [%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
            else:
                msg = "ok: [%s]" % result._host.get_name()
            color = C.COLOR_OK

        if result._task.loop and 'results' in result._result:
            self._process_items(result)
        else:

            if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
                msg += " => %s" % (self._dump_results(result._result),)
            self._display.display(msg, color=color, log_only=True)

        self._handle_warnings(result._result) 
开发者ID:openshift,项目名称:origin-ci-tool,代码行数:34,代码来源:openshift_quick_installer.py

示例9: v2_playbook_on_stats

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_playbook_on_stats(self, stats):
        """Print the final playbook run stats"""
        self._display.display("", screen_only=True)
        self.banner("PLAY RECAP")

        hosts = sorted(stats.processed.keys())
        for h in hosts:
            t = stats.summarize(h)

            self._display.display(
                u"%s : %s %s %s %s" % (
                    hostcolor(h, t),
                    colorize(u'ok', t['ok'], C.COLOR_OK),
                    colorize(u'changed', t['changed'], C.COLOR_CHANGED),
                    colorize(u'unreachable', t['unreachable'], C.COLOR_UNREACHABLE),
                    colorize(u'failed', t['failures'], C.COLOR_ERROR)),
                screen_only=True
            )

            self._display.display(
                u"%s : %s %s %s %s" % (
                    hostcolor(h, t, False),
                    colorize(u'ok', t['ok'], None),
                    colorize(u'changed', t['changed'], None),
                    colorize(u'unreachable', t['unreachable'], None),
                    colorize(u'failed', t['failures'], None)),
                log_only=True
            )

        self._display.display("", screen_only=True)
        self._display.display("", screen_only=True)

        # Some plays are conditional and won't run (such as load
        # balancers) if they aren't required. Let the user know about
        # this to avoid potential confusion.
        if self.plays_total_ran != self.plays_count:
            print("Installation Complete: Note: Play count is an estimate and some were skipped because your install does not require them")
            self._display.display("", screen_only=True) 
开发者ID:openshift,项目名称:origin-ci-tool,代码行数:40,代码来源:openshift_quick_installer.py

示例10: v2_runner_on_ok

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_runner_on_ok(self, result, **kwargs):
        host_name = result._host
        task_name = result._task.get_name()
        task_fields = result._task_fields
        results = result._result  # A dict of the module name etc.
        self._dump_results(results)
        warnings = results.get('warnings', [])
        # Print only tasks that produced some warnings:
        if warnings:
            for warning in warnings:
                warn_msg = "{}\n".format(warning)
            self._display.display(WARNING_TEMPLATE.format(task_name,
                                                          host_name,
                                                          warn_msg),
                                  color=C.COLOR_WARN)

        if 'debug' in task_fields['action']:
            output = ""

            if 'var' in task_fields['args']:
                variable = task_fields['args']['var']
                value = results[variable]
                output = "{}: {}".format(variable, str(value))
            elif 'msg' in task_fields['args']:
                output = "Message: {}".format(
                    task_fields['args']['msg'])

            self._display.display(DEBUG_TEMPLATE.format(host_name, output),
                                  color=C.COLOR_OK) 
开发者ID:openstack,项目名称:tripleo-validations,代码行数:31,代码来源:validation_output.py

示例11: v2_playbook_on_stats

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_playbook_on_stats(self, stats):
        def failed(host):
            _failures = stats.summarize(host).get('failures', 0) > 0
            _unreachable = stats.summarize(host).get('unreachable', 0) > 0
            return (_failures or _unreachable)

        hosts = sorted(stats.processed.keys())
        failed_hosts = [host for host in hosts if failed(host)]

        if hosts:
            if failed_hosts:
                if len(failed_hosts) == len(hosts):
                    print("Failure! The validation failed for all hosts:")
                    for failed_host in failed_hosts:
                        self._display.display("* %s" % failed_host,
                                              color=C.COLOR_ERROR)
                else:
                    print("Failure! The validation failed for hosts:")
                    for failed_host in failed_hosts:
                        self._display.display("* %s" % failed_host,
                                              color=C.COLOR_ERROR)
                    print("and passed for hosts:")
                    for host in [h for h in hosts if h not in failed_hosts]:
                        self._display.display("* %s" % host,
                                              color=C.COLOR_OK)
            else:
                print("Success! The validation passed for all hosts:")
                for host in hosts:
                    self._display.display("* %s" % host,
                                          color=C.COLOR_OK)
        else:
            print("Warning! The validation did not run on any host.") 
开发者ID:openstack,项目名称:tripleo-validations,代码行数:34,代码来源:validation_output.py

示例12: v2_runner_item_on_ok

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_runner_item_on_ok(self, result):

        delegated_vars = result._result.get('_ansible_delegated_vars', None)
        self._clean_results(result._result, result._task.action)
        if isinstance(result._task, TaskInclude):
            return
        elif result._result.get('changed', False):
            if self._last_task_banner != result._task._uuid:
                self._print_task_banner(result._task)

            msg = 'changed'
            color = C.COLOR_CHANGED
        else:
            if not self.display_ok_hosts:
                return

            if self._last_task_banner != result._task._uuid:
                self._print_task_banner(result._task)

            msg = 'ok'
            color = C.COLOR_OK

        if delegated_vars:
            msg += ": [%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
        else:
            msg += ": [%s]" % result._host.get_name()

        msg += " => (item=%s)" % (self._get_item_label(result._result),)

        if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
            msg += " => %s" % self._dump_results(result._result)
            ## refactored for litmuschaos
            self._display.display(msg, color=color) 
开发者ID:litmuschaos,项目名称:litmus,代码行数:35,代码来源:default.py

示例13: v2_runner_on_ok

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_runner_on_ok(self, result):
        if 'changed' in result._result and result._result['changed']:
            self._process_results(result, 'SUCCESS', C.COLOR_CHANGED)
        else:
            self._process_results(result, 'SUCCESS', C.COLOR_OK) 
开发者ID:gluster,项目名称:gdeploy,代码行数:7,代码来源:gdeploy.py

示例14: v2_runner_on_ok

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_runner_on_ok(self, result):

        delegated_vars = result._result.get('_ansible_delegated_vars', None)

        if isinstance(result._task, TaskInclude):
            return
        elif result._result.get('changed', False):
            if self._last_task_banner != result._task._uuid:
                self._print_task_banner(result._task)

            ## refactored for litmuschaos
            '''
            if delegated_vars:
                msg = "changed: [%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
            else:
                msg = "changed: [%s]" % result._host.get_name()
            color = C.COLOR_CHANGED
            '''
        else:
            if not self.display_ok_hosts:
                return

            if self._last_task_banner != result._task._uuid:
                self._print_task_banner(result._task)

            ## refactored for litmuschaos
            '''
            if delegated_vars:
                msg = "ok: [%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
            else:
                msg = "ok: [%s]" % result._host.get_name()
            color = C.COLOR_OK
            '''
        self._handle_warnings(result._result)

        if result._task.loop and 'results' in result._result:
            self._process_items(result)
        else:
            self._clean_results(result._result, result._task.action)

            if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
                ## refactored for litmuschaos
                color = C.COLOR_OK
                msg = "details => %s" % (self._dump_results(result._result),)
                self._display.display(msg, color=color) 
开发者ID:litmuschaos,项目名称:litmus,代码行数:47,代码来源:default.py

示例15: v2_playbook_on_stats

# 需要导入模块: from ansible import constants [as 别名]
# 或者: from ansible.constants import COLOR_OK [as 别名]
def v2_playbook_on_stats(self, stats):
        '''
        self._display.banner("PLAY RECAP")
        '''
        self._display.banner("************ RELAX, EXPERIMENT ENDS! ************")
        hosts = sorted(stats.processed.keys())
        for h in hosts:
            t = stats.summarize(h)

            self._display.display(u"%s : %s %s %s %s" % (
                hostcolor(h, t),
                colorize(u'ok', t['ok'], C.COLOR_OK),
                colorize(u'changed', t['changed'], C.COLOR_CHANGED),
                colorize(u'unreachable', t['unreachable'], C.COLOR_UNREACHABLE),
                colorize(u'failed', t['failures'], C.COLOR_ERROR)),
                screen_only=True
            )

            self._display.display(u"%s : %s %s %s %s" % (
                hostcolor(h, t, False),
                colorize(u'ok', t['ok'], None),
                colorize(u'changed', t['changed'], None),
                colorize(u'unreachable', t['unreachable'], None),
                colorize(u'failed', t['failures'], None)),
                log_only=True
            )

        self._display.display("", screen_only=True)

        # print custom stats if required
        if stats.custom and self.show_custom_stats:
            self._display.banner("CUSTOM STATS: ")
            # per host
            # TODO: come up with 'pretty format'
            for k in sorted(stats.custom.keys()):
                if k == '_run':
                    continue
                self._display.display('\t%s: %s' % (k, self._dump_results(stats.custom[k], indent=1).replace('\n', '')))

            # print per run custom stats
            if '_run' in stats.custom:
                self._display.display("", screen_only=True)
                self._display.display('\tRUN: %s' % self._dump_results(stats.custom['_run'], indent=1).replace('\n', ''))
            self._display.display("", screen_only=True) 
开发者ID:litmuschaos,项目名称:litmus,代码行数:46,代码来源:default.py


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