[Update] 优化测试可连接性时结果获取 (#2825)

pull/2827/head
BaiJiangJie 6 years ago committed by 老广
parent 4fbb4c6082
commit bb1a941240

@ -209,9 +209,13 @@ def test_asset_connectivity_util(assets, task_name=None):
) )
result = task.run() result = task.run()
summary = result[1] summary = result[1]
results_summary['success'] &= summary['success'] success = summary.get('success', False)
results_summary['contacted'].update(summary['contacted']) contacted = summary.get('contacted', {})
results_summary['dark'].update(summary['dark']) dark = summary.get('dark', {})
results_summary['success'] &= success
results_summary['contacted'].update(contacted)
results_summary['dark'].update(dark)
for asset in assets: for asset in assets:
if asset.hostname in results_summary.get('dark', {}): if asset.hostname in results_summary.get('dark', {}):
@ -330,14 +334,17 @@ def test_system_user_connectivity_util(system_user, assets, task_name):
task, created = update_or_create_ansible_task( task, created = update_or_create_ansible_task(
task_name=task_name, hosts=value['hosts'], tasks=value['tasks'], task_name=task_name, hosts=value['hosts'], tasks=value['tasks'],
pattern='all', options=const.TASK_OPTIONS, pattern='all', options=const.TASK_OPTIONS,
run_as=system_user.username, run_as=system_user.username, created_by=system_user.org_id,
created_by=system_user.org_id,
) )
result = task.run() result = task.run()
summary = result[1] summary = result[1]
results_summary['success'] &= summary['success'] success = summary.get('success', False)
results_summary['contacted'].update(summary['contacted']) contacted = summary.get('contacted', {})
results_summary['dark'].update(summary['dark']) dark = summary.get('dark', {})
results_summary['success'] &= success
results_summary['contacted'].update(contacted)
results_summary['dark'].update(dark)
set_system_user_connectivity_info(system_user, results_summary) set_system_user_connectivity_info(system_user, results_summary)
return results_summary return results_summary

Loading…
Cancel
Save