mirror of https://github.com/jumpserver/jumpserver
parent
18e590effd
commit
6a23983331
|
@ -203,11 +203,8 @@ class Node(OrgModelMixin):
|
||||||
# 如果使用current_org 在set_current_org时会死循环
|
# 如果使用current_org 在set_current_org时会死循环
|
||||||
_current_org = get_current_org()
|
_current_org = get_current_org()
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
if _current_org.is_root():
|
if not _current_org.is_real():
|
||||||
key = '0'
|
return cls.default_node()
|
||||||
elif _current_org.is_default():
|
|
||||||
key = '1'
|
|
||||||
else:
|
|
||||||
set_current_org(Organization.root())
|
set_current_org(Organization.root())
|
||||||
org_nodes_roots = cls.objects.filter(key__regex=r'^[0-9]+$')
|
org_nodes_roots = cls.objects.filter(key__regex=r'^[0-9]+$')
|
||||||
org_nodes_roots_keys = org_nodes_roots.values_list('key', flat=True) or ['1']
|
org_nodes_roots_keys = org_nodes_roots.values_list('key', flat=True) or ['1']
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# ~*~ coding: utf-8 ~*~
|
# ~*~ coding: utf-8 ~*~
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
|
@ -163,6 +164,28 @@ class CommandResultCallback(AdHocResultCallback):
|
||||||
self._play = play
|
self._play = play
|
||||||
self._display.banner(msg)
|
self._display.banner(msg)
|
||||||
|
|
||||||
|
def v2_runner_on_unreachable(self, result):
|
||||||
|
self.results_summary['success'] = False
|
||||||
|
self.gather_result("unreachable", result)
|
||||||
|
msg = result._result.get("msg")
|
||||||
|
if not msg:
|
||||||
|
msg = json.dumps(result._result, indent=4)
|
||||||
|
self._display.display("%s | FAILED! => \n%s" % (
|
||||||
|
result._host.get_name(),
|
||||||
|
msg,
|
||||||
|
), color=C.COLOR_ERROR)
|
||||||
|
|
||||||
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
||||||
|
self.results_summary['success'] = False
|
||||||
|
self.gather_result("failed", result)
|
||||||
|
msg = result._result.get("msg") or result._result.get("module_stdout")
|
||||||
|
if not msg:
|
||||||
|
msg = json.dumps(result._result, indent=4)
|
||||||
|
self._display.display("%s | FAILED! => \n%s" % (
|
||||||
|
result._host.get_name(),
|
||||||
|
msg,
|
||||||
|
), color=C.COLOR_ERROR)
|
||||||
|
|
||||||
def _print_task_banner(self, task):
|
def _print_task_banner(self, task):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue