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
|
|
|
|
2022-11-22 09:33:09 +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 {
|
|
|
|
'*': {
|
2022-09-26 10:03:48 +00:00
|
|
|
'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,
|
2024-06-12 11:23:40 +00:00
|
|
|
'push_account_enabled': True,
|
|
|
|
'remove_account_enabled': True,
|
|
|
|
|
2022-09-26 10:03:48 +00:00
|
|
|
},
|
|
|
|
cls.WINDOWS: {
|
|
|
|
'ansible_config': {
|
2022-10-13 09:47:29 +00:00
|
|
|
'ansible_shell_type': 'cmd',
|
2023-03-29 09:10:58 +00:00
|
|
|
'ansible_connection': 'smart',
|
2022-09-26 10:03:48 +00:00
|
|
|
},
|
|
|
|
},
|
2023-02-14 10:34:46 +00:00
|
|
|
cls.OTHER_HOST: {
|
2023-02-21 12:06:45 +00:00
|
|
|
'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
|
2023-02-14 10:34:46 +00:00
|
|
|
},
|
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'},
|
2023-01-18 07:27:09 +00:00
|
|
|
{
|
|
|
|
'name': GATEWAY_NAME,
|
2023-02-06 06:54:30 +00:00
|
|
|
'domain_enabled': True,
|
2023-01-18 07:27:09 +00:00
|
|
|
}
|
2022-09-22 07:24:32 +00:00
|
|
|
],
|
|
|
|
cls.UNIX: [
|
|
|
|
{'name': 'Unix'},
|
|
|
|
{'name': 'macOS'},
|
|
|
|
{'name': 'BSD'},
|
2023-02-20 11:12:57 +00:00
|
|
|
{
|
|
|
|
'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'],
|
2022-12-19 03:35:50 +00:00
|
|
|
'protocols_setting': {
|
2022-10-25 04:57:34 +00:00
|
|
|
'ssh': {
|
|
|
|
'required': True
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-14 10:34:46 +00:00
|
|
|
]
|
2022-09-22 07:24:32 +00:00
|
|
|
}
|
2022-12-19 03:35:50 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_community_types(cls) -> list:
|
|
|
|
return [
|
|
|
|
cls.LINUX, cls.UNIX, cls.WINDOWS, cls.OTHER_HOST
|
|
|
|
]
|