mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-18 16:39:28 +00:00
feat: 添加组件监控;TerminalModel添加type字段; (#5206)
* feat: 添加组件监控;TerminalModel添加type字段; * feat: Terminal序列类添加type字段 * feat: Terminal序列类添加type字段为只读 * feat: 修改组件status文案 * feat: 取消上传组件状态序列类count字段 * reactor: 修改termina/models目录结构 * feat: 修改ComponentTypeChoices * feat: 取消考虑CoreComponent类型 * feat: 修改Terminal status判断逻辑 * feat: 终端列表添加status过滤; 组件状态序列类添加default值 * feat: 添加PrometheusMetricsAPI * feat: 修改PrometheusMetricsAPI Co-authored-by: Bai <bugatti_it@163.com>
This commit is contained in:
42
apps/terminal/migrations/0030_terminal_type.py
Normal file
42
apps/terminal/migrations/0030_terminal_type.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 3.1 on 2020-12-10 07:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
TERMINAL_TYPE_KOKO = 'koko'
|
||||
TERMINAL_TYPE_GUACAMOLE = 'guacamole'
|
||||
TERMINAL_TYPE_OMNIDB = 'omnidb'
|
||||
|
||||
|
||||
def migrate_terminal_type(apps, schema_editor):
|
||||
terminal_model = apps.get_model("terminal", "Terminal")
|
||||
db_alias = schema_editor.connection.alias
|
||||
terminals = terminal_model.objects.using(db_alias).all()
|
||||
for terminal in terminals:
|
||||
name = terminal.name.lower()
|
||||
if 'koko' in name:
|
||||
_type = TERMINAL_TYPE_KOKO
|
||||
elif 'gua' in name:
|
||||
_type = TERMINAL_TYPE_GUACAMOLE
|
||||
elif 'omnidb' in name:
|
||||
_type = TERMINAL_TYPE_OMNIDB
|
||||
else:
|
||||
_type = TERMINAL_TYPE_KOKO
|
||||
terminal.type = _type
|
||||
terminal_model.objects.bulk_update(terminals, ['type'])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('terminal', '0029_auto_20201116_1757'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='terminal',
|
||||
name='type',
|
||||
field=models.CharField(choices=[('koko', 'KoKo'), ('guacamole', 'Guacamole'), ('omnidb', 'OmniDB')], default='koko', max_length=64, verbose_name='type'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.RunPython(migrate_terminal_type)
|
||||
]
|
Reference in New Issue
Block a user