perf: RemoteAppHost 平台支持 winrm (#10542)

Co-authored-by: ibuler <ibuler@qq.com>
pull/10570/head
fit2bot 2023-05-25 13:57:02 +08:00 committed by GitHub
parent b72f8a7241
commit 5e7d474bb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.17 on 2023-05-24 08:45
from django.db import migrations
def migrate_remote_applet_host_support_winrm(apps, *args):
platform_cls = apps.get_model('assets', 'Platform')
protocol_cls = apps.get_model('assets', 'PlatformProtocol')
applet_host_platform = platform_cls.objects.filter(name='RemoteAppHost').first()
if not applet_host_platform:
return
protocols = applet_host_platform.protocols.all()
if not protocols.filter(name='winrm').exists():
protocol = protocol_cls(name='winrm', port=5985, public=False, platform=applet_host_platform)
protocol.save()
applet_host_platform.protocols.add(protocol)
ssh_protocol = protocols.filter(name='ssh').first()
if ssh_protocol:
ssh_protocol.required = False
ssh_protocol.default = True
ssh_protocol.save()
class Migration(migrations.Migration):
dependencies = [
('assets', '0117_alter_baseautomation_params'),
]
operations = [
migrations.RunPython(migrate_remote_applet_host_support_winrm)
]