mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Delete inventory source fields
This commit is contained in:
parent
2eec1317bd
commit
dce946e93f
@ -24,49 +24,6 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
|
||||
const virtualEnvs = ConfigData.custom_virtualenvs || [];
|
||||
$scope.custom_virtualenvs_options = virtualEnvs;
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'rax_regions',
|
||||
choice_name: 'rax_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'ec2_regions',
|
||||
choice_name: 'ec2_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'gce_regions',
|
||||
choice_name: 'gce_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'azure_regions',
|
||||
choice_name: 'azure_rm_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
// Load options for group_by
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'group_by',
|
||||
variable: 'ec2_group_by',
|
||||
choice_name: 'ec2_group_by_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
initRegionSelect();
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'verbosity',
|
||||
@ -205,20 +162,11 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
|
||||
$scope.projectBasePath = GetBasePath('projects') + '?not__status=never updated';
|
||||
}
|
||||
|
||||
// reset fields
|
||||
$scope.group_by_choices = source === 'ec2' ? $scope.ec2_group_by : null;
|
||||
// azure_rm regions choices are keyed as "azure" in an OPTIONS request to the inventory_sources endpoint
|
||||
$scope.source_region_choices = source === 'azure_rm' ? $scope.azure_regions : $scope[source + '_regions'];
|
||||
$scope.cloudCredentialRequired = source !== '' && source !== 'scm' && source !== 'custom' && source !== 'ec2' ? true : false;
|
||||
$scope.source_regions = null;
|
||||
$scope.credential = null;
|
||||
$scope.credential_name = null;
|
||||
$scope.group_by = null;
|
||||
$scope.group_by_choices = [];
|
||||
$scope.overwrite_vars = false;
|
||||
initRegionSelect();
|
||||
};
|
||||
// region / source options callback
|
||||
|
||||
$scope.$on('sourceTypeOptionsReady', function() {
|
||||
CreateSelect2({
|
||||
@ -227,57 +175,6 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
|
||||
});
|
||||
});
|
||||
|
||||
function initRegionSelect(){
|
||||
CreateSelect2({
|
||||
element: '#inventory_source_source_regions',
|
||||
multiple: true
|
||||
});
|
||||
|
||||
let add_new = false;
|
||||
if( _.get($scope, 'source') === 'ec2' || _.get($scope.source, 'value') === 'ec2') {
|
||||
$scope.group_by_choices = $scope.ec2_group_by;
|
||||
$scope.groupByPopOver = "<p>" + i18n._("Select which groups to create automatically. ") +
|
||||
$rootScope.BRAND_NAME + i18n._(" will create group names similar to the following examples based on the options selected:") + "</p><ul>" +
|
||||
"<li>" + i18n._("Availability Zone:") + "<strong>zones » us-east-1b</strong></li>" +
|
||||
"<li>" + i18n._("Image ID:") + "<strong>images » ami-b007ab1e</strong></li>" +
|
||||
"<li>" + i18n._("Instance ID:") + "<strong>instances » i-ca11ab1e</strong></li>" +
|
||||
"<li>" + i18n._("Instance Type:") + "<strong>types » type_m1_medium</strong></li>" +
|
||||
"<li>" + i18n._("Key Name:") + "<strong>keys » key_testing</strong></li>" +
|
||||
"<li>" + i18n._("Region:") + "<strong>regions » us-east-1</strong></li>" +
|
||||
"<li>" + i18n._("Security Group:") + "<strong>security_groups » security_group_default</strong></li>" +
|
||||
"<li>" + i18n._("Tags:") + "<strong>tags » tag_Name » tag_Name_host1</strong></li>" +
|
||||
"<li>" + i18n._("VPC ID:") + "<strong>vpcs » vpc-5ca1ab1e</strong></li>" +
|
||||
"<li>" + i18n._("Tag None:") + "<strong>tags » tag_none</strong></li>" +
|
||||
"</ul><p>" + i18n._("If blank, all groups above are created except") + "<em>" + i18n._("Instance ID") + "</em>.</p>";
|
||||
|
||||
$scope.instanceFilterPopOver = "<p>" + i18n._("Provide a comma-separated list of filter expressions. ") +
|
||||
i18n._("Hosts are imported to ") + $rootScope.BRAND_NAME + i18n._(" when ") + "<em>" + i18n._("ANY") + "</em>" + i18n._(" of the filters match.") + "</p>" +
|
||||
i18n._("Limit to hosts having a tag:") + "<br />\n" +
|
||||
"<blockquote>tag-key=TowerManaged</blockquote>\n" +
|
||||
i18n._("Limit to hosts using either key pair:") + "<br />\n" +
|
||||
"<blockquote>key-name=staging, key-name=production</blockquote>\n" +
|
||||
i18n._("Limit to hosts where the Name tag begins with ") + "<em>" + i18n._("test") + "</em>:<br />\n" +
|
||||
"<blockquote>tag:Name=test*</blockquote>\n" +
|
||||
"<p>" + i18n._("View the ") + "<a href=\"http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html\" target=\"_blank\">" + i18n._("Describe Instances documentation") + "</a> " +
|
||||
i18n._("for a complete list of supported filters.") + "</p>";
|
||||
}
|
||||
if( _.get($scope, 'source') === 'vmware' || _.get($scope.source, 'value') === 'vmware') {
|
||||
add_new = true;
|
||||
$scope.group_by_choices = [];
|
||||
$scope.group_by = $scope.group_by_choices;
|
||||
$scope.groupByPopOver = i18n._("Specify which groups to create automatically. Group names will be created similar to the options selected. If blank, all groups above are created. Refer to Ansible Tower documentation for more detail.");
|
||||
$scope.instanceFilterPopOver = i18n._("Provide a comma-separated list of filter expressions. Hosts are imported when all of the filters match. Refer to Ansible Tower documentation for more detail.");
|
||||
}
|
||||
if( _.get($scope, 'source') === 'tower' || _.get($scope.source, 'value') === 'tower') {
|
||||
$scope.instanceFilterPopOver = i18n._("Provide the named URL encoded name or id of the remote Tower inventory to be imported.");
|
||||
}
|
||||
CreateSelect2({
|
||||
element: '#inventory_source_group_by',
|
||||
multiple: true,
|
||||
addNew: add_new
|
||||
});
|
||||
}
|
||||
|
||||
$scope.formCancel = function() {
|
||||
$state.go('^');
|
||||
};
|
||||
@ -289,7 +186,6 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
|
||||
name: $scope.name,
|
||||
description: $scope.description,
|
||||
inventory: inventoryData.id,
|
||||
instance_filters: $scope.instance_filters,
|
||||
source_script: $scope.inventory_script,
|
||||
credential: $scope.credential,
|
||||
overwrite: $scope.overwrite,
|
||||
@ -298,9 +194,6 @@ export default ['$state', 'ConfigData', '$scope', 'SourcesFormDefinition', 'Pars
|
||||
verbosity: $scope.verbosity.value,
|
||||
update_cache_timeout: $scope.update_cache_timeout || 0,
|
||||
custom_virtualenv: $scope.custom_virtualenv || null,
|
||||
// comma-delimited strings
|
||||
group_by: SourcesService.encodeGroupBy($scope.source, $scope.group_by),
|
||||
source_regions: _.map($scope.source_regions, 'value').join(','),
|
||||
};
|
||||
|
||||
if ($scope.source) {
|
||||
|
||||
@ -34,7 +34,6 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
|
||||
{overwrite_vars: inventorySourceData.overwrite_vars},
|
||||
{update_on_launch: inventorySourceData.update_on_launch},
|
||||
{update_cache_timeout: inventorySourceData.update_cache_timeout},
|
||||
{instance_filters: inventorySourceData.instance_filters},
|
||||
{inventory_script: inventorySourceData.source_script},
|
||||
{verbosity: inventorySourceData.verbosity});
|
||||
|
||||
@ -100,56 +99,6 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
|
||||
scope: $scope,
|
||||
variable: 'source_type_options'
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'rax_regions',
|
||||
choice_name: 'rax_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'ec2_regions',
|
||||
choice_name: 'ec2_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'gce_regions',
|
||||
choice_name: 'gce_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'source_regions',
|
||||
variable: 'azure_regions',
|
||||
choice_name: 'azure_rm_region_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
field: 'group_by',
|
||||
variable: 'ec2_group_by',
|
||||
choice_name: 'ec2_group_by_choices',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
var source = $scope.source === 'azure_rm' ? 'azure' : $scope.source;
|
||||
var regions = inventorySourceData.source_regions.split(',');
|
||||
// azure_rm regions choices are keyed as "azure" in an OPTIONS request to the inventory_sources endpoint
|
||||
$scope.source_region_choices = $scope[source + '_regions'];
|
||||
|
||||
// the API stores azure regions as all-lowercase strings - but the azure regions received from OPTIONS are Snake_Cased
|
||||
if (source === 'azure') {
|
||||
$scope.source_regions = _.map(regions, (region) => _.find($scope[source + '_regions'], (o) => o.value.toLowerCase() === region));
|
||||
}
|
||||
// all other regions are 1-1
|
||||
else {
|
||||
$scope.source_regions = _.map(regions, (region) => _.find($scope[source + '_regions'], (o) => o.value === region));
|
||||
}
|
||||
initRegionSelect();
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
@ -236,63 +185,6 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
|
||||
}
|
||||
}
|
||||
|
||||
function initRegionSelect() {
|
||||
CreateSelect2({
|
||||
element: '#inventory_source_source_regions',
|
||||
multiple: true
|
||||
});
|
||||
|
||||
let add_new = false;
|
||||
if( _.get($scope, 'source') === 'ec2' || _.get($scope.source, 'value') === 'ec2') {
|
||||
$scope.group_by_choices = $scope.ec2_group_by;
|
||||
let group_by = inventorySourceData.group_by.split(',');
|
||||
$scope.group_by = _.map(group_by, (item) => _.find($scope.ec2_group_by, { value: item }));
|
||||
|
||||
$scope.groupByPopOver = "<p>" + i18n._("Select which groups to create automatically. ") +
|
||||
$rootScope.BRAND_NAME + i18n._(" will create group names similar to the following examples based on the options selected:") + "</p><ul>" +
|
||||
"<li>" + i18n._("Availability Zone:") + "<strong>zones » us-east-1b</strong></li>" +
|
||||
"<li>" + i18n._("Image ID:") + "<strong>images » ami-b007ab1e</strong></li>" +
|
||||
"<li>" + i18n._("Instance ID:") + "<strong>instances » i-ca11ab1e</strong></li>" +
|
||||
"<li>" + i18n._("Instance Type:") + "<strong>types » type_m1_medium</strong></li>" +
|
||||
"<li>" + i18n._("Key Name:") + "<strong>keys » key_testing</strong></li>" +
|
||||
"<li>" + i18n._("Region:") + "<strong>regions » us-east-1</strong></li>" +
|
||||
"<li>" + i18n._("Security Group:") + "<strong>security_groups » security_group_default</strong></li>" +
|
||||
"<li>" + i18n._("Tags:") + "<strong>tags » tag_Name » tag_Name_host1</strong></li>" +
|
||||
"<li>" + i18n._("VPC ID:") + "<strong>vpcs » vpc-5ca1ab1e</strong></li>" +
|
||||
"<li>" + i18n._("Tag None:") + "<strong>tags » tag_none</strong></li>" +
|
||||
"</ul><p>" + i18n._("If blank, all groups above are created except") + "<em>" + i18n._("Instance ID") + "</em>.</p>";
|
||||
|
||||
|
||||
$scope.instanceFilterPopOver = "<p>" + i18n._("Provide a comma-separated list of filter expressions. ") +
|
||||
i18n._("Hosts are imported to ") + $rootScope.BRAND_NAME + i18n._(" when ") + "<em>" + i18n._("ANY") + "</em>" + i18n._(" of the filters match.") + "</p>" +
|
||||
i18n._("Limit to hosts having a tag:") + "<br />\n" +
|
||||
"<blockquote>tag-key=TowerManaged</blockquote>\n" +
|
||||
i18n._("Limit to hosts using either key pair:") + "<br />\n" +
|
||||
"<blockquote>key-name=staging, key-name=production</blockquote>\n" +
|
||||
i18n._("Limit to hosts where the Name tag begins with ") + "<em>" + i18n._("test") + "</em>:<br />\n" +
|
||||
"<blockquote>tag:Name=test*</blockquote>\n" +
|
||||
"<p>" + i18n._("View the ") + "<a href=\"http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html\" target=\"_blank\">" + i18n._("Describe Instances documentation") + "</a> " +
|
||||
i18n._("for a complete list of supported filters.") + "</p>";
|
||||
|
||||
}
|
||||
if( _.get($scope, 'source') === 'vmware' || _.get($scope.source, 'value') === 'vmware') {
|
||||
add_new = true;
|
||||
$scope.group_by_choices = (inventorySourceData.group_by) ? inventorySourceData.group_by.split(',')
|
||||
.map((i) => ({name: i, label: i, value: i})) : [];
|
||||
$scope.group_by = $scope.group_by_choices;
|
||||
$scope.groupByPopOver = i18n._(`Specify which groups to create automatically. Group names will be created similar to the options selected. If blank, all groups above are created. Refer to Ansible Tower documentation for more detail.`);
|
||||
$scope.instanceFilterPopOver = i18n._(`Provide a comma-separated list of filter expressions. Hosts are imported when all of the filters match. Refer to Ansible Tower documentation for more detail.`);
|
||||
}
|
||||
if( _.get($scope, 'source') === 'tower' || _.get($scope.source, 'value') === 'tower') {
|
||||
$scope.instanceFilterPopOver = i18n._(`Provide the named URL encoded name or id of the remote Tower inventory to be imported.`);
|
||||
}
|
||||
CreateSelect2({
|
||||
element: '#inventory_source_group_by',
|
||||
multiple: true,
|
||||
addNew: add_new
|
||||
});
|
||||
}
|
||||
|
||||
$scope.lookupProject = function(){
|
||||
$state.go('.project', {
|
||||
project_search: {
|
||||
@ -346,7 +238,6 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
|
||||
name: $scope.name,
|
||||
description: $scope.description,
|
||||
inventory: inventoryData.id,
|
||||
instance_filters: $scope.instance_filters,
|
||||
source_script: $scope.inventory_script,
|
||||
credential: $scope.credential,
|
||||
overwrite: $scope.overwrite,
|
||||
@ -355,9 +246,6 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
|
||||
update_cache_timeout: $scope.update_cache_timeout || 0,
|
||||
verbosity: $scope.verbosity.value,
|
||||
custom_virtualenv: $scope.custom_virtualenv || null,
|
||||
// comma-delimited strings
|
||||
group_by: SourcesService.encodeGroupBy($scope.source, $scope.group_by),
|
||||
source_regions: _.map($scope.source_regions, 'value').join(',')
|
||||
};
|
||||
|
||||
if ($scope.source) {
|
||||
@ -417,20 +305,10 @@ export default ['$state', '$scope', 'ParseVariableString', 'ParseTypeChange',
|
||||
});
|
||||
}
|
||||
|
||||
// reset fields
|
||||
$scope.group_by_choices = source === 'ec2' ? $scope.ec2_group_by : null;
|
||||
// azure_rm regions choices are keyed as "azure" in an OPTIONS request to the inventory_sources endpoint
|
||||
$scope.source_region_choices = source === 'azure_rm' ? $scope.azure_regions : $scope[source + '_regions'];
|
||||
$scope.cloudCredentialRequired = source !== '' && source !== 'scm' && source !== 'custom' && source !== 'ec2' ? true : false;
|
||||
$scope.source_regions = null;
|
||||
$scope.credential = null;
|
||||
$scope.credential_name = null;
|
||||
$scope.group_by = null;
|
||||
$scope.group_by_choices = [];
|
||||
$scope.overwrite_vars = false;
|
||||
|
||||
initRegionSelect();
|
||||
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
@ -126,46 +126,6 @@ export default ['NotificationsList', 'i18n', function(NotificationsList, i18n){
|
||||
includeInventoryFileNotFoundError: true,
|
||||
subForm: 'sourceSubForm'
|
||||
},
|
||||
source_regions: {
|
||||
label: i18n._('Regions'),
|
||||
type: 'select',
|
||||
ngOptions: 'source.label for source in source_region_choices track by source.value',
|
||||
multiSelect: true,
|
||||
ngShow: "source && (source.value == 'rax' || source.value == 'ec2' || source.value == 'gce' || source.value == 'azure_rm')",
|
||||
dataTitle: i18n._('Source Regions'),
|
||||
dataPlacement: 'right',
|
||||
awPopOver: "<p>" + i18n._("Click on the regions field to see a list of regions for your cloud provider. You can select multiple regions, or choose") +
|
||||
"<em>" + i18n._("All") + "</em> " + i18n._("to include all regions. Only Hosts associated with the selected regions will be updated.") + "</p>",
|
||||
dataContainer: 'body',
|
||||
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
subForm: 'sourceSubForm'
|
||||
},
|
||||
instance_filters: {
|
||||
label: i18n._("Instance Filters"),
|
||||
type: 'text',
|
||||
ngShow: "source && (source.value == 'ec2' || source.value == 'vmware' || source.value == 'tower')",
|
||||
dataTitle: i18n._('Instance Filters'),
|
||||
dataPlacement: 'right',
|
||||
awPopOverWatch: 'instanceFilterPopOver',
|
||||
awPopOver: '{{ instanceFilterPopOver }}',
|
||||
dataContainer: 'body',
|
||||
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
subForm: 'sourceSubForm'
|
||||
},
|
||||
group_by: {
|
||||
label: i18n._('Only Group By'),
|
||||
type: 'select',
|
||||
ngShow: "source && (source.value == 'ec2' || source.value == 'vmware')",
|
||||
ngOptions: 'source.label for source in group_by_choices track by source.value',
|
||||
multiSelect: true,
|
||||
dataTitle: i18n._("Only Group By"),
|
||||
dataPlacement: 'right',
|
||||
awPopOverWatch: 'groupByPopOver',
|
||||
awPopOver: '{{ groupByPopOver }}',
|
||||
dataContainer: 'body',
|
||||
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
subForm: 'sourceSubForm'
|
||||
},
|
||||
inventory_script: {
|
||||
label : i18n._("Custom Inventory Script"),
|
||||
type: 'lookup',
|
||||
|
||||
@ -116,24 +116,6 @@ export default
|
||||
.catch(this.error.bind(this))
|
||||
.finally(Wait('stop'));
|
||||
},
|
||||
encodeGroupBy(source, group_by){
|
||||
source = source && source.value ? source.value : '';
|
||||
if(source === 'ec2'){
|
||||
return _.map(group_by, 'value').join(',');
|
||||
}
|
||||
|
||||
if(source === 'vmware'){
|
||||
group_by = _.map(group_by, (i) => {return i.value;});
|
||||
$("#inventory_source_group_by").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
|
||||
group_by.push(option.title);
|
||||
});
|
||||
group_by = (Array.isArray(group_by)) ? _.uniq(group_by).join() : "";
|
||||
return group_by;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
deleteHosts(id) {
|
||||
this.url = GetBasePath('inventory_sources') + id + '/hosts/';
|
||||
Rest.setUrl(this.url);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user