mirror of https://github.com/jumpserver/jumpserver
fix: windows gather account failed
parent
77caa5536f
commit
0ea675f8d6
|
@ -51,8 +51,16 @@ class GatherAccountsManager(AccountBasePlaybookManager):
|
||||||
data = self.generate_data(asset, result)
|
data = self.generate_data(asset, result)
|
||||||
self.asset_account_info[asset] = data
|
self.asset_account_info[asset] = data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_nested_info(data, *keys):
|
||||||
|
for key in keys:
|
||||||
|
data = data.get(key, {})
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
return data
|
||||||
|
|
||||||
def on_host_success(self, host, result):
|
def on_host_success(self, host, result):
|
||||||
info = result.get('debug', {}).get('res', {}).get('info', {})
|
info = self.get_nested_info(result, 'debug', 'res', 'info')
|
||||||
asset = self.host_asset_mapper.get(host)
|
asset = self.host_asset_mapper.get(host)
|
||||||
if asset and info:
|
if asset and info:
|
||||||
result = self.filter_success_result(asset.type, info)
|
result = self.filter_success_result(asset.type, info)
|
||||||
|
|
|
@ -300,12 +300,16 @@ class BasePlaybookManager:
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
result = cb.host_results.get(host)
|
result = cb.host_results.get(host)
|
||||||
if state == 'ok':
|
if state == 'ok':
|
||||||
self.on_host_success(host, result)
|
self.on_host_success(host, result.get('ok', ''))
|
||||||
elif state == 'skipped':
|
elif state == 'skipped':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
error = hosts.get(host)
|
error = hosts.get(host)
|
||||||
self.on_host_error(host, error, result)
|
self.on_host_error(
|
||||||
|
host, error,
|
||||||
|
result.get('failures', '')
|
||||||
|
or result.get('dark', '')
|
||||||
|
)
|
||||||
|
|
||||||
def on_runner_failed(self, runner, e):
|
def on_runner_failed(self, runner, e):
|
||||||
print("Runner failed: {} {}".format(e, self))
|
print("Runner failed: {} {}".format(e, self))
|
||||||
|
|
|
@ -35,10 +35,10 @@ class DefaultCallback:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host_results(self):
|
def host_results(self):
|
||||||
results = {}
|
results = defaultdict(dict)
|
||||||
for state, hosts in self.result.items():
|
for state, hosts in self.result.items():
|
||||||
for host, items in hosts.items():
|
for host, items in hosts.items():
|
||||||
results[host] = items
|
results[host][state] = items
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def is_success(self):
|
def is_success(self):
|
||||||
|
|
Loading…
Reference in New Issue