mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 04:31:21 -03:30
Remove PROJECTS_ROOT and JOBOUTPUT_ROOT from stngs
This commit is contained in:
parent
5e1c98341b
commit
0e98491dac
@ -216,7 +216,7 @@ class ApiV1ConfigView(APIView):
|
||||
|
||||
if request.user.is_superuser or request.user.admin_of_organizations.filter(active=True).count():
|
||||
data.update(dict(
|
||||
project_base_dir = tower_settings.PROJECTS_ROOT,
|
||||
project_base_dir = settings.PROJECTS_ROOT,
|
||||
project_local_paths = Project.get_local_path_choices(),
|
||||
))
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import re
|
||||
import urlparse
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import smart_str
|
||||
@ -45,9 +46,9 @@ class ProjectOptions(models.Model):
|
||||
|
||||
@classmethod
|
||||
def get_local_path_choices(cls):
|
||||
if os.path.exists(tower_settings.PROJECTS_ROOT):
|
||||
paths = [x.decode('utf-8') for x in os.listdir(tower_settings.PROJECTS_ROOT)
|
||||
if (os.path.isdir(os.path.join(tower_settings.PROJECTS_ROOT, x)) and
|
||||
if os.path.exists(settings.PROJECTS_ROOT):
|
||||
paths = [x.decode('utf-8') for x in os.listdir(settings.PROJECTS_ROOT)
|
||||
if (os.path.isdir(os.path.join(settings.PROJECTS_ROOT, x)) and
|
||||
not x.startswith('.') and not x.startswith('_'))]
|
||||
qs = Project.objects.filter(active=True)
|
||||
used_paths = qs.values_list('local_path', flat=True)
|
||||
@ -143,7 +144,7 @@ class ProjectOptions(models.Model):
|
||||
def get_project_path(self, check_if_exists=True):
|
||||
local_path = os.path.basename(self.local_path)
|
||||
if local_path and not local_path.startswith('.'):
|
||||
proj_path = os.path.join(tower_settings.PROJECTS_ROOT, local_path)
|
||||
proj_path = os.path.join(settings.PROJECTS_ROOT, local_path)
|
||||
if not check_if_exists or os.path.exists(smart_str(proj_path)):
|
||||
return proj_path
|
||||
|
||||
|
||||
@ -537,9 +537,9 @@ class BaseTask(Task):
|
||||
cwd = self.build_cwd(instance, **kwargs)
|
||||
env = self.build_env(instance, **kwargs)
|
||||
safe_env = self.build_safe_env(instance, **kwargs)
|
||||
if not os.path.exists(tower_settings.JOBOUTPUT_ROOT):
|
||||
os.makedirs(tower_settings.JOBOUTPUT_ROOT)
|
||||
stdout_filename = os.path.join(tower_settings.JOBOUTPUT_ROOT, "%d-%s.out" % (pk, str(uuid.uuid1())))
|
||||
if not os.path.exists(settings.JOBOUTPUT_ROOT):
|
||||
os.makedirs(settings.JOBOUTPUT_ROOT)
|
||||
stdout_filename = os.path.join(settings.JOBOUTPUT_ROOT, "%d-%s.out" % (pk, str(uuid.uuid1())))
|
||||
stdout_handle = codecs.open(stdout_filename, 'w', encoding='utf-8')
|
||||
if self.should_use_proot(instance, **kwargs):
|
||||
if not check_proot_installed():
|
||||
@ -814,7 +814,7 @@ class RunJob(BaseTask):
|
||||
return self.get_path_to('..', 'playbooks')
|
||||
cwd = job.project.get_project_path()
|
||||
if not cwd:
|
||||
root = tower_settings.PROJECTS_ROOT
|
||||
root = settings.PROJECTS_ROOT
|
||||
raise RuntimeError('project local_path %s cannot be found in %s' %
|
||||
(job.project.local_path, root))
|
||||
return cwd
|
||||
|
||||
@ -331,8 +331,8 @@ class RunAdHocCommandTest(BaseAdHocCommandTest):
|
||||
settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')]
|
||||
# Create list of paths that should not be visible to the command.
|
||||
hidden_paths = [
|
||||
os.path.join(tower_settings.PROJECTS_ROOT, '*'),
|
||||
os.path.join(tower_settings.JOBOUTPUT_ROOT, '*'),
|
||||
os.path.join(settings.PROJECTS_ROOT, '*'),
|
||||
os.path.join(settings.JOBOUTPUT_ROOT, '*'),
|
||||
]
|
||||
# Create a temp directory that should not be visible to the command.
|
||||
temp_path = tempfile.mkdtemp()
|
||||
|
||||
@ -264,14 +264,14 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
|
||||
if not name:
|
||||
name = self.unique_name('Project')
|
||||
|
||||
if not os.path.exists(tower_settings.PROJECTS_ROOT):
|
||||
os.makedirs(tower_settings.PROJECTS_ROOT)
|
||||
if not os.path.exists(settings.PROJECTS_ROOT):
|
||||
os.makedirs(settings.PROJECTS_ROOT)
|
||||
# Create temp project directory.
|
||||
if unicode_prefix:
|
||||
tmp_prefix = u'\u2620tmp'
|
||||
else:
|
||||
tmp_prefix = 'tmp'
|
||||
project_dir = tempfile.mkdtemp(prefix=tmp_prefix, dir=tower_settings.PROJECTS_ROOT)
|
||||
project_dir = tempfile.mkdtemp(prefix=tmp_prefix, dir=settings.PROJECTS_ROOT)
|
||||
self._temp_paths.append(project_dir)
|
||||
# Create temp playbook in project (if playbook content is given).
|
||||
if playbook_content:
|
||||
|
||||
@ -151,7 +151,7 @@ class ProjectsTest(BaseTransactionTest):
|
||||
url = reverse('api:api_v1_config_view')
|
||||
response = self.get(url, expect=200, auth=self.get_super_credentials())
|
||||
self.assertTrue('project_base_dir' in response)
|
||||
self.assertEqual(response['project_base_dir'], tower_settings.PROJECTS_ROOT)
|
||||
self.assertEqual(response['project_base_dir'], settings.PROJECTS_ROOT)
|
||||
self.assertTrue('project_local_paths' in response)
|
||||
self.assertEqual(set(response['project_local_paths']),
|
||||
set(Project.get_local_path_choices()))
|
||||
@ -219,7 +219,7 @@ class ProjectsTest(BaseTransactionTest):
|
||||
self.assertEquals(results['count'], 0)
|
||||
|
||||
# can add projects (super user)
|
||||
project_dir = tempfile.mkdtemp(dir=tower_settings.PROJECTS_ROOT)
|
||||
project_dir = tempfile.mkdtemp(dir=settings.PROJECTS_ROOT)
|
||||
self._temp_paths.append(project_dir)
|
||||
project_data = {
|
||||
'name': 'My Test Project',
|
||||
|
||||
@ -1413,8 +1413,8 @@ class RunJobTest(BaseJobExecutionTest):
|
||||
project_path = self.project.local_path
|
||||
job_template = self.create_test_job_template()
|
||||
extra_vars = {
|
||||
'projects_root': tower_settings.PROJECTS_ROOT,
|
||||
'joboutput_root': tower_settings.JOBOUTPUT_ROOT,
|
||||
'projects_root': settings.PROJECTS_ROOT,
|
||||
'joboutput_root': settings.JOBOUTPUT_ROOT,
|
||||
'project_path': project_path,
|
||||
'other_project_path': other_project_path,
|
||||
'temp_path': temp_path,
|
||||
|
||||
@ -17,6 +17,7 @@ import contextlib
|
||||
import tempfile
|
||||
|
||||
# Django REST Framework
|
||||
from django.conf import settings
|
||||
from rest_framework.exceptions import ParseError, PermissionDenied
|
||||
from django.utils.encoding import smart_str
|
||||
from django.core.urlresolvers import reverse
|
||||
@ -467,8 +468,8 @@ def wrap_args_with_proot(args, cwd, **kwargs):
|
||||
new_args = [getattr(settings, 'AWX_PROOT_CMD', 'proot'), '-v',
|
||||
str(getattr(settings, 'AWX_PROOT_VERBOSITY', '0')), '-r', '/']
|
||||
hide_paths = ['/etc/tower', '/var/lib/awx', '/var/log',
|
||||
tempfile.gettempdir(), tower_settings.PROJECTS_ROOT,
|
||||
tower_settings.JOBOUTPUT_ROOT]
|
||||
tempfile.gettempdir(), settings.PROJECTS_ROOT,
|
||||
settings.JOBOUTPUT_ROOT]
|
||||
hide_paths.extend(getattr(tower_settings, 'AWX_PROOT_HIDE_PATHS', None) or [])
|
||||
for path in sorted(set(hide_paths)):
|
||||
if not os.path.exists(path):
|
||||
|
||||
@ -682,20 +682,6 @@ FACT_CACHE_PORT = 6564
|
||||
ORG_ADMINS_CAN_SEE_ALL_USERS = True
|
||||
|
||||
TOWER_SETTINGS_MANIFEST = {
|
||||
"PROJECTS_ROOT": {
|
||||
"name": "Projects Root Directory",
|
||||
"description": "Directory to store synced projects in and to look for manual projects",
|
||||
"default": PROJECTS_ROOT,
|
||||
"type": "string",
|
||||
"category": "jobs",
|
||||
},
|
||||
"JOBOUTPUT_ROOT": {
|
||||
"name": "Job Standard Output Directory",
|
||||
"description": "Directory to store job standard output files",
|
||||
"default": JOBOUTPUT_ROOT,
|
||||
"type": "string",
|
||||
"category": "jobs",
|
||||
},
|
||||
"SCHEDULE_MAX_JOBS": {
|
||||
"name": "Maximum Scheduled Jobs",
|
||||
"description": "Maximum number of the same job template that can be waiting to run when launching from a schedule before no more are created",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user