Merge pull request #9587 from jumpserver/pr@dev@perf_gateway

perf: 优化 gateway 返回情况
pull/9593/head
老广 2 years ago committed by GitHub
commit 1678eeb915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,19 +12,19 @@ from .base import BaseAccountSerializer
class AccountSerializerCreateValidateMixin:
id: str
from_id: str
template: bool
push_now: bool
replace_attrs: callable
def to_internal_value(self, data):
_id = data.pop('id', None)
from_id = data.pop('id', None)
ret = super().to_internal_value(data)
self.id = _id
self.from_id = from_id
return ret
def set_secret(self, attrs):
_id = self.id
_id = self.from_id
template = attrs.pop('template', None)
if _id and template:

@ -234,9 +234,11 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel):
@lazyproperty
def gateway(self):
if self.domain_id:
return self.domain.select_gateway()
return None
if not self.domain_id:
return
if not self.platform.domain_enabled:
return
return self.domain.select_gateway()
def as_node(self):
from assets.models import Node

@ -151,7 +151,6 @@ class RDPFileClientProtocolURLMixin:
}
})
else:
print("Connect method: {}".format(connect_method_dict))
endpoint = self.get_smart_endpoint(
protocol=connect_method_dict['endpoint_protocol'],
asset=token.asset

@ -228,16 +228,16 @@ class ConnectionToken(JMSOrgBaseModel):
@lazyproperty
def domain(self):
if not self.asset.platform.domain_enabled:
return
domain = self.asset.domain if self.asset else None
return domain
@lazyproperty
def gateway(self):
from assets.models import Domain
if not self.domain:
if not self.asset:
return
self.domain: Domain
return self.domain.select_gateway()
return self.asset.gateway
@lazyproperty
def command_filter_acls(self):

Loading…
Cancel
Save