prevent host deletion when the related inventory is pending deletion

see: https://github.com/ansible/tower/issues/2690
This commit is contained in:
Ryan Petrello 2018-07-31 15:54:20 -04:00
parent 9ff249f5c4
commit 5610cbe735
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -2251,6 +2251,12 @@ class HostDetail(RelatedJobsPreventDeleteMixin, ControlledByScmMixin, RetrieveUp
model = Host
serializer_class = HostSerializer
def delete(self, request, *args, **kwargs):
if self.get_object().inventory.pending_deletion:
return Response({"error": _("The inventory for this host is already being deleted.")},
status=status.HTTP_400_BAD_REQUEST)
return super(HostDetail, self).delete(request, *args, **kwargs)
class HostAnsibleFactsDetail(RetrieveAPIView):