perf: 收集账号

pull/8931/head
feng626 2 years ago
parent 7b4c2ce97e
commit 615f36c6f6

@ -1,16 +1,16 @@
# -*- coding: utf-8 -*-
#
import django_filters
from rest_framework.decorators import action
from rest_framework.response import Response
import django_filters
from common.utils import get_logger
from common.drf.filters import BaseFilterSet
from common.utils import get_logger, get_object_or_none
from common.mixins.api import SuggestionMixin
from orgs.mixins.api import OrgBulkModelViewSet
from orgs.mixins import generics
from assets.models import Asset, Node, Gateway
from assets import serializers
from assets.models import Asset, Gateway
from assets.tasks import (
update_assets_hardware_info_manual, test_assets_connectivity_manual,
)

@ -232,7 +232,7 @@ class AllTypes(ChoicesMixin, metaclass=IncludesTextChoicesMeta):
@staticmethod
def serialize_to_objs(choices):
title = ['value', 'display_name']
title = ['value', 'label']
return [dict(zip(title, choice)) for choice in choices]
@staticmethod

@ -20,7 +20,7 @@ class GatheredUser(OrgModelMixin):
date_updated = models.DateTimeField(auto_now=True, verbose_name=_("Date updated"))
@property
def hostname(self):
def name(self):
return self.asset.name
@property

@ -8,5 +8,5 @@ from .domain import *
from .gathered_user import *
from .favorite_asset import *
from .account import *
from .backup import *
from assets.serializers.account.backup import *
from .platform import *

@ -7,7 +7,7 @@ from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from ops.mixin import PeriodTaskSerializerMixin
from common.utils import get_logger
from ..models import AccountBackupPlan, AccountBackupPlanExecution
from assets.models import AccountBackupPlan, AccountBackupPlanExecution
logger = get_logger(__file__)

@ -8,8 +8,7 @@ __all__ = ['AccountFieldsSerializerMixin']
class AccountFieldsSerializerMixin(serializers.ModelSerializer):
class Meta:
fields_mini = [
'id', 'name', 'username', 'privileged',
'platform', 'version'
'id', 'name', 'username', 'privileged', 'platform', 'version'
]
fields_write_only = ['password', 'private_key', 'public_key', 'passphrase']
fields_other = ['date_created', 'date_updated', 'comment']

@ -12,11 +12,10 @@ class GatheredUserSerializer(OrgResourceModelSerializerMixin):
model = GatheredUser
fields_mini = ['id']
fields_small = fields_mini + [
'username', 'ip_last_login',
'present',
'username', 'ip_last_login', 'present', 'name',
'date_last_login', 'date_created', 'date_updated'
]
fields_fk = ['asset', 'name', 'ip']
fields_fk = ['asset', 'ip']
fields = fields_small + fields_fk
read_only_fields = fields
extra_kwargs = {

@ -90,7 +90,7 @@ class AssetAccountHandler(BaseAccountHandler):
category_dict = {}
for i in AllTypes.grouped_choices_to_objs():
for j in i['children']:
category_dict[j['value']] = j['display_name']
category_dict[j['value']] = j['label']
header_fields = cls.get_header_fields(AccountSecretSerializer(qs.first()))
account_category_map = defaultdict(list)

@ -32,7 +32,7 @@ urlpatterns = [
path('mfa/verify/', api.MFAChallengeVerifyApi.as_view(), name='mfa-verify'),
path('mfa/challenge/', api.MFAChallengeVerifyApi.as_view(), name='mfa-challenge'),
path('mfa/select/', api.MFASendCodeApi.as_view(), name='mfa-select'),
path('mfa/send-code/', api.MFASendCodeApi.as_view(), name='mfa-send-codej'),
path('mfa/send-code/', api.MFASendCodeApi.as_view(), name='mfa-send-code'),
path('password/verify/', api.UserPasswordVerifyApi.as_view(), name='user-password-verify'),
path('login-confirm-ticket/status/', api.TicketStatusApi.as_view(), name='login-confirm-ticket-status'),
]

@ -87,7 +87,7 @@ class CeleryTaskSerializer(serializers.Serializer):
class ChoiceSerializer(serializers.Serializer):
display_name = serializers.CharField(label=_("Display name"))
label = serializers.CharField(label=_("Label"))
value = serializers.CharField(label=_("Value"))

Loading…
Cancel
Save