mirror of https://github.com/jumpserver/jumpserver
parent
9f56ac8a21
commit
118fc8c42f
|
@ -257,10 +257,6 @@ class NodeAssetsMixin:
|
||||||
|
|
||||||
@lazyproperty
|
@lazyproperty
|
||||||
def assets_amount(self):
|
def assets_amount(self):
|
||||||
"""
|
|
||||||
获取节点下所有资产数量速度太慢,所以需要重写,使用cache等方案
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
amount = self.tree().assets_amount(self.key)
|
amount = self.tree().assets_amount(self.key)
|
||||||
return amount
|
return amount
|
||||||
|
|
||||||
|
|
|
@ -36,3 +36,4 @@ class SessionAuditSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Session
|
model = Session
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ from rest_framework.renderers import JSONRenderer
|
||||||
from jumpserver.utils import current_request
|
from jumpserver.utils import current_request
|
||||||
from common.utils import get_request_ip, get_logger, get_syslogger
|
from common.utils import get_request_ip, get_logger, get_syslogger
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from terminal.models import Session
|
from terminal.models import Session, Command
|
||||||
|
from terminal.backends.command.serializers import SessionCommandSerializer
|
||||||
from . import models
|
from . import models
|
||||||
from . import serializers
|
from . import serializers
|
||||||
|
|
||||||
|
@ -88,6 +89,9 @@ def on_audits_log_create(sender, instance=None, **kwargs):
|
||||||
elif sender == Session:
|
elif sender == Session:
|
||||||
category = "host_session_log"
|
category = "host_session_log"
|
||||||
serializer = serializers.SessionAuditSerializer
|
serializer = serializers.SessionAuditSerializer
|
||||||
|
elif sender == Command:
|
||||||
|
category = "session_command_log"
|
||||||
|
serializer = SessionCommandSerializer
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -225,4 +225,4 @@ class lazyproperty:
|
||||||
else:
|
else:
|
||||||
value = self.func(instance)
|
value = self.func(instance)
|
||||||
setattr(instance, self.func.__name__, value)
|
setattr(instance, self.func.__name__, value)
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -286,7 +286,7 @@ LOGGING = {
|
||||||
'handlers': ['console', 'file'],
|
'handlers': ['console', 'file'],
|
||||||
'level': "INFO",
|
'level': "INFO",
|
||||||
},
|
},
|
||||||
'jms_audits': {
|
'jms.audits': {
|
||||||
'handlers': ['syslog'],
|
'handlers': ['syslog'],
|
||||||
'level': 'INFO'
|
'level': 'INFO'
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,7 +36,7 @@ class UserNodeTreeMixin:
|
||||||
assets_amount = self.tree.assets_amount(node.key)
|
assets_amount = self.tree.assets_amount(node.key)
|
||||||
if assets_amount == 0 and node.key != Node.empty_key:
|
if assets_amount == 0 and node.key != Node.empty_key:
|
||||||
continue
|
continue
|
||||||
node._assets_amount = assets_amount
|
node.assets_amount = assets_amount
|
||||||
data = ParserNode.parse_node_to_tree_node(node)
|
data = ParserNode.parse_node_to_tree_node(node)
|
||||||
_queryset.append(data)
|
_queryset.append(data)
|
||||||
return _queryset
|
return _queryset
|
||||||
|
|
|
@ -4,6 +4,7 @@ import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.db.models.signals import post_save
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -267,7 +268,16 @@ class Task(models.Model):
|
||||||
db_table = "terminal_task"
|
db_table = "terminal_task"
|
||||||
|
|
||||||
|
|
||||||
|
class CommandManager(models.Manager):
|
||||||
|
def bulk_create(self, objs, **kwargs):
|
||||||
|
resp = super().bulk_create(objs, **kwargs)
|
||||||
|
for i in objs:
|
||||||
|
post_save.send(i.__class__, instance=i, created=True)
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
class Command(AbstractSessionCommand):
|
class Command(AbstractSessionCommand):
|
||||||
|
objects = CommandManager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "terminal_command"
|
db_table = "terminal_command"
|
||||||
|
|
Loading…
Reference in New Issue