jumpserver/apps/assets/const/host.py

130 lines
3.8 KiB
Python
Raw Normal View History

2023-03-01 02:05:40 +00:00
from django.utils.translation import gettext_lazy as _
2022-09-19 12:11:55 +00:00
from .base import BaseType
2022-09-18 16:07:59 +00:00
GATEWAY_NAME = 'Gateway'
2022-09-19 12:11:55 +00:00
class HostTypes(BaseType):
2022-09-18 16:07:59 +00:00
LINUX = 'linux', 'Linux'
WINDOWS = 'windows', 'Windows'
UNIX = 'unix', 'Unix'
2023-03-01 02:05:40 +00:00
OTHER_HOST = 'other', _("Other")
2022-09-18 16:07:59 +00:00
@classmethod
2022-09-19 12:11:55 +00:00
def _get_base_constrains(cls) -> dict:
2022-09-18 16:07:59 +00:00
return {
2022-09-19 12:11:55 +00:00
'*': {
2022-09-21 11:03:06 +00:00
'charset_enabled': True,
2022-09-22 07:24:32 +00:00
'charset': 'utf-8', # default
2022-09-19 12:11:55 +00:00
'domain_enabled': True,
'su_enabled': True,
2024-08-06 11:32:53 +00:00
'su_methods': ['sudo', 'su', 'only_sudo', 'only_su'],
2022-09-18 16:07:59 +00:00
},
cls.WINDOWS: {
2022-09-19 12:11:55 +00:00
'su_enabled': False,
2022-09-18 16:07:59 +00:00
},
2022-09-19 12:11:55 +00:00
cls.OTHER_HOST: {
'su_enabled': False,
2022-09-18 16:07:59 +00:00
}
2022-09-19 12:11:55 +00:00
}
@classmethod
def _get_protocol_constrains(cls) -> dict:
return {
'*': {
2023-07-25 09:12:06 +00:00
'choices': ['ssh', 'sftp', 'telnet', 'vnc', 'rdp']
2022-10-14 08:33:24 +00:00
},
cls.WINDOWS: {
2023-08-16 06:17:35 +00:00
'choices': ['rdp', 'ssh', 'sftp', 'vnc', 'winrm']
2022-09-19 12:11:55 +00:00
}
}
@classmethod
def _get_automation_constrains(cls) -> dict:
return {
'*': {
'ansible_enabled': True,
'ansible_config': {
'ansible_connection': 'smart',
},
2022-09-19 12:11:55 +00:00
'ping_enabled': True,
'gather_facts_enabled': True,
'gather_accounts_enabled': True,
'verify_account_enabled': True,
2022-10-13 09:47:29 +00:00
'change_secret_enabled': True,
'push_account_enabled': True,
'remove_account_enabled': True,
},
cls.WINDOWS: {
'ansible_config': {
2022-10-13 09:47:29 +00:00
'ansible_shell_type': 'cmd',
'ansible_connection': 'smart',
},
},
cls.OTHER_HOST: {
'ansible_enabled': False,
'ping_enabled': False,
'gather_facts_enabled': False,
'gather_accounts_enabled': False,
'verify_account_enabled': False,
'change_secret_enabled': False,
'push_account_enabled': False
},
2022-09-19 12:11:55 +00:00
}
2022-09-22 07:24:32 +00:00
@classmethod
def internal_platforms(cls):
return {
cls.LINUX: [
{'name': 'Linux'},
{
'name': GATEWAY_NAME,
'domain_enabled': True,
}
2022-09-22 07:24:32 +00:00
],
cls.UNIX: [
{'name': 'Unix'},
{'name': 'macOS'},
{'name': 'BSD'},
{
'name': 'AIX',
'automation': {
'push_account_method': 'push_account_aix',
'change_secret_method': 'change_secret_aix',
}
},
2022-09-22 07:24:32 +00:00
],
cls.WINDOWS: [
{'name': 'Windows'},
2022-10-25 04:57:34 +00:00
{
'name': 'Windows-TLS',
'protocols_setting': {
'rdp': {'security': 'tls'},
}
},
{
'name': 'Windows-RDP',
'protocols_setting': {
'rdp': {'security': 'rdp'},
}
},
{
'name': 'RemoteAppHost',
'_protocols': ['rdp', 'ssh'],
'protocols_setting': {
2022-10-25 04:57:34 +00:00
'ssh': {
'required': True
}
}
}
]
2022-09-22 07:24:32 +00:00
}
@classmethod
def get_community_types(cls) -> list:
return [
cls.LINUX, cls.UNIX, cls.WINDOWS, cls.OTHER_HOST
]