mirror of
https://github.com/ansible/awx.git
synced 2026-05-02 23:25:29 -02:30
Disallow adding or removing instance from iso-IG
This commit is contained in:
@@ -4694,6 +4694,8 @@ class InstanceGroupSerializer(BaseSerializer):
|
||||
raise serializers.ValidationError(_('{} is not a valid hostname of an existing instance.').format(instance_name))
|
||||
if Instance.objects.get(hostname=instance_name).is_isolated():
|
||||
raise serializers.ValidationError(_('Isolated instances may not be added or removed from instances groups via the API.'))
|
||||
if self.instance and self.instance.controller_id is not None:
|
||||
raise serializers.ValidationError(_('Isolated instance group membership may not be managed via the API.'))
|
||||
return value
|
||||
|
||||
def validate_name(self, value):
|
||||
|
||||
@@ -192,6 +192,10 @@ class InstanceGroupMembershipMixin(object):
|
||||
def is_valid_relation(self, parent, sub, created=False):
|
||||
if sub.is_isolated():
|
||||
return {'error': _('Isolated instances may not be added or removed from instances groups via the API.')}
|
||||
if self.parent_model is InstanceGroup:
|
||||
ig_obj = self.get_parent_object()
|
||||
if ig_obj.controller_id is not None:
|
||||
return {'error': _('Isolated instance group membership may not be managed via the API.')}
|
||||
return None
|
||||
|
||||
def unattach_validate(self, request):
|
||||
|
||||
Reference in New Issue
Block a user