Commit ccf3851d authored by Administrator's avatar Administrator

[future] 初步添加测试链接的接口

parent 97d7e6cb
...@@ -468,7 +468,7 @@ def test_run(): ...@@ -468,7 +468,7 @@ def test_run():
"ip": "192.168.1.119", "ip": "192.168.1.119",
"port": "22", "port": "22",
"username": "root", "username": "root",
"password": "tongfang_test", "password": "xxx",
"key": "asset_private_key", "key": "asset_private_key",
}, },
{ {
...@@ -478,7 +478,7 @@ def test_run(): ...@@ -478,7 +478,7 @@ def test_run():
"username": "yumaojun", "username": "yumaojun",
"password": "xxx", "password": "xxx",
"key": "asset_private_key", "key": "asset_private_key",
"become": {"method": "sudo", "user": "root", "pass": "yusky0902"} "become": {"method": "sudo", "user": "root", "pass": "xxx"}
}, },
] ]
# 初始化Play # 初始化Play
......
from __future__ import unicode_literals from __future__ import unicode_literals
from .tasks import get_asset_hardware_info from .tasks import *
from celery.result import AsyncResult from celery.result import AsyncResult
...@@ -9,9 +9,16 @@ def start_get_hardware_info(*assets): ...@@ -9,9 +9,16 @@ def start_get_hardware_info(*assets):
return result.id return result.id
def get_hardware_info(task_id): def get_result(task_id):
result = AsyncResult(task_id) result = AsyncResult(task_id)
if result.ready(): if result.ready():
return {"Completed": False, "data": result.get()} return {"Completed": True, "data": result.get()}
else: else:
return {"Completed": True, "data": None} return {"Completed": False, "data": None}
def start_ping_test(*assets):
result = asset_test_ping_check.delay(*assets)
return result.id
...@@ -23,8 +23,19 @@ def get_asset_hardware_info(*assets): ...@@ -23,8 +23,19 @@ def get_asset_hardware_info(*assets):
@shared_task(name="asset_test_ping_check") @shared_task(name="asset_test_ping_check")
def asset_test_ping_check(): def asset_test_ping_check(*assets):
pass conf = Config()
play_source = {
"name": "Test host connection use ping",
"hosts": "default",
"gather_facts": "no",
"tasks": [
dict(action=dict(module='ping'))
]
}
hoc = ADHocRunner(conf, play_source, *assets)
ext_code, result = hoc.run()
return ext_code, result
@shared_task(name="add_user_to_assert") @shared_task(name="add_user_to_assert")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment