Skip to content

Commit

Permalink
Merge pull request #2527 from mzazrivec/add_additional_playbook_autom…
Browse files Browse the repository at this point in the history
…ation_method_parameters

Add additional playbook automate method parameters
  • Loading branch information
h-kataria committed Oct 27, 2017
2 parents ddf6608 + 75ef859 commit c8411c3
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 7 deletions.
Expand Up @@ -47,6 +47,7 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
vm.currentRegion = currentRegion;
vm.formId = catalogItemFormId;
vm.afterGet = false;
vm.inventory_mode = 'localhost';

ManageIQ.angular.scope = $scope;

Expand Down Expand Up @@ -80,6 +81,9 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', 'catalog
vm.catalogItemModel.provisioning_cloud_credential_id = playbookReusableCodeMixin.setIfDefined(configData.provision.cloud_credential_id);
vm.catalogItemModel.provisioning_execution_ttl = configData.provision.execution_ttl;
vm.catalogItemModel.provisioning_inventory = configData.provision.hosts;
if (configData.provision.hosts !== 'localhost') {
vm.inventory_mode = 'specify';
}
vm.catalogItemModel.provisioning_dialog_existing = configData.provision.dialog_id ? 'existing' : 'create';
vm.catalogItemModel.provisioning_dialog_id = configData.provision.dialog_id;
vm.catalogItemModel.provisioning_dialog_name = configData.provision.new_dialog_name;
Expand Down
Expand Up @@ -28,13 +28,18 @@ function aeMethodFormController($http, $scope, aeMethodFormId, currentRegion, mi
provisioning_verbosity: '0',
provisioning_editMode: false,
provisioning_become_enabled: false,
provisioning_execution_ttl: '',
provisioning_inventory: 'localhost',
provisioning_log_output: 'on_error',
};
vm.verbosity_types = playbookReusableCodeMixin.getVerbosityTypes();
vm.log_output_types = playbookReusableCodeMixin.getLogOutputTypes();
vm.provisioning_cloud_type = '';
vm.currentRegion = currentRegion;
vm.formId = aeMethodFormId;
vm.afterGet = false;
vm.model = "aeMethodModel";
vm.inventory_mode = 'localhost';

ManageIQ.angular.scope = $scope;

Expand Down Expand Up @@ -73,6 +78,12 @@ function aeMethodFormController($http, $scope, aeMethodFormId, currentRegion, mi
vm.aeMethodModel.provisioning_become_enabled = configData.become_enabled === true;
vm.aeMethodModel.provisioning_key = '';
vm.aeMethodModel.provisioning_value = '';
vm.aeMethodModel.provisioning_execution_ttl = configData.execution_ttl;
vm.aeMethodModel.provisioning_inventory = configData.hosts;
if (configData.hosts !== 'localhost') {
vm.inventory_mode = 'specify';
}
vm.aeMethodModel.provisioning_log_output = configData.log_output;

if (configData.verbosity === undefined || configData.verbosity === '') {
vm.aeMethodModel.provisioning_verbosity = '0';
Expand Down Expand Up @@ -136,6 +147,9 @@ function aeMethodFormController($http, $scope, aeMethodFormId, currentRegion, mi
credential_id: configData.provisioning_machine_credential_id,
verbosity: configData.provisioning_verbosity,
become_enabled: configData.provisioning_become_enabled,
execution_ttl: configData.provisioning_execution_ttl,
log_output: configData.provisioning_log_output,
hosts: configData.provisioning_inventory,
extra_vars: configData.provisioning_inputs,
};
if (configData.provisioning_network_credential_id !== '') {
Expand Down
Expand Up @@ -31,6 +31,14 @@ function playbookReusableCodeMixin(API, $q, miqService) {
};
};

var getLogOutputTypes = function() {
return {
"on_error": __("On Error"),
"always": __("Always"),
"never": __("Never"),
};
};

var checkFormPristine = function(model, modelCopy, form) {
if (angular.equals(model, modelCopy)) {
form.$setPristine();
Expand Down Expand Up @@ -224,6 +232,7 @@ function playbookReusableCodeMixin(API, $q, miqService) {
cloudCredentialsList: cloudCredentialsList,
cloudTypeChanged: cloudTypeChanged,
getVerbosityTypes: getVerbosityTypes,
getLogOutputTypes: getLogOutputTypes,
getSortedHash: getSortedHash,
getCloudCredentialsforType: getCloudCredentialsforType,
getRemoveResourcesTypes: getRemoveResourcesTypes,
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/miq_ae_class_controller.rb
Expand Up @@ -993,6 +993,9 @@ def method_form_fields
:cloud_credential_id => method.options[:cloud_credential_id] || '',
:verbosity => method.options[:verbosity],
:become_enabled => method.options[:become_enabled] || false,
:execution_ttl => method.options[:execution_ttl] || '',
:hosts => method.options[:hosts] || 'localhost',
:log_output => method.options[:log_output] || 'on_error',
:extra_vars => method.inputs
}
}
Expand Down Expand Up @@ -1745,7 +1748,10 @@ def set_playbook_data
credential_id
verbosity
network_credential_id
cloud_credential_id)
cloud_credential_id
execution_ttl
hosts
log_output)
boolean_params_list = %i(become_enabled)
params_hash = copy_params_if_set({}, params, params_list)
copy_boolean_params(params_hash, params, boolean_params_list)
Expand Down Expand Up @@ -2702,6 +2708,9 @@ def fetch_playbook_details
@playbook_details[:cloud_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential, options[:cloud_credential_id]) if options[:cloud_credential_id]
@playbook_details[:verbosity] = options[:verbosity]
@playbook_details[:become_enabled] = options[:become_enabled] == true ? _("Yes") : _("No")
@playbook_details[:execution_ttl] = options[:execution_ttl]
@playbook_details[:hosts] = options[:hosts]
@playbook_details[:log_output] = options[:log_output]
@playbook_details
end

Expand Down
6 changes: 6 additions & 0 deletions app/helpers/view_helper.rb
Expand Up @@ -127,6 +127,12 @@ module ViewHelper
'5' => N_('5 (WinRM Debug)')
}.freeze

LOG_OUTPUT_LEVELS = {
'on_error' => N_('On Error'),
'always' => N_('Always'),
'never' => N_('Never')
}.freeze

class << self
def concat_tag(*args, &block)
concat content_tag(*args, &block)
Expand Down
40 changes: 34 additions & 6 deletions app/views/layouts/angular/_ansible_form_options_angular.html.haml
Expand Up @@ -99,15 +99,34 @@
%label.col-md-3.control-label
= _("Hosts")
.col-md-9
%input.form-control{:type => "text",
%label{'for' => "#{prefix}_inventory_localhost", 'title' => _('Run on localhost')}
%input{'type' => "radio",
'ng-model' => "vm.inventory_mode",
'value' => "localhost",
'ng-change' => "#{ng_model}.#{prefix}_inventory = 'localhost'",
'id' => "#{prefix}_inventory_localhost",
'name' => "#{prefix}_inventory_radio"}
= _('Localhost')
%br
%label{'for' => "#{prefix}_inventory_specify", 'title' => _('Specify host values')}
%input{'type' => "radio",
'ng-model' => "vm.inventory_mode",
'value' => "specify",
'ng-change' => "#{ng_model}.#{prefix}_inventory = ''",
'id' => "#{prefix}_inventory_specify",
'name' => "#{prefix}_inventory_radio"}
= _('Specify host values')
%br
%input.form-control{'type' => "text",
'ng-model' => "#{ng_model}.#{prefix}_inventory",
:name => "#{prefix}_inventory",
:maxlength => 50,
"miqrequired" => "",
"checkchange" => true}
'ng-if' => "vm.inventory_mode !== 'localhost'",
'name' => "#{prefix}_inventory",
'maxlength' => 50,
'miqrequired' => "",
'checkchange' => true}
%span.help-block{"ng-show" => "angularForm.#{prefix}_inventory.$error.miqrequired"}
= _("Required")
.form-group{"ng-if" =>"#{ng_model}.#{prefix}_execution_ttl!==undefined", "ng-class" => "{'has-error': angularForm.#{prefix}_execution_ttl.$invalid}"}
.form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_execution_ttl.$invalid}"}
%label.col-md-3.control-label{"for" => "#{prefix}_execution_ttl"}
= _("Max TTL (mins)")
.col-md-9
Expand All @@ -119,6 +138,15 @@
"checkchange" => true}
%span{"style"=>"color:red", "ng-show" => "angularForm.#{prefix}_execution_ttl.$invalid"}
= _("Max TTL value must be numeric")
.form-group{"ng-if" =>"#{ng_model}.#{prefix}_log_output!==undefined", "ng-class" => "{'has-error': angularForm.#{prefix}_log_output.$invalid}"}
%label.col-md-3.control-label{"for" => "#{prefix}_log_output"}
= _("Logging Output")
.col-md-9
%select{"ng-model" => "#{ng_model}.#{prefix}_log_output",
"name" => "#{prefix}_log_output",
'ng-options' => 'v as k for (v, k) in vm.log_output_types',
"checkchange" => "",
'pf-select' => true}
#escalate_privilege{"ng-if" => "(#{ng_model}.#{prefix}_become_enabled!=='undefined' || vm.retirement_playbook_selected('#{prefix}'))"}
.form-group
%label.col-md-3.control-label
Expand Down
6 changes: 6 additions & 0 deletions app/views/miq_ae_class/_method_inputs.html.haml
Expand Up @@ -50,6 +50,12 @@
= format_form_group(_('Cloud Credential'), @playbook_details[:cloud_credential])
.form-group
= format_form_group(_('Escalate Privilege'), @playbook_details[:become_enabled])
.form-group
= format_form_group(_('Max TTL'), @playbook_details[:execution_ttl])
.form-group
= format_form_group(_('Hosts'), @playbook_details[:hosts])
.form-group
= format_form_group(_('Logging Output'), _(ViewHelper::LOG_OUTPUT_LEVELS[@playbook_details[:log_output]]))
.form-group
= format_form_group(_('Verbosity'), _(ViewHelper::VERBOSITY_LEVELS[@playbook_details[:verbosity]]))
- else
Expand Down

0 comments on commit c8411c3

Please sign in to comment.