fix for when modules are already in sync during agent install

This commit is contained in:
wh1te909 2020-09-30 21:04:32 +00:00
parent 9b9ba00983
commit 4df20cce1e
1 changed files with 8 additions and 3 deletions

View File

@ -276,12 +276,17 @@ class SaltMinion(APIView):
def patch(self, request):
# sync modules
agent = get_object_or_404(Agent, agent_id=request.data["agent_id"])
r = agent.salt_api_cmd(timeout=20, func="saltutil.sync_modules")
r = agent.salt_api_cmd(timeout=45, func="saltutil.sync_modules")
if r == "timeout" or r == "error" or not r:
if r == "timeout" or r == "error":
return notify_error("Failed to sync salt modules")
return Response("Successfully synced salt modules")
if isinstance(r, list) and any("modules" in i for i in r):
return Response("Successfully synced salt modules")
elif isinstance(r, list) and not r:
return Response("Modules are already in sync")
else:
return notify_error(f"Failed to sync salt modules: {str(r)}")
def put(self, request):
agent = get_object_or_404(Agent, agent_id=request.data["agent_id"])