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
af2db2d8
Commit
af2db2d8
authored
7 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 增加批量终端session api
parent
0aa47555
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
node_service
password
rbac
restrict_access
test
v52
wph
1.5.2
1.5.1
1.5.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
39 deletions
+77
-39
django.mo
apps/i18n/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/i18n/zh/LC_MESSAGES/django.po
+18
-23
urls.py
apps/jumpserver/urls.py
+1
-1
api.py
apps/terminal/api.py
+22
-4
serializers.py
apps/terminal/serializers.py
+7
-1
session_list.html
apps/terminal/templates/terminal/session_list.html
+27
-10
api_urls.py
apps/terminal/urls/api_urls.py
+1
-0
session.py
apps/terminal/views/session.py
+1
-0
No files found.
apps/i18n/zh/LC_MESSAGES/django.mo
View file @
af2db2d8
No preview for this file type
This diff is collapsed.
Click to expand it.
apps/i18n/zh/LC_MESSAGES/django.po
View file @
af2db2d8
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-0
6 17:5
7+0800\n"
"POT-Creation-Date: 2018-03-0
7 11:2
7+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -660,12 +660,6 @@ msgstr "更新"
msgid "Delete"
msgstr "删除"
#: assets/templates/assets/_system_user.html:16
#: assets/templates/assets/system_user_list.html:16
#: assets/views/system_user.py:45
msgid "Create system user"
msgstr "创建系统用户"
#: assets/templates/assets/_system_user.html:37
#: assets/templates/assets/asset_create.html:16
#: assets/templates/assets/asset_update.html:21
...
...
@@ -762,12 +756,6 @@ msgstr "测试"
msgid "Task has been send, seen left asset status"
msgstr "任务已下发,查看左侧资产状态"
#: assets/templates/assets/admin_user_create_update.html:16
#: assets/templates/assets/admin_user_list.html:14
#: assets/views/admin_user.py:48
msgid "Create admin user"
msgstr "创建管理用户"
#: assets/templates/assets/admin_user_detail.html:83
msgid "Replace node assets admin user with this"
msgstr "替换资产的管理员"
...
...
@@ -788,6 +776,11 @@ msgstr "替换资产的管理员"
msgid "Confirm"
msgstr "确认"
#: assets/templates/assets/admin_user_list.html:14
#: assets/views/admin_user.py:48
msgid "Create admin user"
msgstr "创建管理用户"
#: assets/templates/assets/admin_user_list.html:26
#: assets/templates/assets/system_user_list.html:28
msgid "Unreachable"
...
...
@@ -979,6 +972,11 @@ msgstr "Uid"
msgid "Add to node"
msgstr "添加到节点"
#: assets/templates/assets/system_user_list.html:16
#: assets/views/system_user.py:45
msgid "Create system user"
msgstr "创建系统用户"
#: assets/templates/assets/system_user_list.html:131
msgid "This will delete the selected System Users !!!"
msgstr "删除选择系统用户"
...
...
@@ -1607,10 +1605,6 @@ msgstr "选择资产组"
msgid "Join"
msgstr "加入"
#: perms/templates/perms/asset_permission_create_update.html:17
msgid "Create asset permission "
msgstr "创建资产权限"
#: perms/templates/perms/asset_permission_detail.html:66
msgid "User count"
msgstr "用户数量"
...
...
@@ -1783,7 +1777,7 @@ msgstr "Web终端"
#: templates/_nav.html:50 terminal/templates/terminal/session_list.html:75
#: terminal/views/command.py:47 terminal/views/session.py:75
#: terminal/views/session.py:9
2 terminal/views/session.py:114
#: terminal/views/session.py:9
3 terminal/views/session.py:115
#: terminal/views/terminal.py:31 terminal/views/terminal.py:46
#: terminal/views/terminal.py:58
msgid "Terminal"
...
...
@@ -1896,7 +1890,7 @@ msgid "Goto"
msgstr "转到"
#: terminal/templates/terminal/session_detail.html:17
#: terminal/views/session.py:11
5
#: terminal/views/session.py:11
6
msgid "Session detail"
msgstr "会话详情"
...
...
@@ -1939,10 +1933,8 @@ msgid "Terminate"
msgstr "终断"
#: terminal/templates/terminal/session_list.html:116
#, fuzzy
#| msgid "Deactive selected"
msgid "Terminate selected"
msgstr "
禁用
所选"
msgstr "
终断
所选"
#: terminal/templates/terminal/session_list.html:136
msgid "Terminate task send, waiting ..."
...
...
@@ -1991,7 +1983,7 @@ msgstr "信息"
msgid "Session online list"
msgstr "在线会话"
#: terminal/views/session.py:9
3
#: terminal/views/session.py:9
4
msgid "Session offline list"
msgstr "离线会话"
...
...
@@ -2653,3 +2645,6 @@ msgstr "密码更新"
#: users/views/user.py:374
msgid "Public key update"
msgstr "密钥更新"
#~ msgid "Create asset permission "
#~ msgstr "创建资产权限"
This diff is collapsed.
Click to expand it.
apps/jumpserver/urls.py
View file @
af2db2d8
...
...
@@ -13,7 +13,7 @@ from .views import IndexView, LunaView
schema_view
=
get_schema_view
(
title
=
'Users API'
,
renderer_classes
=
[
OpenAPIRenderer
,
SwaggerUIRenderer
])
urlpatterns
=
[
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
'index'
),
url
(
r'^luna/
$
'
,
LunaView
.
as_view
(),
name
=
'luna-error'
),
url
(
r'^luna/'
,
LunaView
.
as_view
(),
name
=
'luna-error'
),
url
(
r'^users/'
,
include
(
'users.urls.views_urls'
,
namespace
=
'users'
)),
url
(
r'^assets/'
,
include
(
'assets.urls.views_urls'
,
namespace
=
'assets'
)),
url
(
r'^perms/'
,
include
(
'perms.urls.views_urls'
,
namespace
=
'perms'
)),
...
...
This diff is collapsed.
Click to expand it.
apps/terminal/api.py
View file @
af2db2d8
...
...
@@ -5,14 +5,15 @@ import logging
import
os
import
uuid
from
rest_framework
import
viewsets
,
serializers
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.permissions
import
AllowAny
from
django.core.cache
import
cache
from
django.shortcuts
import
get_object_or_404
,
redirect
from
django.utils
import
timezone
from
django.core.files.storage
import
default_storage
from
django.http
import
HttpResponseNotFound
from
rest_framework
import
viewsets
,
serializers
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.permissions
import
AllowAny
from
rest_framework_bulk
import
BulkModelViewSet
from
common.utils
import
get_object_or_none
from
.models
import
Terminal
,
Status
,
Session
,
Task
...
...
@@ -178,12 +179,29 @@ class SessionViewSet(viewsets.ModelViewSet):
return
self
.
queryset
class
TaskViewSet
(
viewsets
.
ModelViewSet
):
class
TaskViewSet
(
Bulk
ModelViewSet
):
queryset
=
Task
.
objects
.
all
()
serializer_class
=
TaskSerializer
permission_classes
=
(
IsSuperUserOrAppUser
,)
class
KillSessionAPI
(
APIView
):
permission_classes
=
(
IsSuperUserOrAppUser
,)
model
=
Task
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
validated_session
=
[]
for
session_id
in
request
.
data
:
session
=
get_object_or_none
(
Session
,
id
=
session_id
)
if
session
and
not
session
.
is_finished
:
validated_session
.
append
(
session_id
)
self
.
model
.
objects
.
create
(
name
=
"kill_session"
,
args
=
session
.
id
,
terminal
=
session
.
terminal
,
)
return
Response
({
"ok"
:
validated_session
})
class
CommandViewSet
(
viewsets
.
ViewSet
):
"""接受app发送来的command log, 格式如下
{
...
...
This diff is collapsed.
Click to expand it.
apps/terminal/serializers.py
View file @
af2db2d8
...
...
@@ -3,7 +3,11 @@
from
django.utils
import
timezone
from
rest_framework
import
serializers
from
rest_framework_bulk.serializers
import
BulkListSerializer
from
common.mixins
import
BulkSerializerMixin
from
common.utils
import
get_object_or_none
from
.models
import
Terminal
,
Status
,
Session
,
Task
from
.backends
import
get_multi_command_store
...
...
@@ -47,6 +51,7 @@ class SessionSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Session
list_serializer_class
=
BulkListSerializer
fields
=
'__all__'
def
get_command_amount
(
self
,
obj
):
...
...
@@ -60,11 +65,12 @@ class StatusSerializer(serializers.ModelSerializer):
model
=
Status
class
TaskSerializer
(
serializers
.
ModelSerializer
):
class
TaskSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
class
Meta
:
fields
=
'__all__'
model
=
Task
list_serializer_class
=
BulkListSerializer
class
ReplaySerializer
(
serializers
.
Serializer
):
...
...
This diff is collapsed.
Click to expand it.
apps/terminal/templates/terminal/session_list.html
View file @
af2db2d8
...
...
@@ -110,10 +110,10 @@
{% endblock %}
{% block content_bottom_left %}
<div
id=
"actions"
>
<div
id=
"actions"
{%
if
type
!=
"
online
"
%}
style=
"display: none"
{%
endif
%}
>
<div
class=
"input-group"
>
<select
class=
"form-control m-b"
style=
"width: auto"
id=
"slct_bulk_update"
>
<option
value=
"
dele
te"
>
{% trans 'Terminate selected' %}
</option>
<option
value=
"
termina
te"
>
{% trans 'Terminate selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
...
...
@@ -134,7 +134,7 @@
},
1000
)
}
var
success_message
=
'{% trans "Terminate task send, waiting ..." %}'
;
var
the_url
=
"{% url 'api-terminal:
tasks-list
' %}"
;
var
the_url
=
"{% url 'api-terminal:
kill-session
' %}"
;
APIUpdateAttr
({
url
:
the_url
,
method
:
'POST'
,
...
...
@@ -165,14 +165,31 @@
}).
on
(
'click'
,
'.btn-term'
,
function
()
{
var
$this
=
$
(
this
);
var
session_id
=
$this
.
attr
(
'value'
);
var
terminal_id
=
$this
.
attr
(
'terminal'
);
var
data
=
{
name
:
"kill_session"
,
args
:
session_id
,
terminal
:
terminal_id
};
var
data
=
[
session_id
];
terminateSession
(
data
)
})
}).
on
(
'click'
,
'#btn_bulk_update'
,
function
()
{
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
id_list
=
[];
$
(
".cbx-term:checked"
).
each
(
function
(
index
,
data
)
{
id_list
.
push
(
$
(
data
).
attr
(
"value"
))
});
if
(
id_list
.
length
===
0
)
{
return
false
;
}
function
doTerminate
()
{
terminateSession
(
id_list
)
}
switch
(
action
)
{
case
'terminate'
:
doTerminate
();
break
;
default
:
break
;
}
});
</script>
{% endblock %}
This diff is collapsed.
Click to expand it.
apps/terminal/urls/api_urls.py
View file @
af2db2d8
...
...
@@ -22,6 +22,7 @@ urlpatterns = [
url
(
r'^v1/sessions/(?P<pk>[0-9a-zA-Z\-]{36})/replay/$'
,
api
.
SessionReplayViewSet
.
as_view
({
'get'
:
'retrieve'
,
'post'
:
'create'
}),
name
=
'session-replay'
),
url
(
r'^v1/tasks/kill-session/'
,
api
.
KillSessionAPI
.
as_view
(),
name
=
'kill-session'
),
url
(
r'^v1/terminal/(?P<terminal>[a-zA-Z0-9\-]{36})/access-key'
,
api
.
TerminalTokenApi
.
as_view
(),
name
=
'terminal-access-key'
),
url
(
r'^v1/terminal/config'
,
api
.
TerminalConfig
.
as_view
(),
name
=
'terminal-config'
),
]
...
...
This diff is collapsed.
Click to expand it.
apps/terminal/views/session.py
View file @
af2db2d8
...
...
@@ -74,6 +74,7 @@ class SessionOnlineListView(SessionListView):
context
=
{
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Session online list'
),
'type'
:
'online'
,
'now'
:
timezone
.
now
(),
}
kwargs
.
update
(
context
)
...
...
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