mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Update settings references
* PROOT * Pendo tracking state * ad hoc commands * activity stream * org admin visibility
This commit is contained in:
@@ -194,7 +194,7 @@ class ApiV1ConfigView(APIView):
|
|||||||
license_reader = TaskSerializer()
|
license_reader = TaskSerializer()
|
||||||
license_data = license_reader.from_file(show_key=request.user.is_superuser)
|
license_data = license_reader.from_file(show_key=request.user.is_superuser)
|
||||||
|
|
||||||
pendo_state = settings.PENDO_TRACKING_STATE if settings.PENDO_TRACKING_STATE in ('off', 'anonymous', 'detailed') else 'off'
|
pendo_state = tower_settings.PENDO_TRACKING_STATE if tower_settings.PENDO_TRACKING_STATE in ('off', 'anonymous', 'detailed') else 'off'
|
||||||
|
|
||||||
data = dict(
|
data = dict(
|
||||||
time_zone=settings.TIME_ZONE,
|
time_zone=settings.TIME_ZONE,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from awx.main.utils import * # noqa
|
|||||||
from awx.main.models import * # noqa
|
from awx.main.models import * # noqa
|
||||||
from awx.api.license import LicenseForbids
|
from awx.api.license import LicenseForbids
|
||||||
from awx.main.task_engine import TaskSerializer
|
from awx.main.task_engine import TaskSerializer
|
||||||
|
from awx.main.conf import tower_settings
|
||||||
|
|
||||||
__all__ = ['get_user_queryset', 'check_user_access']
|
__all__ = ['get_user_queryset', 'check_user_access']
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ class UserAccess(BaseAccess):
|
|||||||
qs = self.model.objects.filter(is_active=True).distinct()
|
qs = self.model.objects.filter(is_active=True).distinct()
|
||||||
if self.user.is_superuser:
|
if self.user.is_superuser:
|
||||||
return qs
|
return qs
|
||||||
if settings.ORG_ADMINS_CAN_SEE_ALL_USERS and self.user.admin_of_organizations.filter(active=True).exists():
|
if tower_settings.ORG_ADMINS_CAN_SEE_ALL_USERS and self.user.admin_of_organizations.filter(active=True).exists():
|
||||||
return qs
|
return qs
|
||||||
return qs.filter(
|
return qs.filter(
|
||||||
Q(pk=self.user.pk) |
|
Q(pk=self.user.pk) |
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from awx.main.models import * # noqa
|
|||||||
from awx.main.utils import ignore_inventory_computed_fields, check_proot_installed, wrap_args_with_proot
|
from awx.main.utils import ignore_inventory_computed_fields, check_proot_installed, wrap_args_with_proot
|
||||||
from awx.main.signals import disable_activity_stream
|
from awx.main.signals import disable_activity_stream
|
||||||
from awx.main.task_engine import TaskSerializer as LicenseReader
|
from awx.main.task_engine import TaskSerializer as LicenseReader
|
||||||
|
from awx.main.conf import tower_settings
|
||||||
|
|
||||||
logger = logging.getLogger('awx.main.commands.inventory_import')
|
logger = logging.getLogger('awx.main.commands.inventory_import')
|
||||||
|
|
||||||
@@ -356,7 +357,7 @@ class ExecutableJsonLoader(BaseLoader):
|
|||||||
data = {}
|
data = {}
|
||||||
stdout, stderr = '', ''
|
stdout, stderr = '', ''
|
||||||
try:
|
try:
|
||||||
if self.is_custom and getattr(settings, 'AWX_PROOT_ENABLED', False):
|
if self.is_custom and getattr(tower_settings, 'AWX_PROOT_ENABLED', False):
|
||||||
if not check_proot_installed():
|
if not check_proot_installed():
|
||||||
raise RuntimeError("proot is not installed but is configured for use")
|
raise RuntimeError("proot is not installed but is configured for use")
|
||||||
kwargs = {'proot_temp_dir': self.source_dir} # TODO: Remove proot dir
|
kwargs = {'proot_temp_dir': self.source_dir} # TODO: Remove proot dir
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from jsonfield import JSONField
|
|||||||
from awx.main.models.base import * # noqa
|
from awx.main.models.base import * # noqa
|
||||||
from awx.main.models.unified_jobs import * # noqa
|
from awx.main.models.unified_jobs import * # noqa
|
||||||
from awx.main.utils import decrypt_field
|
from awx.main.utils import decrypt_field
|
||||||
|
from awx.main.conf import tower_settings
|
||||||
|
|
||||||
logger = logging.getLogger('awx.main.models.ad_hoc_commands')
|
logger = logging.getLogger('awx.main.models.ad_hoc_commands')
|
||||||
|
|
||||||
@@ -29,8 +30,8 @@ __all__ = ['AdHocCommand', 'AdHocCommandEvent']
|
|||||||
|
|
||||||
class AdHocCommand(UnifiedJob):
|
class AdHocCommand(UnifiedJob):
|
||||||
|
|
||||||
MODULE_NAME_CHOICES = [(x,x) for x in settings.AD_HOC_COMMANDS]
|
MODULE_NAME_CHOICES = [(x,x) for x in tower_settings.AD_HOC_COMMANDS]
|
||||||
MODULE_NAME_DEFAULT = 'command' if 'command' in settings.AD_HOC_COMMANDS else None
|
MODULE_NAME_DEFAULT = 'command' if 'command' in tower_settings.AD_HOC_COMMANDS else None
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
@@ -104,7 +105,7 @@ class AdHocCommand(UnifiedJob):
|
|||||||
if type(self.module_name) not in (str, unicode):
|
if type(self.module_name) not in (str, unicode):
|
||||||
raise ValidationError("Invalid type for ad hoc command")
|
raise ValidationError("Invalid type for ad hoc command")
|
||||||
module_name = self.module_name.strip() or 'command'
|
module_name = self.module_name.strip() or 'command'
|
||||||
if module_name not in settings.AD_HOC_COMMANDS:
|
if module_name not in tower_settings.AD_HOC_COMMANDS:
|
||||||
raise ValidationError('Unsupported module for ad hoc commands.')
|
raise ValidationError('Unsupported module for ad hoc commands.')
|
||||||
return module_name
|
return module_name
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class ActivityStreamRegistrar(object):
|
|||||||
self.models = []
|
self.models = []
|
||||||
|
|
||||||
def connect(self, model):
|
def connect(self, model):
|
||||||
if not getattr(settings, 'ACTIVITY_STREAM_ENABLED', True):
|
from awx.main.conf import tower_settings
|
||||||
|
if not getattr(tower_settings, 'ACTIVITY_STREAM_ENABLED', True):
|
||||||
return
|
return
|
||||||
from awx.main.signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate
|
from awx.main.signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ from awx.api.serializers import * # noqa
|
|||||||
from awx.main.utils import model_instance_diff, model_to_dict, camelcase_to_underscore, emit_websocket_notification
|
from awx.main.utils import model_instance_diff, model_to_dict, camelcase_to_underscore, emit_websocket_notification
|
||||||
from awx.main.utils import ignore_inventory_computed_fields, ignore_inventory_group_removal, _inventory_updates
|
from awx.main.utils import ignore_inventory_computed_fields, ignore_inventory_group_removal, _inventory_updates
|
||||||
from awx.main.tasks import update_inventory_computed_fields
|
from awx.main.tasks import update_inventory_computed_fields
|
||||||
|
from awx.main.conf import tower_settings
|
||||||
|
|
||||||
__all__ = []
|
__all__ = []
|
||||||
|
|
||||||
@@ -273,7 +274,7 @@ def update_host_last_job_after_job_deleted(sender, **kwargs):
|
|||||||
|
|
||||||
class ActivityStreamEnabled(threading.local):
|
class ActivityStreamEnabled(threading.local):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.enabled = getattr(settings, 'ACTIVITY_STREAM_ENABLED', True)
|
self.enabled = getattr(tower_settings, 'ACTIVITY_STREAM_ENABLED', True)
|
||||||
|
|
||||||
def __nonzero__(self):
|
def __nonzero__(self):
|
||||||
return bool(self.enabled)
|
return bool(self.enabled)
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ class BaseTask(Task):
|
|||||||
python_paths.insert(0, local_site_packages)
|
python_paths.insert(0, local_site_packages)
|
||||||
env['PYTHONPATH'] = os.pathsep.join(python_paths)
|
env['PYTHONPATH'] = os.pathsep.join(python_paths)
|
||||||
if self.should_use_proot:
|
if self.should_use_proot:
|
||||||
env['PROOT_TMP_DIR'] = settings.AWX_PROOT_BASE_PATH
|
env['PROOT_TMP_DIR'] = tower_settings.AWX_PROOT_BASE_PATH
|
||||||
return env
|
return env
|
||||||
|
|
||||||
def build_safe_env(self, instance, **kwargs):
|
def build_safe_env(self, instance, **kwargs):
|
||||||
@@ -462,7 +462,7 @@ class BaseTask(Task):
|
|||||||
instance = self.update_model(instance.pk)
|
instance = self.update_model(instance.pk)
|
||||||
if instance.cancel_flag:
|
if instance.cancel_flag:
|
||||||
try:
|
try:
|
||||||
if settings.AWX_PROOT_ENABLED:
|
if tower_settings.AWX_PROOT_ENABLED:
|
||||||
# NOTE: Refactor this once we get a newer psutil across the board
|
# NOTE: Refactor this once we get a newer psutil across the board
|
||||||
if not psutil:
|
if not psutil:
|
||||||
os.kill(child.pid, signal.SIGKILL)
|
os.kill(child.pid, signal.SIGKILL)
|
||||||
@@ -655,9 +655,9 @@ class RunJob(BaseTask):
|
|||||||
'''
|
'''
|
||||||
plugin_dir = self.get_path_to('..', 'plugins', 'callback')
|
plugin_dir = self.get_path_to('..', 'plugins', 'callback')
|
||||||
plugin_dirs = [plugin_dir]
|
plugin_dirs = [plugin_dir]
|
||||||
if hasattr(settings, 'AWX_ANSIBLE_CALLBACK_PLUGINS') and \
|
if hasattr(tower_settings, 'AWX_ANSIBLE_CALLBACK_PLUGINS') and \
|
||||||
settings.AWX_ANSIBLE_CALLBACK_PLUGINS:
|
tower_settings.AWX_ANSIBLE_CALLBACK_PLUGINS:
|
||||||
plugin_dirs.append(settings.AWX_ANSIBLE_CALLBACK_PLUGINS)
|
plugin_dirs.append(tower_settings.AWX_ANSIBLE_CALLBACK_PLUGINS)
|
||||||
plugin_path = ':'.join(plugin_dirs)
|
plugin_path = ':'.join(plugin_dirs)
|
||||||
env = super(RunJob, self).build_env(job, **kwargs)
|
env = super(RunJob, self).build_env(job, **kwargs)
|
||||||
# Set environment variables needed for inventory and job event
|
# Set environment variables needed for inventory and job event
|
||||||
@@ -851,7 +851,7 @@ class RunJob(BaseTask):
|
|||||||
'''
|
'''
|
||||||
Return whether this task should use proot.
|
Return whether this task should use proot.
|
||||||
'''
|
'''
|
||||||
return getattr(settings, 'AWX_PROOT_ENABLED', False)
|
return getattr(tower_settings, 'AWX_PROOT_ENABLED', False)
|
||||||
|
|
||||||
def pre_run_hook(self, job, **kwargs):
|
def pre_run_hook(self, job, **kwargs):
|
||||||
if job.job_type == PERM_INVENTORY_SCAN:
|
if job.job_type == PERM_INVENTORY_SCAN:
|
||||||
@@ -1476,7 +1476,7 @@ class RunAdHocCommand(BaseTask):
|
|||||||
'''
|
'''
|
||||||
Return whether this task should use proot.
|
Return whether this task should use proot.
|
||||||
'''
|
'''
|
||||||
return getattr(settings, 'AWX_PROOT_ENABLED', False)
|
return getattr(tower_settings, 'AWX_PROOT_ENABLED', False)
|
||||||
|
|
||||||
def post_run_hook(self, ad_hoc_command, **kwargs):
|
def post_run_hook(self, ad_hoc_command, **kwargs):
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -326,9 +326,9 @@ class RunAdHocCommandTest(BaseAdHocCommandTest):
|
|||||||
if not has_proot:
|
if not has_proot:
|
||||||
self.skipTest('proot is not installed')
|
self.skipTest('proot is not installed')
|
||||||
# Enable proot for this test.
|
# Enable proot for this test.
|
||||||
tower_settings.AWX_PROOT_ENABLED = True
|
settings.AWX_PROOT_ENABLED = True
|
||||||
# Hide local settings path.
|
# Hide local settings path.
|
||||||
tower_settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')]
|
settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')]
|
||||||
# Create list of paths that should not be visible to the command.
|
# Create list of paths that should not be visible to the command.
|
||||||
hidden_paths = [
|
hidden_paths = [
|
||||||
os.path.join(tower_settings.PROJECTS_ROOT, '*'),
|
os.path.join(tower_settings.PROJECTS_ROOT, '*'),
|
||||||
|
|||||||
Reference in New Issue
Block a user