From c094bce71ee91ce0280cc805ba454826cde950b9 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 17 Mar 2023 16:57:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20ansible=20?= =?UTF-8?q?=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ansible/inventory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index 89442b34f..8c45cba39 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -49,12 +49,12 @@ class JMSInventory: if gateway.password: proxy_command_list.insert( - 0, "sshpass -p '{}'".format(gateway.password) + 0, "sshpass -p {}".format(gateway.password) ) if gateway.private_key: proxy_command_list.append("-i {}".format(gateway.private_key_path)) - proxy_command = '-o ProxyCommand=\"{}\"'.format( + proxy_command = "-o ProxyCommand='{}'".format( " ".join(proxy_command_list) ) return {"ansible_ssh_common_args": proxy_command} From 1acfdf0398ab0243e5a1dc27fe29141e93bba6ad Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Fri, 17 Mar 2023 17:10:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?perf:=20=E6=89=B9=E9=87=8F=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E8=B4=A6=E5=8F=B7=20=E5=88=86=E6=89=B9=E5=A4=84?= =?UTF-8?q?=E7=90=86=20(#10000)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/perms/serializers/permission.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/perms/serializers/permission.py b/apps/perms/serializers/permission.py index 27bc90d89..9260267cb 100644 --- a/apps/perms/serializers/permission.py +++ b/apps/perms/serializers/permission.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # - -from django.db.models import Q, QuerySet +from django.db.models import Q from django.utils.translation import ugettext_lazy as _ from rest_framework import serializers @@ -119,7 +118,10 @@ class AssetPermissionSerializer(BulkOrgResourceModelSerializer): return assets = self.get_all_assets(nodes, assets) accounts = self.create_accounts(assets) - push_accounts_to_assets_task.delay([str(account.id) for account in accounts]) + account_ids = [str(account.id) for account in accounts] + slice_count = 20 + for i in range(0, len(account_ids), slice_count): + push_accounts_to_assets_task.delay(account_ids[i:i + slice_count]) def validate_accounts(self, usernames: list[str]): template_ids = [] From f5523aaf7b1d4fa3c9a8a5b521644664007204f2 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 17 Mar 2023 18:44:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/serializers/account/account.py | 2 +- apps/accounts/serializers/account/base.py | 2 +- apps/common/drf/parsers/base.py | 2 +- apps/locale/ja/LC_MESSAGES/django.po | 2 +- apps/locale/zh/LC_MESSAGES/django.po | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index 5b7bbdbce..295c8ed1f 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -81,7 +81,7 @@ class AccountAssetSerializer(serializers.ModelSerializer): def to_internal_value(self, data): if isinstance(data, dict): - i = data.get('id') + i = data.get('id') or data.get('pk') else: i = data diff --git a/apps/accounts/serializers/account/base.py b/apps/accounts/serializers/account/base.py index f31f19196..88239c98e 100644 --- a/apps/accounts/serializers/account/base.py +++ b/apps/accounts/serializers/account/base.py @@ -16,7 +16,7 @@ class AuthValidateMixin(serializers.Serializer): choices=SecretType.choices, required=True, label=_('Secret type') ) secret = EncryptedField( - label=_('Secret/Password'), required=False, max_length=40960, allow_blank=True, + label=_('Secret'), required=False, max_length=40960, allow_blank=True, allow_null=True, write_only=True, ) passphrase = serializers.CharField( diff --git a/apps/common/drf/parsers/base.py b/apps/common/drf/parsers/base.py index 7f3d4b055..94b9df159 100644 --- a/apps/common/drf/parsers/base.py +++ b/apps/common/drf/parsers/base.py @@ -111,7 +111,7 @@ class BaseFileParser(BaseParser): return {'pk': obj_id, 'name': obj_name} def parse_value(self, field, value): - if value is '-': + if value is '-' and field and field.allow_null: return None elif hasattr(field, 'to_file_internal_value'): value = field.to_file_internal_value(value) diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index d4b4ecc20..8db56f83f 100644 --- a/apps/locale/ja/LC_MESSAGES/django.po +++ b/apps/locale/ja/LC_MESSAGES/django.po @@ -584,7 +584,7 @@ msgid "Asset type" msgstr "資産タイプ" #: accounts/serializers/account/base.py:19 -msgid "Secret/Password" +msgid "Secret" msgstr "キー/パスワード" #: accounts/serializers/account/base.py:24 diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index ba0a34c84..268aa8bdb 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -580,8 +580,8 @@ msgid "Asset type" msgstr "资产类型" #: accounts/serializers/account/base.py:19 -msgid "Secret/Password" -msgstr "密钥/密码" +msgid "Secret" +msgstr "密文" #: accounts/serializers/account/base.py:24 msgid "Key password"