mirror of https://github.com/jumpserver/jumpserver
[future] 初步添加测试链接的接口
parent
97d7e6cb9b
commit
ccf3851d81
|
@ -468,7 +468,7 @@ def test_run():
|
|||
"ip": "192.168.1.119",
|
||||
"port": "22",
|
||||
"username": "root",
|
||||
"password": "tongfang_test",
|
||||
"password": "xxx",
|
||||
"key": "asset_private_key",
|
||||
},
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ def test_run():
|
|||
"username": "yumaojun",
|
||||
"password": "xxx",
|
||||
"key": "asset_private_key",
|
||||
"become": {"method": "sudo", "user": "root", "pass": "yusky0902"}
|
||||
"become": {"method": "sudo", "user": "root", "pass": "xxx"}
|
||||
},
|
||||
]
|
||||
# 初始化Play
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from .tasks import get_asset_hardware_info
|
||||
from .tasks import *
|
||||
from celery.result import AsyncResult
|
||||
|
||||
|
||||
|
@ -9,9 +9,16 @@ def start_get_hardware_info(*assets):
|
|||
return result.id
|
||||
|
||||
|
||||
def get_hardware_info(task_id):
|
||||
def get_result(task_id):
|
||||
result = AsyncResult(task_id)
|
||||
if result.ready():
|
||||
return {"Completed": False, "data": result.get()}
|
||||
return {"Completed": True, "data": result.get()}
|
||||
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):
|
|||
|
||||
|
||||
@shared_task(name="asset_test_ping_check")
|
||||
def asset_test_ping_check():
|
||||
pass
|
||||
def asset_test_ping_check(*assets):
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue