mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 16:28:43 -03:30
do not require mongo to be on
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
# Copyright (c) 2015 Ansible, Inc.
|
|
||||||
# All Rights Reserved.
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from mongoengine import connect
|
|
||||||
from mongoengine.connection import ConnectionError
|
|
||||||
from pymongo.errors import AutoReconnect
|
|
||||||
|
|
||||||
def test_mongo_connection():
|
|
||||||
# Connect to Mongo
|
|
||||||
try:
|
|
||||||
# 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.
|
|
||||||
db = 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)
|
|
||||||
db[settings.MONGO_DB].command('ping')
|
|
||||||
return True
|
|
||||||
except (ConnectionError, AutoReconnect):
|
|
||||||
return False
|
|
||||||
|
|
||||||
@@ -53,7 +53,6 @@ from awx.main.task_engine import TaskSerializer, TASK_TIMEOUT_INTERVAL
|
|||||||
from awx.main.utils import (get_ansible_version, get_ssh_version, decrypt_field, update_scm_url,
|
from awx.main.utils import (get_ansible_version, get_ssh_version, decrypt_field, update_scm_url,
|
||||||
ignore_inventory_computed_fields, emit_websocket_notification,
|
ignore_inventory_computed_fields, emit_websocket_notification,
|
||||||
check_proot_installed, build_proot_temp_dir, wrap_args_with_proot)
|
check_proot_installed, build_proot_temp_dir, wrap_args_with_proot)
|
||||||
from awx.fact.utils.connection import test_mongo_connection
|
|
||||||
|
|
||||||
__all__ = ['RunJob', 'RunSystemJob', 'RunProjectUpdate', 'RunInventoryUpdate',
|
__all__ = ['RunJob', 'RunSystemJob', 'RunProjectUpdate', 'RunInventoryUpdate',
|
||||||
'RunAdHocCommand', 'handle_work_error', 'handle_work_success',
|
'RunAdHocCommand', 'handle_work_error', 'handle_work_success',
|
||||||
@@ -959,11 +958,6 @@ class RunJob(BaseTask):
|
|||||||
'''
|
'''
|
||||||
return getattr(tower_settings, 'AWX_PROOT_ENABLED', False)
|
return getattr(tower_settings, 'AWX_PROOT_ENABLED', False)
|
||||||
|
|
||||||
def pre_run_hook(self, job, **kwargs):
|
|
||||||
if job.job_type == PERM_INVENTORY_SCAN:
|
|
||||||
if not test_mongo_connection():
|
|
||||||
raise RuntimeError("Fact Scan Database is offline")
|
|
||||||
|
|
||||||
def post_run_hook(self, job, **kwargs):
|
def post_run_hook(self, job, **kwargs):
|
||||||
'''
|
'''
|
||||||
Hook for actions to run after job/task has completed.
|
Hook for actions to run after job/task has completed.
|
||||||
|
|||||||
Reference in New Issue
Block a user