New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command_store.save()方法报错 #820

Closed
B9527 opened this Issue Nov 21, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@B9527

B9527 commented Nov 21, 2017

[简述你的问题]
.命令记录存数据时程序会报错!

使用版本0.4.0

[请提供你使用的Jumpserver版本 0.3.2 或 0.4.0]

问题复现步骤
  1. [步骤1] conmand_log .命令记录存数据时程序会报错!

解决方法:可自己重写command_store.save()方法。

[注:] 完成后请关闭 issue

@B9527

This comment has been minimized.

Show comment
Hide comment
@B9527

B9527 Nov 21, 2017

\jumpserver\apps\audits\backends\command\serializers.py

` class CommandLogSerializer(serializers.ModelSerializer):
"""使用这个类作为基础Command Log Serializer类, 用来序列化"""

class Meta:
    model = CommandLog
    fields = '__all__'

def create(self, validated_data):

    try:
        output = validated_data['output']
        validated_data['output'] = base64.b64decode(output)
    except IndexError:
        pass
    return command_store.save(validated_data)`

\jumpserver\apps\audits\backends\command\db.py
` def save(self,validated_data):

        command_log = self.model.objects.create(**validated_data)
        return command_log`

B9527 commented Nov 21, 2017

\jumpserver\apps\audits\backends\command\serializers.py

` class CommandLogSerializer(serializers.ModelSerializer):
"""使用这个类作为基础Command Log Serializer类, 用来序列化"""

class Meta:
    model = CommandLog
    fields = '__all__'

def create(self, validated_data):

    try:
        output = validated_data['output']
        validated_data['output'] = base64.b64decode(output)
    except IndexError:
        pass
    return command_store.save(validated_data)`

\jumpserver\apps\audits\backends\command\db.py
` def save(self,validated_data):

        command_log = self.model.objects.create(**validated_data)
        return command_log`
@ibuler

This comment has been minimized.

Show comment
Hide comment
@ibuler

ibuler Jan 15, 2018

Member

已修复

Member

ibuler commented Jan 15, 2018

已修复

@ibuler ibuler closed this Jan 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment