mirror of https://github.com/jumpserver/jumpserver
parent
3b45ad0c61
commit
166d074adb
|
@ -2,11 +2,10 @@
|
||||||
#
|
#
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orgs.mixins.models import OrgManager
|
|
||||||
from assets.models.platform import Platform
|
|
||||||
from assets.const import GATEWAY_NAME
|
from assets.const import GATEWAY_NAME
|
||||||
|
from assets.models.platform import Platform
|
||||||
from common.utils import get_logger, lazyproperty
|
from common.utils import get_logger, lazyproperty
|
||||||
|
from orgs.mixins.models import OrgManager
|
||||||
from .asset.host import Host
|
from .asset.host import Host
|
||||||
|
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
@ -57,6 +56,14 @@ class Gateway(Host):
|
||||||
account = self.select_account
|
account = self.select_account
|
||||||
return account.password if account else None
|
return account.password if account else None
|
||||||
|
|
||||||
|
@lazyproperty
|
||||||
|
def port(self):
|
||||||
|
protocol = self.protocols.filter(name='ssh').first()
|
||||||
|
if protocol:
|
||||||
|
return protocol.port
|
||||||
|
else:
|
||||||
|
return '22'
|
||||||
|
|
||||||
@lazyproperty
|
@lazyproperty
|
||||||
def private_key(self):
|
def private_key(self):
|
||||||
account = self.select_account
|
account = self.select_account
|
||||||
|
|
|
@ -101,15 +101,8 @@ class JMSInventory:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_primary_protocol(protocols):
|
def get_primary_protocol(protocols):
|
||||||
primary_protocol = [p for p in protocols if p.primary]
|
if protocols:
|
||||||
if len(primary_protocol) >= 1:
|
|
||||||
primary = primary_protocol[0]
|
|
||||||
elif protocols:
|
|
||||||
primary = protocols[0]
|
primary = protocols[0]
|
||||||
else:
|
|
||||||
primary = None
|
|
||||||
|
|
||||||
if primary:
|
|
||||||
protocol = primary.name
|
protocol = primary.name
|
||||||
port = primary.port
|
port = primary.port
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue