mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 13:11:19 -03:30
openstack inventory ui support
This commit is contained in:
parent
4fc04a3709
commit
e67dfa3b92
@ -164,7 +164,9 @@ export default
|
||||
},
|
||||
inventory_variables: {
|
||||
label: 'Source Variables', //"{{vars_label}}" ,
|
||||
ngShow: "source && (source.value == 'vmware')",
|
||||
|
||||
ngShow: "source && (source.value == 'vmware' || " +
|
||||
"source.value == 'openstack')",
|
||||
type: 'textarea',
|
||||
addRequired: false,
|
||||
editRequird: false,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*********************************************
|
||||
* Copyright (c) 2014 AnsibleWorks, Inc.
|
||||
* Copyright (c) 2015 AnsibleWorks, Inc.
|
||||
*
|
||||
* GroupsHelper
|
||||
*
|
||||
@ -232,102 +232,117 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
||||
])
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO: Document
|
||||
*
|
||||
*/
|
||||
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList' ,
|
||||
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList) {
|
||||
return function (params) {
|
||||
|
||||
var scope = params.scope,
|
||||
form = params.form,
|
||||
kind, url, callback, invUrl;
|
||||
|
||||
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList', 'CreateSelect2',
|
||||
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList, CreateSelect2) {
|
||||
return function (params) {
|
||||
|
||||
var scope = params.scope,
|
||||
form = params.form,
|
||||
kind, url, callback, invUrl;
|
||||
|
||||
|
||||
if (!Empty(scope.source)) {
|
||||
if (scope.source.value === 'file') {
|
||||
scope.sourcePathRequired = true;
|
||||
} else {
|
||||
scope.sourcePathRequired = false;
|
||||
// reset fields
|
||||
scope.source_path = '';
|
||||
scope[form.name + '_form'].source_path.$setValidity('required', true);
|
||||
}
|
||||
if (scope.source.value === 'rax') {
|
||||
scope.source_region_choices = scope.rax_regions;
|
||||
$('#source_form').addClass('squeeze');
|
||||
CreateSelect2({
|
||||
element: '#source_source_regions'
|
||||
});
|
||||
}
|
||||
else if (scope.source.value === 'ec2') {
|
||||
scope.source_region_choices = scope.ec2_regions;
|
||||
scope.group_by_choices = scope.ec2_group_by;
|
||||
$('#source_form').addClass('squeeze');
|
||||
CreateSelect2({
|
||||
element: '#source_source_regions'
|
||||
});
|
||||
CreateSelect2({
|
||||
element: '#source_group_by'
|
||||
});
|
||||
|
||||
}
|
||||
else if (scope.source.value === 'gce') {
|
||||
scope.source_region_choices = scope.gce_regions;
|
||||
$('#source_form').addClass('squeeze');
|
||||
CreateSelect2({
|
||||
element: '#source_source_regions'
|
||||
});
|
||||
|
||||
} else if (scope.source.value === 'azure') {
|
||||
scope.source_region_choices = scope.azure_regions;
|
||||
$('#source_form').addClass('squeeze');
|
||||
CreateSelect2({
|
||||
element: '#source_source_regions'
|
||||
});
|
||||
}
|
||||
if(scope.source.value==="custom"){
|
||||
// need to filter the possible custom scripts by the organization defined for the current inventory
|
||||
invUrl = GetBasePath('inventory_scripts') + '?organization='+scope.$parent.inventory.organization;
|
||||
LookUpInit({
|
||||
url: invUrl,
|
||||
scope: scope,
|
||||
form: form,
|
||||
hdr: "Select Custom Inventory",
|
||||
list: CustomInventoryList,
|
||||
field: 'source_script',
|
||||
input_type: 'radio'
|
||||
});
|
||||
scope.extra_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
|
||||
ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName,
|
||||
field_id: 'source_extra_vars', onReady: callback });
|
||||
}
|
||||
if(scope.source.value==="vmware"){
|
||||
scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
|
||||
ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName,
|
||||
field_id: 'source_inventory_variables', onReady: callback });
|
||||
}
|
||||
if (scope.source.value === 'rax' || scope.source.value === 'ec2'|| scope.source.value==='gce' || scope.source.value === 'azure' || scope.source.value === 'vmware') {
|
||||
kind = (scope.source.value === 'rax') ? 'rax' : (scope.source.value==='gce') ? 'gce' : (scope.source.value==='azure') ? 'azure' : (scope.source.value === 'vmware') ? 'vmware' : 'aws' ;
|
||||
url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
|
||||
LookUpInit({
|
||||
url: url,
|
||||
scope: scope,
|
||||
form: form,
|
||||
list: CredentialList,
|
||||
field: 'credential',
|
||||
input_type: "radio"
|
||||
});
|
||||
if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'ec2' )) {
|
||||
callback = function(){ Wait('stop'); };
|
||||
Wait('start');
|
||||
scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
|
||||
ParseTypeChange({ scope: scope, variable: 'source_vars', parse_variable: form.fields.source_vars.parseTypeName,
|
||||
field_id: 'source_source_vars', onReady: callback });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!Empty(scope.source)) {
|
||||
if (scope.source.value === 'file') {
|
||||
scope.sourcePathRequired = true;
|
||||
} else {
|
||||
scope.sourcePathRequired = false;
|
||||
// reset fields
|
||||
scope.source_path = '';
|
||||
scope[form.name + '_form'].source_path.$setValidity('required', true);
|
||||
}
|
||||
if (scope.source.value === 'rax') {
|
||||
scope.source_region_choices = scope.rax_regions;
|
||||
//$('#s2id_group_source_regions').select2('data', []);
|
||||
$('#s2id_source_source_regions').select2('data', [{
|
||||
id: 'all',
|
||||
text: 'All'
|
||||
}]);
|
||||
$('#source_form').addClass('squeeze');
|
||||
} else if (scope.source.value === 'ec2') {
|
||||
scope.source_region_choices = scope.ec2_regions;
|
||||
$('#s2id_source_source_regions').select2('data', [{
|
||||
id: 'all',
|
||||
text: 'All'
|
||||
}]);
|
||||
scope.group_by_choices = scope.ec2_group_by;
|
||||
$('#s2id_group_by').select2('data', []);
|
||||
$('#source_form').addClass('squeeze');
|
||||
} else if (scope.source.value === 'gce') {
|
||||
scope.source_region_choices = scope.gce_regions;
|
||||
//$('#s2id_group_source_regions').select2('data', []);
|
||||
$('#s2id_source_source_regions').select2('data', [{
|
||||
id: 'all',
|
||||
text: 'All'
|
||||
}]);
|
||||
$('#source_form').addClass('squeeze');
|
||||
} else if (scope.source.value === 'azure') {
|
||||
scope.source_region_choices = scope.azure_regions;
|
||||
//$('#s2id_group_source_regions').select2('data', []);
|
||||
$('#s2id_source_source_regions').select2('data', [{
|
||||
id: 'all',
|
||||
text: 'All'
|
||||
}]);
|
||||
$('#source_form').addClass('squeeze');
|
||||
}
|
||||
if(scope.source.value==="custom"){
|
||||
// need to filter the possible custom scripts by the organization defined for the current inventory
|
||||
invUrl = GetBasePath('inventory_scripts') + '?organization='+scope.$parent.inventory.organization;
|
||||
LookUpInit({
|
||||
url: invUrl,
|
||||
scope: scope,
|
||||
form: form,
|
||||
hdr: "Select Custom Inventory",
|
||||
list: CustomInventoryList,
|
||||
field: 'source_script',
|
||||
input_type: 'radio'
|
||||
});
|
||||
scope.extra_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
|
||||
ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName,
|
||||
field_id: 'source_extra_vars', onReady: callback });
|
||||
}
|
||||
if(scope.source.value==="vmware"
|
||||
|| scope.source.value==="openstack"){
|
||||
scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
|
||||
ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName,
|
||||
field_id: 'source_inventory_variables', onReady: callback });
|
||||
}
|
||||
if (scope.source.value === 'rax'
|
||||
|| scope.source.value === 'ec2'
|
||||
|| scope.source.value==='gce'
|
||||
|| scope.source.value === 'azure'
|
||||
|| scope.source.value === 'vmware'
|
||||
|| scope.source.value === 'openstack') {
|
||||
if (scope.source.value === 'ec2') {
|
||||
kind = 'aws';
|
||||
} else {
|
||||
kind = scope.source.value;
|
||||
}
|
||||
url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
|
||||
LookUpInit({
|
||||
url: url,
|
||||
scope: scope,
|
||||
form: form,
|
||||
list: CredentialList,
|
||||
field: 'credential',
|
||||
input_type: "radio"
|
||||
});
|
||||
if ($('#group_tabs .active a').text() === 'Source'
|
||||
&& (scope.source.value === 'ec2' )) {
|
||||
callback = function(){ Wait('stop'); };
|
||||
Wait('start');
|
||||
scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
|
||||
ParseTypeChange({ scope: scope, variable: 'source_vars',
|
||||
parse_variable: form.fields.source_vars.parseTypeName,
|
||||
field_id: 'source_source_vars', onReady: callback });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
/**
|
||||
@ -903,7 +918,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
||||
Wait('start');
|
||||
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName,
|
||||
field_id: 'source_source_vars', onReady: waitStop });
|
||||
} else if (sources_scope.source && (sources_scope.source.value === 'vmware')) {
|
||||
} else if (sources_scope.source && (sources_scope.source.value === 'vmware'
|
||||
|| sources_scope.source.value === 'openstack')) {
|
||||
Wait('start');
|
||||
ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: SourceForm.fields.inventory_variables.parseTypeName,
|
||||
field_id: 'source_inventory_variables', onReady: waitStop });
|
||||
@ -1282,7 +1298,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
|
||||
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.extra_vars, true);
|
||||
}
|
||||
|
||||
if (sources_scope.source && (sources_scope.source.value === 'vmware')) {
|
||||
if (sources_scope.source && (sources_scope.source.value === 'vmware'
|
||||
|| sources_scope.source.value === 'openstack')) {
|
||||
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true);
|
||||
}
|
||||
|
||||
|
||||
@ -78,6 +78,9 @@ export default
|
||||
},{
|
||||
name: "Microsoft Azure",
|
||||
value: "azure"
|
||||
},{
|
||||
name: "Openstack",
|
||||
value: "openstack"
|
||||
}],
|
||||
sourceModel: 'inventory_source',
|
||||
sourceField: 'source',
|
||||
@ -86,7 +89,7 @@ export default
|
||||
has_external_source: {
|
||||
label: 'Has external source?',
|
||||
searchType: 'in',
|
||||
searchValue: 'ec2,rax,vmware,azure,gce',
|
||||
searchValue: 'ec2,rax,vmware,azure,gce,openstack',
|
||||
searchOnly: true,
|
||||
sourceModel: 'inventory_source',
|
||||
sourceField: 'source'
|
||||
@ -170,4 +173,4 @@ export default
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -47,6 +47,9 @@ export default
|
||||
},{
|
||||
name: "Microsoft Azure",
|
||||
value: "azure"
|
||||
},{
|
||||
name: "Openstack",
|
||||
value: "openstack"
|
||||
}],
|
||||
sourceModel: 'inventory_source',
|
||||
sourceField: 'source',
|
||||
@ -55,7 +58,7 @@ export default
|
||||
has_external_source: {
|
||||
label: 'Has external source?',
|
||||
searchType: 'in',
|
||||
searchValue: 'ec2,rax,vmware,azure,gce',
|
||||
searchValue: 'ec2,rax,vmware,azure,gce,openstack',
|
||||
searchOnly: true,
|
||||
sourceModel: 'inventory_source',
|
||||
sourceField: 'source'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user