mirror of https://github.com/jumpserver/jumpserver
perf: change asset
parent
196e38897f
commit
88d4bf932c
|
@ -97,25 +97,10 @@ class AssetSerializer(CategoryDisplayMixin, OrgResourceModelSerializerMixin):
|
|||
@classmethod
|
||||
def setup_eager_loading(cls, queryset):
|
||||
""" Perform necessary eager loading of data. """
|
||||
queryset = queryset.prefetch_related('domain', 'platform')
|
||||
queryset = queryset.prefetch_related('domain', 'platform', 'protocols')
|
||||
queryset = queryset.prefetch_related('nodes', 'labels')
|
||||
return queryset
|
||||
|
||||
def compatible_with_old_protocol(self, validated_data):
|
||||
protocols_data = validated_data.pop("protocols", [])
|
||||
|
||||
# 兼容老的api
|
||||
name = validated_data.get("protocol")
|
||||
port = validated_data.get("port")
|
||||
if not protocols_data and name and port:
|
||||
protocols_data.insert(0, '/'.join([name, str(port)]))
|
||||
elif not name and not port and protocols_data:
|
||||
protocol = protocols_data[0].split('/')
|
||||
validated_data["protocol"] = protocol[0]
|
||||
validated_data["port"] = int(protocol[1])
|
||||
if protocols_data:
|
||||
validated_data["protocols"] = protocols_data
|
||||
|
||||
def perform_nodes_display_create(self, instance, nodes_display):
|
||||
if not nodes_display:
|
||||
return
|
||||
|
|
|
@ -6,6 +6,6 @@ import subprocess
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
subprocess.call('python3 jms start all', shell=True,
|
||||
stdin=sys.stdin, stdout=sys.stdout)
|
||||
kwargs = dict(shell=True, stdin=sys.stdin, stdout=sys.stdout)
|
||||
subprocess.call('python3 jms start all', **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue