Generate policies and tasks on agent creation
This commit is contained in:
parent
31cd3433bd
commit
5d9886052c
|
@ -191,6 +191,10 @@ def add(request):
|
|||
else:
|
||||
WinUpdatePolicy(agent=agent).save()
|
||||
|
||||
# Generate policies for new agent
|
||||
agent.generate_checks_from_policies()
|
||||
agent.generate_tasks_from_policies()
|
||||
|
||||
return Response({"pk": agent.pk})
|
||||
else:
|
||||
return Response("err", status=status.HTTP_400_BAD_REQUEST)
|
||||
|
|
|
@ -10,13 +10,12 @@ from .serializers import (
|
|||
AutoTaskPolicySerializer,
|
||||
PolicyOverviewSerializer,
|
||||
PolicyCheckStatusSerializer,
|
||||
PolicyCheckSerializer,
|
||||
RelatedAgentPolicySerializer,
|
||||
RelatedSitePolicySerializer,
|
||||
RelatedClientPolicySerializer,
|
||||
)
|
||||
|
||||
from checks.serializers import CheckSerializer
|
||||
|
||||
from automation.models import Policy
|
||||
from checks.models import Check
|
||||
from autotasks.models import AutomatedTask
|
||||
|
@ -128,7 +127,7 @@ class TestPolicyViews(BaseTestCase):
|
|||
url = f"/automation/{self.policy.pk}/policychecks/"
|
||||
|
||||
resp = self.client.get(url, format="json")
|
||||
serializer = CheckSerializer([self.policyDiskCheck], many=True)
|
||||
serializer = PolicyCheckSerializer([self.policyDiskCheck], many=True)
|
||||
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertEqual(resp.data, serializer.data)
|
||||
|
|
Loading…
Reference in New Issue