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: class AccountSerializerCreateValidateMixin:
id: str from_id: str
template: bool template: bool
push_now: bool push_now: bool
replace_attrs: callable replace_attrs: callable
def to_internal_value(self, data): def to_internal_value(self, data):
_id = data.pop('id', None) from_id = data.pop('id', None)
ret = super().to_internal_value(data) ret = super().to_internal_value(data)
self.id = _id self.from_id = from_id
return ret return ret
def set_secret(self, attrs): def set_secret(self, attrs):
_id = self.id _id = self.from_id
template = attrs.pop('template', None) template = attrs.pop('template', None)
if _id and template: if _id and template:

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

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

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

Loading…
Cancel
Save