Set ip_address to empty string

ip_address cannot be null, so set to
empty instead of None

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster
2023-10-04 20:46:50 -04:00
committed by Seth Foster
parent a0ef25006a
commit 127a0cff23

View File

@@ -125,12 +125,13 @@ class InstanceManager(models.Manager):
with advisory_lock('instance_registration_%s' % hostname): with advisory_lock('instance_registration_%s' % hostname):
if settings.AWX_AUTO_DEPROVISION_INSTANCES: if settings.AWX_AUTO_DEPROVISION_INSTANCES:
# detect any instances with the same IP address. # detect any instances with the same IP address.
# if one exists, set it to None # if one exists, set it to ""
if ip_address:
inst_conflicting_ip = self.filter(ip_address=ip_address).exclude(hostname=hostname) inst_conflicting_ip = self.filter(ip_address=ip_address).exclude(hostname=hostname)
if inst_conflicting_ip.exists(): if inst_conflicting_ip.exists():
for other_inst in inst_conflicting_ip: for other_inst in inst_conflicting_ip:
other_hostname = other_inst.hostname other_hostname = other_inst.hostname
other_inst.ip_address = None other_inst.ip_address = ""
other_inst.save(update_fields=['ip_address']) other_inst.save(update_fields=['ip_address'])
logger.warning("IP address {0} conflict detected, ip address unset for host {1}.".format(ip_address, other_hostname)) logger.warning("IP address {0} conflict detected, ip address unset for host {1}.".format(ip_address, other_hostname))