mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Do not accept enterprise licenses in some cases.
This commit makes it so that enterprise licenses are rejected in HA environments if there is no active MongoDB server. Additionally, it suppresses trying to connect to MongoDB in cases where it is not present or meaningful.
This commit is contained in:
@@ -14,7 +14,19 @@ logger = logging.getLogger('awx.fact')
|
||||
|
||||
# Connect to Mongo
|
||||
try:
|
||||
connect(settings.MONGO_DB, tz_aware=settings.USE_TZ)
|
||||
# Sanity check: If we have intentionally invalid settings, then we
|
||||
# know we cannot connect.
|
||||
if settings.MONGO_HOST == NotImplemented:
|
||||
raise ConnectionError
|
||||
|
||||
# Attempt to connect to the MongoDB database.
|
||||
connect(settings.MONGO_DB,
|
||||
host=settings.MONGO_HOST,
|
||||
port=int(settings.MONGO_PORT),
|
||||
username=settings.MONGO_USERNAME,
|
||||
password=settings.MONGO_PASSWORD,
|
||||
tz_aware=settings.USE_TZ,
|
||||
)
|
||||
register_key_transform(get_db())
|
||||
except ConnectionError:
|
||||
logger.warn('Failed to establish connect to MongoDB "%s"' % (settings.MONGO_DB))
|
||||
|
||||
Reference in New Issue
Block a user