mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-12 21:39:18 +00:00
feat: ops 支持节点和资产
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.db.models import Count
|
||||
from rest_framework.views import APIView
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework.response import Response
|
||||
@@ -5,12 +6,14 @@ from rest_framework.response import Response
|
||||
from ops.models import Job, JobExecution
|
||||
from ops.serializers.job import JobSerializer, JobExecutionSerializer
|
||||
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobAssetDetail', 'JobExecutionTaskDetail']
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView',
|
||||
'JobAssetDetail', 'JobExecutionTaskDetail','FrequentUsernames']
|
||||
|
||||
from ops.tasks import run_ops_job_execution
|
||||
from ops.variables import JMS_JOB_VARIABLE_HELP
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
from orgs.utils import tmp_to_org, get_current_org_id, get_current_org
|
||||
from assets.models import Account
|
||||
|
||||
|
||||
def set_task_to_serializer_data(serializer, task):
|
||||
@@ -111,3 +114,12 @@ class JobExecutionTaskDetail(APIView):
|
||||
'is_success': execution.is_success,
|
||||
'time_cost': execution.time_cost,
|
||||
})
|
||||
|
||||
|
||||
class FrequentUsernames(APIView):
|
||||
rbac_perms = ()
|
||||
permission_classes = ()
|
||||
|
||||
def get(self, request, **kwargs):
|
||||
top_accounts = Account.objects.all().values('username').annotate(total=Count('username')).order_by('total')
|
||||
return Response(data=top_accounts)
|
||||
|
Reference in New Issue
Block a user