mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Handle ENOENT during license removal
This commit is contained in:
parent
c7e2c333d4
commit
3f9c2cf465
@ -10,6 +10,7 @@ import dateutil
|
||||
import time
|
||||
import socket
|
||||
import sys
|
||||
import errno
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -270,19 +271,21 @@ class ApiV1ConfigView(APIView):
|
||||
return Response(None, status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Remove license file
|
||||
has_error = False
|
||||
errno = None
|
||||
for fname in (TEMPORARY_TASK_FILE, TASK_FILE):
|
||||
try:
|
||||
os.remove(fname)
|
||||
except OSError:
|
||||
has_error = True
|
||||
except OSError, e:
|
||||
if e.errno != errno.ENOENT
|
||||
errno = e.errno
|
||||
break
|
||||
|
||||
# Only stop mongod if license removal succeeded
|
||||
if has_error:
|
||||
return Response({"error": "Failed to remove license"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
else:
|
||||
if errno is None:
|
||||
mongodb_control.delay('stop')
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
else:
|
||||
return Response({"error": "Failed to remove license (%s)" % errno}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
class DashboardView(APIView):
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user