mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Protect isolated and control groups from api deletion
Isolated and Control groups are managed strictly from the standalone setup playbook installer and should not be directly managable from the api. Especially true since you can't assign or create isolated groups from within the API itself. In the future this may change but allowing this in the API could leave the system in a bad state.
This commit is contained in:
@@ -671,6 +671,14 @@ class InstanceGroupDetail(RelatedJobsPreventDeleteMixin, RetrieveUpdateDestroyAP
|
||||
serializer_class = InstanceGroupSerializer
|
||||
permission_classes = (InstanceGroupTowerPermission,)
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
if instance.controller is not None:
|
||||
raise PermissionDenied(detail=_("Isolated Groups can not be removed from the API"))
|
||||
if instance.controlled_groups.count():
|
||||
raise PermissionDenied(detail=_("Instance Groups acting as a controller for an Isolated Group can not be removed from the API"))
|
||||
return super(InstanceGroupDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
class InstanceGroupUnifiedJobsList(SubListAPIView):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user