2017-12-12 04:19:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
2021-01-12 10:06:42 +00:00
|
|
|
from django.db.models import TextChoices
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2022-11-16 13:05:15 +00:00
|
|
|
from assets.const import Protocol
|
|
|
|
|
|
|
|
|
2021-01-12 10:06:42 +00:00
|
|
|
# Replay & Command Storage Choices
|
|
|
|
# --------------------------------
|
2019-12-05 07:09:25 +00:00
|
|
|
|
|
|
|
|
2022-11-04 03:40:16 +00:00
|
|
|
class ReplayStorageType(TextChoices):
|
2021-01-12 10:06:42 +00:00
|
|
|
null = 'null', 'Null',
|
|
|
|
server = 'server', 'Server'
|
|
|
|
s3 = 's3', 'S3'
|
|
|
|
ceph = 'ceph', 'Ceph'
|
|
|
|
swift = 'swift', 'Swift'
|
|
|
|
oss = 'oss', 'OSS'
|
|
|
|
azure = 'azure', 'Azure'
|
2021-04-12 11:37:04 +00:00
|
|
|
obs = 'obs', 'OBS'
|
2022-02-28 11:28:58 +00:00
|
|
|
cos = 'cos', 'COS'
|
2019-12-05 07:09:25 +00:00
|
|
|
|
|
|
|
|
2022-11-04 03:40:16 +00:00
|
|
|
class CommandStorageType(TextChoices):
|
2021-01-12 10:06:42 +00:00
|
|
|
null = 'null', 'Null',
|
|
|
|
server = 'server', 'Server'
|
|
|
|
es = 'es', 'Elasticsearch'
|
2020-12-10 12:50:22 +00:00
|
|
|
|
|
|
|
|
2021-01-12 10:06:42 +00:00
|
|
|
# Component Status Choices
|
|
|
|
# ------------------------
|
2020-12-10 12:50:22 +00:00
|
|
|
|
2022-11-04 03:40:16 +00:00
|
|
|
class ComponentLoad(TextChoices):
|
2020-12-10 12:50:22 +00:00
|
|
|
critical = 'critical', _('Critical')
|
|
|
|
high = 'high', _('High')
|
|
|
|
normal = 'normal', _('Normal')
|
2021-03-26 11:09:34 +00:00
|
|
|
offline = 'offline', _('Offline')
|
2020-12-10 12:50:22 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def status(cls):
|
|
|
|
return set(dict(cls.choices).keys())
|
|
|
|
|
|
|
|
|
2022-11-04 03:40:16 +00:00
|
|
|
class TerminalType(TextChoices):
|
2020-12-10 12:50:22 +00:00
|
|
|
koko = 'koko', 'KoKo'
|
|
|
|
guacamole = 'guacamole', 'Guacamole'
|
|
|
|
omnidb = 'omnidb', 'OmniDB'
|
2021-03-03 03:20:40 +00:00
|
|
|
xrdp = 'xrdp', 'Xrdp'
|
2021-05-17 06:46:40 +00:00
|
|
|
lion = 'lion', 'Lion'
|
2021-08-06 11:16:18 +00:00
|
|
|
core = 'core', 'Core'
|
|
|
|
celery = 'celery', 'Celery'
|
2022-11-16 13:05:15 +00:00
|
|
|
magnus = 'magnus', 'Magnus'
|
|
|
|
razor = 'razor', 'Razor'
|
2022-11-03 08:55:38 +00:00
|
|
|
tinker = 'tinker', 'Tinker'
|
2020-12-10 12:50:22 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def types(cls):
|
|
|
|
return set(dict(cls.choices).keys())
|
|
|
|
|
2022-11-16 13:05:15 +00:00
|
|
|
|
|
|
|
class NativeClient:
|
|
|
|
# Koko
|
|
|
|
ssh = 'ssh', 'ssh'
|
|
|
|
putty = 'putty', 'PuTTY'
|
|
|
|
xshell = 'xshell', 'Xshell'
|
|
|
|
|
|
|
|
# Magnus
|
|
|
|
mysql = 'mysql', 'MySQL Client'
|
|
|
|
psql = 'psql', 'psql'
|
|
|
|
sqlplus = 'sqlplus', 'sqlplus'
|
|
|
|
redis = 'redis-cli', 'redis-cli'
|
|
|
|
|
|
|
|
# Razor
|
|
|
|
mstsc = 'mstsc', 'Remote Desktop'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def commands(cls, name, os):
|
|
|
|
return {
|
|
|
|
'ssh': 'ssh {username}@{hostname} -p {port}',
|
|
|
|
'putty': 'putty -ssh {username}@{hostname} -P {port}',
|
|
|
|
'xshell': '-url ssh://root:passwd@192.168.10.100',
|
|
|
|
'mysql': 'mysql -h {hostname} -P {port} -u {username} -p',
|
|
|
|
'psql': {
|
|
|
|
'default': 'psql -h {hostname} -p {port} -U {username} -W',
|
|
|
|
'windows': 'psql /h {hostname} /p {port} /U {username} -W',
|
|
|
|
},
|
|
|
|
'sqlplus': 'sqlplus {username}/{password}@{hostname}:{port}',
|
|
|
|
'redis': 'redis-cli -h {hostname} -p {port} -a {password}',
|
|
|
|
'mstsc': 'mstsc /v:{hostname}:{port}',
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ConnectMethod(TextChoices):
|
|
|
|
web_cli = 'web_cli', _('Web CLI')
|
|
|
|
web_gui = 'web_gui', _('Web GUI')
|
|
|
|
native_client = 'native_client', _('Native Client')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def methods(cls):
|
|
|
|
return {
|
|
|
|
Protocol.ssh: [cls.web_cli, cls.native_client],
|
|
|
|
Protocol.rdp: ([cls.web_gui], [cls.native_client]),
|
|
|
|
Protocol.vnc: [cls.web_gui],
|
|
|
|
Protocol.telnet: [cls.web_cli, cls.native_client],
|
|
|
|
Protocol.mysql: [cls.web_cli, cls.web_gui, cls.native_client],
|
|
|
|
Protocol.sqlserver: [cls.web_cli, cls.web_gui],
|
|
|
|
}
|