mirror of
https://github.com/ansible/awx.git
synced 2024-11-05 05:51:21 +03:00
AC-503 Inventory source field changes corresponding to API changes.
This commit is contained in:
parent
956b392f45
commit
ea9e73726b
@ -68,29 +68,6 @@ angular.module('GroupFormDefinition', [])
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
awRequiredWhen: {variable: "sourcePathRequired", init: "false" }
|
awRequiredWhen: {variable: "sourcePathRequired", init: "false" }
|
||||||
},
|
},
|
||||||
source_env: {
|
|
||||||
label: 'Script Environment Variables',
|
|
||||||
ngShow: "source.value == 'file'",
|
|
||||||
type: 'textarea',
|
|
||||||
addRequired: false,
|
|
||||||
editRequird: false,
|
|
||||||
excludeModal: true,
|
|
||||||
rows: 10,
|
|
||||||
'default': '---',
|
|
||||||
parseTypeName: 'envParseType',
|
|
||||||
dataTitle: 'Script Environment Variables',
|
|
||||||
dataPlacement: 'left',
|
|
||||||
awPopOver: "<p>Define environment variables here that will be referenced by the inventory script at runtime. " +
|
|
||||||
"Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
|
|
||||||
"JSON:<br />\n" +
|
|
||||||
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
|
||||||
"YAML:<br />\n" +
|
|
||||||
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
|
||||||
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
|
||||||
'<p>View YAML examples at <a href="http://www.ansibleworks.com/docs/YAMLSyntax.html" target="_blank">ansibleworks.com</a></p>',
|
|
||||||
dataContainer: 'body',
|
|
||||||
awPopOverRight: true
|
|
||||||
},
|
|
||||||
source_username: {
|
source_username: {
|
||||||
labelBind: 'sourceUsernameLabel',
|
labelBind: 'sourceUsernameLabel',
|
||||||
excludeModal: true,
|
excludeModal: true,
|
||||||
@ -133,10 +110,33 @@ angular.module('GroupFormDefinition', [])
|
|||||||
label: 'Tags',
|
label: 'Tags',
|
||||||
excludeModal: true,
|
excludeModal: true,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
ngShow: "source.value == 'rackspace' || source.value == 'ec2'",
|
ngShow: "source.value == 'ec2'",
|
||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false
|
editRequired: false
|
||||||
},
|
},
|
||||||
|
source_vars: {
|
||||||
|
label: 'Source Variables',
|
||||||
|
ngShow: "source.value == 'file' || source.value == 'ec2'",
|
||||||
|
type: 'textarea',
|
||||||
|
addRequired: false,
|
||||||
|
editRequird: false,
|
||||||
|
excludeModal: true,
|
||||||
|
rows: 10,
|
||||||
|
'default': '---',
|
||||||
|
parseTypeName: 'envParseType',
|
||||||
|
dataTitle: 'Source Variables',
|
||||||
|
dataPlacement: 'left',
|
||||||
|
awPopOver: "<p>Define additional variables here that will be referenced by the inventory script at runtime. " +
|
||||||
|
"Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
|
||||||
|
"JSON:<br />\n" +
|
||||||
|
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||||
|
"YAML:<br />\n" +
|
||||||
|
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
||||||
|
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
||||||
|
'<p>View YAML examples at <a href="http://www.ansibleworks.com/docs/YAMLSyntax.html" target="_blank">ansibleworks.com</a></p>',
|
||||||
|
dataContainer: 'body',
|
||||||
|
awPopOverRight: true
|
||||||
|
},
|
||||||
checkbox_group: {
|
checkbox_group: {
|
||||||
label: 'Update Options',
|
label: 'Update Options',
|
||||||
type: 'checkbox_group',
|
type: 'checkbox_group',
|
||||||
@ -144,7 +144,7 @@ angular.module('GroupFormDefinition', [])
|
|||||||
|
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'overwite_hosts',
|
name: 'overwrite',
|
||||||
label: 'Overwrite Hosts',
|
label: 'Overwrite Hosts',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
ngShow: "source.value !== '' && source.value !== null",
|
ngShow: "source.value !== '' && source.value !== null",
|
||||||
@ -158,7 +158,7 @@ angular.module('GroupFormDefinition', [])
|
|||||||
inline: false
|
inline: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'overwite_vars',
|
name: 'overwrite_vars',
|
||||||
label: 'Overwrite Variables',
|
label: 'Overwrite Variables',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
ngShow: "source.value !== '' && source.value !== null",
|
ngShow: "source.value !== '' && source.value !== null",
|
||||||
@ -171,20 +171,6 @@ angular.module('GroupFormDefinition', [])
|
|||||||
labelClass: 'checkbox-options',
|
labelClass: 'checkbox-options',
|
||||||
inline: false
|
inline: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'keep_vars',
|
|
||||||
label: 'Keep Variables',
|
|
||||||
type: 'checkbox',
|
|
||||||
ngShow: "source.value !== '' && source.value !== null",
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
awPopOver: '<p></p>',
|
|
||||||
dataTitle: 'Keep Variables',
|
|
||||||
dataContainer: 'body',
|
|
||||||
dataPlacement: 'left',
|
|
||||||
labelClass: 'checkbox-options',
|
|
||||||
inline: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'update_on_launch',
|
name: 'update_on_launch',
|
||||||
label: 'Update on Launch',
|
label: 'Update on Launch',
|
||||||
|
@ -18,7 +18,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
{ label: 'Manual', value: null },
|
{ label: 'Manual', value: null },
|
||||||
{ label: 'Amazon EC2', value: 'ec2' },
|
{ label: 'Amazon EC2', value: 'ec2' },
|
||||||
{ label: 'Rackspace', value: 'rackspace' },
|
{ label: 'Rackspace', value: 'rackspace' },
|
||||||
{ label: 'Local script', value: 'file' }
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
@ -174,9 +173,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (scope.groups[i].source) {
|
switch (scope.groups[i].source) {
|
||||||
case 'file':
|
|
||||||
source = 'Local Script';
|
|
||||||
break;
|
|
||||||
case 'ec2':
|
case 'ec2':
|
||||||
source = 'Amazon EC2';
|
source = 'Amazon EC2';
|
||||||
break;
|
break;
|
||||||
@ -410,7 +406,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
|
|
||||||
scope.source_type_options = getSourceTypeOptions();
|
scope.source_type_options = getSourceTypeOptions();
|
||||||
scope.parseType = 'yaml';
|
scope.parseType = 'yaml';
|
||||||
scope[form.fields['source_env'].parseTypeName] = 'yaml';
|
scope[form.fields['source_vars'].parseTypeName] = 'yaml';
|
||||||
scope.sourcePasswordRequired = false;
|
scope.sourcePasswordRequired = false;
|
||||||
scope.sourceUsernameRequired = false;
|
scope.sourceUsernameRequired = false;
|
||||||
scope.sourceUsernameLabel = 'Username';
|
scope.sourceUsernameLabel = 'Username';
|
||||||
@ -419,7 +415,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
scope.sourcePathRequired = false;
|
scope.sourcePathRequired = false;
|
||||||
|
|
||||||
ParseTypeChange(scope);
|
ParseTypeChange(scope);
|
||||||
ParseTypeChange(scope, 'source_env', form.fields['source_env'].parseTypeName);
|
ParseTypeChange(scope, 'source_vars', form.fields['source_vars'].parseTypeName);
|
||||||
|
|
||||||
//$('#form-modal .btn-none').removeClass('btn-none').addClass('btn-success');
|
//$('#form-modal .btn-none').removeClass('btn-none').addClass('btn-success');
|
||||||
|
|
||||||
@ -489,17 +485,17 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
}
|
}
|
||||||
master['source'] = scope['source'];
|
master['source'] = scope['source'];
|
||||||
}
|
}
|
||||||
else if (fld == 'source_env') {
|
else if (fld == 'source_vars') {
|
||||||
// Parse source_env, converting to YAML.
|
// Parse source_vars, converting to YAML.
|
||||||
if ($.isEmptyObject(data.source_env) || data.source_env == "\{\}" ||
|
if ($.isEmptyObject(data.source_vars) || data.source_vars == "\{\}" ||
|
||||||
data.source_env == "null" || data.source_env == "") {
|
data.source_vars == "null" || data.source_vars == "") {
|
||||||
scope.source_env = "---";
|
scope.source_vars = "---";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var json_obj = JSON.parse(data.extra_vars);
|
var json_obj = JSON.parse(data.extra_vars);
|
||||||
scope.source_env = jsyaml.safeDump(json_obj);
|
scope.source_vars = jsyaml.safeDump(json_obj);
|
||||||
}
|
}
|
||||||
master.source_env = scope.variables;
|
master.source_vars = scope.variables;
|
||||||
}
|
}
|
||||||
else if (data[fld]) {
|
else if (data[fld]) {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
@ -561,27 +557,26 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
source_password: scope['source_password'],
|
source_password: scope['source_password'],
|
||||||
source_regions: scope['source_regions'],
|
source_regions: scope['source_regions'],
|
||||||
source_tags: scope['source_tags'],
|
source_tags: scope['source_tags'],
|
||||||
overwrite_hosts: scope['overwite_hosts'],
|
overwrite: scope['overwrite'],
|
||||||
overwrite_vars: scope['overwite_vars'],
|
overwrite_vars: scope['overwrite_vars'],
|
||||||
keep_vars: scope['keep_vars'],
|
|
||||||
update_on_launch: scope['update_on_launch']
|
update_on_launch: scope['update_on_launch']
|
||||||
};
|
};
|
||||||
|
|
||||||
if (scope['source'].value == 'file') {
|
if (scope['source'].value == 'ec2') {
|
||||||
try {
|
try {
|
||||||
// Make sure we have valid variable data
|
// Make sure we have valid variable data
|
||||||
if (scope.envParseType == 'json') {
|
if (scope.envParseType == 'json') {
|
||||||
var json_data = JSON.parse(scope.source_env); //make sure JSON parses
|
var json_data = JSON.parse(scope.source_vars); //make sure JSON parses
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var json_data = jsyaml.load(scope.source_env); //parse yaml
|
var json_data = jsyaml.load(scope.source_vars); //parse yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our JSON is actually an object
|
// Make sure our JSON is actually an object
|
||||||
if (typeof json_data !== 'object') {
|
if (typeof json_data !== 'object') {
|
||||||
throw "failed to return an object!";
|
throw "failed to return an object!";
|
||||||
}
|
}
|
||||||
data.source_env = JSON.stringify(json_data, undefined, '\t');
|
data.source_vars = JSON.stringify(json_data, undefined, '\t');
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
parseError = true;
|
parseError = true;
|
||||||
|
@ -570,7 +570,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variable editing
|
// Variable editing
|
||||||
if (fld == "variables" || fld == "extra_vars" || fld == 'inventory_variables' || fld == 'source_env') {
|
if (fld == "variables" || fld == "extra_vars" || fld == 'inventory_variables' || fld == 'source_vars') {
|
||||||
html += "<div class=\"parse-selection\" id=\"" + this.form.name + "_" + fld + "_parse_type\">Parse as: " +
|
html += "<div class=\"parse-selection\" id=\"" + this.form.name + "_" + fld + "_parse_type\">Parse as: " +
|
||||||
"<input type=\"radio\" ng-model=\"";
|
"<input type=\"radio\" ng-model=\"";
|
||||||
html += (field.parseTypeName) ? field.parseTypeName : 'parseType';
|
html += (field.parseTypeName) ? field.parseTypeName : 'parseType';
|
||||||
|
Loading…
Reference in New Issue
Block a user