mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 15:27:47 -02:30
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:
@@ -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))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user