mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 19:07:39 -02:30
Merge pull request #2200 from ryanpetrello/custom_venv_allow_bundled
allow the bundled `ansible` virtualenv to be selected on JT/Project
This commit is contained in:
@@ -173,11 +173,15 @@ def test_extract_ansible_vars():
|
|||||||
|
|
||||||
|
|
||||||
def test_get_custom_venv_choices():
|
def test_get_custom_venv_choices():
|
||||||
assert common.get_custom_venv_choices() == []
|
bundled_venv = os.path.join(settings.BASE_VENV_PATH, 'ansible', '')
|
||||||
|
assert common.get_custom_venv_choices() == [bundled_venv]
|
||||||
|
|
||||||
with TemporaryDirectory(dir=settings.BASE_VENV_PATH) as temp_dir:
|
with TemporaryDirectory(dir=settings.BASE_VENV_PATH, prefix='tmp') as temp_dir:
|
||||||
os.makedirs(os.path.join(temp_dir, 'bin', 'activate'))
|
os.makedirs(os.path.join(temp_dir, 'bin', 'activate'))
|
||||||
assert common.get_custom_venv_choices() == [os.path.join(temp_dir, '')]
|
assert sorted(common.get_custom_venv_choices()) == [
|
||||||
|
bundled_venv,
|
||||||
|
os.path.join(temp_dir, '')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_region_sorting():
|
def test_region_sorting():
|
||||||
|
|||||||
@@ -928,7 +928,7 @@ def get_custom_venv_choices():
|
|||||||
return [
|
return [
|
||||||
os.path.join(custom_venv_path, x.decode('utf-8'), '')
|
os.path.join(custom_venv_path, x.decode('utf-8'), '')
|
||||||
for x in os.listdir(custom_venv_path)
|
for x in os.listdir(custom_venv_path)
|
||||||
if x not in ('awx', 'ansible') and
|
if x != 'awx' and
|
||||||
os.path.isdir(os.path.join(custom_venv_path, x)) and
|
os.path.isdir(os.path.join(custom_venv_path, x)) and
|
||||||
os.path.exists(os.path.join(custom_venv_path, x, 'bin', 'activate'))
|
os.path.exists(os.path.join(custom_venv_path, x, 'bin', 'activate'))
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ export default ['$scope', '$rootScope', '$location', '$stateParams',
|
|||||||
function init(){
|
function init(){
|
||||||
// @issue What is this doing, why
|
// @issue What is this doing, why
|
||||||
$scope.$emit("HideOrgListHeader");
|
$scope.$emit("HideOrgListHeader");
|
||||||
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs;
|
$scope.custom_virtualenvs_visible = ConfigData.custom_virtualenvs.length > 1;
|
||||||
|
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs.filter(
|
||||||
|
v => !/\/ansible\/$/.test(v)
|
||||||
|
);
|
||||||
CreateSelect2({
|
CreateSelect2({
|
||||||
element: '#organization_custom_virtualenv',
|
element: '#organization_custom_virtualenv',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup',
|
|||||||
|
|
||||||
$scope.$emit("HideOrgListHeader");
|
$scope.$emit("HideOrgListHeader");
|
||||||
$scope.instance_groups = InstanceGroupsData;
|
$scope.instance_groups = InstanceGroupsData;
|
||||||
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs;
|
$scope.custom_virtualenvs_visible = ConfigData.custom_virtualenvs.length > 1;
|
||||||
|
$scope.custom_virtualenvs_options = ConfigData.custom_virtualenvs.filter(
|
||||||
|
v => !/\/ansible\/$/.test(v)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default ['NotificationsList', 'i18n',
|
|||||||
},
|
},
|
||||||
custom_virtualenv: {
|
custom_virtualenv: {
|
||||||
label: i18n._('Ansible Environment'),
|
label: i18n._('Ansible Environment'),
|
||||||
defaultText: i18n._('Default Environment'),
|
defaultText: i18n._('Use Default Environment'),
|
||||||
type: 'select',
|
type: 'select',
|
||||||
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
|
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
|
||||||
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this organization to run on.") + "</p>",
|
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this organization to run on.") + "</p>",
|
||||||
@@ -53,7 +53,7 @@ export default ['NotificationsList', 'i18n',
|
|||||||
dataContainer: 'body',
|
dataContainer: 'body',
|
||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
ngDisabled: '!(organization_obj.summary_fields.user_capabilities.edit || canAdd)',
|
ngDisabled: '!(organization_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||||
ngShow: 'custom_virtualenvs_options.length > 0'
|
ngShow: 'custom_virtualenvs_visible'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -206,14 +206,14 @@ export default ['i18n', 'NotificationsList', 'TemplateList',
|
|||||||
custom_virtualenv: {
|
custom_virtualenv: {
|
||||||
label: i18n._('Ansible Environment'),
|
label: i18n._('Ansible Environment'),
|
||||||
type: 'select',
|
type: 'select',
|
||||||
defaultText: i18n._('Default Environment'),
|
defaultText: i18n._('Use Default Environment'),
|
||||||
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
|
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
|
||||||
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this project to run on.") + "</p>",
|
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this project to run on.") + "</p>",
|
||||||
dataTitle: i18n._('Ansible Environment'),
|
dataTitle: i18n._('Ansible Environment'),
|
||||||
dataContainer: 'body',
|
dataContainer: 'body',
|
||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||||
ngShow: 'custom_virtualenvs_options.length > 0'
|
ngShow: 'custom_virtualenvs_options.length > 1'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -234,14 +234,15 @@ function(NotificationsList, i18n) {
|
|||||||
custom_virtualenv: {
|
custom_virtualenv: {
|
||||||
label: i18n._('Ansible Environment'),
|
label: i18n._('Ansible Environment'),
|
||||||
type: 'select',
|
type: 'select',
|
||||||
defaultText: i18n._('Default Environment'),
|
defaultText: i18n._('Use Default Environment'),
|
||||||
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
|
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
|
||||||
|
|
||||||
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this job template to run on.") + "</p>",
|
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this job template to run on.") + "</p>",
|
||||||
dataTitle: i18n._('Ansible Environment'),
|
dataTitle: i18n._('Ansible Environment'),
|
||||||
dataContainer: 'body',
|
dataContainer: 'body',
|
||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAdd)',
|
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||||
ngShow: 'custom_virtualenvs_options.length > 0'
|
ngShow: 'custom_virtualenvs_options.length > 1'
|
||||||
},
|
},
|
||||||
instance_groups: {
|
instance_groups: {
|
||||||
label: i18n._('Instance Groups'),
|
label: i18n._('Instance Groups'),
|
||||||
|
|||||||
Reference in New Issue
Block a user