mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 05:55:59 -03:30
Make ip_address read only
Setting a different value for ip_address and hostname does not work with the current way we create receptor certs.
This commit is contained in:
@@ -5386,7 +5386,7 @@ class InstanceSerializer(BaseSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Instance
|
||||
read_only_fields = ('uuid', 'version')
|
||||
read_only_fields = ('ip_address', 'uuid', 'version')
|
||||
fields = (
|
||||
'id',
|
||||
'hostname',
|
||||
@@ -5551,15 +5551,6 @@ class InstanceSerializer(BaseSerializer):
|
||||
|
||||
return value
|
||||
|
||||
def validate_ip_address(self, value):
|
||||
"""
|
||||
Cannot change ip address
|
||||
"""
|
||||
if self.instance and self.instance.ip_address != value:
|
||||
raise serializers.ValidationError(_("Cannot change ip_address."))
|
||||
|
||||
return value
|
||||
|
||||
def validate_listener_port(self, value):
|
||||
"""
|
||||
Cannot change listener port, unless going from none to integer, and vice versa
|
||||
|
||||
@@ -343,6 +343,7 @@ class InstanceDetail(RetrieveUpdateAPIView):
|
||||
# these fields are only valid on creation of an instance, so they unwanted on detail view
|
||||
data.pop('node_type', None)
|
||||
data.pop('hostname', None)
|
||||
data.pop('ip_address', None)
|
||||
return super(InstanceDetail, self).update_raw_data(data)
|
||||
|
||||
def update(self, request, *args, **kwargs):
|
||||
|
||||
@@ -126,8 +126,7 @@ def generate_inventory_yml(instance_obj):
|
||||
def generate_group_vars_all_yml(instance_obj):
|
||||
peers = []
|
||||
for instance in instance_obj.peers.all():
|
||||
host_or_ip = instance.ip_address or instance.hostname
|
||||
peers.append(dict(host=host_or_ip, port=instance.listener_port))
|
||||
peers.append(dict(host=instance.hostname, port=instance.listener_port))
|
||||
all_yaml = render_to_string("instance_install_bundle/group_vars/all.yml", context=dict(instance=instance_obj, peers=peers))
|
||||
# convert consecutive newlines with a single newline
|
||||
return re.sub(r'\n+', '\n', all_yaml)
|
||||
|
||||
Reference in New Issue
Block a user