mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Prevent altering certain fields on Instance
- Prevents changing hostname, listener_port, or node_type for instances that already exist - API default node_type is execution - API default node_state is installed
This commit is contained in:
parent
9c6aa93093
commit
e0c9013d9c
@ -4884,12 +4884,12 @@ class InstanceSerializer(BaseSerializer):
|
||||
read_only_fields = ('ip_address', 'uuid', 'version')
|
||||
fields = (
|
||||
'id',
|
||||
'hostname',
|
||||
'type',
|
||||
'url',
|
||||
'related',
|
||||
'summary_fields',
|
||||
'uuid',
|
||||
'hostname',
|
||||
'created',
|
||||
'modified',
|
||||
'last_seen',
|
||||
@ -4913,6 +4913,7 @@ class InstanceSerializer(BaseSerializer):
|
||||
'ip_address',
|
||||
'listener_port',
|
||||
)
|
||||
extra_kwargs = {'node_type': {'default': 'execution'}, 'node_state': {'default': 'installed'}}
|
||||
|
||||
def get_related(self, obj):
|
||||
res = super(InstanceSerializer, self).get_related(obj)
|
||||
@ -4974,6 +4975,18 @@ class InstanceSerializer(BaseSerializer):
|
||||
|
||||
return value
|
||||
|
||||
def validate_hostname(self, value):
|
||||
if self.instance and self.instance.hostname != value:
|
||||
raise serializers.ValidationError("Cannot change hostname.")
|
||||
|
||||
return value
|
||||
|
||||
def validate_listener_port(self, value):
|
||||
if self.instance and self.instance.listener_port != value:
|
||||
raise serializers.ValidationError("Cannot change listener port.")
|
||||
|
||||
return value
|
||||
|
||||
|
||||
class InstanceHealthCheckSerializer(BaseSerializer):
|
||||
class Meta:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user