mirror of https://github.com/jumpserver/jumpserver
fix: 修改获取smart endpoint的逻辑
parent
5f370c1c04
commit
57969a4e23
|
@ -2,7 +2,7 @@ from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from common.drf.api import JMSBulkModelViewSet
|
from common.drf.api import JMSBulkModelViewSet
|
||||||
from common.utils import get_object_or_none
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from assets.models import Asset
|
from assets.models import Asset
|
||||||
from orgs.utils import tmp_to_root_org
|
from orgs.utils import tmp_to_root_org
|
||||||
|
|
|
@ -31,8 +31,11 @@ class Endpoint(JMSModel):
|
||||||
def get_port(self, protocol):
|
def get_port(self, protocol):
|
||||||
return getattr(self, f'{protocol}_port', 0)
|
return getattr(self, f'{protocol}_port', 0)
|
||||||
|
|
||||||
|
def is_default(self):
|
||||||
|
return self.id == self.default_id
|
||||||
|
|
||||||
def delete(self, using=None, keep_parents=False):
|
def delete(self, using=None, keep_parents=False):
|
||||||
if self.id == self.default_id:
|
if self.is_default():
|
||||||
return
|
return
|
||||||
return super().delete(using, keep_parents)
|
return super().delete(using, keep_parents)
|
||||||
|
|
||||||
|
@ -78,6 +81,8 @@ class EndpointRule(JMSModel):
|
||||||
continue
|
continue
|
||||||
if not endpoint_rule.endpoint:
|
if not endpoint_rule.endpoint:
|
||||||
continue
|
continue
|
||||||
|
if endpoint_rule.endpoint.is_default():
|
||||||
|
return endpoint_rule
|
||||||
if not endpoint_rule.endpoint.host:
|
if not endpoint_rule.endpoint.host:
|
||||||
continue
|
continue
|
||||||
if endpoint_rule.endpoint.get_port(protocol) == 0:
|
if endpoint_rule.endpoint.get_port(protocol) == 0:
|
||||||
|
|
Loading…
Reference in New Issue