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