mirror of https://github.com/jumpserver/jumpserver
Merge pull request #11186 from jumpserver/pr@dev@perf_merge_migrations
perf: 合并 migrationspull/11190/head
commit
4dc6bd3660
@ -1,24 +0,0 @@
|
|||||||
# Generated by Django 4.1.10 on 2023-08-01 11:40
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
def windows_platform_protocols_ssh_default(apps, schema_editor):
|
|
||||||
platform_cls = apps.get_model('assets', 'Platform')
|
|
||||||
windows_platform = platform_cls.objects.filter(
|
|
||||||
name='Windows', internal=True, type='windows'
|
|
||||||
).first()
|
|
||||||
if not windows_platform:
|
|
||||||
return
|
|
||||||
|
|
||||||
windows_platform.protocols.filter(name='ssh').update(default=True)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
('assets', '0121_auto_20230725_1458'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(windows_platform_protocols_ssh_default)
|
|
||||||
]
|
|
@ -1,33 +0,0 @@
|
|||||||
# Generated by Django 4.1.10 on 2023-08-02 09:40
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def migrate_telnet_regex(apps, schema_editor):
|
|
||||||
setting_cls = apps.get_model('settings', 'Setting')
|
|
||||||
setting = setting_cls.objects.filter(name='TERMINAL_TELNET_REGEX').first()
|
|
||||||
if not setting:
|
|
||||||
print("Not found telnet regex setting, skip")
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
value = json.loads(setting.value)
|
|
||||||
except Exception:
|
|
||||||
print("Invalid telnet regex setting, skip")
|
|
||||||
return
|
|
||||||
platform_protocol_cls = apps.get_model('assets', 'PlatformProtocol')
|
|
||||||
telnets = platform_protocol_cls.objects.filter(name='telnet')
|
|
||||||
if telnets.count() > 0:
|
|
||||||
telnets.update(setting={'success_prompt': value})
|
|
||||||
print("Migrate telnet regex setting success: ", telnets.count())
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('assets', '0122_auto_20230801_1940'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(migrate_telnet_regex)
|
|
||||||
]
|
|
Loading…
Reference in new issue