mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
'managed' is a read-only field on InstanceSerializer
so we don't need complex logic to compare an incoming to existing value.
This commit is contained in:
committed by
Seth Foster
parent
1e254c804c
commit
cc4cc37d46
@@ -5666,9 +5666,6 @@ class InstanceSerializer(BaseSerializer):
|
|||||||
if 'canonical_address_peers_from_control_nodes' in attrs:
|
if 'canonical_address_peers_from_control_nodes' in attrs:
|
||||||
attrs['peers_from_control_nodes'] = attrs.pop('canonical_address_peers_from_control_nodes')
|
attrs['peers_from_control_nodes'] = attrs.pop('canonical_address_peers_from_control_nodes')
|
||||||
|
|
||||||
def get_field_from_model_or_attrs(fd):
|
|
||||||
return attrs.get(fd, self.instance and getattr(self.instance, fd) or None)
|
|
||||||
|
|
||||||
def check_peers_changed():
|
def check_peers_changed():
|
||||||
'''
|
'''
|
||||||
return True if
|
return True if
|
||||||
@@ -5680,9 +5677,7 @@ class InstanceSerializer(BaseSerializer):
|
|||||||
if not self.instance and not settings.IS_K8S:
|
if not self.instance and not settings.IS_K8S:
|
||||||
raise serializers.ValidationError(_("Can only create instances on Kubernetes or OpenShift."))
|
raise serializers.ValidationError(_("Can only create instances on Kubernetes or OpenShift."))
|
||||||
|
|
||||||
managed = get_field_from_model_or_attrs("managed")
|
if self.instance and self.instance.managed:
|
||||||
|
|
||||||
if managed:
|
|
||||||
if check_peers_changed():
|
if check_peers_changed():
|
||||||
raise serializers.ValidationError(_("Setting peers manually for managed nodes is not allowed."))
|
raise serializers.ValidationError(_("Setting peers manually for managed nodes is not allowed."))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user