mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Make sure project updates run in default EE (#9172)
* Make sure project updates run in default EE * Remove project execution_environment field from collection
This commit is contained in:
committed by
Shane McDonald
parent
8ab7745e3a
commit
c7e0e30f93
@@ -1394,7 +1394,7 @@ class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Project
|
model = Project
|
||||||
fields = ('*', 'organization', 'scm_update_on_launch',
|
fields = ('*', '-execution_environment', 'organization', 'scm_update_on_launch',
|
||||||
'scm_update_cache_timeout', 'allow_override', 'custom_virtualenv', 'default_environment') + \
|
'scm_update_cache_timeout', 'allow_override', 'custom_virtualenv', 'default_environment') + \
|
||||||
('last_update_failed', 'last_updated') # Backwards compatibility
|
('last_update_failed', 'last_updated') # Backwards compatibility
|
||||||
|
|
||||||
|
|||||||
@@ -455,12 +455,17 @@ class ExecutionEnvironmentMixin(models.Model):
|
|||||||
help_text=_('The container image to be used for execution.'),
|
help_text=_('The container image to be used for execution.'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_execution_environment_default(self):
|
||||||
|
from awx.main.models.execution_environments import ExecutionEnvironment
|
||||||
|
|
||||||
|
if settings.DEFAULT_EXECUTION_ENVIRONMENT is not None:
|
||||||
|
return settings.DEFAULT_EXECUTION_ENVIRONMENT
|
||||||
|
return ExecutionEnvironment.objects.filter(organization=None, managed_by_tower=True).first()
|
||||||
|
|
||||||
def resolve_execution_environment(self):
|
def resolve_execution_environment(self):
|
||||||
"""
|
"""
|
||||||
Return the execution environment that should be used when creating a new job.
|
Return the execution environment that should be used when creating a new job.
|
||||||
"""
|
"""
|
||||||
from awx.main.models.execution_environments import ExecutionEnvironment
|
|
||||||
|
|
||||||
if self.execution_environment is not None:
|
if self.execution_environment is not None:
|
||||||
return self.execution_environment
|
return self.execution_environment
|
||||||
if getattr(self, 'project_id', None) and self.project.default_environment is not None:
|
if getattr(self, 'project_id', None) and self.project.default_environment is not None:
|
||||||
@@ -470,9 +475,8 @@ class ExecutionEnvironmentMixin(models.Model):
|
|||||||
if getattr(self, 'inventory', None) and self.inventory.organization is not None:
|
if getattr(self, 'inventory', None) and self.inventory.organization is not None:
|
||||||
if self.inventory.organization.default_environment is not None:
|
if self.inventory.organization.default_environment is not None:
|
||||||
return self.inventory.organization.default_environment
|
return self.inventory.organization.default_environment
|
||||||
if settings.DEFAULT_EXECUTION_ENVIRONMENT is not None:
|
|
||||||
return settings.DEFAULT_EXECUTION_ENVIRONMENT
|
return self.get_execution_environment_default()
|
||||||
return ExecutionEnvironment.objects.filter(organization=None, managed_by_tower=True).first()
|
|
||||||
|
|
||||||
|
|
||||||
class CustomVirtualEnvMixin(models.Model):
|
class CustomVirtualEnvMixin(models.Model):
|
||||||
|
|||||||
@@ -187,6 +187,14 @@ class ProjectOptions(models.Model):
|
|||||||
pass
|
pass
|
||||||
return cred
|
return cred
|
||||||
|
|
||||||
|
def resolve_execution_environment(self):
|
||||||
|
"""
|
||||||
|
Project updates, themselves, will use the default execution environment.
|
||||||
|
Jobs using the project can use the default_environment, but the project updates
|
||||||
|
are not flexible enough to allow customizing the image they use.
|
||||||
|
"""
|
||||||
|
return self.get_execution_environment_default()
|
||||||
|
|
||||||
def get_project_path(self, check_if_exists=True):
|
def get_project_path(self, check_if_exists=True):
|
||||||
local_path = os.path.basename(self.local_path)
|
local_path = os.path.basename(self.local_path)
|
||||||
if local_path and not local_path.startswith('.'):
|
if local_path and not local_path.startswith('.'):
|
||||||
|
|||||||
@@ -106,10 +106,6 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Default Execution Environment to use for jobs relating to the project.
|
- Default Execution Environment to use for jobs relating to the project.
|
||||||
type: str
|
type: str
|
||||||
execution_environment:
|
|
||||||
description:
|
|
||||||
- Execution Environment to use for project updates.
|
|
||||||
type: str
|
|
||||||
organization:
|
organization:
|
||||||
description:
|
description:
|
||||||
- Name of organization for project.
|
- Name of organization for project.
|
||||||
@@ -248,7 +244,6 @@ def main():
|
|||||||
timeout=dict(type='int', default=0, aliases=['job_timeout']),
|
timeout=dict(type='int', default=0, aliases=['job_timeout']),
|
||||||
custom_virtualenv=dict(),
|
custom_virtualenv=dict(),
|
||||||
default_environment=dict(),
|
default_environment=dict(),
|
||||||
execution_environment=dict(),
|
|
||||||
organization=dict(),
|
organization=dict(),
|
||||||
notification_templates_started=dict(type="list", elements='str'),
|
notification_templates_started=dict(type="list", elements='str'),
|
||||||
notification_templates_success=dict(type="list", elements='str'),
|
notification_templates_success=dict(type="list", elements='str'),
|
||||||
@@ -281,7 +276,6 @@ def main():
|
|||||||
timeout = module.params.get('timeout')
|
timeout = module.params.get('timeout')
|
||||||
custom_virtualenv = module.params.get('custom_virtualenv')
|
custom_virtualenv = module.params.get('custom_virtualenv')
|
||||||
default_ee = module.params.get('default_environment')
|
default_ee = module.params.get('default_environment')
|
||||||
ee = module.params.get('execution_environment')
|
|
||||||
organization = module.params.get('organization')
|
organization = module.params.get('organization')
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
wait = module.params.get('wait')
|
wait = module.params.get('wait')
|
||||||
@@ -347,8 +341,6 @@ def main():
|
|||||||
project_fields['credential'] = credential
|
project_fields['credential'] = credential
|
||||||
if default_ee is not None:
|
if default_ee is not None:
|
||||||
project_fields['default_environment'] = module.resolve_name_to_id('execution_environments', default_ee)
|
project_fields['default_environment'] = module.resolve_name_to_id('execution_environments', default_ee)
|
||||||
if ee is not None:
|
|
||||||
project_fields['execution_environment'] = module.resolve_name_to_id('execution_environments', ee)
|
|
||||||
if allow_override is not None:
|
if allow_override is not None:
|
||||||
project_fields['allow_override'] = allow_override
|
project_fields['allow_override'] = allow_override
|
||||||
if scm_type == '':
|
if scm_type == '':
|
||||||
|
|||||||
Reference in New Issue
Block a user