feat: 丰富资产任务API创建;支持针对多个系统用户一个资产的推送和测试

This commit is contained in:
Bai
2021-07-20 14:48:38 +08:00
committed by 老广
parent 630164cd51
commit 07898004b0
5 changed files with 77 additions and 11 deletions

View File

@@ -345,6 +345,13 @@ class Asset(AbsConnectivity, ProtocolsMixin, NodesRelationMixin, OrgModelMixin):
tree_node = TreeNode(**data)
return tree_node
def get_all_systemusers(self):
from .user import SystemUser
system_user_ids = SystemUser.assets.through.objects.filter(asset=self)\
.values_list('systemuser_id', flat=True)
system_users = SystemUser.objects.filter(id__in=system_user_ids)
return system_users
class Meta:
unique_together = [('org_id', 'hostname')]
verbose_name = _("Asset")