mirror of
https://github.com/ansible/awx.git
synced 2026-07-09 07:18:05 -02:30
Adjust usage of is_ha_environment()
Limit it to just instance count and make sure we use it for the mongo check
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
# Copyright (c) 2015 Ansible, Inc.
|
||||
# All Rights Reserved.
|
||||
|
||||
# Python
|
||||
import os
|
||||
from IPy import IP
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
|
||||
# AWX
|
||||
from awx.main.models import Instance
|
||||
|
||||
@@ -18,27 +11,4 @@ def is_ha_environment():
|
||||
# If there are two or more instances, then we are in an HA environment.
|
||||
if Instance.objects.count() > 1:
|
||||
return True
|
||||
|
||||
# If the database is not local, then we are in an HA environment.
|
||||
host = settings.DATABASES['default'].get('HOST', 'localhost')
|
||||
|
||||
# Is host special case 'localhost' ?
|
||||
if host is 'localhost':
|
||||
return False
|
||||
|
||||
# Check if host is an absolute file (i.e. named socket)
|
||||
if os.path.isabs(host):
|
||||
return False
|
||||
|
||||
# Is host a LOCAL or REMOTE ip address ?
|
||||
try:
|
||||
if IP(host).iptype() is 'LOOPBACK':
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# host may be a domain name like postgres.mycompany.com
|
||||
# Assume HA Environment
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user