From 9ec7a8ac61b61f771ee44442f7938f43a4a7abf0 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 17:46:56 +0800 Subject: [PATCH 1/7] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20asset=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset/asset.py | 8 ++- apps/assets/models/asset/common.py | 52 +++++++++---------- apps/assets/serializers/asset/common.py | 26 +++++++--- .../serializers/connect_token_secret.py | 3 +- apps/ops/ansible/inventory.py | 2 +- apps/terminal/applets/navicat/app.py | 3 +- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/apps/assets/api/asset/asset.py b/apps/assets/api/asset/asset.py index c0dda34c7..a02d35121 100644 --- a/apps/assets/api/asset/asset.py +++ b/apps/assets/api/asset/asset.py @@ -2,7 +2,6 @@ # import django_filters from django.db.models import Q -from django.utils.translation import ugettext_lazy as _ from rest_framework.decorators import action from rest_framework.response import Response @@ -72,11 +71,13 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet): ("platform", serializers.PlatformSerializer), ("suggestion", serializers.MiniAssetSerializer), ("gateways", serializers.GatewaySerializer), + ("spec_info", serializers.SpecSerializer), ) rbac_perms = ( ("match", "assets.match_asset"), ("platform", "assets.view_platform"), ("gateways", "assets.view_gateway"), + ("spec_info", "assets.view_asset"), ) extra_filter_backends = [LabelFilterBackend, IpInFilterBackend, NodeFilterBackend] @@ -94,6 +95,11 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet): serializer = super().get_serializer(instance=asset.platform) return Response(serializer.data) + @action(methods=["GET"], detail=True, url_path="spec-info") + def spec_info(self, *args, **kwargs): + asset = super().get_object() + return Response(asset.spec_info) + @action(methods=["GET"], detail=True, url_path="gateways") def gateways(self, *args, **kwargs): asset = self.get_object() diff --git a/apps/assets/models/asset/common.py b/apps/assets/models/asset/common.py index 60f2f3c14..dfbf2ecf0 100644 --- a/apps/assets/models/asset/common.py +++ b/apps/assets/models/asset/common.py @@ -10,8 +10,8 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from assets import const -from common.utils import lazyproperty from common.db.fields import EncryptMixin +from common.utils import lazyproperty from orgs.mixins.models import OrgManager, JMSOrgBaseModel from ..base import AbsConnectivity from ..platform import Platform @@ -113,45 +113,47 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel): verbose_name=_("Nodes")) is_active = models.BooleanField(default=True, verbose_name=_('Is active')) labels = models.ManyToManyField('assets.Label', blank=True, related_name='assets', verbose_name=_("Labels")) - info = models.JSONField(verbose_name='Info', default=dict, blank=True) + info = models.JSONField(verbose_name='Info', default=dict, blank=True) # 资产的一些信息,如 硬件信息 objects = AssetManager.from_queryset(AssetQuerySet)() def __str__(self): return '{0.name}({0.address})'.format(self) - @property - def specific(self): - instance = getattr(self, self.category, None) - if not instance: - return {} - specific_fields = self.get_specific_fields(instance) + @staticmethod + def get_spec_values(instance, fields): info = {} - for i in specific_fields: + for i in fields: v = getattr(instance, i.name) if isinstance(i, models.JSONField) and not isinstance(v, (list, dict)): v = json.loads(v) info[i.name] = v return info - @property + @lazyproperty def spec_info(self): instance = getattr(self, self.category, None) if not instance: - return [] - specific_fields = self.get_specific_fields(instance) - info = [ - { - 'label': i.verbose_name, - 'name': i.name, - 'value': getattr(instance, i.name) - } - for i in specific_fields - ] - return info + return {} + spec_fields = self.get_spec_fields(instance) + return self.get_spec_values(instance, spec_fields) + + @staticmethod + def get_spec_fields(instance, secret=False): + spec_fields = [i for i in instance._meta.local_fields if i.name != 'asset_ptr'] + spec_fields = [i for i in spec_fields if isinstance(i, EncryptMixin) == secret] + return spec_fields @lazyproperty - def enabled_info(self): + def secret_info(self): + instance = getattr(self, self.category, None) + if not instance: + return {} + spec_fields = self.get_spec_fields(instance, secret=True) + return self.get_spec_values(instance, spec_fields) + + @lazyproperty + def auto_info(self): platform = self.platform automation = self.platform.automation return { @@ -165,12 +167,6 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel): 'gather_accounts_enabled': automation.gather_accounts_enabled, } - @staticmethod - def get_specific_fields(instance): - specific_fields = [i for i in instance._meta.local_fields if i.name != 'asset_ptr'] - specific_fields = [i for i in specific_fields if not isinstance(i, EncryptMixin)] - return specific_fields - def get_target_ip(self): return self.address diff --git a/apps/assets/serializers/asset/common.py b/apps/assets/serializers/asset/common.py index 89d5a66eb..47c866603 100644 --- a/apps/assets/serializers/asset/common.py +++ b/apps/assets/serializers/asset/common.py @@ -18,7 +18,7 @@ __all__ = [ 'AssetSerializer', 'AssetSimpleSerializer', 'MiniAssetSerializer', 'AssetTaskSerializer', 'AssetsTaskSerializer', 'AssetProtocolsSerializer', 'AssetDetailSerializer', 'DetailMixin', 'AssetAccountSerializer', - 'AccountSecretSerializer' + 'AccountSecretSerializer', 'SpecSerializer' ] @@ -113,13 +113,25 @@ class AccountSecretSerializer(SecretReadableMixin, CommonModelSerializer): } +class SpecSerializer(serializers.Serializer): + # 数据库 + db_name = serializers.CharField(label=_("Database"), max_length=128, required=False) + use_ssl = serializers.BooleanField(label=_("Use SSL"), required=False) + allow_invalid_cert = serializers.BooleanField(label=_("Allow invalid cert"), required=False) + # Web + autofill = serializers.CharField(label=_("Auto fill"), required=False) + username_selector = serializers.CharField(label=_("Username selector"), required=False) + password_selector = serializers.CharField(label=_("Password selector"), required=False) + submit_selector = serializers.CharField(label=_("Submit selector"), required=False) + script = serializers.JSONField(label=_("Script"), required=False) + + class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSerializer): category = LabeledChoiceField(choices=Category.choices, read_only=True, label=_('Category')) type = LabeledChoiceField(choices=AllTypes.choices(), read_only=True, label=_('Type')) labels = AssetLabelSerializer(many=True, required=False, label=_('Label')) protocols = AssetProtocolsSerializer(many=True, required=False, label=_('Protocols')) accounts = AssetAccountSerializer(many=True, required=False, write_only=True, label=_('Account')) - enabled_info = serializers.DictField(read_only=True, label=_('Enabled info')) class Meta: model = Asset @@ -127,11 +139,11 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali fields_small = fields_mini + ['is_active', 'comment'] fields_fk = ['domain', 'platform'] fields_m2m = [ - 'nodes', 'labels', 'protocols', 'nodes_display', 'accounts' + 'nodes', 'labels', 'protocols', + 'nodes_display', 'accounts' ] read_only_fields = [ - 'category', 'type', 'info', 'enabled_info', - 'connectivity', 'date_verified', + 'category', 'type', 'connectivity', 'date_verified', 'created_by', 'date_created' ] fields = fields_small + fields_fk + fields_m2m + read_only_fields @@ -235,11 +247,13 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali class DetailMixin(serializers.Serializer): accounts = AssetAccountSerializer(many=True, required=False, label=_('Accounts')) + spec_info = serializers.DictField(label=_('Spec info'), read_only=True) + auto_info = serializers.DictField(read_only=True, label=_('Auto info')) def get_field_names(self, declared_fields, info): names = super().get_field_names(declared_fields, info) names.extend([ - 'accounts', 'info', 'specific', 'spec_info' + 'accounts', 'info', 'spec_info', 'auto_info' ]) return names diff --git a/apps/authentication/serializers/connect_token_secret.py b/apps/authentication/serializers/connect_token_secret.py index 4585111ea..41ee8d116 100644 --- a/apps/authentication/serializers/connect_token_secret.py +++ b/apps/authentication/serializers/connect_token_secret.py @@ -31,7 +31,8 @@ class _ConnectionTokenAssetSerializer(serializers.ModelSerializer): model = Asset fields = [ 'id', 'name', 'address', 'protocols', - 'category', 'type', 'org_id', 'specific' + 'category', 'type', 'org_id', 'spec_info', + 'secret_info', ] diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index e50a0801f..243f1b319 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -105,7 +105,7 @@ class JMSInventory: 'id': str(asset.id), 'name': asset.name, 'address': asset.address, 'type': asset.type, 'category': asset.category, 'protocol': asset.protocol, 'port': asset.port, - 'specific': asset.specific, + 'specific': asset.spec, 'protocols': [{'name': p.name, 'port': p.port} for p in protocols], }, 'jms_account': { diff --git a/apps/terminal/applets/navicat/app.py b/apps/terminal/applets/navicat/app.py index 33d89d2d2..37c80f144 100644 --- a/apps/terminal/applets/navicat/app.py +++ b/apps/terminal/applets/navicat/app.py @@ -11,7 +11,6 @@ if sys.platform == 'win32': ) from common import wait_pid, BaseApplication - _default_path = r'C:\Program Files\PremiumSoft\Navicat Premium 16\navicat.exe' @@ -24,7 +23,7 @@ class AppletApplication(BaseApplication): self.privileged = self.account.privileged self.host = self.asset.address self.port = self.asset.get_protocol_port(self.protocol) - self.db = self.asset.specific.db_name + self.db = self.asset.spec.db_name self.name = '%s-%s' % (self.host, self.db) self.pid = None self.app = None From 41154d3793aeba3f476d1928f9f1de7ab17e7aa7 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 17:57:06 +0800 Subject: [PATCH 2/7] asset: specific to spec_info --- .../change_secret/database/mongodb/main.yml | 12 ++-- .../change_secret/database/oracle/main.yml | 10 ++-- .../database/postgresql/main.yml | 10 ++-- .../change_secret/database/sqlserver/main.yml | 58 +++++++++---------- .../gather_accounts/database/mongodb/main.yml | 2 +- .../gather_accounts/database/oracle/main.yml | 2 +- .../database/postgresql/main.yml | 2 +- .../verify_account/database/mongodb/main.yml | 2 +- .../verify_account/database/oracle/main.yml | 2 +- .../database/postgresql/main.yml | 2 +- .../database/sqlserver/main.yml | 2 +- .../gather_facts/database/mongodb/main.yml | 2 +- .../gather_facts/database/oracle/main.yml | 2 +- .../gather_facts/database/postgresql/main.yml | 2 +- .../ping/database/mongodb/main.yml | 2 +- .../automations/ping/database/oracle/main.yml | 2 +- .../ping/database/postgresql/main.yml | 2 +- .../ping/database/sqlserver/main.yml | 2 +- apps/terminal/applets/chrome/app.py | 4 +- apps/terminal/applets/navicat/app.py | 2 +- 20 files changed, 62 insertions(+), 62 deletions(-) diff --git a/apps/accounts/automations/change_secret/database/mongodb/main.yml b/apps/accounts/automations/change_secret/database/mongodb/main.yml index 02a568e0b..95702c8bb 100644 --- a/apps/accounts/automations/change_secret/database/mongodb/main.yml +++ b/apps/accounts/automations/change_secret/database/mongodb/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" register: db_info - name: Display MongoDB version @@ -24,8 +24,8 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" - db: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" + db: "{{ jms_asset.spec_info.db_name }}" name: "{{ account.username }}" password: "{{ account.secret }}" when: db_info is succeeded @@ -37,7 +37,7 @@ login_password: "{{ account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" when: - - db_info is succeeded - - change_info is succeeded + - db_info is succeeded + - change_info is succeeded diff --git a/apps/accounts/automations/change_secret/database/oracle/main.yml b/apps/accounts/automations/change_secret/database/oracle/main.yml index c7b20a8db..a58d776a7 100644 --- a/apps/accounts/automations/change_secret/database/oracle/main.yml +++ b/apps/accounts/automations/change_secret/database/oracle/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ jms_account.mode }}" register: db_info @@ -25,7 +25,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ jms_account.mode }}" name: "{{ account.username }}" password: "{{ account.secret }}" @@ -38,8 +38,8 @@ login_password: "{{ account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ account.mode }}" when: - - db_info is succeeded - - change_info is succeeded + - db_info is succeeded + - change_info is succeeded diff --git a/apps/accounts/automations/change_secret/database/postgresql/main.yml b/apps/accounts/automations/change_secret/database/postgresql/main.yml index ada11bbd6..6a903171f 100644 --- a/apps/accounts/automations/change_secret/database/postgresql/main.yml +++ b/apps/accounts/automations/change_secret/database/postgresql/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_db: "{{ jms_asset.specific.db_name }}" + login_db: "{{ jms_asset.spec_info.db_name }}" register: db_info - name: Display PostgreSQL version @@ -24,7 +24,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - db: "{{ jms_asset.specific.db_name }}" + db: "{{ jms_asset.spec_info.db_name }}" name: "{{ account.username }}" password: "{{ account.secret }}" when: db_info is succeeded @@ -36,7 +36,7 @@ login_password: "{{ account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - db: "{{ jms_asset.specific.db_name }}" + db: "{{ jms_asset.spec_info.db_name }}" when: - - db_info is succeeded - - change_info is succeeded + - db_info is succeeded + - change_info is succeeded diff --git a/apps/accounts/automations/change_secret/database/sqlserver/main.yml b/apps/accounts/automations/change_secret/database/sqlserver/main.yml index a617a1434..d3ea188b0 100644 --- a/apps/accounts/automations/change_secret/database/sqlserver/main.yml +++ b/apps/accounts/automations/change_secret/database/sqlserver/main.yml @@ -10,38 +10,38 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - name: '{{ jms_asset.specific.db_name }}' + name: '{{ jms_asset.spec_info.db_name }}' script: | SELECT @@version register: db_info - - name: SQLServer version - set_fact: - info: - version: "{{ db_info.query_results[0][0][0][0].splitlines()[0] }}" - - debug: - var: info + - name: SQLServer version + set_fact: + info: + version: "{{ db_info.query_results[0][0][0][0].splitlines()[0] }}" + - debug: + var: info - - name: Change SQLServer password - community.general.mssql_script: - login_user: "{{ jms_account.username }}" - login_password: "{{ jms_account.secret }}" - login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" - name: '{{ jms_asset.specific.db_name }}' - script: "ALTER LOGIN {{ account.username }} WITH PASSWORD = '{{ account.secret }}'; select @@version" - when: db_info is succeeded - register: change_info + - name: Change SQLServer password + community.general.mssql_script: + login_user: "{{ jms_account.username }}" + login_password: "{{ jms_account.secret }}" + login_host: "{{ jms_asset.address }}" + login_port: "{{ jms_asset.port }}" + name: '{{ jms_asset.spec_info.db_name }}' + script: "ALTER LOGIN {{ account.username }} WITH PASSWORD = '{{ account.secret }}'; select @@version" + when: db_info is succeeded + register: change_info - - name: Verify password - community.general.mssql_script: - login_user: "{{ account.username }}" - login_password: "{{ account.secret }}" - login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" - name: '{{ jms_asset.specific.db_name }}' - script: | - SELECT @@version - when: - - db_info is succeeded - - change_info is succeeded + - name: Verify password + community.general.mssql_script: + login_user: "{{ account.username }}" + login_password: "{{ account.secret }}" + login_host: "{{ jms_asset.address }}" + login_port: "{{ jms_asset.port }}" + name: '{{ jms_asset.spec_info.db_name }}' + script: | + SELECT @@version + when: + - db_info is succeeded + - change_info is succeeded diff --git a/apps/accounts/automations/gather_accounts/database/mongodb/main.yml b/apps/accounts/automations/gather_accounts/database/mongodb/main.yml index fd7a296b7..b94f2be1d 100644 --- a/apps/accounts/automations/gather_accounts/database/mongodb/main.yml +++ b/apps/accounts/automations/gather_accounts/database/mongodb/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" filter: users register: db_info diff --git a/apps/accounts/automations/gather_accounts/database/oracle/main.yml b/apps/accounts/automations/gather_accounts/database/oracle/main.yml index a0e20ff7b..f492583f4 100644 --- a/apps/accounts/automations/gather_accounts/database/oracle/main.yml +++ b/apps/accounts/automations/gather_accounts/database/oracle/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ jms_account.mode }}" filter: users register: db_info diff --git a/apps/accounts/automations/gather_accounts/database/postgresql/main.yml b/apps/accounts/automations/gather_accounts/database/postgresql/main.yml index f282b390d..c1c25c8b4 100644 --- a/apps/accounts/automations/gather_accounts/database/postgresql/main.yml +++ b/apps/accounts/automations/gather_accounts/database/postgresql/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_db: "{{ jms_asset.specific.db_name }}" + login_db: "{{ jms_asset.spec_info.db_name }}" filter: "roles" register: db_info diff --git a/apps/accounts/automations/verify_account/database/mongodb/main.yml b/apps/accounts/automations/verify_account/database/mongodb/main.yml index 1cf79b694..a65eee915 100644 --- a/apps/accounts/automations/verify_account/database/mongodb/main.yml +++ b/apps/accounts/automations/verify_account/database/mongodb/main.yml @@ -10,4 +10,4 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" diff --git a/apps/accounts/automations/verify_account/database/oracle/main.yml b/apps/accounts/automations/verify_account/database/oracle/main.yml index ed4091401..12896f09a 100644 --- a/apps/accounts/automations/verify_account/database/oracle/main.yml +++ b/apps/accounts/automations/verify_account/database/oracle/main.yml @@ -10,5 +10,5 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ jms_account.mode }}" diff --git a/apps/accounts/automations/verify_account/database/postgresql/main.yml b/apps/accounts/automations/verify_account/database/postgresql/main.yml index 08db4d869..cb6344b39 100644 --- a/apps/accounts/automations/verify_account/database/postgresql/main.yml +++ b/apps/accounts/automations/verify_account/database/postgresql/main.yml @@ -10,4 +10,4 @@ login_password: "{{ account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - db: "{{ jms_asset.specific.db_name }}" + db: "{{ jms_asset.spec_info.db_name }}" diff --git a/apps/accounts/automations/verify_account/database/sqlserver/main.yml b/apps/accounts/automations/verify_account/database/sqlserver/main.yml index 256803702..bb079fa59 100644 --- a/apps/accounts/automations/verify_account/database/sqlserver/main.yml +++ b/apps/accounts/automations/verify_account/database/sqlserver/main.yml @@ -10,6 +10,6 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - name: '{{ jms_asset.specific.db_name }}' + name: '{{ jms_asset.spec_info.db_name }}' script: | SELECT @@version diff --git a/apps/assets/automations/gather_facts/database/mongodb/main.yml b/apps/assets/automations/gather_facts/database/mongodb/main.yml index 37ce8bbd3..7cfe212a4 100644 --- a/apps/assets/automations/gather_facts/database/mongodb/main.yml +++ b/apps/assets/automations/gather_facts/database/mongodb/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" register: db_info - name: Define info by set_fact diff --git a/apps/assets/automations/gather_facts/database/oracle/main.yml b/apps/assets/automations/gather_facts/database/oracle/main.yml index 21ab639a4..f88fc11a1 100644 --- a/apps/assets/automations/gather_facts/database/oracle/main.yml +++ b/apps/assets/automations/gather_facts/database/oracle/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ jms_account.mode }}" register: db_info diff --git a/apps/assets/automations/gather_facts/database/postgresql/main.yml b/apps/assets/automations/gather_facts/database/postgresql/main.yml index a3c481b48..302fe1f9d 100644 --- a/apps/assets/automations/gather_facts/database/postgresql/main.yml +++ b/apps/assets/automations/gather_facts/database/postgresql/main.yml @@ -10,7 +10,7 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_db: "{{ jms_asset.specific.db_name }}" + login_db: "{{ jms_asset.spec_info.db_name }}" register: db_info - name: Define info by set_fact diff --git a/apps/assets/automations/ping/database/mongodb/main.yml b/apps/assets/automations/ping/database/mongodb/main.yml index 867c51ace..f89c44b1e 100644 --- a/apps/assets/automations/ping/database/mongodb/main.yml +++ b/apps/assets/automations/ping/database/mongodb/main.yml @@ -10,4 +10,4 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" diff --git a/apps/assets/automations/ping/database/oracle/main.yml b/apps/assets/automations/ping/database/oracle/main.yml index fefad7148..9cc6695ac 100644 --- a/apps/assets/automations/ping/database/oracle/main.yml +++ b/apps/assets/automations/ping/database/oracle/main.yml @@ -10,5 +10,5 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_database: "{{ jms_asset.specific.db_name }}" + login_database: "{{ jms_asset.spec_info.db_name }}" mode: "{{ jms_account.mode }}" diff --git a/apps/assets/automations/ping/database/postgresql/main.yml b/apps/assets/automations/ping/database/postgresql/main.yml index e97b3946d..f48c7d4f7 100644 --- a/apps/assets/automations/ping/database/postgresql/main.yml +++ b/apps/assets/automations/ping/database/postgresql/main.yml @@ -10,4 +10,4 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - login_db: "{{ jms_asset.specific.db_name }}" + login_db: "{{ jms_asset.spec_info.db_name }}" diff --git a/apps/assets/automations/ping/database/sqlserver/main.yml b/apps/assets/automations/ping/database/sqlserver/main.yml index 839a785a5..ca242538e 100644 --- a/apps/assets/automations/ping/database/sqlserver/main.yml +++ b/apps/assets/automations/ping/database/sqlserver/main.yml @@ -10,6 +10,6 @@ login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" login_port: "{{ jms_asset.port }}" - name: '{{ jms_asset.specific.db_name }}' + name: '{{ jms_asset.spec_info.db_name }}' script: | SELECT @@version diff --git a/apps/terminal/applets/chrome/app.py b/apps/terminal/applets/chrome/app.py index 89ae3fc3b..7d9b12c36 100644 --- a/apps/terminal/applets/chrome/app.py +++ b/apps/terminal/applets/chrome/app.py @@ -89,11 +89,11 @@ class WebAPP(object): self.extra_data = self.asset.specific self._steps = list() - autofill_type = self.asset.specific.autofill + autofill_type = self.asset.spec_info.autofill if autofill_type == "basic": self._steps = self._default_custom_steps() elif autofill_type == "script": - script_list = self.asset.specific.script + script_list = self.asset.spec_info.script steps = sorted(script_list, key=lambda step_item: step_item.step) for item in steps: val = item.value diff --git a/apps/terminal/applets/navicat/app.py b/apps/terminal/applets/navicat/app.py index 37c80f144..f7447007b 100644 --- a/apps/terminal/applets/navicat/app.py +++ b/apps/terminal/applets/navicat/app.py @@ -23,7 +23,7 @@ class AppletApplication(BaseApplication): self.privileged = self.account.privileged self.host = self.asset.address self.port = self.asset.get_protocol_port(self.protocol) - self.db = self.asset.spec.db_name + self.db = self.asset.spec_info.db_name self.name = '%s-%s' % (self.host, self.db) self.pid = None self.app = None From ef51e74b8ef900ea501b53b623043ec6366dd393 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 18:06:44 +0800 Subject: [PATCH 3/7] =?UTF-8?q?perf=EF=BC=9A=20=E7=BB=A7=E7=BB=AD=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=20spec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/models/base.py | 2 +- apps/accounts/serializers/account/base.py | 6 +++--- apps/ops/ansible/inventory.py | 2 +- apps/perms/serializers/user_permission.py | 6 +++--- apps/terminal/applets/chrome/app.py | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/accounts/models/base.py b/apps/accounts/models/base.py index ffae7051b..37b97f21a 100644 --- a/apps/accounts/models/base.py +++ b/apps/accounts/models/base.py @@ -50,7 +50,7 @@ class BaseAccount(JMSOrgBaseModel): return bool(self.username) @property - def specific(self): + def spec_info(self): data = {} if self.secret_type != SecretType.SSH_KEY: return data diff --git a/apps/accounts/serializers/account/base.py b/apps/accounts/serializers/account/base.py index d92c4cc9c..fb5b51d6f 100644 --- a/apps/accounts/serializers/account/base.py +++ b/apps/accounts/serializers/account/base.py @@ -68,14 +68,14 @@ class BaseAccountSerializer(AuthValidateMixin, BulkOrgResourceModelSerializer): fields_mini = ['id', 'name', 'username'] fields_small = fields_mini + [ 'secret_type', 'secret', 'has_secret', 'passphrase', - 'privileged', 'is_active', 'specific', + 'privileged', 'is_active', 'spec_info', ] fields_other = ['created_by', 'date_created', 'date_updated', 'comment'] fields = fields_small + fields_other read_only_fields = [ - 'has_secret', 'specific', + 'has_secret', 'spec_info', 'date_verified', 'created_by', 'date_created', ] extra_kwargs = { - 'specific': {'label': _('Specific')}, + 'spec_info': {'label': _('Spec info')}, } diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index 243f1b319..0a3ce43af 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -105,7 +105,7 @@ class JMSInventory: 'id': str(asset.id), 'name': asset.name, 'address': asset.address, 'type': asset.type, 'category': asset.category, 'protocol': asset.protocol, 'port': asset.port, - 'specific': asset.spec, + 'spec_info': asset.spec_info, 'protocols': [{'name': p.name, 'port': p.port} for p in protocols], }, 'jms_account': { diff --git a/apps/perms/serializers/user_permission.py b/apps/perms/serializers/user_permission.py index 8e22623fc..27fde71d1 100644 --- a/apps/perms/serializers/user_permission.py +++ b/apps/perms/serializers/user_permission.py @@ -4,13 +4,13 @@ from django.utils.translation import ugettext_lazy as _ from rest_framework import serializers +from accounts.models import Account from assets.const import Category, AllTypes from assets.models import Node, Asset, Platform -from accounts.models import Account from assets.serializers.asset.common import AssetProtocolsSerializer from common.serializers.fields import ObjectRelatedField, LabeledChoiceField -from perms.serializers.permission import ActionChoicesField from orgs.mixins.serializers import OrgResourceModelSerializerMixin +from perms.serializers.permission import ActionChoicesField __all__ = [ 'NodePermedSerializer', 'AssetPermedSerializer', @@ -32,7 +32,7 @@ class AssetPermedSerializer(OrgResourceModelSerializerMixin): "id", "name", "address", 'domain', 'platform', "comment", "org_id", "is_active", ] - fields = only_fields + ['protocols', 'category', 'type', 'specific'] + ['org_name'] + fields = only_fields + ['protocols', 'category', 'type', 'spec_info'] + ['org_name'] read_only_fields = fields diff --git a/apps/terminal/applets/chrome/app.py b/apps/terminal/applets/chrome/app.py index 7d9b12c36..491f1e09d 100644 --- a/apps/terminal/applets/chrome/app.py +++ b/apps/terminal/applets/chrome/app.py @@ -87,7 +87,7 @@ class WebAPP(object): self.account = account self.platform = platform - self.extra_data = self.asset.specific + self.extra_data = self.asset.spec_info self._steps = list() autofill_type = self.asset.spec_info.autofill if autofill_type == "basic": @@ -105,24 +105,24 @@ class WebAPP(object): def _default_custom_steps(self) -> list: account = self.account - specific_property = self.asset.specific + spec_info = self.asset.spec_info default_steps = [ Step({ "step": 1, "value": account.username, - "target": specific_property.username_selector, + "target": spec_info.username_selector, "command": "type" }), Step({ "step": 2, "value": account.secret, - "target": specific_property.password_selector, + "target": spec_info.password_selector, "command": "type" }), Step({ "step": 3, "value": "", - "target": specific_property.submit_selector, + "target": spec_info.submit_selector, "command": "click" }) ] From 03c0d2edbd6c30895543df31d0ae34e43a9836ff Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 18:51:04 +0800 Subject: [PATCH 4/7] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20connectivity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/automations/verify_account/manager.py | 4 ++-- apps/assets/automations/ping/manager.py | 6 +++--- apps/assets/automations/ping_gateway/manager.py | 10 +++++----- apps/assets/const/automation.py | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/accounts/automations/verify_account/manager.py b/apps/accounts/automations/verify_account/manager.py index 12c247849..fc25794bf 100644 --- a/apps/accounts/automations/verify_account/manager.py +++ b/apps/accounts/automations/verify_account/manager.py @@ -1,7 +1,7 @@ from django.db.models import QuerySet -from common.utils import get_logger from accounts.const import AutomationTypes, Connectivity +from common.utils import get_logger from ..base.manager import PushOrVerifyHostCallbackMixin, AccountBasePlaybookManager logger = get_logger(__name__) @@ -29,4 +29,4 @@ class VerifyAccountManager(PushOrVerifyHostCallbackMixin, AccountBasePlaybookMan def on_host_error(self, host, error, result): account = self.host_account_mapper.get(host) - account.set_connectivity(Connectivity.FAILED) + account.set_connectivity(Connectivity.ERR) diff --git a/apps/assets/automations/ping/manager.py b/apps/assets/automations/ping/manager.py index 305771f0b..0f166d0ad 100644 --- a/apps/assets/automations/ping/manager.py +++ b/apps/assets/automations/ping/manager.py @@ -1,5 +1,5 @@ -from common.utils import get_logger from assets.const import AutomationTypes, Connectivity +from common.utils import get_logger from ..base.manager import BasePlaybookManager logger = get_logger(__name__) @@ -28,7 +28,7 @@ class PingManager(BasePlaybookManager): def on_host_error(self, host, error, result): asset, account = self.host_asset_and_account_mapper.get(host) - asset.set_connectivity(Connectivity.FAILED) + asset.set_connectivity(Connectivity.ERR) if not account: return - account.set_connectivity(Connectivity.FAILED) + account.set_connectivity(Connectivity.ERR) diff --git a/apps/assets/automations/ping_gateway/manager.py b/apps/assets/automations/ping_gateway/manager.py index 5ffbc2734..858717665 100644 --- a/apps/assets/automations/ping_gateway/manager.py +++ b/apps/assets/automations/ping_gateway/manager.py @@ -1,12 +1,12 @@ import socket -import paramiko +import paramiko from django.utils import timezone from django.utils.translation import ugettext_lazy as _ -from common.utils import get_logger -from assets.models import Gateway from assets.const import AutomationTypes, Connectivity +from assets.models import Gateway +from common.utils import get_logger logger = get_logger(__name__) @@ -100,10 +100,10 @@ class PingGatewayManager: @staticmethod def on_host_error(gateway, account, error): logger.info('\033[31m {} -> {} 原因: {} \033[0m\n'.format(gateway, account, error)) - gateway.set_connectivity(Connectivity.FAILED) + gateway.set_connectivity(Connectivity.ERR) if not account: return - account.set_connectivity(Connectivity.FAILED) + account.set_connectivity(Connectivity.ERR) @staticmethod def before_runner_start(): diff --git a/apps/assets/const/automation.py b/apps/assets/const/automation.py index a811cb50b..831b11b66 100644 --- a/apps/assets/const/automation.py +++ b/apps/assets/const/automation.py @@ -3,9 +3,9 @@ from django.utils.translation import ugettext_lazy as _ class Connectivity(TextChoices): - UNKNOWN = 'unknown', _('Unknown') + UNKNOWN = '-', _('Unknown') OK = 'ok', _('Ok') - FAILED = 'failed', _('Failed') + ERR = 'err', _('Error') class AutomationTypes(TextChoices): From 6bbb1f7e86d2d3d7ffb549cb9442a5bbb7c64efb Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 19:02:24 +0800 Subject: [PATCH 5/7] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20connectivity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/migrations/0075_auto_20210705_1759.py | 6 +++--- apps/assets/migrations/0097_auto_20220426_1558.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/assets/migrations/0075_auto_20210705_1759.py b/apps/assets/migrations/0075_auto_20210705_1759.py index 84e970075..686d61bf0 100644 --- a/apps/assets/migrations/0075_auto_20210705_1759.py +++ b/apps/assets/migrations/0075_auto_20210705_1759.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='asset', name='connectivity', - field=models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], default='unknown', max_length=16, verbose_name='Connectivity'), + field=models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity'), ), migrations.AddField( model_name='asset', @@ -23,7 +23,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='authbook', name='connectivity', - field=models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], default='unknown', max_length=16, verbose_name='Connectivity'), + field=models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity'), ), migrations.AddField( model_name='authbook', @@ -33,7 +33,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='historicalauthbook', name='connectivity', - field=models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], default='unknown', max_length=16, verbose_name='Connectivity'), + field=models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity'), ), migrations.AddField( model_name='historicalauthbook', diff --git a/apps/assets/migrations/0097_auto_20220426_1558.py b/apps/assets/migrations/0097_auto_20220426_1558.py index ec7f64084..2a16841d5 100644 --- a/apps/assets/migrations/0097_auto_20220426_1558.py +++ b/apps/assets/migrations/0097_auto_20220426_1558.py @@ -34,6 +34,13 @@ def migrate_macos_platform(apps, schema_editor): platform_model.objects.using(db_alias).filter(id=old_macos.id).delete() +def migrate_connectivity(apps, schema_editor): + db_alias = schema_editor.connection.alias + asset_model = apps.get_model('assets', 'Asset') + asset_model.objects.using(db_alias).filter(connectivity='unknown').update(connectivity='-') + asset_model.objects.using(db_alias).filter(connectivity='failed').update(connectivity='err') + + class Migration(migrations.Migration): dependencies = [ ('assets', '0096_auto_20220426_1550'), @@ -43,4 +50,5 @@ class Migration(migrations.Migration): migrations.RunPython(create_internal_platforms), migrations.RunPython(update_user_platforms), migrations.RunPython(migrate_macos_platform), + migrations.RunPython(migrate_connectivity), ] From ae1b134f70516677d1f00c2abd3827f307dbce25 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 19:30:38 +0800 Subject: [PATCH 6/7] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20spec=20for=20c?= =?UTF-8?q?ert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../change_secret/database/mongodb/main.yml | 12 ++++++------ .../gather_accounts/database/mongodb/main.yml | 4 ++-- .../verify_account/database/mongodb/main.yml | 4 ++-- .../gather_facts/database/mongodb/main.yml | 4 ++-- .../automations/ping/database/mongodb/main.yml | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/accounts/automations/change_secret/database/mongodb/main.yml b/apps/accounts/automations/change_secret/database/mongodb/main.yml index 880234c4f..42ccd78ea 100644 --- a/apps/accounts/automations/change_secret/database/mongodb/main.yml +++ b/apps/accounts/automations/change_secret/database/mongodb/main.yml @@ -12,8 +12,8 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" register: db_info @@ -31,8 +31,8 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" db: "{{ jms_asset.spec_info.db_name }}" @@ -49,8 +49,8 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" when: diff --git a/apps/accounts/automations/gather_accounts/database/mongodb/main.yml b/apps/accounts/automations/gather_accounts/database/mongodb/main.yml index 1ec0a3af0..452241f6a 100644 --- a/apps/accounts/automations/gather_accounts/database/mongodb/main.yml +++ b/apps/accounts/automations/gather_accounts/database/mongodb/main.yml @@ -12,8 +12,8 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" filter: users diff --git a/apps/accounts/automations/verify_account/database/mongodb/main.yml b/apps/accounts/automations/verify_account/database/mongodb/main.yml index ec974f160..261fe63ca 100644 --- a/apps/accounts/automations/verify_account/database/mongodb/main.yml +++ b/apps/accounts/automations/verify_account/database/mongodb/main.yml @@ -12,7 +12,7 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" diff --git a/apps/assets/automations/gather_facts/database/mongodb/main.yml b/apps/assets/automations/gather_facts/database/mongodb/main.yml index 1b5602308..084a27348 100644 --- a/apps/assets/automations/gather_facts/database/mongodb/main.yml +++ b/apps/assets/automations/gather_facts/database/mongodb/main.yml @@ -12,8 +12,8 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" register: db_info diff --git a/apps/assets/automations/ping/database/mongodb/main.yml b/apps/assets/automations/ping/database/mongodb/main.yml index adf42b2fa..23a06c08d 100644 --- a/apps/assets/automations/ping/database/mongodb/main.yml +++ b/apps/assets/automations/ping/database/mongodb/main.yml @@ -12,7 +12,7 @@ login_port: "{{ jms_asset.port }}" login_database: "{{ jms_asset.spec_info.db_name }}" ssl: "{{ jms_asset.spec_info.use_ssl }}" - ssl_ca_certs: "{{ jms_asset.spec_info.ca_cert }}" - ssl_certfile: "{{ jms_asset.spec_info.client_key }}" + ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert }}" + ssl_certfile: "{{ jms_asset.secret_info.client_key }}" connection_options: - tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}" From 34b740583e90a51d1b1d728eaf9d1057bf939244 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 31 Jan 2023 19:37:16 +0800 Subject: [PATCH 7/7] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20asset=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/migrations/0001_initial.py | 3 +-- apps/assets/migrations/0106_auto_20221228_1838.py | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/apps/accounts/migrations/0001_initial.py b/apps/accounts/migrations/0001_initial.py index 201a5141d..6e211a7fc 100644 --- a/apps/accounts/migrations/0001_initial.py +++ b/apps/accounts/migrations/0001_initial.py @@ -29,8 +29,7 @@ class Migration(migrations.Migration): ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)), ('org_id', models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')), - ('connectivity', models.CharField(choices=[('unknown', 'Unknown'), ('ok', 'Ok'), ('failed', 'Failed')], - default='unknown', max_length=16, verbose_name='Connectivity')), + ('connectivity', models.CharField(choices=[('-', 'Unknown'), ('ok', 'Ok'), ('err', 'Error')], default='-', max_length=16, verbose_name='Connectivity')), ('date_verified', models.DateTimeField(null=True, verbose_name='Date verified')), ('name', models.CharField(max_length=128, verbose_name='Name')), ('username', models.CharField(blank=True, db_index=True, max_length=128, verbose_name='Username')), diff --git a/apps/assets/migrations/0106_auto_20221228_1838.py b/apps/assets/migrations/0106_auto_20221228_1838.py index 9637bbd1d..ce7718ccd 100644 --- a/apps/assets/migrations/0106_auto_20221228_1838.py +++ b/apps/assets/migrations/0106_auto_20221228_1838.py @@ -52,11 +52,7 @@ class Migration(migrations.Migration): migrations.AlterModelOptions( name='asset', options={'ordering': ['name'], - 'permissions': [('refresh_assethardwareinfo', 'Can refresh asset hardware info'), - ('test_assetconnectivity', 'Can test asset connectivity'), - ('push_assetaccount', 'Can push account to asset'), - ('match_asset', 'Can match asset'), ('add_assettonode', 'Add asset to node'), - ('move_assettonode', 'Move asset to node')], 'verbose_name': 'Asset'}, + 'permissions': [('refresh_assethardwareinfo', 'Can refresh asset hardware info'), ('test_assetconnectivity', 'Can test asset connectivity'), ('push_assetaccount', 'Can push account to asset'), ('test_account', 'Can verify account'), ('match_asset', 'Can match asset'), ('add_assettonode', 'Add asset to node'), ('move_assettonode', 'Move asset to node')], 'verbose_name': 'Asset'}, ), migrations.AlterUniqueTogether( name='accountbackupplan',