mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 04:47:44 -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:
@@ -5,7 +5,7 @@ import sys
|
|||||||
|
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from awx.main.models import Instance
|
from awx.main.ha import is_ha_environment
|
||||||
from awx.main.task_engine import TaskSerializer
|
from awx.main.task_engine import TaskSerializer
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ class Command(BaseCommand):
|
|||||||
# rules here will grow more complicated over time.
|
# rules here will grow more complicated over time.
|
||||||
uses_mongo = system_tracking # noqa
|
uses_mongo = system_tracking # noqa
|
||||||
|
|
||||||
if Instance.objects.count() > 1 and kwargs['local'] and uses_mongo:
|
if is_ha_environment() and kwargs['local'] and uses_mongo:
|
||||||
print("HA Configuration detected. Database should be remote")
|
print("HA Configuration detected. Database should be remote")
|
||||||
uses_mongo = False
|
uses_mongo = False
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
# Copyright (c) 2015 Ansible, Inc.
|
# Copyright (c) 2015 Ansible, Inc.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
|
||||||
# Python
|
|
||||||
import os
|
|
||||||
from IPy import IP
|
|
||||||
|
|
||||||
# Django
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.models import Instance
|
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 there are two or more instances, then we are in an HA environment.
|
||||||
if Instance.objects.count() > 1:
|
if Instance.objects.count() > 1:
|
||||||
return True
|
return True
|
||||||
|
return False
|
||||||
# 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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user