From 3e73dbdb11171d9c9bbe022fff9a64a1ae803268 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 21 Jun 2019 12:45:32 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E5=B0=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/asset.py | 21 ------------------- .../templates/assets/system_user_asset.html | 4 ++-- apps/assets/utils.py | 4 ---- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/apps/assets/models/asset.py b/apps/assets/models/asset.py index 4f7509d4f..45d4cfe3c 100644 --- a/apps/assets/models/asset.py +++ b/apps/assets/models/asset.py @@ -134,13 +134,6 @@ class Asset(OrgModelMixin): comment = models.TextField(max_length=128, default='', blank=True, verbose_name=_('Comment')) objects = AssetManager.from_queryset(AssetQuerySet)() - CONNECTIVITY_CACHE_KEY = '_JMS_ASSET_CONNECTIVITY_{}' - UNREACHABLE, REACHABLE, UNKNOWN = range(0, 3) - CONNECTIVITY_CHOICES = ( - (UNREACHABLE, _("Unreachable")), - (REACHABLE, _('Reachable')), - (UNKNOWN, _("Unknown")), - ) def __str__(self): return '{0.hostname}({0.ip})'.format(self) @@ -215,20 +208,6 @@ class Asset(OrgModelMixin): nodes = list(reduce(lambda x, y: set(x) | set(y), nodes)) return nodes - @classmethod - def get_queryset_by_fullname_list(cls, fullname_list): - org_fullname_map = defaultdict(list) - for fullname in fullname_list: - hostname, org = cls.split_fullname(fullname) - org_fullname_map[org].append(hostname) - filter_arg = Q() - for org, hosts in org_fullname_map.items(): - if org.is_real(): - filter_arg |= Q(hostname__in=hosts, org_id=org.id) - else: - filter_arg |= Q(Q(org_id__isnull=True) | Q(org_id=''), hostname__in=hosts) - return Asset.objects.filter(filter_arg) - @property def cpu_info(self): info = "" diff --git a/apps/assets/templates/assets/system_user_asset.html b/apps/assets/templates/assets/system_user_asset.html index 1b72a9c9f..fb9dd9d4b 100644 --- a/apps/assets/templates/assets/system_user_asset.html +++ b/apps/assets/templates/assets/system_user_asset.html @@ -25,7 +25,7 @@
-
+
{% trans 'Assets of ' %} {{ system_user.name }} {{ paginator.count }} @@ -48,7 +48,7 @@
-
+
{% trans 'Quick update' %} diff --git a/apps/assets/utils.py b/apps/assets/utils.py index 707d67a50..a4809e3a7 100644 --- a/apps/assets/utils.py +++ b/apps/assets/utils.py @@ -16,10 +16,6 @@ def get_system_users_by_id_list(id_list): return SystemUser.objects.filter(id__in=id_list) -def get_assets_by_fullname_list(hostname_list): - return Asset.get_queryset_by_fullname_list(hostname_list) - - def get_system_user_by_name(name): system_user = get_object_or_none(SystemUser, name=name) return system_user