From 59b27822be58300c2c49db3d168b16e89c5e5f6f Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 11 Apr 2023 19:29:56 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B7=BB=E5=8A=A0=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0113_auto_20230411_1917.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 apps/assets/migrations/0113_auto_20230411_1917.py diff --git a/apps/assets/migrations/0113_auto_20230411_1917.py b/apps/assets/migrations/0113_auto_20230411_1917.py new file mode 100644 index 000000000..ca41a30ab --- /dev/null +++ b/apps/assets/migrations/0113_auto_20230411_1917.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.17 on 2023-04-11 11:17 + +from django.db import migrations + + +def migrate_device_platform_su_method(apps, schema_editor): + platform_model = apps.get_model('assets', 'Platform') + device_map = { + 'Huawei': 'super', + 'Cisco': 'enable', + 'H3C': 'super_level', + } + platforms = platform_model.objects.filter(name__in=device_map.keys()) + print() + for platform in platforms: + print("Migrate platform su method: {}".format(platform.name)) + if platform.name not in device_map: + continue + platform.su_method = device_map[platform.name] + platform.su_enabled = True + platform.save(update_fields=['su_method', 'su_enabled']) + + +class Migration(migrations.Migration): + dependencies = [ + ('assets', '0112_auto_20230404_1631'), + ] + + operations = [ + migrations.RunPython(migrate_device_platform_su_method) + ]