perf: 优化内置平台创建

pull/10232/head
ibuler 2 years ago
parent bacda8248b
commit b30e9aedce

@ -352,5 +352,6 @@ class AllTypes(ChoicesMixin):
for platform in user_platforms:
print("\t- Update platform: {}".format(platform.name))
platform_data = cls.get_type_default_platform(platform.category, platform.type)
platform_data['name'] = platform.name
cls.create_or_update_by_platform_data(platform_data, platform_cls=platform_cls)
user_platforms.update(internal=False)

@ -70,7 +70,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "host",
"type": "linux",
@ -134,7 +134,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "host",
"type": "unix",
@ -198,7 +198,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "host",
"type": "unix",
@ -262,7 +262,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "host",
"type": "unix",
@ -326,7 +326,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "host",
"type": "unix",
@ -390,7 +390,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "host",
"type": "windows",
@ -448,7 +448,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "host",
"type": "windows",
@ -506,7 +506,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "host",
"type": "windows",
@ -564,7 +564,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "host",
"type": "windows",
@ -615,7 +615,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "device",
"type": "general",
@ -656,7 +656,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "device",
"type": "general",
@ -697,7 +697,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "device",
"type": "general",
@ -738,7 +738,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "device",
"type": "general",
@ -779,7 +779,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "mysql",
@ -815,7 +815,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "database",
"type": "mariadb",
@ -851,7 +851,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "postgresql",
@ -887,7 +887,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "oracle",
@ -923,7 +923,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "sqlserver",
@ -958,7 +958,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "clickhouse",
@ -989,7 +989,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "mongodb",
@ -1025,7 +1025,7 @@ platforms_data_json = '''[
"setting": {}
}
]
}
},
{
"category": "database",
"type": "redis",
@ -1058,7 +1058,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "database",
"type": "redis",
@ -1091,7 +1091,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "web",
"type": "website",
@ -1123,7 +1123,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "cloud",
"type": "private",
@ -1155,7 +1155,7 @@ platforms_data_json = '''[
"default": false
}
]
}
},
{
"category": "cloud",
"type": "k8s",

@ -55,7 +55,7 @@ def migrate_device_platform_automation(apps, *args):
"ansible_connection": "local",
"first_connect_delay": 0.5,
}
automation.ansible_enable = True
automation.ansible_enabled = True
automation.change_secret_enabled = True
automation.change_secret_method = "change_secret_by_ssh"
automation.ping_enabled = True
@ -65,6 +65,17 @@ def migrate_device_platform_automation(apps, *args):
automation.save()
def migrate_web_login_button_error(apps, *args):
protocol_cls = apps.get_model('assets', 'PlatformProtocol')
protocols = protocol_cls.objects.filter(name='http')
for protocol in protocols:
submit_selector = protocol.setting.get('submit_selector', '')
submit_selector = submit_selector.replace('id=longin_button', 'id=login_button')
protocol.setting['submit_selector'] = submit_selector
protocol.save()
class Migration(migrations.Migration):
dependencies = [
('assets', '0110_auto_20230315_1741'),
@ -85,4 +96,5 @@ class Migration(migrations.Migration):
migrations.RunPython(migrate_platform_protocol_primary),
migrations.RunPython(migrate_winrm_for_win),
migrations.RunPython(migrate_device_platform_automation),
migrations.RunPython(migrate_web_login_button_error),
]

Loading…
Cancel
Save