openstack inventory ui support

This commit is contained in:
John Mitchell
2015-04-16 17:48:27 -04:00
parent 4fc04a3709
commit e67dfa3b92
4 changed files with 126 additions and 101 deletions

View File

@@ -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,

View File

@@ -1,5 +1,5 @@
/********************************************* /*********************************************
* Copyright (c) 2014 AnsibleWorks, Inc. * Copyright (c) 2015 AnsibleWorks, Inc.
* *
* GroupsHelper * GroupsHelper
* *
@@ -232,17 +232,19 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
]) ])
/**
*
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList', 'CreateSelect2', * TODO: Document
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList, CreateSelect2) { *
*/
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList' ,
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList) {
return function (params) { return function (params) {
var scope = params.scope, var scope = params.scope,
form = params.form, form = params.form,
kind, url, callback, invUrl; kind, url, callback, invUrl;
if (!Empty(scope.source)) { if (!Empty(scope.source)) {
if (scope.source.value === 'file') { if (scope.source.value === 'file') {
scope.sourcePathRequired = true; scope.sourcePathRequired = true;
@@ -254,36 +256,37 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
} }
if (scope.source.value === 'rax') { if (scope.source.value === 'rax') {
scope.source_region_choices = scope.rax_regions; 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'); $('#source_form').addClass('squeeze');
CreateSelect2({ } else if (scope.source.value === 'ec2') {
element: '#source_source_regions'
});
}
else if (scope.source.value === 'ec2') {
scope.source_region_choices = scope.ec2_regions; 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; scope.group_by_choices = scope.ec2_group_by;
$('#s2id_group_by').select2('data', []);
$('#source_form').addClass('squeeze'); $('#source_form').addClass('squeeze');
CreateSelect2({ } else if (scope.source.value === 'gce') {
element: '#source_source_regions'
});
CreateSelect2({
element: '#source_group_by'
});
}
else if (scope.source.value === 'gce') {
scope.source_region_choices = scope.gce_regions; 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'); $('#source_form').addClass('squeeze');
CreateSelect2({
element: '#source_source_regions'
});
} else if (scope.source.value === 'azure') { } else if (scope.source.value === 'azure') {
scope.source_region_choices = scope.azure_regions; 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'); $('#source_form').addClass('squeeze');
CreateSelect2({
element: '#source_source_regions'
});
} }
if(scope.source.value==="custom"){ if(scope.source.value==="custom"){
// need to filter the possible custom scripts by the organization defined for the current inventory // need to filter the possible custom scripts by the organization defined for the current inventory
@@ -301,13 +304,23 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName, ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName,
field_id: 'source_extra_vars', onReady: callback }); field_id: 'source_extra_vars', onReady: callback });
} }
if(scope.source.value==="vmware"){ if(scope.source.value==="vmware"
|| scope.source.value==="openstack"){
scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars; scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName, ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName,
field_id: 'source_inventory_variables', onReady: callback }); 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') { if (scope.source.value === 'rax'
kind = (scope.source.value === 'rax') ? 'rax' : (scope.source.value==='gce') ? 'gce' : (scope.source.value==='azure') ? 'azure' : (scope.source.value === 'vmware') ? 'vmware' : 'aws' ; || 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; url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
LookUpInit({ LookUpInit({
url: url, url: url,
@@ -317,11 +330,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
field: 'credential', field: 'credential',
input_type: "radio" input_type: "radio"
}); });
if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'ec2' )) { if ($('#group_tabs .active a').text() === 'Source'
&& (scope.source.value === 'ec2' )) {
callback = function(){ Wait('stop'); }; callback = function(){ Wait('stop'); };
Wait('start'); Wait('start');
scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars; scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
ParseTypeChange({ scope: scope, variable: 'source_vars', parse_variable: form.fields.source_vars.parseTypeName, ParseTypeChange({ scope: scope, variable: 'source_vars',
parse_variable: form.fields.source_vars.parseTypeName,
field_id: 'source_source_vars', onReady: callback }); 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);
} }

View File

@@ -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'

View File

@@ -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'