mirror of https://github.com/jumpserver/jumpserver
perf: 修改 v3
parent
b16e8ef1a5
commit
5c73cb9b4e
|
@ -4,7 +4,7 @@ from rest_framework.response import Response
|
|||
from common.drf.api import JMSModelViewSet
|
||||
from common.drf.serializers import GroupedChoiceSerailizer
|
||||
from assets.models import Platform
|
||||
from assets.serializers import PlatformSerializer
|
||||
from assets.serializers import PlatformSerializer, PlatformOpsMethodSerializer
|
||||
from assets.const import AllTypes, Category
|
||||
from assets.playbooks.platform import filter_platform_methods
|
||||
|
||||
|
@ -45,7 +45,8 @@ class AssetPlatformViewSet(JMSModelViewSet):
|
|||
tp = request.query_params.get('type')
|
||||
method = request.query_params.get('method')
|
||||
methods = filter_platform_methods(category, tp, method)
|
||||
return Response(methods)
|
||||
serializer = PlatformOpsMethodSerializer(methods, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
def check_object_permissions(self, request, obj):
|
||||
if request.method.lower() in ['delete', 'put', 'patch'] and obj.internal:
|
||||
|
|
|
@ -76,7 +76,8 @@ class HostTypes(PlatformMixin, ChoicesMixin, models.TextChoices):
|
|||
'_protocols': ['ssh', 'rdp', 'vnc', 'telnet']
|
||||
},
|
||||
cls.WINDOWS: {
|
||||
'_protocols': ['ssh', 'rdp', 'vnc']
|
||||
'_protocols': ['ssh', 'rdp', 'vnc'],
|
||||
'has_su': False
|
||||
},
|
||||
cls.MACOS: {
|
||||
'_protocols': ['ssh', 'vnc']
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
id: change_password_aix
|
||||
name: Change password for AIX
|
||||
version: 1
|
||||
category: host
|
||||
method: change_password
|
||||
|
|
|
@ -5,8 +5,3 @@ type:
|
|||
- unix
|
||||
- linux
|
||||
method: change_password
|
||||
vars:
|
||||
account:
|
||||
username: test
|
||||
password: teset123
|
||||
public_key: test
|
||||
|
|
|
@ -7,7 +7,7 @@ from ..models import Platform, PlatformProtocol
|
|||
from ..const import Category, AllTypes
|
||||
|
||||
|
||||
__all__ = ['PlatformSerializer']
|
||||
__all__ = ['PlatformSerializer', 'PlatformOpsMethodSerializer']
|
||||
|
||||
|
||||
class ProtocolSettingSerializer(serializers.Serializer):
|
||||
|
@ -72,3 +72,11 @@ class PlatformSerializer(JMSWritableNestedModelSerializer):
|
|||
if attrs.get(method_enabled, False) and not attrs.get(method_name, False):
|
||||
raise serializers.ValidationError({method_name: _('This field is required.')})
|
||||
return attrs
|
||||
|
||||
|
||||
class PlatformOpsMethodSerializer(serializers.Serializer):
|
||||
id = serializers.CharField(read_only=True)
|
||||
name = serializers.CharField(max_length=50, label=_('Name'))
|
||||
category = serializers.CharField(max_length=50, label=_('Category'))
|
||||
type = serializers.ListSerializer(child=serializers.CharField())
|
||||
method = serializers.CharField()
|
||||
|
|
Loading…
Reference in New Issue