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
1f544b98
Commit
1f544b98
authored
Feb 11, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Stash] 删除结束会话之前
parent
42e4c64d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
4 deletions
+32
-4
api.py
apps/applications/api.py
+26
-2
api_urls.py
apps/applications/urls/api_urls.py
+4
-1
api.py
apps/audits/api.py
+0
-1
proxy_log_list.html
apps/audits/templates/audits/proxy_log_list.html
+2
-0
No files found.
apps/applications/api.py
View file @
1f544b98
...
...
@@ -9,11 +9,12 @@ from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIV
from
rest_framework
import
viewsets
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.permissions
import
AllowAny
from
django.shortcuts
import
get_object_or_404
from
rest_framework.decorators
import
api_view
from
.models
import
Terminal
,
TerminalHeatbeat
from
.serializers
import
TerminalSerializer
,
TerminalHeatbeatSerializer
from
.hands
import
IsSuperUserOrAppUser
,
IsAppUser
,
User
from
.hands
import
IsSuperUserOrAppUser
,
IsAppUser
,
User
,
ProxyLog
from
common.utils
import
get_object_or_none
...
...
@@ -64,6 +65,9 @@ class TerminalViewSet(viewsets.ModelViewSet):
# instance.user.delete()
# return super(TerminalViewSet, self).destroy(request, *args, **kwargs)
tasks
=
OrderedDict
()
# tasks = {1: [{'name': 'kill_proxy', 'proxy_log_id': 23}]}
class
TerminalHeatbeatViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
TerminalHeatbeat
.
objects
.
all
()
...
...
@@ -73,4 +77,24 @@ class TerminalHeatbeatViewSet(viewsets.ModelViewSet):
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
terminal
=
request
.
user
.
terminal
TerminalHeatbeat
.
objects
.
create
(
terminal
=
terminal
)
return
Response
({
'msg'
:
'Success'
},
status
=
201
)
task
=
tasks
.
get
(
terminal
.
name
)
tasks
[
terminal
.
name
]
=
[]
return
Response
({
'msg'
:
'Success'
,
'tasks'
:
task
,},
status
=
201
)
class
TerminateConnectionView
(
APIView
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
proxy_log_id
=
request
.
data
.
get
(
'proxy_log_id'
)
proxy_log
=
get_object_or_404
(
ProxyLog
,
id
=
proxy_log_id
)
terminal_id
=
proxy_log
.
terminal
if
terminal_id
in
tasks
:
tasks
[
terminal_id
]
.
append
({
'name'
:
'kill_proxy'
,
'proxy_log_id'
:
proxy_log_id
})
else
:
tasks
[
terminal_id
]
=
[{
'name'
:
'kill_proxy'
,
'proxy_log_id'
:
proxy_log_id
}]
print
(
tasks
)
return
Response
({
'msg'
:
'get it'
})
apps/applications/urls/api_urls.py
View file @
1f544b98
...
...
@@ -14,7 +14,10 @@ router.register(r'v1/terminal/heatbeat', api.TerminalHeatbeatViewSet, 'terminal-
router
.
register
(
r'v1/terminal'
,
api
.
TerminalViewSet
,
'terminal'
)
urlpatterns
=
[
url
(
r'^v1/terminal/register/$'
,
api
.
TerminalRegisterView
.
as_view
(),
name
=
'terminal-register'
),
url
(
r'^v1/terminal/register/$'
,
api
.
TerminalRegisterView
.
as_view
(),
name
=
'terminal-register'
),
url
(
r'^v1/terminate/connection/$'
,
api
.
TerminateConnectionView
.
as_view
(),
name
=
'terminate-connection'
)
# url(r'^v1/terminal/heatbeat/$', api.TestHeatbeat.as_view())
]
...
...
apps/audits/api.py
View file @
1f544b98
...
...
@@ -14,7 +14,6 @@ from . import models, serializers
from
.hands
import
IsSuperUserOrAppUser
,
IsAppUser
# Todo: 忘记当时为何不和ProxyLogViewSet复用了
class
ProxyLogReceiveView
(
generics
.
CreateAPIView
):
queryset
=
models
.
ProxyLog
.
objects
.
all
()
serializer_class
=
serializers
.
ProxyLogSerializer
...
...
apps/audits/templates/audits/proxy_log_list.html
View file @
1f544b98
...
...
@@ -64,6 +64,7 @@
<th
class=
"text-center"
>
{% trans 'User' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset' %}
</th>
<th
class=
"text-center"
>
{% trans 'System user' %}
</th>
<th
class=
"text-center"
>
{% trans 'Terminal' %}
</th>
<th
class=
"text-center"
>
{% trans 'Command' %}
</th>
<th
class=
"text-center"
>
{% trans 'Success' %}
</th>
<th
class=
"text-center"
>
{% trans 'Finished' %}
</th>
...
...
@@ -81,6 +82,7 @@
<td
class=
"text-center"
>
{{ proxy_log.user }}
</td>
<td
class=
"text-center"
>
{{ proxy_log.asset }}
</td>
<td
class=
"text-center"
>
{{ proxy_log.system_user }}
</td>
<td
class=
"text-center"
>
{{ proxy_log.terminal }}
</td>
<td
class=
"text-center"
>
{{ proxy_log.commands.all|length}}
</td>
<td
class=
"text-center"
>
{% if proxy_log.is_failed %}
...
...
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