Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
ccf3851d
Commit
ccf3851d
authored
8 years ago
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[future] 初步添加测试链接的接口
parent
97d7e6cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
8 deletions
+26
-8
ansible_api.py
apps/ops/ansible_api.py
+2
-2
taskers.py
apps/ops/taskers.py
+11
-4
tasks.py
apps/ops/tasks.py
+13
-2
No files found.
apps/ops/ansible_api.py
View file @
ccf3851d
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
apps/ops/taskers.py
View file @
ccf3851d
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"
:
Fals
e
,
"data"
:
result
.
get
()}
return
{
"Completed"
:
Tru
e
,
"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
This diff is collapsed.
Click to expand it.
apps/ops/tasks.py
View file @
ccf3851d
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment