move runchecks to nats
This commit is contained in:
parent
9b52b4efd9
commit
fe0ddec0f9
|
@ -56,10 +56,3 @@ def handle_check_sms_alert_task(pk):
|
|||
check.save(update_fields=["text_sent"])
|
||||
|
||||
return "ok"
|
||||
|
||||
|
||||
@app.task
|
||||
def run_checks_task(pk):
|
||||
agent = Agent.objects.get(pk=pk)
|
||||
agent.salt_api_async(func="win_agent.run_manual_checks")
|
||||
return "ok"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import asyncio
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from rest_framework.views import APIView
|
||||
|
@ -13,7 +15,6 @@ from scripts.models import Script
|
|||
|
||||
from .serializers import CheckSerializer
|
||||
|
||||
from .tasks import run_checks_task
|
||||
|
||||
from automation.tasks import (
|
||||
generate_agent_checks_from_policies_task,
|
||||
|
@ -178,7 +179,10 @@ class GetUpdateDeleteCheck(APIView):
|
|||
@api_view()
|
||||
def run_checks(request, pk):
|
||||
agent = get_object_or_404(Agent, pk=pk)
|
||||
run_checks_task.delay(agent.pk)
|
||||
if not agent.has_nats:
|
||||
return notify_error("Requires agent version 1.1.0 or greater")
|
||||
|
||||
asyncio.run(agent.nats_cmd({"func": "runchecks"}, wait=False))
|
||||
return Response(agent.hostname)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue