* [Update] 修改发送command日志

* [Update] 修复用户树显示资产数量不对的bug
pull/3283/head
老广 2019-09-25 16:31:58 +08:00 committed by GitHub
parent 9f56ac8a21
commit 118fc8c42f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 8 deletions

View File

@ -257,10 +257,6 @@ class NodeAssetsMixin:
@lazyproperty
def assets_amount(self):
"""
获取节点下所有资产数量速度太慢所以需要重写使用cache等方案
:return:
"""
amount = self.tree().assets_amount(self.key)
return amount

View File

@ -36,3 +36,4 @@ class SessionAuditSerializer(serializers.ModelSerializer):
class Meta:
model = Session
fields = '__all__'

View File

@ -9,7 +9,8 @@ from rest_framework.renderers import JSONRenderer
from jumpserver.utils import current_request
from common.utils import get_request_ip, get_logger, get_syslogger
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 serializers
@ -88,6 +89,9 @@ def on_audits_log_create(sender, instance=None, **kwargs):
elif sender == Session:
category = "host_session_log"
serializer = serializers.SessionAuditSerializer
elif sender == Command:
category = "session_command_log"
serializer = SessionCommandSerializer
else:
return

View File

@ -225,4 +225,4 @@ class lazyproperty:
else:
value = self.func(instance)
setattr(instance, self.func.__name__, value)
return value
return value

View File

@ -286,7 +286,7 @@ LOGGING = {
'handlers': ['console', 'file'],
'level': "INFO",
},
'jms_audits': {
'jms.audits': {
'handlers': ['syslog'],
'level': 'INFO'
},

View File

@ -36,7 +36,7 @@ class UserNodeTreeMixin:
assets_amount = self.tree.assets_amount(node.key)
if assets_amount == 0 and node.key != Node.empty_key:
continue
node._assets_amount = assets_amount
node.assets_amount = assets_amount
data = ParserNode.parse_node_to_tree_node(node)
_queryset.append(data)
return _queryset

View File

@ -4,6 +4,7 @@ import os
import uuid
from django.db import models
from django.db.models.signals import post_save
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.conf import settings
@ -267,7 +268,16 @@ class Task(models.Model):
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):
objects = CommandManager()
class Meta:
db_table = "terminal_command"