當前位置: 首頁>>代碼示例>>Python>>正文


Python constants.COLOR_CHANGED屬性代碼示例

本文整理匯總了Python中ansible.constants.COLOR_CHANGED屬性的典型用法代碼示例。如果您正苦於以下問題:Python constants.COLOR_CHANGED屬性的具體用法?Python constants.COLOR_CHANGED怎麽用?Python constants.COLOR_CHANGED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在ansible.constants的用法示例。


在下文中一共展示了constants.COLOR_CHANGED屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: v2_runner_item_on_ok

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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: _get_item_line

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例3: _changed_or_not

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例4: v2_runner_on_unreachable

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [as 別名]
def v2_runner_on_unreachable(self, result):
        self._emit_line('{} | UNREACHABLE!: {}'.format(
            self._host_string(result), result._result.get('msg', '')), color=C.COLOR_CHANGED) 
開發者ID:octplane,項目名稱:ansible_stdout_compact_logger,代碼行數:5,代碼來源:anstomlog.py

示例5: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例6: v2_runner_on_ok

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例7: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例8: v2_runner_item_on_ok

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例9: v2_runner_on_ok

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例10: v2_runner_on_ok

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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

示例11: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_CHANGED [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_CHANGED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。