mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -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,14 +125,15 @@ 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 ""
|
||||||
inst_conflicting_ip = self.filter(ip_address=ip_address).exclude(hostname=hostname)
|
if ip_address:
|
||||||
if inst_conflicting_ip.exists():
|
inst_conflicting_ip = self.filter(ip_address=ip_address).exclude(hostname=hostname)
|
||||||
for other_inst in inst_conflicting_ip:
|
if inst_conflicting_ip.exists():
|
||||||
other_hostname = other_inst.hostname
|
for other_inst in inst_conflicting_ip:
|
||||||
other_inst.ip_address = None
|
other_hostname = other_inst.hostname
|
||||||
other_inst.save(update_fields=['ip_address'])
|
other_inst.ip_address = ""
|
||||||
logger.warning("IP address {0} conflict detected, ip address unset for host {1}.".format(ip_address, other_hostname))
|
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))
|
||||||
|
|
||||||
# Return existing instance that matches hostname or UUID (default to UUID)
|
# Return existing instance that matches hostname or UUID (default to UUID)
|
||||||
if node_uuid is not None and node_uuid != UUID_DEFAULT and self.filter(uuid=node_uuid).exists():
|
if node_uuid is not None and node_uuid != UUID_DEFAULT and self.filter(uuid=node_uuid).exists():
|
||||||
|
|||||||
Reference in New Issue
Block a user