mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-05-20 14:00:05 +00:00
* [Update] 修改config * [Update] 移动存储设置到到terminal中 * [Update] 修改permission 查看 * [Update] pre merge * [Update] 录像存储 * [Update] 命令存储 * [Update] 添加存储测试可连接性 * [Update] 修改 meta 值的 key 为大写 * [Update] 修改 Terminal 相关 Storage 配置 * [Update] 删除之前获取录像/命令存储的代码 * [Update] 修改导入失败 * [Update] 迁移文件添加default存储 * [Update] 删除之前代码,添加help_text信息 * [Update] 删除之前代码 * [Update] 删除之前代码 * [Update] 抽象命令/录像存储 APIView * [Update] 抽象命令/录像存储 APIView 1 * [Update] 抽象命令/录像存储 DictField * [Update] 抽象命令/录像存储列表页面 * [Update] 修复CustomDictField的bug * [Update] RemoteApp 页面添加 hidden * [Update] 用户页面添加用户关联授权 * [Update] 修改存储测试可连接性 target * [Update] 修改配置 * [Update] 修改存储前端 Form 渲染逻辑 * [Update] 修改存储细节 * [Update] 统一存储类型到 const 文件 * [Update] 修改迁移文件及Model,创建默认存储 * [Update] 修改迁移文件及Model初始化默认数据 * [Update] 修改迁移文件 * [Update] 修改迁移文件 * [Update] 修改迁移文件 * [Update] 修改迁移文件 * [Update] 修改迁移文件 * [Update] 修改迁移文件 * [Update] 修改迁移文件 * [Update] 限制删除默认存储配置,只允许创建扩展的存储类型 * [Update] 修改ip字段长度 * [Update] 修改ip字段长度 * [Update] 修改一些css * [Update] 修改关联 * [Update] 添加操作日志定时清理 * [Update] 修改记录syslog的instance encoder * [Update] 忽略登录产生的操作日志 * [Update] 限制更新存储时不覆盖原有AK SK 等字段 * [Update] 修改迁移文件添加comment字段 * [Update] 修改迁移文件 * [Update] 添加 comment 字段 * [Update] 修改默认存储no -> null * [Update] 修改细节 * [Update] 更新翻译(存储配置 * [Update] 修改定时任务注册,修改系统用户资产、节点关系api * [Update] 添加监控磁盘任务 * [Update] 修改session * [Update] 拆分serializer * [Update] 还原setting原来的manager
75 lines
2.3 KiB
Python
75 lines
2.3 KiB
Python
# coding: utf-8
|
|
#
|
|
|
|
from rest_framework import viewsets, generics, status
|
|
from rest_framework.response import Response
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from common.permissions import IsSuperUser
|
|
from ..models import CommandStorage, ReplayStorage
|
|
from ..serializers import CommandStorageSerializer, ReplayStorageSerializer
|
|
|
|
|
|
__all__ = [
|
|
'CommandStorageViewSet', 'CommandStorageTestConnectiveApi',
|
|
'ReplayStorageViewSet', 'ReplayStorageTestConnectiveApi'
|
|
]
|
|
|
|
|
|
class BaseStorageViewSetMixin:
|
|
|
|
def destroy(self, request, *args, **kwargs):
|
|
instance = self.get_object()
|
|
if not instance.can_delete():
|
|
data = {'msg': _('Deleting the default storage is not allowed')}
|
|
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
|
return super().destroy(request, *args, **kwargs)
|
|
|
|
|
|
class CommandStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
|
filter_fields = ('name', 'type',)
|
|
search_fields = filter_fields
|
|
queryset = CommandStorage.objects.all()
|
|
serializer_class = CommandStorageSerializer
|
|
permission_classes = (IsSuperUser,)
|
|
|
|
|
|
class ReplayStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
|
filter_fields = ('name', 'type',)
|
|
search_fields = filter_fields
|
|
queryset = ReplayStorage.objects.all()
|
|
serializer_class = ReplayStorageSerializer
|
|
permission_classes = (IsSuperUser,)
|
|
|
|
|
|
class BaseStorageTestConnectiveMixin:
|
|
permission_classes = (IsSuperUser,)
|
|
|
|
def retrieve(self, request, *args, **kwargs):
|
|
instance = self.get_object()
|
|
try:
|
|
is_valid = instance.is_valid()
|
|
except Exception as e:
|
|
is_valid = False
|
|
msg = _("Test failure: {}".format(str(e)))
|
|
else:
|
|
if is_valid:
|
|
msg = _("Test successful")
|
|
else:
|
|
msg = _("Test failure: Account invalid")
|
|
data = {
|
|
'is_valid': is_valid,
|
|
'msg': msg
|
|
}
|
|
return Response(data)
|
|
|
|
|
|
class CommandStorageTestConnectiveApi(BaseStorageTestConnectiveMixin,
|
|
generics.RetrieveAPIView):
|
|
queryset = CommandStorage.objects.all()
|
|
|
|
|
|
class ReplayStorageTestConnectiveApi(BaseStorageTestConnectiveMixin,
|
|
generics.RetrieveAPIView):
|
|
queryset = ReplayStorage.objects.all()
|