mirror of https://github.com/jumpserver/jumpserver
perf: 修改 connectivity
parent
ef51e74b8e
commit
03c0d2edbd
|
@ -1,7 +1,7 @@
|
|||
from django.db.models import QuerySet
|
||||
|
||||
from common.utils import get_logger
|
||||
from accounts.const import AutomationTypes, Connectivity
|
||||
from common.utils import get_logger
|
||||
from ..base.manager import PushOrVerifyHostCallbackMixin, AccountBasePlaybookManager
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
@ -29,4 +29,4 @@ class VerifyAccountManager(PushOrVerifyHostCallbackMixin, AccountBasePlaybookMan
|
|||
|
||||
def on_host_error(self, host, error, result):
|
||||
account = self.host_account_mapper.get(host)
|
||||
account.set_connectivity(Connectivity.FAILED)
|
||||
account.set_connectivity(Connectivity.ERR)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from common.utils import get_logger
|
||||
from assets.const import AutomationTypes, Connectivity
|
||||
from common.utils import get_logger
|
||||
from ..base.manager import BasePlaybookManager
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
@ -28,7 +28,7 @@ class PingManager(BasePlaybookManager):
|
|||
|
||||
def on_host_error(self, host, error, result):
|
||||
asset, account = self.host_asset_and_account_mapper.get(host)
|
||||
asset.set_connectivity(Connectivity.FAILED)
|
||||
asset.set_connectivity(Connectivity.ERR)
|
||||
if not account:
|
||||
return
|
||||
account.set_connectivity(Connectivity.FAILED)
|
||||
account.set_connectivity(Connectivity.ERR)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import socket
|
||||
import paramiko
|
||||
|
||||
import paramiko
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common.utils import get_logger
|
||||
from assets.models import Gateway
|
||||
from assets.const import AutomationTypes, Connectivity
|
||||
from assets.models import Gateway
|
||||
from common.utils import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
@ -100,10 +100,10 @@ class PingGatewayManager:
|
|||
@staticmethod
|
||||
def on_host_error(gateway, account, error):
|
||||
logger.info('\033[31m {} -> {} 原因: {} \033[0m\n'.format(gateway, account, error))
|
||||
gateway.set_connectivity(Connectivity.FAILED)
|
||||
gateway.set_connectivity(Connectivity.ERR)
|
||||
if not account:
|
||||
return
|
||||
account.set_connectivity(Connectivity.FAILED)
|
||||
account.set_connectivity(Connectivity.ERR)
|
||||
|
||||
@staticmethod
|
||||
def before_runner_start():
|
||||
|
|
|
@ -3,9 +3,9 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
|
||||
class Connectivity(TextChoices):
|
||||
UNKNOWN = 'unknown', _('Unknown')
|
||||
UNKNOWN = '-', _('Unknown')
|
||||
OK = 'ok', _('Ok')
|
||||
FAILED = 'failed', _('Failed')
|
||||
ERR = 'err', _('Error')
|
||||
|
||||
|
||||
class AutomationTypes(TextChoices):
|
||||
|
|
Loading…
Reference in New Issue