From 55e04e8e9f69c8880a51714b1f802697812945f8 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 21 Apr 2022 11:05:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=86=85=E7=BD=AEAIX=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=EF=BC=8C=E6=A0=B9=E6=8D=AE=E7=B3=BB=E7=BB=9F=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=AE=97=E6=B3=95=E5=8A=A0=E5=AF=86=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/migrations/0090_auto_20220412_1145.py | 15 +++++++++++++++ apps/assets/models/asset.py | 4 ---- apps/assets/tasks/push_system_user.py | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/assets/migrations/0090_auto_20220412_1145.py b/apps/assets/migrations/0090_auto_20220412_1145.py index c2cb879aa..434b7b3cf 100644 --- a/apps/assets/migrations/0090_auto_20220412_1145.py +++ b/apps/assets/migrations/0090_auto_20220412_1145.py @@ -3,6 +3,20 @@ from django.db import migrations, models +def create_internal_platform(apps, schema_editor): + model = apps.get_model("assets", "Platform") + db_alias = schema_editor.connection.alias + type_platforms = ( + ('AIX', 'Unix', None), + ) + for name, base, meta in type_platforms: + defaults = {'name': name, 'base': base, 'meta': meta, 'internal': True} + model.objects.using(db_alias).update_or_create( + name=name, defaults=defaults + ) + migrations.RunPython(create_internal_platform) + + class Migration(migrations.Migration): dependencies = [ @@ -15,4 +29,5 @@ class Migration(migrations.Migration): name='number', field=models.CharField(blank=True, max_length=128, null=True, verbose_name='Asset number'), ), + migrations.RunPython(create_internal_platform) ] diff --git a/apps/assets/models/asset.py b/apps/assets/models/asset.py index 7d46a4b25..7dde0862f 100644 --- a/apps/assets/models/asset.py +++ b/apps/assets/models/asset.py @@ -142,10 +142,6 @@ class Platform(models.Model): internal = models.BooleanField(default=False, verbose_name=_("Internal")) comment = models.TextField(blank=True, null=True, verbose_name=_("Comment")) - @property - def algorithm(self): - return self.meta.get('algorithm') - @classmethod def default(cls): linux, created = cls.objects.get_or_create( diff --git a/apps/assets/tasks/push_system_user.py b/apps/assets/tasks/push_system_user.py index 46734e4be..98d2a0922 100644 --- a/apps/assets/tasks/push_system_user.py +++ b/apps/assets/tasks/push_system_user.py @@ -244,7 +244,7 @@ def push_system_user_util(system_user, assets, task_name, username=None): for u in usernames: for a in _assets: system_user.load_asset_special_auth(a, u) - algorithm = a.platform.algorithm + algorithm = 'des' if a.platform.name == 'AIX' else 'sha512' tasks = get_push_system_user_tasks( system_user, platform, username=u, algorithm=algorithm