mirror of https://github.com/jumpserver/jumpserver
34 lines
999 B
Python
34 lines
999 B
Python
# 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)
|
|
]
|