# Generated by Django 3.2.17 on 2023-06-30 07:55 import json from django.db import migrations platform_json_data = """{ "category": "host", "type": "windows", "internal": true, "charset": "utf-8", "domain_enabled": true, "su_enabled": false, "name": "Windows-RDP7", "automation": { "ansible_enabled": true, "ansible_config": { "ansible_shell_type": "cmd", "ansible_connection": "ssh" }, "ping_enabled": true, "gather_facts_enabled": true, "gather_accounts_enabled": true, "verify_account_enabled": true, "change_secret_enabled": true, "push_account_enabled": true, "ping_method": "win_ping", "gather_facts_method": "gather_facts_windows", "gather_accounts_method": "gather_accounts_windows", "verify_account_method": "verify_account_windows", "change_secret_method": "change_secret_local_windows", "push_account_method": "push_account_local_windows" }, "protocols": [ { "name": "rdp7", "port": 3390, "setting": { "console": false, "security": "any" }, "primary": true, "required": false, "default": false } ] }""" def create_rdp7_internal_platform(apps, *args): platform_cls = apps.get_model('assets', 'Platform') platform_automation_cls = apps.get_model('assets', 'PlatformAutomation') platform_data = json.loads(platform_json_data) protocols = platform_data.pop('protocols') automation_data = platform_data.pop('automation', {}) rdp7_obj = platform_cls.objects.create(**platform_data) for p in protocols: rdp7_obj.protocols.create(**p) platform_automation_cls.objects.create(platform=rdp7_obj, **automation_data) class Migration(migrations.Migration): dependencies = [ ('assets', '0119_assets_add_default_node'), ] operations = [ migrations.RunPython(create_rdp7_internal_platform), ]