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
24c4e1df
Commit
24c4e1df
authored
Apr 02, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 资产,系统用户,管理用户等支持查看日志
parent
d247e49b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
65 additions
and
60 deletions
+65
-60
admin_user.py
apps/assets/api/admin_user.py
+2
-3
asset.py
apps/assets/api/asset.py
+4
-12
node.py
apps/assets/api/node.py
+4
-5
system_user.py
apps/assets/api/system_user.py
+4
-5
tasks.py
apps/assets/tasks.py
+3
-2
admin_user_assets.html
apps/assets/templates/assets/admin_user_assets.html
+6
-4
asset_detail.html
apps/assets/templates/assets/asset_detail.html
+12
-12
asset_list.html
apps/assets/templates/assets/asset_list.html
+12
-6
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+12
-8
task_list.html
apps/ops/templates/ops/task_list.html
+2
-1
jumpserver.js
apps/static/js/jumpserver.js
+4
-2
No files found.
apps/assets/api/admin_user.py
View file @
24c4e1df
...
...
@@ -79,5 +79,5 @@ class AdminUserTestConnectiveApi(generics.RetrieveAPIView):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
admin_user
=
self
.
get_object
()
test_admin_user_connectability_manual
.
delay
(
admin_user
)
return
Response
({
"msg"
:
"Task created"
})
\ No newline at end of file
task
=
test_admin_user_connectability_manual
.
delay
(
admin_user
)
return
Response
({
"task"
:
task
.
id
})
apps/assets/api/asset.py
View file @
24c4e1df
...
...
@@ -87,12 +87,8 @@ class AssetRefreshHardwareApi(generics.RetrieveAPIView):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
asset_id
=
kwargs
.
get
(
'pk'
)
asset
=
get_object_or_404
(
Asset
,
pk
=
asset_id
)
summary
=
update_asset_hardware_info_manual
(
asset
)[
1
]
logger
.
debug
(
"Refresh summary: {}"
.
format
(
summary
))
if
summary
.
get
(
'dark'
):
return
Response
(
summary
[
'dark'
]
.
values
(),
status
=
501
)
else
:
return
Response
({
"msg"
:
"ok"
})
task
=
update_asset_hardware_info_manual
.
delay
(
asset
)
return
Response
({
"task"
:
task
.
id
})
class
AssetAdminUserTestApi
(
generics
.
RetrieveAPIView
):
...
...
@@ -105,8 +101,5 @@ class AssetAdminUserTestApi(generics.RetrieveAPIView):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
asset_id
=
kwargs
.
get
(
'pk'
)
asset
=
get_object_or_404
(
Asset
,
pk
=
asset_id
)
ok
,
msg
=
test_asset_connectability_manual
(
asset
)
if
ok
:
return
Response
({
"msg"
:
"pong"
})
else
:
return
Response
({
"error"
:
msg
},
status
=
502
)
\ No newline at end of file
task
=
test_asset_connectability_manual
.
delay
(
asset
)
return
Response
({
"task"
:
task
.
id
})
apps/assets/api/node.py
View file @
24c4e1df
...
...
@@ -130,10 +130,9 @@ class RefreshNodeHardwareInfoApi(APIView):
node_id
=
kwargs
.
get
(
'pk'
)
node
=
get_object_or_404
(
self
.
model
,
id
=
node_id
)
assets
=
node
.
assets
.
all
()
# task_name = _("Refresh node assets hardware info: {}".format(node.name))
task_name
=
_
(
"更新节点资产硬件信息: {}"
.
format
(
node
.
name
))
update_assets_hardware_info_util
.
delay
(
assets
,
task_name
=
task_name
)
return
Response
({
"
msg"
:
"Task created"
})
task
=
update_assets_hardware_info_util
.
delay
(
assets
,
task_name
=
task_name
)
return
Response
({
"
task"
:
task
.
id
})
class
TestNodeConnectiveApi
(
APIView
):
...
...
@@ -145,6 +144,6 @@ class TestNodeConnectiveApi(APIView):
node
=
get_object_or_404
(
self
.
model
,
id
=
node_id
)
assets
=
node
.
assets
.
all
()
task_name
=
_
(
"测试节点下资产是否可连接: {}"
.
format
(
node
.
name
))
test_asset_connectability_util
.
delay
(
assets
,
task_name
=
task_name
)
return
Response
({
"
msg"
:
"Task created"
})
t
ask
=
t
est_asset_connectability_util
.
delay
(
assets
,
task_name
=
task_name
)
return
Response
({
"
task"
:
task
.
id
})
apps/assets/api/system_user.py
View file @
24c4e1df
...
...
@@ -58,8 +58,8 @@ class SystemUserPushApi(generics.RetrieveAPIView):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
system_user
=
self
.
get_object
()
push_system_user_to_assets_manual
.
delay
(
system_user
)
return
Response
({
"
msg"
:
"Task created"
})
task
=
push_system_user_to_assets_manual
.
delay
(
system_user
)
return
Response
({
"
task"
:
task
.
id
})
class
SystemUserTestConnectiveApi
(
generics
.
RetrieveAPIView
):
...
...
@@ -71,5 +71,5 @@ class SystemUserTestConnectiveApi(generics.RetrieveAPIView):
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
system_user
=
self
.
get_object
()
test_system_user_connectability_manual
.
delay
(
system_user
)
return
Response
({
"msg"
:
"Task created"
})
\ No newline at end of file
task
=
test_system_user_connectability_manual
.
delay
(
system_user
)
return
Response
({
"task"
:
task
.
id
})
apps/assets/tasks.py
View file @
24c4e1df
...
...
@@ -215,7 +215,7 @@ def test_admin_user_connectability_period():
def
test_admin_user_connectability_manual
(
admin_user
):
# task_name = _("Test admin user connectability: {}").format(admin_user.name)
task_name
=
_
(
"测试管理行号可连接性: {}"
)
.
format
(
admin_user
.
name
)
return
test_admin_user_connectability_util
.
delay
(
admin_user
,
task_name
)
return
test_admin_user_connectability_util
(
admin_user
,
task_name
)
@shared_task
...
...
@@ -395,11 +395,12 @@ def get_node_push_system_user_task_name(system_user, node):
)
@shared_task
def
push_system_user_to_node
(
system_user
,
node
):
logger
.
info
(
"Start push system user node: {} => {}"
.
format
(
system_user
.
name
,
node
.
value
))
assets
=
node
.
get_all_assets
()
task_name
=
get_node_push_system_user_task_name
(
system_user
,
node
)
push_system_user_util
.
delay
([
system_user
],
assets
,
task_name
)
push_system_user_util
([
system_user
],
assets
,
task_name
)
@shared_task
...
...
apps/assets/templates/assets/admin_user_assets.html
View file @
24c4e1df
...
...
@@ -121,14 +121,16 @@ $(document).ready(function () {
})
.
on
(
'click'
,
'.btn-test-connective'
,
function
()
{
var
the_url
=
"{% url 'api-assets:admin-user-connective' pk=admin_user.id %}"
;
var
error
=
function
(
data
)
{
alert
(
data
)
var
success
=
function
(
data
)
{
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
};
APIUpdateAttr
({
url
:
the_url
,
error
:
error
,
method
:
'GET'
,
success_message
:
"{% trans 'Task has been send, seen left asset status' %}"
success
:
success
,
flash_message
:
false
});
})
</script>
...
...
apps/assets/templates/assets/asset_detail.html
View file @
24c4e1df
...
...
@@ -269,16 +269,15 @@ function updateAssetNodes(nodes) {
function
refreshAssetHardware
()
{
var
the_url
=
"{% url 'api-assets:asset-refresh' pk=asset.id %}"
;
var
success
=
function
(
data
)
{
location
.
reload
(
);
}
;
var
error
=
function
(
data
)
{
alert
(
data
)
var
success
=
function
(
data
)
{
console
.
log
(
data
);
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
};
APIUpdateAttr
({
url
:
the_url
,
success
:
success
,
error
:
error
,
method
:
'GET'
});
}
...
...
@@ -344,19 +343,20 @@ $(document).ready(function () {
var
redirect_url
=
"{% url 'assets:asset-list' %}"
;
objectDelete
(
$this
,
name
,
the_url
,
redirect_url
);
}).
on
(
'click'
,
'#btn_refresh_asset'
,
function
()
{
alert
(
'关闭alert, 等待完成, 自动刷新页面'
);
refreshAssetHardware
()
}).
on
(
'click'
,
'#btn-test-is-alive'
,
function
()
{
var
the_url
=
"{% url 'api-assets:asset-alive-test' pk=asset.id %}"
;
var
error
=
function
(
data
)
{
alert
(
data
)
var
success
=
function
(
data
)
{
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
};
alert
(
'关闭alert, 等待完成'
);
APIUpdateAttr
({
url
:
the_url
,
error
:
error
,
method
:
'GET'
,
success
_message
:
"{% trans "
Reachable
" %}"
success
:
success
});
})
...
...
apps/assets/templates/assets/asset_list.html
View file @
24c4e1df
...
...
@@ -497,14 +497,17 @@ $(document).ready(function(){
}
var
the_url
=
url
.
replace
(
"{{ DEFAULT_PK }}"
,
current_node
.
id
);
function
success
()
{
function
success
(
data
)
{
rMenu
.
css
({
"visibility"
:
"hidden"
});
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
}
APIUpdateAttr
({
url
:
the_url
,
method
:
"GET"
,
success
_message
:
"更新硬件信息任务下发成功"
,
success
:
success
success
:
success
,
flash_message
:
false
});
})
...
...
@@ -519,14 +522,17 @@ $(document).ready(function(){
}
var
the_url
=
url
.
replace
(
"{{ DEFAULT_PK }}"
,
current_node
.
id
);
function
success
()
{
function
success
(
data
)
{
rMenu
.
css
({
"visibility"
:
"hidden"
});
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
}
APIUpdateAttr
({
url
:
the_url
,
method
:
"GET"
,
success
_message
:
"测试可连接性任务下发成功"
,
success
:
success
success
:
success
,
flash_message
:
false
});
})
.
on
(
'click'
,
'.btn_asset_delete'
,
function
()
{
...
...
apps/assets/templates/assets/system_user_detail.html
View file @
24c4e1df
...
...
@@ -293,26 +293,30 @@ $(document).ready(function () {
})
.
on
(
'click'
,
'.btn-push'
,
function
()
{
var
the_url
=
"{% url 'api-assets:system-user-push' pk=system_user.id %}"
;
var
error
=
function
(
data
)
{
alert
(
data
)
var
success
=
function
(
data
)
{
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
};
APIUpdateAttr
({
url
:
the_url
,
error
:
error
,
method
:
'GET'
,
success_message
:
"{% trans "
Task
has
been
send
,
Go
to
ops
task
list
seen
result
" %}"
success
:
success
,
flash_message
:
false
});
})
.
on
(
'click'
,
'.btn-test-connective'
,
function
()
{
var
the_url
=
"{% url 'api-assets:system-user-connective' pk=system_user.id %}"
;
var
error
=
function
(
data
)
{
alert
(
data
)
var
success
=
function
(
data
)
{
var
task_id
=
data
.
task
;
var
url
=
'{% url "ops:celery-task-log" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
task_id
);
window
.
open
(
url
,
''
,
'width=800,height=600'
)
};
APIUpdateAttr
({
url
:
the_url
,
error
:
error
,
method
:
'GET'
,
success_message
:
"{% trans "
Task
has
been
send
,
seen
left
assets
status
" %}"
success
:
success
,
flash_message
:
false
});
})
</script>
...
...
apps/ops/templates/ops/task_list.html
View file @
24c4e1df
{% extends '_base_list.html' %}
{% load i18n %}
{% load static %}
{% block content_left_head %}
<
link
href=
"{% static 'css/plugins/datepicker/datepicker3.css' %}"
rel=
"stylesheet"
>
<
div
class=
"uc pull-left m-r-5"
><a
class=
"btn btn-sm btn-primary btn-create-asset"
>
{% trans "Create task" %}
</a></div
>
{% endblock %}
...
...
apps/static/js/jumpserver.js
View file @
24c4e1df
...
...
@@ -157,7 +157,7 @@ function APIUpdateAttr(props) {
props
=
props
||
{};
var
success_message
=
props
.
success_message
||
'更新成功!'
;
var
fail_message
=
props
.
fail_message
||
'更新时发生未知错误.'
;
var
flash_message
=
true
;
var
flash_message
=
props
.
flash_message
||
true
;
if
(
props
.
flash_message
===
false
){
flash_message
=
false
;
}
...
...
@@ -170,7 +170,9 @@ function APIUpdateAttr(props) {
dataType
:
props
.
data_type
||
"json"
}).
done
(
function
(
data
,
textStatue
,
jqXHR
)
{
if
(
flash_message
)
{
toastr
.
success
(
success_message
);
if
(
send_message
)
{
toastr
.
success
(
success_message
);
}
}
if
(
typeof
props
.
success
===
'function'
)
{
return
props
.
success
(
data
);
...
...
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