Skip to content

Commit

Permalink
Added changes to show playbook data on method summary screen.
Browse files Browse the repository at this point in the history
Moved couple of common methods to application controller. Removed some unrequired/leftover code

https://www.pivotaltracker.com/story/show/149747321
  • Loading branch information
h-kataria committed Sep 6, 2017
1 parent c940e73 commit 1051660
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ManageIQ.angular.app.controller('aeMethodFormController', ['$http', '$scope', 'a
vm.aeMethodModel.provisioning_key = '';
vm.aeMethodModel.provisioning_value = '';

if (configData['verbosity'] === undefined) {
if (configData['verbosity'] === undefined || configData['verbosity'] == '') {
vm.aeMethodModel.provisioning_verbosity = '0';
} else {
vm.aeMethodModel.provisioning_verbosity = configData['verbosity'];
Expand Down
18 changes: 18 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2337,4 +2337,22 @@ def build_accordions_and_trees
@accords = allowed_features.map(&:accord_hash)
set_active_elements(allowed_features.first)
end

def fetch_name_from_object(klass, id)
klass.find_by(:id => from_cid(id)).try(:name)
end

def verbosity_display(verbosity)
verbosity ||= "0"
verbosity_hsh = {
"0" => "0 (Normal)",
"1" => "1 (Verbose)",
"2" => "2 (More Verbose)",
"3" => "3 (Debug)",
"4" => "4 (Connection Debug)",
"5" => "5 (WinRM Debug)"
}
verbosity_hsh[verbosity.to_s]
end
helper_method :verbosity_display
end
18 changes: 0 additions & 18 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -832,20 +832,6 @@ def remove_resources_display(remove_resources)
end
helper_method :remove_resources_display

def verbosity_display(verbosity)
verbosity ||= "0"
verbosity_hsh = {
"0" => "0 (Normal)",
"1" => "1 (Verbose)",
"2" => "2 (More Verbose)",
"3" => "3 (Debug)",
"4" => "4 (Connection Debug)",
"5" => "5 (WinRM Debug)"
}
verbosity_hsh[verbosity.to_s]
end
helper_method :verbosity_display

def features
[{:role => "svc_catalog_accord",
:role_any => true,
Expand Down Expand Up @@ -1866,10 +1852,6 @@ def fetch_playbook_details
playbook_details
end

def fetch_name_from_object(klass, id)
klass.find_by(:id => id).try(:name)
end

def fetch_dialog(playbook_details, dialog_id, key)
return nil if dialog_id.nil?
dialog = Dialog.find_by(:id => dialog_id)
Expand Down
33 changes: 15 additions & 18 deletions app/controllers/miq_ae_class_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -991,18 +991,6 @@ def method_form_fields
:cloud_credential_id => data['cloud_credential_id'] || '',
:hosts => data['hosts'],
:verbosity => data['verbosity'],
# :extra_vars => {
# :sleep => '40',
# :pkg => 'httpd',
# :user => 'root',
# :host => 'localhost'
# },
# :extra_vars => [
# ['sleep', '40', 'string'],
# ['pkg', 'httpd', 'string'],
# ['user', 'root', 'string'],
# ['host', 'localhost', "string"]
# ]
:extra_vars => method.inputs
}
}
Expand Down Expand Up @@ -1213,12 +1201,6 @@ def set_playbook_data
:credential_id => params['credential_id'],
:hosts => params['hosts'],
:verbosity => params['verbosity'],
:extra_vars => {
:sleep => '40',
:pkg => 'httpd',
:user => 'root',
:host => 'localhost'
}
}
data[:network_credential_id] = params['network_credential_id'] if params['network_credential_id']
data[:cloud_credential_id] = params['cloud_credential_id'] if params['cloud_credential_id']
Expand Down Expand Up @@ -2678,11 +2660,26 @@ def get_method_node_info(id)
if @record.location == 'expression'
hash = YAML.load(@record.data)
@expression = hash[:expression] ? MiqExpression.new(hash[:expression]).to_human : ""
elsif @record.location == "playbook"
fetch_playbook_details
end
domain_overrides
set_right_cell_text(x_node, @record)
end

def fetch_playbook_details
@playbook_details = {}
data = JSON.parse(@record.data)
@playbook_details[:repository] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource, data['repository_id'])
@playbook_details[:playbook] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook, data['playbook_id'])
@playbook_details[:machine_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::MachineCredential, data['credential_id'])
@playbook_details[:network_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::NetworkCredential, data['network_credential_id']) if data['network_credential_id']
@playbook_details[:cloud_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential, data['cloud_credential_id']) if data['cloud_credential_id']
@playbook_details[:verbosity] = data['verbosity']
@playbook_details[:hosts] = data['hosts']
@playbook_details
end

def get_class_node_info(id)
@sb[:active_tab] = "instances" if !@in_a_form && !params[:button] && !params[:pressed]
begin
Expand Down
32 changes: 32 additions & 0 deletions app/views/miq_ae_class/_method_inputs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@
:read_only => true}
- elsif @ae_method.location == 'expression'
= @expression
- elsif @ae_method.location == 'playbook'
.form-horizontal.static
.form-group
%label.col-md-2.control-label
= _('Repository')
.col-md-8
= h(@playbook_details[:repository])
.form-group
%label.col-md-2.control-label
= _('Playbook')
.col-md-8
= h(@playbook_details[:playbook])
.form-group
%label.col-md-2.control-label
= _('Machine Credential')
.col-md-8
= h(@playbook_details[:machine_credential])
.form-group
%label.col-md-2.control-label
= _('Cloud Credential')
.col-md-8
= h(@playbook_details[:cloud_credential])
.form-group
%label.col-md-2.control-label
= _('Hosts')
.col-md-8
= h(@playbook_details[:hosts])
.form-group
%label.col-md-2.control-label
= _('Verbosity')
.col-md-8
= h(verbosity_display(@playbook_details[:verbosity]))
- else
= @ae_method.data
-# show inputs parameters grid if there are any inputs
Expand Down

0 comments on commit 1051660

Please sign in to comment.