jumpserver/apps/assets/const/host.py

107 lines
3.1 KiB
Python
Raw Normal View History

2022-09-19 12:11:55 +00:00
from .base import BaseType
2022-09-18 16:07:59 +00:00
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'
2022-09-19 12:11:55 +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,
2022-09-22 07:24:32 +00:00
'su_methods': [
2022-09-22 08:39:41 +00:00
{'name': 'sudo su', 'id': 'sudo su'},
{'name': 'su -', 'id': 'su -'}
2022-09-22 07:24:32 +00:00
],
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 {
'*': {
'choices': ['ssh', 'telnet', 'vnc', 'rdp']
2022-10-14 08:33:24 +00:00
},
cls.WINDOWS: {
'choices': ['rdp', 'ssh', 'vnc']
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,
2022-10-19 03:39:11 +00:00
'push_account_enabled': True,
},
cls.WINDOWS: {
'ansible_config': {
2022-10-13 09:47:29 +00:00
'ansible_shell_type': 'cmd',
'ansible_connection': 'ssh',
},
},
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'},
2022-10-25 04:57:34 +00:00
{'name': 'Gateway'}
2022-09-22 07:24:32 +00:00
],
cls.UNIX: [
{'name': 'Unix'},
{'name': 'macOS'},
{'name': 'BSD'},
{'name': 'AIX', 'automation': {
2022-10-19 03:39:11 +00:00
'push_account_method': 'push_account_aix',
'change_secret_method': 'push_secret_aix'
2022-10-25 04:57:34 +00:00
}}
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': {
'ssh': {
'required': True
}
}
}
2022-09-22 07:24:32 +00:00
],
cls.OTHER_HOST: []
}